Skip to content

HDDS-16365. Pipeline.getReplicaIndexes() unnecessarily create a new map. - #11194

Open
szetszwo wants to merge 1 commit into
apache:masterfrom
szetszwo:HDDS-16365
Open

HDDS-16365. Pipeline.getReplicaIndexes() unnecessarily create a new map.#11194
szetszwo wants to merge 1 commit into
apache:masterfrom
szetszwo:HDDS-16365

Conversation

@szetszwo

@szetszwo szetszwo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

In Pipeline, the getReplicaIndexes() method, which copies the replicaIndexes map, is not really needed:

  1. In many cases, the copied map is used for calling get(dn) -- just directly call the existing getReplicaIndex(dn) method.
  2. One special case is in the ScmClient in OM for checking if a pipeline containing all replica indexes -- create a new containsAllReplicaIndexes method.
  3. The remaining cases are used in tests for iterating the nodes -- rename it to getReplicaIndexesForTesting() and use unmodifiableMap instead of copying.

For #1 above, getReplicaIndexes() is mainly used for building DatanodeBlockID protos. We will also refactor the code:

  • Add a new replicaIdx parameter to BlockID.getDatanodeBlockIDProtobufBuilder().
  • For the code using DatanodeBlockID.Builder, change them to use getDatanodeBlockIDProtobufBuilder(..) instead.

What is the link to the Apache JIRA

HDDS-16365

How was this patch tested?

By updating existing tests.

@szetszwo
szetszwo requested a review from chungen0126 September 3, 2026 08:50
.setContainerID(containerBlockID.getContainerID())
.setLocalID(containerBlockID.getLocalID())
.setBlockCommitSequenceId(blockCommitSequenceId);
if (replicaIdx != null && replicaIdx > 0) {

@rich7420 rich7420 Sep 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

return true;
}

public Map<DatanodeDetails, Integer> getReplicaIndexesForTesting() {

@rich7420 rich7420 Sep 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

return Collections.unmodifiableList(validators);
}

public static HashMap<DatanodeDetails, GetBlockResponseProto>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants