@Test public void testRecoverTransitionReadDoTransitionFailure() throws IOException { final int numLocations = 3; List<StorageLocation> locations = createStorageLocations(numLocations); storage.recoverTransitionRead(mockDN, nsInfo, locations, START_OPT); assertEquals(numLocations, storage.getNumStorageDirs()); storage.unlockAll(); storage = new DataStorage(); nsInfo.clusterID = "cluster1"; try { storage.recoverTransitionRead(mockDN, nsInfo, locations, START_OPT); fail("Expect to throw an exception from doTransition()"); } catch (IOException e) { GenericTestUtils.assertExceptionContains("All specified directories", e); } assertEquals(0, storage.getNumStorageDirs()); }
void recoverTransitionRead(DataNode datanode, NamespaceInfo nsInfo, Collection<StorageLocation> dataDirs, StartupOption startOpt) throws IOException { if (this.initialized) { LOG.info("DataNode version: " + HdfsConstants.DATANODE_LAYOUT_VERSION + " and NameNode layout version: " + nsInfo.getLayoutVersion()); this.storageDirs = new ArrayList<StorageDirectory>(dataDirs.size()); this.initialized = true; } if (addStorageLocations(datanode, nsInfo, dataDirs, startOpt).isEmpty()) { throw new IOException("All specified directories are failed to load."); } }
DataStorage extends Storage { void recoverTransitionRead(DataNode datanode, NamespaceInfo nsInfo, Collection<StorageLocation> dataDirs, StartupOption startOpt) throws IOException { if (this.initialized) { LOG.info("DataNode version: " + HdfsConstants.DATANODE_LAYOUT_VERSION + " and NameNode layout version: " + nsInfo.getLayoutVersion()); this.storageDirs = new ArrayList<StorageDirectory>(dataDirs.size()); this.initialized = true; } if (addStorageLocations(datanode, nsInfo, dataDirs, startOpt).isEmpty()) { throw new IOException("All specified directories are failed to load."); } } }
DataStorage extends Storage { void recoverTransitionRead(DataNode datanode, NamespaceInfo nsInfo, Collection<StorageLocation> dataDirs, StartupOption startOpt) throws IOException { if (this.initialized) { LOG.info("DataNode version: " + HdfsConstants.DATANODE_LAYOUT_VERSION + " and NameNode layout version: " + nsInfo.getLayoutVersion()); this.storageDirs = new ArrayList<StorageDirectory>(dataDirs.size()); this.initialized = true; } if (addStorageLocations(datanode, nsInfo, dataDirs, startOpt).isEmpty()) { throw new IOException("All specified directories are failed to load."); } } DataStorage();  DataStorage(StorageInfo storageInfo); }
DataStorage extends Storage { void recoverTransitionRead(DataNode datanode, NamespaceInfo nsInfo, Collection<StorageLocation> dataDirs, StartupOption startOpt) throws IOException { if (this.initialized) { LOG.info("DataNode version: " + HdfsConstants.DATANODE_LAYOUT_VERSION + " and NameNode layout version: " + nsInfo.getLayoutVersion()); this.storageDirs = new ArrayList<StorageDirectory>(dataDirs.size()); this.initialized = true; } if (addStorageLocations(datanode, nsInfo, dataDirs, startOpt).isEmpty()) { throw new IOException("All specified directories are failed to load."); } } DataStorage();  DataStorage(StorageInfo storageInfo); BlockPoolSliceStorage getBPStorage(String bpid); synchronized String getDatanodeUuid(); synchronized void setDatanodeUuid(String newDatanodeUuid); synchronized boolean createStorageID(
      StorageDirectory sd, boolean regenerateStorageIds); void enableTrash(String bpid); void clearTrash(String bpid); boolean trashEnabled(String bpid); void setRollingUpgradeMarker(String bpid); void clearRollingUpgradeMarker(String bpid); String getTrashDirectoryForBlockFile(String bpid, File blockFile); VolumeBuilder prepareVolume(DataNode datanode, File volume,
      List<NamespaceInfo> nsInfos); @Override boolean isPreUpgradableLayout(StorageDirectory sd); }
DataStorage extends Storage { void recoverTransitionRead(DataNode datanode, NamespaceInfo nsInfo, Collection<StorageLocation> dataDirs, StartupOption startOpt) throws IOException { if (this.initialized) { LOG.info("DataNode version: " + HdfsConstants.DATANODE_LAYOUT_VERSION + " and NameNode layout version: " + nsInfo.getLayoutVersion()); this.storageDirs = new ArrayList<StorageDirectory>(dataDirs.size()); this.initialized = true; } if (addStorageLocations(datanode, nsInfo, dataDirs, startOpt).isEmpty()) { throw new IOException("All specified directories are failed to load."); } } DataStorage();  DataStorage(StorageInfo storageInfo); BlockPoolSliceStorage getBPStorage(String bpid); synchronized String getDatanodeUuid(); synchronized void setDatanodeUuid(String newDatanodeUuid); synchronized boolean createStorageID(
      StorageDirectory sd, boolean regenerateStorageIds); void enableTrash(String bpid); void clearTrash(String bpid); boolean trashEnabled(String bpid); void setRollingUpgradeMarker(String bpid); void clearRollingUpgradeMarker(String bpid); String getTrashDirectoryForBlockFile(String bpid, File blockFile); VolumeBuilder prepareVolume(DataNode datanode, File volume,
      List<NamespaceInfo> nsInfos); @Override boolean isPreUpgradableLayout(StorageDirectory sd); final static String BLOCK_SUBDIR_PREFIX; final static String STORAGE_DIR_RBW; final static String STORAGE_DIR_FINALIZED; final static String STORAGE_DIR_LAZY_PERSIST; final static String STORAGE_DIR_TMP; }