[GitHub] [kafka] Hangleton commented on a diff in pull request #13524: MINOR: Refine `PartitionAssignor` server-side interface

2023-04-13 Thread via GitHub


Hangleton commented on code in PR #13524:
URL: https://github.com/apache/kafka/pull/13524#discussion_r1165311719


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/common/TopicIdToPartition.java:
##
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.group.common;
+
+import org.apache.kafka.common.Uuid;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+public class TopicIdToPartition {
+private final Uuid topicId;
+private final Integer partition;
+private final Optional> rackIds;
+
+public TopicIdToPartition(Uuid topicId, Integer topicPartition, 
Optional> rackIds) {
+this.topicId = Objects.requireNonNull(topicId, "topicId cannot be 
null");
+this.partition = Objects.requireNonNull(topicPartition, 
"topicPartition cannot be null");
+this.rackIds = Objects.requireNonNull(rackIds, "rackId cannot be 
null");
+}
+
+/**
+ * @return Universally unique id representing this topic partition.
+ */
+public Uuid topicId() {
+return topicId;
+}
+
+/**
+ * @return the partition number.
+ */
+public int partition() {
+return partition;
+}
+
+@Override
+public boolean equals(Object o) {
+if (this == o) {
+return true;
+}
+if (o == null || getClass() != o.getClass()) {
+return false;
+}
+TopicIdToPartition that = (TopicIdToPartition) o;
+return topicId.equals(that.topicId) &&
+partition.equals(that.partition);
+}
+
+@Override
+public int hashCode() {
+final int prime = 31;

Review Comment:
   I see, thanks for explaining. Rack-aware topic id partition? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] Hangleton commented on a diff in pull request #13524: MINOR: Refine `PartitionAssignor` server-side interface

2023-04-12 Thread via GitHub


Hangleton commented on code in PR #13524:
URL: https://github.com/apache/kafka/pull/13524#discussion_r1164088051


##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/common/TopicIdToPartition.java:
##
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.group.common;
+
+import org.apache.kafka.common.Uuid;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+public class TopicIdToPartition {
+private final Uuid topicId;
+private final Integer partition;
+private final Optional> rackIds;
+
+public TopicIdToPartition(Uuid topicId, Integer topicPartition, 
Optional> rackIds) {
+this.topicId = Objects.requireNonNull(topicId, "topicId cannot be 
null");
+this.partition = Objects.requireNonNull(topicPartition, 
"topicPartition cannot be null");
+this.rackIds = Objects.requireNonNull(rackIds, "rackId cannot be 
null");
+}
+
+/**
+ * @return Universally unique id representing this topic partition.
+ */
+public Uuid topicId() {
+return topicId;
+}
+
+/**
+ * @return the partition number.
+ */
+public int partition() {
+return partition;
+}
+
+@Override
+public boolean equals(Object o) {
+if (this == o) {
+return true;
+}
+if (o == null || getClass() != o.getClass()) {
+return false;
+}
+TopicIdToPartition that = (TopicIdToPartition) o;
+return topicId.equals(that.topicId) &&
+partition.equals(that.partition);
+}
+
+@Override
+public int hashCode() {
+final int prime = 31;

Review Comment:
   nit: `Objects.hashCode()` could be of use here.



##
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/common/TopicIdToPartition.java:
##
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * 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
+ *
+ *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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.group.common;
+
+import org.apache.kafka.common.Uuid;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+public class TopicIdToPartition {

Review Comment:
   Nit: sorry I keep coming after names, but what does topic id to partition 
mean? Is this class a `TopicIdPartition` w/o the topic name and augmented by a 
list of rack ids? If so, the differentiating characteristic of this class seems 
to be the location of the partition. Should that be reflected in the class name?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org