Skip to content

Commit

Permalink
Reduce map lookups (#88418)
Browse files Browse the repository at this point in the history
This change replcase 2 hash map operations with a single one and a null
check.
  • Loading branch information
idegtiarenko authored Jul 12, 2022
1 parent dd1bd83 commit 47510ad
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;

import java.util.Map;
import java.util.Optional;

public class NodeReplacementAllocationDecider extends AllocationDecider {
Expand Down Expand Up @@ -185,8 +184,8 @@ private static boolean isReplacementSource(RoutingAllocation allocation, String
if (nodeId == null || replacementOngoing(allocation) == false) {
return false;
}
final Map<String, SingleNodeShutdownMetadata> nodeShutdowns = allocation.nodeShutdowns();
return nodeShutdowns.containsKey(nodeId) && nodeShutdowns.get(nodeId).getType().equals(SingleNodeShutdownMetadata.Type.REPLACE);
final SingleNodeShutdownMetadata shutdown = allocation.nodeShutdowns().get(nodeId);
return shutdown != null && shutdown.getType().equals(SingleNodeShutdownMetadata.Type.REPLACE);
}

/**
Expand Down

0 comments on commit 47510ad

Please sign in to comment.