mimaison commented on code in PR #13247:
URL: https://github.com/apache/kafka/pull/13247#discussion_r1266975779


##########
tools/src/main/java/org/apache/kafka/tools/reassign/VerifyAssignmentResult.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.tools.reassign;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.TopicPartitionReplica;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * A result returned from verifyAssignment.
+ */
+public final class VerifyAssignmentResult {
+    private final Map<TopicPartition, PartitionReassignmentState> partStates;
+    private final boolean partsOngoing;
+    private final Map<TopicPartitionReplica, LogDirMoveState> moveStates;
+    private final boolean movesOngoing;
+
+    public VerifyAssignmentResult(Map<TopicPartition, 
PartitionReassignmentState> partStates) {
+        this(partStates, false, Collections.emptyMap(), false);
+    }
+
+    /**
+     * @param partStates    A map from partitions to reassignment states.
+     * @param partsOngoing  True if there are any ongoing partition 
reassignments.
+     * @param moveStates    A map from log directories to movement states.
+     * @param movesOngoing  True if there are any ongoing moves that we know 
about.
+     */
+    public VerifyAssignmentResult(
+        Map<TopicPartition, PartitionReassignmentState> partStates,
+        boolean partsOngoing,
+        Map<org.apache.kafka.common.TopicPartitionReplica, LogDirMoveState> 
moveStates,
+        boolean movesOngoing
+    ) {
+        this.partStates = partStates;
+        this.partsOngoing = partsOngoing;
+        this.moveStates = moveStates;
+        this.movesOngoing = movesOngoing;
+    }
+
+    public Map<TopicPartition, PartitionReassignmentState> partStates() {
+        return partStates;
+    }
+
+    public boolean partsOngoing() {
+        return partsOngoing;
+    }
+
+    public Map<TopicPartitionReplica, LogDirMoveState> moveStates() {
+        return moveStates;
+    }
+
+    public boolean movesOngoing() {
+        return movesOngoing;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        VerifyAssignmentResult that = (VerifyAssignmentResult) o;
+        return partsOngoing == that.partsOngoing && movesOngoing == 
that.movesOngoing && Objects.equals(partStates, that.partStates) && 
Objects.equals(moveStates, that.moveStates);
+    }
+
+    @Override
+    public int hashCode() {

Review Comment:
   Do we need `hashCode()` and `toString()` here? It looks like the original 
`VerifyAssignmentResult` class is only used by test (afaict the tool creates an 
instance but it's not used)



##########
tools/src/main/java/org/apache/kafka/tools/reassign/CancelledMoveState.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.tools.reassign;
+
+import java.util.Objects;
+
+/**
+ * A replica log directory move state where there is no move in progress, but 
we did not
+ * reach the target log directory.
+ */
+public final class CancelledMoveState implements LogDirMoveState {
+    private final String currentLogDir;
+
+    private final String targetLogDir;
+
+    /**
+     * @param currentLogDir       The current log directory.
+     * @param targetLogDir        The log directory that we wanted the replica 
to move to.
+     */
+    public CancelledMoveState(String currentLogDir, String targetLogDir) {
+        this.currentLogDir = currentLogDir;
+        this.targetLogDir = targetLogDir;
+    }
+
+    public String currentLogDir() {
+        return currentLogDir;
+    }
+
+    public String targetLogDir() {
+        return targetLogDir;
+    }
+
+    @Override
+    public boolean done() {
+        return true;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        CancelledMoveState that = (CancelledMoveState) o;
+        return Objects.equals(currentLogDir, that.currentLogDir) && 
Objects.equals(targetLogDir, that.targetLogDir);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(currentLogDir, targetLogDir);
+    }
+
+    @Override
+    public String toString() {
+        return "CancelledMoveState{" +
+            "currentLogDir='" + currentLogDir + '\'' +
+            ", targetLogDir='" + targetLogDir + '\'' +
+            '}';
+    }
+}

Review Comment:
   We're missing a new line here



##########
tools/src/main/java/org/apache/kafka/tools/reassign/ActiveMoveState.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.tools.reassign;
+
+import java.util.Objects;
+
+/**
+ * A replica log directory move state where the move is in progress.
+ */
+public final class ActiveMoveState implements LogDirMoveState {

Review Comment:
   These classes are extremely verbose. I wonder if we could make the `final` 
fields public and get rid of all the setters. 



##########
tools/src/main/java/org/apache/kafka/tools/reassign/TerseReassignmentFailureException.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.tools.reassign;
+
+import org.apache.kafka.common.KafkaException;
+
+/**
+ * An exception thrown to indicate that the command has failed, but we don't 
want to
+ * print a stack trace.
+ */
+public class TerseReassignmentFailureException extends KafkaException {

Review Comment:
   Yes we try to keep the logic as is as but in this case, I think we can do 
this simplification. There's no point of creating this new class where it 
really looks like it will not be needed. Worst case scenario, we'll create it 
when we move the tool if we can't do without.



##########
tools/src/main/java/org/apache/kafka/tools/reassign/ActiveMoveState.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.tools.reassign;
+
+import java.util.Objects;
+
+/**
+ * A replica log directory move state where the move is in progress.
+ */
+public final class ActiveMoveState implements LogDirMoveState {
+    private final String currentLogDir;
+
+    private final String targetLogDir;
+
+    private final String futureLogDir;
+
+    /**
+     * @param currentLogDir       The current log directory.
+     * @param futureLogDir        The log directory that the replica is moving 
to.
+     * @param targetLogDir        The log directory that we wanted the replica 
to move to.
+     */
+    public ActiveMoveState(String currentLogDir, String targetLogDir, String 
futureLogDir) {
+        this.currentLogDir = currentLogDir;
+        this.targetLogDir = targetLogDir;
+        this.futureLogDir = futureLogDir;
+    }
+
+    public String currentLogDir() {
+        return currentLogDir;
+    }
+
+    public String targetLogDir() {
+        return targetLogDir;
+    }
+
+    public String futureLogDir() {
+        return futureLogDir;
+    }
+
+    @Override
+    public boolean done() {
+        return false;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        ActiveMoveState that = (ActiveMoveState) o;
+        return Objects.equals(currentLogDir, that.currentLogDir) && 
Objects.equals(targetLogDir, that.targetLogDir) && Objects.equals(futureLogDir, 
that.futureLogDir);
+    }
+
+    @Override
+    public int hashCode() {

Review Comment:
   Do we need to override `hashCode()` and `toString()` for these classes?



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

Reply via email to