Class NioEchoServer
java.lang.Object
java.lang.Thread
org.apache.kafka.common.network.NioEchoServer
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
NettyNioEchoServer
Non-blocking EchoServer implementation that uses ChannelBuilder to create channels
with the configured security protocol.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionNioEchoServer(org.apache.kafka.common.network.ListenerName listenerName, org.apache.kafka.common.security.auth.SecurityProtocol securityProtocol, org.apache.kafka.common.config.AbstractConfig config, String serverHost, org.apache.kafka.common.network.ChannelBuilder channelBuilder, org.apache.kafka.common.security.authenticator.CredentialCache credentialCache, int failedAuthenticationDelayMs, org.apache.kafka.common.utils.Time time) NioEchoServer(org.apache.kafka.common.network.ListenerName listenerName, org.apache.kafka.common.security.auth.SecurityProtocol securityProtocol, org.apache.kafka.common.config.AbstractConfig config, String serverHost, org.apache.kafka.common.network.ChannelBuilder channelBuilder, org.apache.kafka.common.security.authenticator.CredentialCache credentialCache, int failedAuthenticationDelayMs, org.apache.kafka.common.utils.Time time, org.apache.kafka.common.security.token.delegation.internals.DelegationTokenCache tokenCache, Optional<org.apache.kafka.server.audit.AuditLogProvider> auditLogProvider, org.apache.kafka.common.network.ProxyProtocolEngineFactory proxyProtocolEngineFactory) NioEchoServer(org.apache.kafka.common.network.ListenerName listenerName, org.apache.kafka.common.security.auth.SecurityProtocol securityProtocol, org.apache.kafka.common.config.AbstractConfig config, String serverHost, org.apache.kafka.common.network.ChannelBuilder channelBuilder, org.apache.kafka.common.security.authenticator.CredentialCache credentialCache, org.apache.kafka.common.utils.Time time) NioEchoServer(org.apache.kafka.common.network.ListenerName listenerName, org.apache.kafka.common.security.auth.SecurityProtocol securityProtocol, org.apache.kafka.common.config.AbstractConfig config, String serverHost, org.apache.kafka.common.network.ChannelBuilder channelBuilder, org.apache.kafka.common.security.authenticator.CredentialCache credentialCache, org.apache.kafka.common.utils.Time time, Optional<org.apache.kafka.server.audit.AuditLogProvider> auditLogProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidvoidvoidorg.apache.kafka.common.security.authenticator.CredentialCacheorg.apache.kafka.common.metrics.Metricsmetrics()doublemetricValue(String name) doublemetricValue(String name, String mechanism) nioChannelsWithCredential(org.apache.kafka.common.network.PublicCredential matchingCredential) intnumSent()voidoutputChannel(WritableByteChannel channel) Sets the output channel to which messages received on this server are echoed.intport()voidrun()org.apache.kafka.common.network.Selectableorg.apache.kafka.common.network.Selectorselector()voidsend(org.apache.kafka.common.network.NetworkSend send) org.apache.kafka.common.security.token.delegation.internals.DelegationTokenCachevoidverifyAuthenticationMetrics(int successfulAuthentications, int failedAuthentications) voidverifyAuthenticationMetricsForMechanism(int successfulAuthentications, int failedAuthentications, String mechanism) voidverifyAuthenticationMetricsForMechanism(int successfulAuthentications, int failedAuthentications, String mechanism, Set<NioEchoServer.MetricType> set) voidverifyReauthenticationMetrics(int successfulReauthentications, int failedReauthentications) voidwaitForMetric(String name, double expectedValue) voidwaitForMetrics(String namePrefix, double expectedValue, Set<NioEchoServer.MetricType> metricTypes) voidwaitForMetrics(String namePrefix, double expectedValue, Set<NioEchoServer.MetricType> metricTypes, String mechanism) Methods inherited from class Thread
activeCount, checkAccess, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Constructor Details
-
NioEchoServer
public NioEchoServer(org.apache.kafka.common.network.ListenerName listenerName, org.apache.kafka.common.security.auth.SecurityProtocol securityProtocol, org.apache.kafka.common.config.AbstractConfig config, String serverHost, org.apache.kafka.common.network.ChannelBuilder channelBuilder, org.apache.kafka.common.security.authenticator.CredentialCache credentialCache, org.apache.kafka.common.utils.Time time) throws Exception - Throws:
Exception
-
NioEchoServer
public NioEchoServer(org.apache.kafka.common.network.ListenerName listenerName, org.apache.kafka.common.security.auth.SecurityProtocol securityProtocol, org.apache.kafka.common.config.AbstractConfig config, String serverHost, org.apache.kafka.common.network.ChannelBuilder channelBuilder, org.apache.kafka.common.security.authenticator.CredentialCache credentialCache, int failedAuthenticationDelayMs, org.apache.kafka.common.utils.Time time) throws Exception - Throws:
Exception
-
NioEchoServer
public NioEchoServer(org.apache.kafka.common.network.ListenerName listenerName, org.apache.kafka.common.security.auth.SecurityProtocol securityProtocol, org.apache.kafka.common.config.AbstractConfig config, String serverHost, org.apache.kafka.common.network.ChannelBuilder channelBuilder, org.apache.kafka.common.security.authenticator.CredentialCache credentialCache, org.apache.kafka.common.utils.Time time, Optional<org.apache.kafka.server.audit.AuditLogProvider> auditLogProvider) throws Exception - Throws:
Exception
-
NioEchoServer
public NioEchoServer(org.apache.kafka.common.network.ListenerName listenerName, org.apache.kafka.common.security.auth.SecurityProtocol securityProtocol, org.apache.kafka.common.config.AbstractConfig config, String serverHost, org.apache.kafka.common.network.ChannelBuilder channelBuilder, org.apache.kafka.common.security.authenticator.CredentialCache credentialCache, int failedAuthenticationDelayMs, org.apache.kafka.common.utils.Time time, org.apache.kafka.common.security.token.delegation.internals.DelegationTokenCache tokenCache, Optional<org.apache.kafka.server.audit.AuditLogProvider> auditLogProvider, org.apache.kafka.common.network.ProxyProtocolEngineFactory proxyProtocolEngineFactory) throws Exception - Throws:
Exception
-
-
Method Details
-
port
public int port() -
credentialCache
public org.apache.kafka.common.security.authenticator.CredentialCache credentialCache() -
tokenCache
public org.apache.kafka.common.security.token.delegation.internals.DelegationTokenCache tokenCache() -
metrics
public org.apache.kafka.common.metrics.Metrics metrics() -
selectable
public org.apache.kafka.common.network.Selectable selectable() -
nioChannels
-
nioChannelsWithCredential
public Collection<NioEchoChannel> nioChannelsWithCredential(org.apache.kafka.common.network.PublicCredential matchingCredential) -
metricValue
-
metricValue
-
verifyAuthenticationMetrics
public void verifyAuthenticationMetrics(int successfulAuthentications, int failedAuthentications) throws InterruptedException - Throws:
InterruptedException
-
verifyReauthenticationMetrics
public void verifyReauthenticationMetrics(int successfulReauthentications, int failedReauthentications) throws InterruptedException - Throws:
InterruptedException
-
verifyAuthenticationMetricsForMechanism
public void verifyAuthenticationMetricsForMechanism(int successfulAuthentications, int failedAuthentications, String mechanism) throws InterruptedException - Throws:
InterruptedException
-
verifyAuthenticationMetricsForMechanism
public void verifyAuthenticationMetricsForMechanism(int successfulAuthentications, int failedAuthentications, String mechanism, Set<NioEchoServer.MetricType> set) throws InterruptedException - Throws:
InterruptedException
-
waitForMetric
- Throws:
InterruptedException
-
waitForMetrics
public void waitForMetrics(String namePrefix, double expectedValue, Set<NioEchoServer.MetricType> metricTypes) throws InterruptedException - Throws:
InterruptedException
-
waitForMetrics
public void waitForMetrics(String namePrefix, double expectedValue, Set<NioEchoServer.MetricType> metricTypes, String mechanism) throws InterruptedException - Throws:
InterruptedException
-
run
-
numSent
public int numSent() -
send
- Throws:
IOException
-
outputChannel
Sets the output channel to which messages received on this server are echoed. This is useful in tests where the clients sending the messages don't receive the responses (eg. testing graceful close). -
selector
public org.apache.kafka.common.network.Selector selector() -
closeKafkaChannels
public void closeKafkaChannels() -
closeSocketChannels
- Throws:
IOException
-
closeNewChannels
- Throws:
IOException
-
close
- Throws:
IOExceptionInterruptedException
-