Browse Source

MINOR: Move TopicIdPartition class to server-common (#14418)

This patch moves the TopicIdPartition from the metadata module to the server-common module so it can be used by the group-coordinator module as well.

Reviewers: Sagar Rao <sagarmeansocean@gmail.com>, David Jacot <djacot@confluent.io>
pull/14458/head
Ritika Reddy 1 year ago committed by GitHub
parent
commit
bcfc9543d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java
  2. 1
      metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java
  3. 1
      metadata/src/test/java/org/apache/kafka/controller/BrokersToIsrsTest.java
  4. 1
      metadata/src/test/java/org/apache/kafka/controller/QuorumControllerTest.java
  5. 1
      metadata/src/test/java/org/apache/kafka/controller/ReplicationControlManagerTest.java
  6. 17
      server-common/src/main/java/org/apache/kafka/server/common/TopicIdPartition.java

1
metadata/src/main/java/org/apache/kafka/controller/BrokersToIsrs.java

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
package org.apache.kafka.controller;
import org.apache.kafka.common.Uuid;
import org.apache.kafka.server.common.TopicIdPartition;
import org.apache.kafka.metadata.Replicas;
import org.apache.kafka.timeline.SnapshotRegistry;
import org.apache.kafka.timeline.TimelineHashMap;

1
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java

@ -91,6 +91,7 @@ import org.apache.kafka.metadata.placement.PlacementSpec; @@ -91,6 +91,7 @@ import org.apache.kafka.metadata.placement.PlacementSpec;
import org.apache.kafka.metadata.placement.TopicAssignment;
import org.apache.kafka.metadata.placement.UsableBroker;
import org.apache.kafka.server.common.ApiMessageAndVersion;
import org.apache.kafka.server.common.TopicIdPartition;
import org.apache.kafka.server.mutable.BoundedList;
import org.apache.kafka.server.policy.CreateTopicPolicy;
import org.apache.kafka.timeline.SnapshotRegistry;

1
metadata/src/test/java/org/apache/kafka/controller/BrokersToIsrsTest.java

@ -19,6 +19,7 @@ package org.apache.kafka.controller; @@ -19,6 +19,7 @@ package org.apache.kafka.controller;
import org.apache.kafka.common.Uuid;
import org.apache.kafka.common.utils.LogContext;
import org.apache.kafka.server.common.TopicIdPartition;
import org.apache.kafka.controller.BrokersToIsrs.PartitionsOnReplicaIterator;
import org.apache.kafka.timeline.SnapshotRegistry;
import org.junit.jupiter.api.Test;

1
metadata/src/test/java/org/apache/kafka/controller/QuorumControllerTest.java

@ -128,6 +128,7 @@ import org.apache.kafka.raft.Batch; @@ -128,6 +128,7 @@ import org.apache.kafka.raft.Batch;
import org.apache.kafka.raft.OffsetAndEpoch;
import org.apache.kafka.server.common.ApiMessageAndVersion;
import org.apache.kafka.server.common.MetadataVersion;
import org.apache.kafka.server.common.TopicIdPartition;
import org.apache.kafka.server.fault.FaultHandlerException;
import org.apache.kafka.snapshot.FileRawSnapshotReader;
import org.apache.kafka.snapshot.Snapshots;

1
metadata/src/test/java/org/apache/kafka/controller/ReplicationControlManagerTest.java

@ -85,6 +85,7 @@ import org.apache.kafka.metadata.placement.StripedReplicaPlacer; @@ -85,6 +85,7 @@ import org.apache.kafka.metadata.placement.StripedReplicaPlacer;
import org.apache.kafka.metadata.placement.UsableBroker;
import org.apache.kafka.server.common.ApiMessageAndVersion;
import org.apache.kafka.server.common.MetadataVersion;
import org.apache.kafka.server.common.TopicIdPartition;
import org.apache.kafka.server.policy.CreateTopicPolicy;
import org.apache.kafka.server.util.MockRandom;
import org.apache.kafka.timeline.SnapshotRegistry;

17
metadata/src/main/java/org/apache/kafka/controller/TopicIdPartition.java → server-common/src/main/java/org/apache/kafka/server/common/TopicIdPartition.java

@ -14,25 +14,34 @@ @@ -14,25 +14,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.kafka.server.common;
package org.apache.kafka.controller;
import org.apache.kafka.common.Uuid;
import java.util.Objects;
import org.apache.kafka.common.Uuid;
final class TopicIdPartition {
/**
* Represents a partition using its unique topic Id and partition number.
*/
public final class TopicIdPartition {
private final Uuid topicId;
private final int partitionId;
TopicIdPartition(Uuid topicId, int partitionId) {
public TopicIdPartition(Uuid topicId, int partitionId) {
this.topicId = topicId;
this.partitionId = partitionId;
}
/**
* @return Universally unique Id representing this topic partition.
*/
public Uuid topicId() {
return topicId;
}
/**
* @return The partition Id.
*/
public int partitionId() {
return partitionId;
}
Loading…
Cancel
Save