StorageDirectory sd = sdit.next(); try { Properties props = readPropertiesFile(sd.getVersionFile()); if (props == null) { cid = null;
@Override public void inspectDirectory(StorageDirectory sd) throws IOException { if (!sd.getVersionFile().exists()) { LOG.info("No version file in " + sd.getRoot()); needToSave |= true;
it.hasNext();) { StorageDirectory sd = it.next(); if (!sd.getVersionFile().exists()) { FSImage.LOG.warn("Storage directory " + sd + " contains no VERSION file. Skipping...");
/** * Read properties from the VERSION file in the given storage directory. */ public void readProperties(StorageDirectory sd) throws IOException { Properties props = readPropertiesFile(sd.getVersionFile()); setFieldsFromProperties(props, sd); }
/** * Write properties to the VERSION file in the given storage directory. */ public void writeProperties(StorageDirectory sd) throws IOException { writeProperties(sd.getVersionFile(), sd); }
/** * Read version file. * * @throws IOException if file cannot be read or contains inconsistent data */ public void read() throws IOException { read(getVersionFile()); }
/** Check whether the root is a valid BlockPoolSlice storage. */ private static void checkDir(File root, String bpid) { Storage.StorageDirectory sd = new Storage.StorageDirectory(root); File bpRoot = new File(sd.getCurrentDir(), bpid); Storage.StorageDirectory bpSd = new Storage.StorageDirectory(bpRoot); assertTrue(bpSd.getRoot().isDirectory()); assertTrue(bpSd.getCurrentDir().isDirectory()); assertTrue(bpSd.getVersionFile().isFile()); }
/** Check whether the path is a valid DataNode data directory. */ private static void checkDir(File dataDir) { Storage.StorageDirectory sd = new Storage.StorageDirectory(dataDir); assertTrue(sd.getRoot().isDirectory()); assertTrue(sd.getCurrentDir().isDirectory()); assertTrue(sd.getVersionFile().isFile()); }
boolean shouldCheckpointAtStartup() { FSImage fsImage = getFSImage(); if(isRole(NamenodeRole.CHECKPOINT)) { assert fsImage.getStorage().getNumStorageDirs() > 0; return ! fsImage.getStorage().getStorageDir(0).getVersionFile().exists(); } // BN always checkpoints on startup in order to get in sync with namespace return true; }
/** * Read properties from the VERSION file in the given storage directory. */ public void readProperties(StorageDirectory sd) throws IOException { Properties props = readPropertiesFile(sd.getVersionFile()); setFieldsFromProperties(props, sd); }
/** Read VERSION file for rollback */ void readProperties(StorageDirectory sd, int rollbackLayoutVersion) throws IOException { Properties props = readPropertiesFile(sd.getVersionFile()); setFieldsFromProperties(props, sd, true, rollbackLayoutVersion); }
File versionFile = getVersionFile(); boolean hasCurrent = versionFile.exists();
@Override void inspectDirectory(StorageDirectory sd) throws IOException { if (!sd.getVersionFile().exists()) { hasOutOfDateStorageDirs = true; return;
/** * Activate a volume to serve requests. * @throws IOException if the storage UUID already exists. */ private void activateVolume( ReplicaMap replicaMap, Storage.StorageDirectory sd, StorageType storageType, FsVolumeReference ref) throws IOException { try (AutoCloseableLock lock = datasetLock.acquire()) { DatanodeStorage dnStorage = storageMap.get(sd.getStorageUuid()); if (dnStorage != null) { final String errorMsg = String.format( "Found duplicated storage UUID: %s in %s.", sd.getStorageUuid(), sd.getVersionFile()); LOG.error(errorMsg); throw new IOException(errorMsg); } volumeMap.addAll(replicaMap); storageMap.put(sd.getStorageUuid(), new DatanodeStorage(sd.getStorageUuid(), DatanodeStorage.State.NORMAL, storageType)); asyncDiskService.addVolume((FsVolumeImpl) ref.getVolume()); volumes.addVolume(ref); } }
void readProperties(StorageDirectory sd, StartupOption startupOption) throws IOException { Properties props = readPropertiesFile(sd.getVersionFile()); if (props == null) { throw new IOException( "Properties not found for storage directory " + sd); } if (HdfsServerConstants.RollingUpgradeStartupOption.ROLLBACK .matches(startupOption)) { int lv = Integer.parseInt(getProperty(props, sd, "layoutVersion")); if (lv > getServiceLayoutVersion()) { // we should not use a newer version for rollingUpgrade rollback throw new IncorrectVersionException(getServiceLayoutVersion(), lv, "storage directory " + sd.getRoot().getAbsolutePath()); } props.setProperty("layoutVersion", Integer.toString(HdfsServerConstants.NAMENODE_LAYOUT_VERSION)); } setFieldsFromProperties(props, sd); }
/** * Create a VERSION file in the newly added storage directories. */ private void initNewDirs() { if (newDirs == null) { return; } for (StorageDirectory sd : newDirs) { try { storage.writeProperties(sd); LOG.info("Wrote VERSION in the new storage, " + sd.getCurrentDir()); } catch (IOException e) { // Failed to create a VERSION file. Report the error. storage.reportErrorOnFile(sd.getVersionFile()); } } newDirs.clear(); newDirs = null; }
/** Read VERSION file for rollback */ void readProperties(StorageDirectory sd, int rollbackLayoutVersion) throws IOException { Properties props = readPropertiesFile(sd.getVersionFile()); setFieldsFromProperties(props, sd, true, rollbackLayoutVersion); }
boolean shouldCheckpointAtStartup() { FSImage fsImage = getFSImage(); if(isRole(NamenodeRole.CHECKPOINT)) { assert fsImage.getStorage().getNumStorageDirs() > 0; return ! fsImage.getStorage().getStorageDir(0).getVersionFile().exists(); } // BN always checkpoints on startup in order to get in sync with namespace return true; }
/** * Write properties to the VERSION file in the given storage directory. */ public void writeProperties(StorageDirectory sd) throws IOException { writeProperties(sd.getVersionFile(), sd); }
/** * Read properties from the VERSION file in the given storage directory. */ public void readProperties(StorageDirectory sd) throws IOException { Properties props = readPropertiesFile(sd.getVersionFile()); setFieldsFromProperties(props, sd); }