Skip to content

Commit e895ab5

Browse files
author
zengqiang.xu
committed
HDFS-16783. Remove the redundant lock in getFinalizedBlocks
1 parent e012308 commit e895ab5

File tree

1 file changed

+9
-12
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl

1 file changed

+9
-12
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,19 +2167,16 @@ public Map<DatanodeStorage, BlockListAsLongs> getBlockReports(String bpid) {
21672167
*/
21682168
@Override
21692169
public List<ReplicaInfo> getFinalizedBlocks(String bpid) {
2170-
try (AutoCloseDataSetLock l = lockManager.readLock(LockLevel.BLOCK_POOl, bpid)) {
2171-
ArrayList<ReplicaInfo> finalized =
2172-
new ArrayList<>(volumeMap.size(bpid));
2173-
volumeMap.replicas(bpid, (iterator) -> {
2174-
while (iterator.hasNext()) {
2175-
ReplicaInfo b = iterator.next();
2176-
if (b.getState() == ReplicaState.FINALIZED) {
2177-
finalized.add(new FinalizedReplica((FinalizedReplica)b));
2178-
}
2170+
ArrayList<ReplicaInfo> finalized = new ArrayList<>();
2171+
volumeMap.replicas(bpid, (iterator) -> {
2172+
while (iterator.hasNext()) {
2173+
ReplicaInfo b = iterator.next();
2174+
if (b.getState() == ReplicaState.FINALIZED) {
2175+
finalized.add(new FinalizedReplica((FinalizedReplica)b));
21792176
}
2180-
});
2181-
return finalized;
2182-
}
2177+
}
2178+
});
2179+
return finalized;
21832180
}
21842181

21852182
/**

0 commit comments

Comments
 (0)