java-topology/defects/hadoop/patch/hadoop-0003.patch

32 lines
1.7 KiB
Diff

# UNDF: UNDF-2026-000000098
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/sps/StoragePolicySatisfier.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/sps/StoragePolicySatisfier.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -520,7 +520,8 @@ public class StoragePolicySatisfier<T> implements SPSService<T> {
List<DatanodeInfo> existingBlockStorages = new ArrayList<DatanodeInfo>(
Arrays.asList(blockInfo.getLocations()));
- List<DatanodeInfo> excludeNodes = new ArrayList<>(existingBlockStorages);
+ // Use HashSet for O(1) contains() in findTargetNode() hot path
+ Collection<DatanodeInfo> excludeNodes = new HashSet<>(existingBlockStorages);
@@ -591,7 +592,7 @@ public class StoragePolicySatisfier<T> implements SPSService<T> {
List<BlockMovingInfo> blockMovingInfos, LocatedBlock blockInfo,
List<StorageTypeNodePair> sourceWithStorageList,
List<StorageType> expectedTypes,
EnumMap<StorageType, List<DatanodeWithStorage.StorageDetails>> targetDns,
ErasureCodingPolicy ecPolicy,
- List<DatanodeInfo> excludeNodes) {
+ Collection<DatanodeInfo> excludeNodes) {
@@ -778,7 +779,7 @@ public class StoragePolicySatisfier<T> implements SPSService<T> {
private StorageTypeNodePair findTargetNode(BlockInfo block,
StorageType[] targetTypes, boolean isEC,
EnumMap<StorageType, List<DatanodeWithStorage.StorageDetails>> locsForExpectedStorageTypes,
- List<DatanodeInfo> excludeNodes) {
+ Collection<DatanodeInfo> excludeNodes) {