Bläddra i källkod

HDFS-11883: [SPS] : Handle NPE in BlockStorageMovementTracker when dropSPSWork() called. Contributed by Surendra Singh Lilhore.

Uma Maheswara Rao G 8 år sedan
förälder
incheckning
e53f89ccc3

+ 5 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockStorageMovementTracker.java

@@ -88,13 +88,17 @@ public class BlockStorageMovementTracker implements Runnable {
           long trackId = result.getTrackId();
           long trackId = result.getTrackId();
           List<Future<BlockMovementResult>> blocksMoving = moverTaskFutures
           List<Future<BlockMovementResult>> blocksMoving = moverTaskFutures
               .get(trackId);
               .get(trackId);
+          if (blocksMoving == null) {
+            LOG.warn("Future task doesn't exist for trackId " + trackId);
+            continue;
+          }
           blocksMoving.remove(future);
           blocksMoving.remove(future);
 
 
           List<BlockMovementResult> resultPerTrackIdList =
           List<BlockMovementResult> resultPerTrackIdList =
               addMovementResultToTrackIdList(result);
               addMovementResultToTrackIdList(result);
 
 
           // Completed all the scheduled blocks movement under this 'trackId'.
           // Completed all the scheduled blocks movement under this 'trackId'.
-          if (blocksMoving.isEmpty()) {
+          if (blocksMoving.isEmpty() || moverTaskFutures.get(trackId) == null) {
             synchronized (moverTaskFutures) {
             synchronized (moverTaskFutures) {
               moverTaskFutures.remove(trackId);
               moverTaskFutures.remove(trackId);
             }
             }