navinko commented on code in PR #11805:
URL: https://github.com/apache/ozone/pull/11805#discussion_r4401146844


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationTestUtil.java:
##########
@@ -573,9 +572,153 @@ public static void 
mockRMSendThrottledDeleteCommand(ReplicationManager mock,
       DeleteContainerCommand deleteCommand = new DeleteContainerCommand(
           containerInfo.getContainerID(), forceDelete);
       deleteCommand.setReplicaIndex(replicaIndex);
-      commandsSent.add(Pair.of(target, deleteCommand));
+      commandsSent.add(DatanodeCommand.of(target, deleteCommand));
       return null;
     }).when(mock)
         .sendThrottledDeleteCommand(any(), anyInt(), any(), anyBoolean());
   }
+
+  /**
+   * Operational state of the node hosting a test replica, and the replica 
index.
+   */
+  public static final class NodeOperationalStateAndIndex {
+    private final HddsProtos.NodeOperationalState state;
+    private final int index;
+
+    private NodeOperationalStateAndIndex(HddsProtos.NodeOperationalState 
state, int index) {
+      this.state = state;
+      this.index = index;
+    }
+
+    public static NodeOperationalStateAndIndex 
of(HddsProtos.NodeOperationalState state, int index) {
+      return new NodeOperationalStateAndIndex(state, index);
+    }
+
+    public HddsProtos.NodeOperationalState getState() {
+      return state;
+    }
+
+    public int getIndex() {
+      return index;
+    }
+  }
+
+  /**
+   * Origin datanode of a test replica, and the operational state of its node.
+   */
+  public static final class NodeOperationalStateAndOrigin {
+    private final DatanodeID origin;
+    private final HddsProtos.NodeOperationalState state;
+
+    private NodeOperationalStateAndOrigin(DatanodeID origin, 
HddsProtos.NodeOperationalState state) {
+      this.origin = origin;
+      this.state = state;
+    }
+
+    public static NodeOperationalStateAndOrigin of(DatanodeID origin, 
HddsProtos.NodeOperationalState state) {
+      return new NodeOperationalStateAndOrigin(origin, state);
+    }
+
+    public DatanodeID getOrigin() {
+      return origin;
+    }
+
+    public HddsProtos.NodeOperationalState getState() {
+      return state;
+    }
+  }
+
+  /**
+   * A command sent to a datanode, as recorded by tests.
+   */
+  public static final class DatanodeCommand {
+    private final DatanodeDetails datanode;
+    private final SCMCommand<?> command;
+
+    private DatanodeCommand(DatanodeDetails datanode, SCMCommand<?> command) {
+      this.datanode = datanode;
+      this.command = command;
+    }
+
+    public static DatanodeCommand of(DatanodeDetails datanode, SCMCommand<?> 
command) {
+      return new DatanodeCommand(datanode, command);
+    }
+
+    public DatanodeDetails getDatanode() {
+      return datanode;
+    }
+
+    public SCMCommand<?> getCommand() {
+      return command;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+      if (this == o) {
+        return true;
+      }
+      if (!(o instanceof DatanodeCommand)) {
+        return false;
+      }
+      DatanodeCommand that = (DatanodeCommand) o;
+      return Objects.equals(datanode, that.datanode) && 
Objects.equals(command, that.command);
+    }
+
+    @Override
+    public int hashCode() {
+      return Objects.hash(datanode, command);
+    }
+
+    @Override
+    public String toString() {
+      return "(" + datanode + ", " + command + ")";
+    }
+  }

Review Comment:
   > Can you please replace these new value classes using records to avoid the 
boilerplate?
   > 
   > ```java
   >   public record DatanodeCommand(DatanodeDetails datanode, SCMCommand<?> 
command) { }
   > ```
   > 
   > https://openjdk.org/jeps/395
   
   Thanks @adoroszlai for the review suggestions, updated the value classes to 
use Java records to eliminate boilerplate, as suggested. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to