@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()); }
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 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 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); }
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); }
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; }