@@ -447,29 +447,37 @@ private List<StorageDirectory> loadBlockPoolSliceStorage(DataNode datanode,
447447 StartupOption startOpt , ExecutorService executor ) throws IOException {
448448 final String bpid = nsInfo .getBlockPoolID ();
449449 final BlockPoolSliceStorage bpStorage = getBlockPoolSliceStorage (nsInfo );
450+ Map <StorageLocation , List <Callable <StorageDirectory >>> upgradeCallableMap =
451+ new HashMap <>();
450452 final List <StorageDirectory > success = Lists .newArrayList ();
451453 final List <UpgradeTask > tasks = Lists .newArrayList ();
452454 for (StorageLocation dataDir : dataDirs ) {
453455 dataDir .makeBlockPoolDir (bpid , null );
454456 try {
455- final List <Callable <StorageDirectory >> callables = Lists .newArrayList ();
457+ final List <Callable <StorageDirectory >> sdCallables =
458+ Lists .newArrayList ();
456459 final List <StorageDirectory > dirs = bpStorage .recoverTransitionRead (
457- nsInfo , dataDir , startOpt , callables , datanode .getConf ());
458- if (callables .isEmpty ()) {
460+ nsInfo , dataDir , startOpt , sdCallables , datanode .getConf ());
461+ if (sdCallables .isEmpty ()) {
459462 for (StorageDirectory sd : dirs ) {
460463 success .add (sd );
461464 }
462465 } else {
463- for (Callable <StorageDirectory > c : callables ) {
464- tasks .add (new UpgradeTask (dataDir , executor .submit (c )));
465- }
466+ upgradeCallableMap .put (dataDir , sdCallables );
466467 }
467468 } catch (IOException e ) {
468469 LOG .warn ("Failed to add storage directory {} for block pool {}" ,
469470 dataDir , bpid , e );
470471 }
471472 }
472473
474+ for (Map .Entry <StorageLocation , List <Callable <StorageDirectory >>> entry :
475+ upgradeCallableMap .entrySet ()) {
476+ for (Callable <StorageDirectory > c : entry .getValue ()) {
477+ tasks .add (new UpgradeTask (entry .getKey (), executor .submit (c )));
478+ }
479+ }
480+
473481 if (!tasks .isEmpty ()) {
474482 LOG .info ("loadBlockPoolSliceStorage: {} upgrade tasks" , tasks .size ());
475483 for (UpgradeTask t : tasks ) {
0 commit comments