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>
This commit is contained in:
Ritika Reddy 2023-09-28 13:55:44 -07:00 committed by GitHub
parent 7b0352f1bd
commit bcfc9543d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 5 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 java.util.Objects;
import org.apache.kafka.common.Uuid;
final class TopicIdPartition {
import java.util.Objects;
/**
* 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;
}