You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by mi...@apache.org on 2024/09/04 09:04:47 UTC
(kafka) branch trunk updated: KAFKA-17406: Move ClientIdAndBroker to server-common module (#16967)
This is an automated email from the ASF dual-hosted git repository.
mimaison pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 005155ba5ca KAFKA-17406: Move ClientIdAndBroker to server-common module (#16967)
005155ba5ca is described below
commit 005155ba5cad313d22fb84efc9959dd3fd484bf3
Author: Dmitry Werner <gr...@gmail.com>
AuthorDate: Wed Sep 4 14:04:40 2024 +0500
KAFKA-17406: Move ClientIdAndBroker to server-common module (#16967)
Reviewers: Mickael Maison <mi...@gmail.com>, David Arthur <mu...@gmail.com>
---
.../scala/kafka/server/AbstractFetcherThread.scala | 5 ++--
.../org/apache/kafka/common/ClientIdAndBroker.java | 28 ++++++++++++++--------
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/core/src/main/scala/kafka/server/AbstractFetcherThread.scala b/core/src/main/scala/kafka/server/AbstractFetcherThread.scala
index ec5e1d0306c..119f9d01bae 100755
--- a/core/src/main/scala/kafka/server/AbstractFetcherThread.scala
+++ b/core/src/main/scala/kafka/server/AbstractFetcherThread.scala
@@ -18,7 +18,6 @@
package kafka.server
import com.yammer.metrics.core.Meter
-import kafka.common.ClientIdAndBroker
import kafka.server.AbstractFetcherThread.{ReplicaFetch, ResultWithPartitions}
import kafka.utils.CoreUtils.inLock
import kafka.utils.Implicits._
@@ -32,7 +31,7 @@ import org.apache.kafka.common.protocol.Errors
import org.apache.kafka.common.record.{FileRecords, MemoryRecords, Records}
import org.apache.kafka.common.requests.OffsetsForLeaderEpochResponse.{UNDEFINED_EPOCH, UNDEFINED_EPOCH_OFFSET}
import org.apache.kafka.common.requests._
-import org.apache.kafka.common.{InvalidRecordException, TopicPartition, Uuid}
+import org.apache.kafka.common.{ClientIdAndBroker, InvalidRecordException, TopicPartition, Uuid}
import org.apache.kafka.server.common.OffsetAndEpoch
import org.apache.kafka.server.metrics.KafkaMetricsGroup
import org.apache.kafka.server.util.ShutdownableThread
@@ -72,7 +71,7 @@ abstract class AbstractFetcherThread(name: String,
protected val partitionMapLock = new ReentrantLock
private val partitionMapCond = partitionMapLock.newCondition()
- private val metricId = ClientIdAndBroker(clientId, leader.brokerEndPoint().host, leader.brokerEndPoint().port)
+ private val metricId = new ClientIdAndBroker(clientId, leader.brokerEndPoint().host, leader.brokerEndPoint().port)
val fetcherStats = new FetcherStats(metricId)
val fetcherLagStats = new FetcherLagStats(metricId)
diff --git a/core/src/main/scala/kafka/common/ClientIdAndBroker.scala b/server-common/src/main/java/org/apache/kafka/common/ClientIdAndBroker.java
similarity index 53%
rename from core/src/main/scala/kafka/common/ClientIdAndBroker.scala
rename to server-common/src/main/java/org/apache/kafka/common/ClientIdAndBroker.java
index c9c5c67e06e..5ef9bb227b3 100644
--- a/core/src/main/scala/kafka/common/ClientIdAndBroker.scala
+++ b/server-common/src/main/java/org/apache/kafka/common/ClientIdAndBroker.java
@@ -1,14 +1,12 @@
-package kafka.common
-
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,15 +14,25 @@ package kafka.common
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.kafka.common;
/**
* Convenience case class since (clientId, brokerInfo) pairs are used to create
* SyncProducer Request Stats and SimpleConsumer Request and Response Stats.
*/
+public class ClientIdAndBroker {
+ public final String clientId;
+ public final String brokerHost;
+ public final int brokerPort;
-trait ClientIdBroker {
-}
+ public ClientIdAndBroker(String clientId, String brokerHost, int brokerPort) {
+ this.clientId = clientId;
+ this.brokerHost = brokerHost;
+ this.brokerPort = brokerPort;
+ }
-case class ClientIdAndBroker(clientId: String, brokerHost: String, brokerPort: Int) extends ClientIdBroker {
- override def toString: String = "%s-%s-%d".format(clientId, brokerHost, brokerPort)
+ @Override
+ public String toString() {
+ return String.format("%s-%s-%d", clientId, brokerHost, brokerPort);
+ }
}