### Question:
DataStorage extends Storage { synchronized void recoverTransitionRead(DataNode datanode, NamespaceInfo nsInfo, Collection<StorageLocation> dataDirs, StartupOption startOpt) throws IOException { if (initialized) { return; } LOG.info("DataNode version: " + HdfsConstants.DATANODE_LAYOUT_VERSION + " and NameNode layout version: " + nsInfo.getLayoutVersion()); this.storageDirs = new ArrayList<StorageDirectory>(dataDirs.size()); addStorageLocations(datanode, nsInfo, dataDirs, startOpt, true, false); this.initialized = true; } DataStorage();  DataStorage(StorageInfo storageInfo); BlockPoolSliceStorage getBPStorage(String bpid); synchronized String getDatanodeUuid(); synchronized void setDatanodeUuid(String newDatanodeUuid); synchronized void createStorageID(StorageDirectory sd); void enableTrash(String bpid); void restoreTrash(String bpid); boolean trashEnabled(String bpid); String getTrashDirectoryForBlockFile(String bpid, File blockFile); @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_TMP; }### Answer:
@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 are not accessible or do not exist.", e); } assertEquals(0, storage.getNumStorageDirs()); }
@Test public void testRecoverTransitionReadDoTransitionFailure() throws IOException { final int numLocations = 3; List<StorageLocation> locations = createStorageLocations(numLocations); String bpid = nsInfo.getBlockPoolID(); storage.recoverTransitionRead(mockDN, bpid, nsInfo, locations, START_OPT); storage.unlockAll(); storage = new DataStorage(); nsInfo.clusterID = "cluster1"; try { storage.recoverTransitionRead(mockDN, bpid, nsInfo, locations, START_OPT); fail("Expect to throw an exception from doTransition()"); } catch (IOException e) { GenericTestUtils.assertExceptionContains("Incompatible clusterIDs", e); } assertEquals(numLocations, storage.getNumStorageDirs()); }