protected static String getProperty(Properties props, StorageDirectory sd, String name) throws InconsistentFSStateException { String property = props.getProperty(name); if (property == null) { throw new InconsistentFSStateException(sd.root, "file " + STORAGE_FILE_VERSION + " has " + name + " missing."); } return property; }
public InconsistentFSStateException(File dir, String descr) { super("Directory " + getFilePath(dir) + " is in an inconsistent state: " + descr); }
/** Validate and set block pool ID */ private void setBlockPoolID(File storage, String bpid) throws InconsistentFSStateException { if (bpid == null || bpid.equals("")) { throw new InconsistentFSStateException(storage, "file " + STORAGE_FILE_VERSION + " is invalid."); } if (!blockpoolID.equals("") && !blockpoolID.equals(bpid)) { throw new InconsistentFSStateException(storage, "Unexpected blockpoolID " + bpid + ". Expected " + blockpoolID); } blockpoolID = bpid; }
public InconsistentFSStateException(File dir, String descr) { super("Directory " + getFilePath(dir) + " is in an inconsistent state: " + descr); }
/** Validate and set block pool ID. */ private void setBlockPoolID(File storage, String bpid) throws InconsistentFSStateException { if (bpid == null || bpid.equals("")) { throw new InconsistentFSStateException(storage, "file " + Storage.STORAGE_FILE_VERSION + " has no block pool Id."); } if (!blockpoolID.equals("") && !blockpoolID.equals(bpid)) { throw new InconsistentFSStateException(storage, "Unexepcted blockpoolID " + bpid + " . Expected " + blockpoolID); } setBlockPoolID(bpid); }
public InconsistentFSStateException(File dir, String descr) { super("Directory " + getFilePath(dir) + " is in an inconsistent state: " + descr); }
/** Validate and set namespaceID version from {@link Properties}*/ protected void setNamespaceID(Properties props, StorageDirectory sd) throws InconsistentFSStateException { int nsId = Integer.parseInt(getProperty(props, sd, "namespaceID")); if (namespaceID != 0 && nsId != 0 && namespaceID != nsId) { throw new InconsistentFSStateException(sd.root, "namespaceID is incompatible with others."); } namespaceID = nsId; }
public InconsistentFSStateException(File dir, String descr) { super("Directory " + getFilePath(dir) + " is in an inconsistent state: " + descr); }
/** Check if upgrade is in progress. */ public static void checkUpgrade(NNStorage storage) throws IOException { // Upgrade or rolling upgrade is allowed only if there are // no previous fs states in any of the local directories for (Iterator<StorageDirectory> it = storage.dirIterator(false); it.hasNext();) { StorageDirectory sd = it.next(); if (sd.getPreviousDir().exists()) throw new InconsistentFSStateException(sd.getRoot(), "previous fs state should not exist during upgrade. " + "Finalize or rollback first."); } }
public InconsistentFSStateException(File dir, String descr) { super("Directory " + getFilePath(dir) + " is in an inconsistent state: " + descr); }
/** * Check to see if current/ directory is empty. This method is used * before determining to format the directory. * * @throws InconsistentFSStateException if not empty. * @throws IOException if unable to list files under the directory. */ private void checkEmptyCurrent() throws InconsistentFSStateException, IOException { File currentDir = getCurrentDir(); if(currentDir == null || !currentDir.exists()) { // if current/ does not exist, it's safe to format it. return; } try(DirectoryStream<java.nio.file.Path> dirStream = Files.newDirectoryStream(currentDir.toPath())) { if (dirStream.iterator().hasNext()) { throw new InconsistentFSStateException(root, "Can't format the storage directory because the current " + "directory is not empty."); } } }
/** Validate and set clusterId from {@link Properties}*/ protected void setClusterId(Properties props, int layoutVersion, StorageDirectory sd) throws InconsistentFSStateException { // Set cluster ID in version that supports federation if (LayoutVersion.supports(getServiceLayoutFeatureMap(), Feature.FEDERATION, layoutVersion)) { String cid = getProperty(props, sd, "clusterID"); if (!(clusterID.equals("") || cid.equals("") || clusterID.equals(cid))) { throw new InconsistentFSStateException(sd.getRoot(), "cluster Id is incompatible with others."); } clusterID = cid; } }
/** Validate and set storage type from {@link Properties}*/ protected void checkStorageType(Properties props, StorageDirectory sd) throws InconsistentFSStateException { if (storageType == null) { //don't care about storage type return; } NodeType type = NodeType.valueOf(getProperty(props, sd, "storageType")); if (!storageType.equals(type)) { throw new InconsistentFSStateException(sd.root, "Incompatible node types: storageType=" + storageType + " but StorageDirectory type=" + type); } }
return StorageState.NORMAL; if (hasPrevious) throw new InconsistentFSStateException(root, "version file in current directory is missing."); if (checkCurrentIsEmpty) { + (hasFinalizedTmp?1:0) + (hasCheckpointTmp?1:0) > 1) throw new InconsistentFSStateException(root, "too many temporary directories."); throw new InconsistentFSStateException(root, STORAGE_DIR_PREVIOUS + " and " + STORAGE_TMP_FINALIZED + "cannot exist together."); throw new InconsistentFSStateException(root, STORAGE_DIR_PREVIOUS + " and " + STORAGE_TMP_PREVIOUS + " cannot exist together."); throw new InconsistentFSStateException(root, "one and only one directory " + STORAGE_DIR_CURRENT + " or " + STORAGE_DIR_PREVIOUS
case NON_EXISTENT: throw new InconsistentFSStateException(sd.getRoot(), "checkpoint directory does not exist or is not accessible."); case NOT_FORMATTED:
throw new InconsistentFSStateException(sd.getRoot(), "file " + STORAGE_FILE_VERSION + " is invalid."); if (!(sid == null || sid.equals("") || ssid.equals("") || sid.equals(ssid))) { throw new InconsistentFSStateException(sd.getRoot(), "has incompatible storage Id."); setDatanodeUuid(dnUuid); } else if (getDatanodeUuid().compareTo(dnUuid) != 0) { throw new InconsistentFSStateException(sd.getRoot(), "Root " + sd.getRoot() + ": DatanodeUuid=" + dnUuid + ", does not match " + getDatanodeUuid() + " from other" +
throw new InconsistentFSStateException(sd.getRoot(), "cannot access checkpoint directory."); case NON_EXISTENT: throw new InconsistentFSStateException(sd.getRoot(), "checkpoint directory does not exist or is not accessible."); case NOT_FORMATTED:
case NON_EXISTENT: throw new InconsistentFSStateException(sd.getRoot(), "storage directory does not exist or is not accessible."); case NOT_FORMATTED:
throw new InconsistentFSStateException(curFile, "imgVersion " + imgVersion + " expected to be " + getLayoutVersion());
throw new InconsistentFSStateException(bpSd.getRoot(), "Cannot rollback to a newer state.\nDatanode previous state: LV = " + prevInfo.getLayoutVersion() + " CTime = " + prevInfo.getCTime()