-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-18353: Remove zk config control.plane.listener.name
#18329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e76144d
cf3121c
5f15b0a
c6b682d
73061df
c888cef
b7e6c29
804bd44
e0a02ee
4adce10
c248675
8f2abed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,13 +69,6 @@ import scala.util.control.ControlThrowable | |
| * It is possible to configure multiple data-planes by specifying multiple "," separated endpoints for "listeners" in KafkaConfig. | ||
| * Acceptor has N Processor threads that each have their own selector and read requests from sockets | ||
| * M Handler threads that handle requests and produce responses back to the processor threads for writing. | ||
| * - control-plane : | ||
| * - Handles requests from controller. This is optional and can be configured by specifying "control.plane.listener.name". | ||
| * If not configured, the controller requests are handled by the data-plane. | ||
| * - The threading model is | ||
| * 1 Acceptor thread that handles new connections | ||
| * Acceptor has 1 Processor thread that has its own selector and read requests from the socket. | ||
| * 1 Handler thread that handles requests and produces responses back to the processor thread for writing. | ||
| */ | ||
| class SocketServer( | ||
| val config: KafkaConfig, | ||
|
|
@@ -105,10 +98,6 @@ class SocketServer( | |
| // data-plane | ||
| private[network] val dataPlaneAcceptors = new ConcurrentHashMap[EndPoint, DataPlaneAcceptor]() | ||
| val dataPlaneRequestChannel = new RequestChannel(maxQueuedRequests, DataPlaneAcceptor.MetricPrefix, time, apiVersionManager.newRequestMetrics) | ||
| // control-plane | ||
| private[network] var controlPlaneAcceptorOpt: Option[ControlPlaneAcceptor] = None | ||
| val controlPlaneRequestChannelOpt: Option[RequestChannel] = config.controlPlaneListenerName.map(_ => | ||
| new RequestChannel(20, ControlPlaneAcceptor.MetricPrefix, time, apiVersionManager.newRequestMetrics)) | ||
|
|
||
| private[this] val nextProcessorId: AtomicInteger = new AtomicInteger(0) | ||
| val connectionQuotas = new ConnectionQuotas(config, time, metrics) | ||
|
|
@@ -137,17 +126,7 @@ class SocketServer( | |
| }.sum / dataPlaneProcessors.size | ||
| } | ||
| }) | ||
| if (config.requiresZookeeper) { | ||
| metricsGroup.newGauge(s"${ControlPlaneAcceptor.MetricPrefix}NetworkProcessorAvgIdlePercent", () => SocketServer.this.synchronized { | ||
| val controlPlaneProcessorOpt = controlPlaneAcceptorOpt.map(a => a.processors(0)) | ||
| val ioWaitRatioMetricName = controlPlaneProcessorOpt.map { p => | ||
| metrics.metricName("io-wait-ratio", MetricsGroup, p.metricTags) | ||
| } | ||
| ioWaitRatioMetricName.map { metricName => | ||
| Option(metrics.metric(metricName)).fold(0.0)(m => Math.min(m.metricValue.asInstanceOf[Double], 1.0)) | ||
| }.getOrElse(Double.NaN) | ||
| }) | ||
| } | ||
|
|
||
| metricsGroup.newGauge("MemoryPoolAvailable", () => memoryPool.availableMemory) | ||
| metricsGroup.newGauge("MemoryPoolUsed", () => memoryPool.size() - memoryPool.availableMemory) | ||
| metricsGroup.newGauge(s"${DataPlaneAcceptor.MetricPrefix}ExpiredConnectionsKilledCount", () => SocketServer.this.synchronized { | ||
|
|
@@ -159,17 +138,6 @@ class SocketServer( | |
| Option(metrics.metric(metricName)).fold(0.0)(m => m.metricValue.asInstanceOf[Double]) | ||
| }.sum | ||
| }) | ||
| if (config.requiresZookeeper) { | ||
| metricsGroup.newGauge(s"${ControlPlaneAcceptor.MetricPrefix}ExpiredConnectionsKilledCount", () => SocketServer.this.synchronized { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| val controlPlaneProcessorOpt = controlPlaneAcceptorOpt.map(a => a.processors(0)) | ||
| val expiredConnectionsKilledCountMetricNames = controlPlaneProcessorOpt.map { p => | ||
| metrics.metricName("expired-connections-killed-count", MetricsGroup, p.metricTags) | ||
| } | ||
| expiredConnectionsKilledCountMetricNames.map { metricName => | ||
| Option(metrics.metric(metricName)).fold(0.0)(m => m.metricValue.asInstanceOf[Double]) | ||
| }.getOrElse(0.0) | ||
| }) | ||
| } | ||
|
|
||
| // Create acceptors and processors for the statically configured endpoints when the | ||
| // SocketServer is constructed. Note that this just opens the ports and creates the data | ||
|
|
@@ -178,7 +146,6 @@ class SocketServer( | |
| if (apiVersionManager.listenerType.equals(ListenerType.CONTROLLER)) { | ||
| config.controllerListeners.foreach(createDataPlaneAcceptorAndProcessors) | ||
| } else { | ||
| config.controlPlaneListener.foreach(createControlPlaneAcceptorAndProcessor) | ||
| config.dataPlaneListeners.foreach(createDataPlaneAcceptorAndProcessors) | ||
| } | ||
|
|
||
|
|
@@ -232,16 +199,14 @@ class SocketServer( | |
| } | ||
|
|
||
| info("Enabling request processing.") | ||
| controlPlaneAcceptorOpt.foreach(chainAcceptorFuture) | ||
| dataPlaneAcceptors.values().forEach(chainAcceptorFuture) | ||
| FutureUtils.chainFuture(CompletableFuture.allOf(authorizerFutures.values.toArray: _*), | ||
| allAuthorizerFuturesComplete) | ||
|
|
||
| // Construct a future that will be completed when all Acceptors have been successfully started. | ||
| // Alternately, if any of them fail to start, this future will be completed exceptionally. | ||
| val allAcceptors = dataPlaneAcceptors.values().asScala.toSeq ++ controlPlaneAcceptorOpt | ||
| val enableFuture = new CompletableFuture[Void] | ||
| FutureUtils.chainFuture(CompletableFuture.allOf(allAcceptors.map(_.startedFuture).toArray: _*), enableFuture) | ||
| FutureUtils.chainFuture(CompletableFuture.allOf(dataPlaneAcceptors.values().asScala.toArray.map(_.startedFuture): _*), enableFuture) | ||
| enableFuture | ||
| } | ||
|
|
||
|
|
@@ -251,36 +216,20 @@ class SocketServer( | |
| } | ||
| val parsedConfigs = config.valuesFromThisConfigWithPrefixOverride(endpoint.listenerName.configPrefix) | ||
| connectionQuotas.addListener(config, endpoint.listenerName) | ||
| val isPrivilegedListener = controlPlaneRequestChannelOpt.isEmpty && | ||
| config.interBrokerListenerName == endpoint.listenerName | ||
| val isPrivilegedListener = config.interBrokerListenerName == endpoint.listenerName | ||
| val dataPlaneAcceptor = createDataPlaneAcceptor(endpoint, isPrivilegedListener, dataPlaneRequestChannel) | ||
| config.addReconfigurable(dataPlaneAcceptor) | ||
| dataPlaneAcceptor.configure(parsedConfigs) | ||
| dataPlaneAcceptors.put(endpoint, dataPlaneAcceptor) | ||
| info(s"Created data-plane acceptor and processors for endpoint : ${endpoint.listenerName}") | ||
| } | ||
|
|
||
| private def createControlPlaneAcceptorAndProcessor(endpoint: EndPoint): Unit = synchronized { | ||
| if (stopped) { | ||
| throw new RuntimeException("Can't create new control plane acceptor and processor: SocketServer is stopped.") | ||
| } | ||
| connectionQuotas.addListener(config, endpoint.listenerName) | ||
| val controlPlaneAcceptor = createControlPlaneAcceptor(endpoint, controlPlaneRequestChannelOpt.get) | ||
| controlPlaneAcceptor.addProcessors(1) | ||
| controlPlaneAcceptorOpt = Some(controlPlaneAcceptor) | ||
| info(s"Created control-plane acceptor and processor for endpoint : ${endpoint.listenerName}") | ||
| } | ||
|
|
||
| private def endpoints = config.listeners.map(l => l.listenerName -> l).toMap | ||
|
|
||
| protected def createDataPlaneAcceptor(endPoint: EndPoint, isPrivilegedListener: Boolean, requestChannel: RequestChannel): DataPlaneAcceptor = { | ||
| new DataPlaneAcceptor(this, endPoint, config, nodeId, connectionQuotas, time, isPrivilegedListener, requestChannel, metrics, credentialProvider, logContext, memoryPool, apiVersionManager) | ||
| } | ||
|
|
||
| private def createControlPlaneAcceptor(endPoint: EndPoint, requestChannel: RequestChannel): ControlPlaneAcceptor = { | ||
| new ControlPlaneAcceptor(this, endPoint, config, nodeId, connectionQuotas, time, requestChannel, metrics, credentialProvider, logContext, memoryPool, apiVersionManager) | ||
| } | ||
|
|
||
| /** | ||
| * Stop processing requests and new connections. | ||
| */ | ||
|
|
@@ -289,11 +238,8 @@ class SocketServer( | |
| stopped = true | ||
| info("Stopping socket server request processors") | ||
| dataPlaneAcceptors.asScala.values.foreach(_.beginShutdown()) | ||
| controlPlaneAcceptorOpt.foreach(_.beginShutdown()) | ||
| dataPlaneAcceptors.asScala.values.foreach(_.close()) | ||
| controlPlaneAcceptorOpt.foreach(_.close()) | ||
| dataPlaneRequestChannel.clear() | ||
| controlPlaneRequestChannelOpt.foreach(_.clear()) | ||
| info("Stopped socket server request processors") | ||
| } | ||
| } | ||
|
|
@@ -309,7 +255,6 @@ class SocketServer( | |
| this.synchronized { | ||
| stopProcessingRequests() | ||
| dataPlaneRequestChannel.shutdown() | ||
| controlPlaneRequestChannelOpt.foreach(_.shutdown()) | ||
| connectionQuotas.close() | ||
| } | ||
| info("Shutdown completed") | ||
|
|
@@ -321,7 +266,7 @@ class SocketServer( | |
| if (acceptor != null) { | ||
| acceptor.localPort | ||
| } else { | ||
| controlPlaneAcceptorOpt.map(_.localPort).getOrElse(throw new KafkaException("Could not find listenerName : " + listenerName + " in data-plane or control-plane")) | ||
| throw new KafkaException("Could not find listenerName : " + listenerName + " in data-plane.") | ||
| } | ||
| } catch { | ||
| case e: Exception => | ||
|
|
@@ -528,42 +473,6 @@ class DataPlaneAcceptor(socketServer: SocketServer, | |
| } | ||
| } | ||
|
|
||
| object ControlPlaneAcceptor { | ||
| val ThreadPrefix = "control-plane" | ||
| val MetricPrefix = "ControlPlane" | ||
| } | ||
|
|
||
| class ControlPlaneAcceptor(socketServer: SocketServer, | ||
| endPoint: EndPoint, | ||
| config: KafkaConfig, | ||
| nodeId: Int, | ||
| connectionQuotas: ConnectionQuotas, | ||
| time: Time, | ||
| requestChannel: RequestChannel, | ||
| metrics: Metrics, | ||
| credentialProvider: CredentialProvider, | ||
| logContext: LogContext, | ||
| memoryPool: MemoryPool, | ||
| apiVersionManager: ApiVersionManager) | ||
| extends Acceptor(socketServer, | ||
| endPoint, | ||
| config, | ||
| nodeId, | ||
| connectionQuotas, | ||
| time, | ||
| true, | ||
| requestChannel, | ||
| metrics, | ||
| credentialProvider, | ||
| logContext, | ||
| memoryPool, | ||
| apiVersionManager) { | ||
|
|
||
| override def metricPrefix(): String = ControlPlaneAcceptor.MetricPrefix | ||
| override def threadPrefix(): String = ControlPlaneAcceptor.ThreadPrefix | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Thread that accepts and configures new connections. There is one of these per endpoint. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,6 @@ object SaslApiVersionsRequestTest { | |
|
|
||
| // Configure control plane listener to make sure we have separate listeners for testing. | ||
| val serverProperties = new java.util.HashMap[String, String]() | ||
| serverProperties.put(SocketServerConfigs.CONTROL_PLANE_LISTENER_NAME_CONFIG, controlPlaneListenerName) | ||
| serverProperties.put(SocketServerConfigs.LISTENER_SECURITY_PROTOCOL_MAP_CONFIG, s"$controlPlaneListenerName:$securityProtocol,$securityProtocol:$securityProtocol") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, #18330 handles it already |
||
| serverProperties.put("listeners", s"$securityProtocol://localhost:0,$controlPlaneListenerName://localhost:0") | ||
| serverProperties.put(SocketServerConfigs.ADVERTISED_LISTENERS_CONFIG, s"$securityProtocol://localhost:0,$controlPlaneListenerName://localhost:0") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m1a2st please include this in #18365