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

1 participant