rich7420 commented on code in PR #11194:
URL: https://github.com/apache/ozone/pull/11194#discussion_r3941561195


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/BlockID.java:
##########
@@ -98,24 +98,24 @@ public void appendTo(StringBuilder sb) {
   }
 
   @JsonIgnore
-  public ContainerProtos.DatanodeBlockID getDatanodeBlockIDProtobuf() {
-    ContainerProtos.DatanodeBlockID.Builder blockID = 
getDatanodeBlockIDProtobufBuilder();
-    if (replicaIndex != null) {
-      blockID.setReplicaIndex(replicaIndex);
-    }
-    return blockID.build();
+  public DatanodeBlockID getDatanodeBlockIDProtobuf() {
+    return getDatanodeBlockIDProtobufBuilder(replicaIndex).build();
   }
 
   @JsonIgnore
-  public ContainerProtos.DatanodeBlockID.Builder 
getDatanodeBlockIDProtobufBuilder() {
-    return ContainerProtos.DatanodeBlockID.newBuilder().
-        setContainerID(containerBlockID.getContainerID())
+  public DatanodeBlockID.Builder getDatanodeBlockIDProtobufBuilder(Integer 
replicaIdx) {
+    final DatanodeBlockID.Builder b = DatanodeBlockID.newBuilder()
+        .setContainerID(containerBlockID.getContainerID())
         .setLocalID(containerBlockID.getLocalID())
         .setBlockCommitSequenceId(blockCommitSequenceId);
+    if (replicaIdx != null && replicaIdx > 0) {

Review Comment:
   This drops explicit replica index 0 on re-serialization. A base/head probe 
(`setReplicaIndex(0)` -> `getFromProtobuf` -> serialize) keeps presence on base 
but loses it here. Please preserve explicit zero and add a round-trip test.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/pipeline/Pipeline.java:
##########
@@ -240,10 +238,27 @@ public int getReplicaIndex(DatanodeDetails dn) {
   }
 
   /**
-   * Get the replicaIndex Map.
+   * @param fromIndex the replica index starting from (inclusive)
+   * @param toIndex the replica index starting to (exclusive)
+   * @return true iff this pipeline contain all replica indexes within the 
given range.
    */
-  public Map<DatanodeDetails, Integer> getReplicaIndexes() {
-    return 
this.getNodes().stream().collect(Collectors.toMap(Function.identity(), 
this::getReplicaIndex));
+  public boolean containsAllReplicaIndexes(int fromIndex, int toIndex) {
+    final boolean[] contains = new boolean[toIndex - fromIndex];
+    for (int r : replicaIndexes.values()) {
+      if (r >= fromIndex && r < toIndex) {
+        contains[r - fromIndex] = true;
+      }
+    }
+    for (boolean contain : contains) {
+      if (!contain) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  public Map<DatanodeDetails, Integer> getReplicaIndexesForTesting() {

Review Comment:
   This renames the `ozone admin pipeline list --json` field from 
`replicaIndexes` to `replicaIndexesForTesting`, since `Pipeline` is serialized 
directly here. A base/head `JsonUtils` probe reproduces it. Please preserve the 
existing property 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: [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