Skip to content

Commit 9f9b0fc

Browse files
committed
refine code
1 parent 1b89f2f commit 9f9b0fc

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static org.apache.hadoop.hdfs.DFSConfigKeys.*;
2121
import static org.apache.hadoop.hdfs.protocol.BlockType.CONTIGUOUS;
2222
import static org.apache.hadoop.hdfs.protocol.BlockType.STRIPED;
23-
import static org.apache.hadoop.hdfs.server.blockmanagement.ReconstructionSkipReason.SourceUnavailableDetail;
2423
import static org.apache.hadoop.util.ExitUtil.terminate;
2524
import static org.apache.hadoop.util.Time.now;
2625

@@ -90,6 +89,7 @@
9089
import org.apache.hadoop.hdfs.server.blockmanagement.PendingDataNodeMessages.ReportedBlockInfo;
9190
import org.apache.hadoop.hdfs.server.blockmanagement.PendingReconstructionBlocks.PendingBlockInfo;
9291
import org.apache.hadoop.hdfs.server.blockmanagement.ExcessRedundancyMap.ExcessBlockInfo;
92+
import org.apache.hadoop.hdfs.server.blockmanagement.ReconstructionSkipReason.SourceUnavailableDetail;
9393
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
9494
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.ReplicaState;
9595
import org.apache.hadoop.hdfs.server.namenode.CachedBlock;
@@ -2134,6 +2134,7 @@ int computeReconstructionWorkForBlocks(
21342134
List<List<BlockInfo>> blocksToReconstruct) {
21352135
int scheduledWork = 0;
21362136
List<BlockReconstructionWork> reconWork = new ArrayList<>();
2137+
21372138
// Step 1: categorize at-risk blocks into replication and EC tasks
21382139
namesystem.writeLock();
21392140
try {

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/ReconstructionSkipReason.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* to you under the Apache License, Version 2.0 (the
77
* "License"); you may not use this file except in compliance
88
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,8 +31,8 @@
3131
* 2. No Target node is available
3232
* 3. ReconstructionWork is built but validation failed
3333
* I put above 3 cases as ReconstructionSkipReason.
34-
* - For the detailed reason of `No source node is available`, I put it into SourceUnavailableDetail enum
35-
* - For the detailed reason of `No Target node is available`, we already has NodeNotChosenReason in BlockPlacementPolicyDefault
34+
* - For the detailed reason of `No source node is available`, I put it into SourceUnavailableDetail enum
35+
* - For the detailed reason of `No Target node is available`, we already has NodeNotChosenReason in BlockPlacementPolicyDefault
3636
*/
3737
public enum ReconstructionSkipReason {
3838
SOURCE_UNAVAILABLE("source node or storage unavailable"),
@@ -56,6 +56,7 @@ public String toString() {
5656
return text;
5757
}
5858
}
59+
5960
public static final Logger LOG = LoggerFactory.getLogger(
6061
BlockManager.class);
6162

@@ -74,47 +75,47 @@ public String toString() {
7475
return text;
7576
}
7677

77-
public static void start(){
78+
public static void start() {
7879
blockNotChosenReasonMap.get().clear();
7980
}
8081

8182
public static void genReasonWithDetail(BlockInfo block, DatanodeStorageInfo storage,
8283
ReconstructionSkipReason reason) {
83-
if(LOG.isDebugEnabled()){
84+
if (LOG.isDebugEnabled()) {
8485
genReasonImpl(block, storage, reason, null);
8586
}
8687
}
8788

8889
public static void genReasonWithDetail(BlockInfo block, DatanodeStorageInfo storage,
8990
ReconstructionSkipReason reason, SourceUnavailableDetail reasonDetails) {
90-
if(LOG.isDebugEnabled()){
91+
if (LOG.isDebugEnabled()) {
9192
genReasonImpl(block, storage, reason, reasonDetails);
9293
}
9394
}
9495

9596
@VisibleForTesting
9697
static void genReasonImpl(BlockInfo block, DatanodeStorageInfo storage,
97-
ReconstructionSkipReason reason, SourceUnavailableDetail reasonDetails){
98+
ReconstructionSkipReason reason, SourceUnavailableDetail reasonDetails) {
9899
// build the error message for later use.
99-
HashMap<BlockInfo, StringBuilder> blockReason = blockNotChosenReasonMap.get();
100+
HashMap<BlockInfo, StringBuilder> blockReason = blockNotChosenReasonMap.get();
100101
StringBuilder reasonForBlock = null;
101102
blockReason.putIfAbsent(block, new StringBuilder()
102103
.append("Block ")
103104
.append(block)
104105
.append(" is not scheduled for reconstruction since: ["));
105106
reasonForBlock = blockReason.get(block);
106107
reasonForBlock.append("\n").append(reason);
107-
if(storage != null)
108+
if (storage != null)
108109
reasonForBlock.append(" on node ").append(storage);
109110
if (reasonDetails != null) {
110111
reasonForBlock.append(". Detail : [").append(reasonDetails).append("]");
111112
}
112113
}
113114

114115
@VisibleForTesting
115-
static String summary(){
116+
static String summary() {
116117
StringBuilder finalReasonForAllBlocks = new StringBuilder();
117-
for(Map.Entry<BlockInfo, StringBuilder> blockReason: blockNotChosenReasonMap.get().entrySet()){
118+
for (Map.Entry<BlockInfo, StringBuilder> blockReason : blockNotChosenReasonMap.get().entrySet()) {
118119
blockReason.getValue().append("\n]");
119120
finalReasonForAllBlocks.append(blockReason.getValue());
120121
}

0 commit comments

Comments
 (0)