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 ( 
->  -> 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  field from  to , since  is serialized directly here. A 
base/head  probe reproduces it. Please preserve the existing property name.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/storage/ContainerProtocolCalls.java:
##########
@@ -931,41 +920,6 @@ public static List<Validator> toValidatorList(Validator 
validator) {
     return Collections.unmodifiableList(validators);
   }
 
-  public static HashMap<DatanodeDetails, GetBlockResponseProto>

Review Comment:
   Please avoid removing this public method in HDDS-16365. It is unrelated, was 
added by HDDS-3867, and exists in released Ozone versions; please restore it or 
move the cleanup to a follow-up Jira.



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