Skip to content

Commit 8907573

Browse files
Balancer is running when datanode is down , will throw NullPointerException
1 parent 57d0a94 commit 8907573

File tree

1 file changed

+4
-3
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer

1 file changed

+4
-3
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,21 +286,22 @@ private boolean chooseProxySource() {
286286
// if node group is supported, first try add nodes in the same node group
287287
if (cluster.isNodeGroupAware()) {
288288
for (StorageGroup loc : reportedBlock.getLocations()) {
289-
if (cluster.isOnSameNodeGroup(loc.getDatanodeInfo(), targetDN)
289+
//loc may throw NullPointerException
290+
if (loc!=null && cluster.isOnSameNodeGroup(loc.getDatanodeInfo(), targetDN)
290291
&& addTo(loc)) {
291292
return true;
292293
}
293294
}
294295
}
295296
// check if there is replica which is on the same rack with the target
296297
for (StorageGroup loc : reportedBlock.getLocations()) {
297-
if (cluster.isOnSameRack(loc.getDatanodeInfo(), targetDN) && addTo(loc)) {
298+
if (loc!=null && cluster.isOnSameRack(loc.getDatanodeInfo(), targetDN) && addTo(loc)) {
298299
return true;
299300
}
300301
}
301302
// find out a non-busy replica
302303
for (StorageGroup loc : reportedBlock.getLocations()) {
303-
if (addTo(loc)) {
304+
if (loc!=null && addTo(loc)) {
304305
return true;
305306
}
306307
}

0 commit comments

Comments
 (0)