DataStorage extends Storage { void recoverTransitionRead(DataNode datanode, NamespaceInfo nsInfo, Collection<StorageLocation> dataDirs, StartupOption startOpt) throws IOException { if (addStorageLocations(datanode, nsInfo, dataDirs, startOpt).isEmpty()) { throw new IOException("All specified directories have failed to load."); } } DataStorage();  DataStorage(StorageInfo storageInfo); BlockPoolSliceStorage getBPStorage(String bpid); String getDatanodeUuid(); void setDatanodeUuid(String newDatanodeUuid); static boolean createStorageID(
      StorageDirectory sd, boolean regenerateStorageIds, Configuration conf); void enableTrash(String bpid); void clearTrash(String bpid); boolean trashEnabled(String bpid); void setRollingUpgradeMarker(String bpid); void clearRollingUpgradeMarker(String bpid); String getTrashDirectoryForReplica(String bpid, ReplicaInfo info); VolumeBuilder prepareVolume(DataNode datanode,
      StorageLocation location, List<NamespaceInfo> nsInfos); @Override boolean isPreUpgradableLayout(StorageDirectory sd); @Deprecated static boolean fullyDelete(final File dir); 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; }
@Test public void testRecoverTransitionReadFailure() throws IOException { final int numLocations = 3; List<StorageLocation> locations = createStorageLocations(numLocations, true); try { storage.recoverTransitionRead(mockDN, nsInfo, locations, START_OPT); fail("An IOException should throw: all StorageLocations are NON_EXISTENT"); } catch (IOException e) { GenericTestUtils.assertExceptionContains( "All specified directories have failed to load.", e); } assertEquals(0, storage.getNumStorageDirs()); }
@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()); }