Java Code Examples for org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption#ROLLBACK

The following examples show how to use org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption#ROLLBACK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataNode.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Parse and verify command line arguments and set configuration parameters.
 *
 * @return false if passed argements are incorrect
 */
@VisibleForTesting
static boolean parseArguments(String args[], Configuration conf) {
  StartupOption startOpt = StartupOption.REGULAR;
  int i = 0;

  if (args != null && args.length != 0) {
    String cmd = args[i++];
    if ("-r".equalsIgnoreCase(cmd) || "--rack".equalsIgnoreCase(cmd)) {
      LOG.error("-r, --rack arguments are not supported anymore. RackID " +
          "resolution is handled by the NameNode.");
      return false;
    } else if (StartupOption.ROLLBACK.getName().equalsIgnoreCase(cmd)) {
      startOpt = StartupOption.ROLLBACK;
    } else if (StartupOption.REGULAR.getName().equalsIgnoreCase(cmd)) {
      startOpt = StartupOption.REGULAR;
    } else {
      return false;
    }
  }

  setStartupOption(conf, startOpt);
  return (args == null || i == args.length);    // Fail if more than one cmd specified!
}
 
Example 2
Source File: DataNode.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Parse and verify command line arguments and set configuration parameters.
 *
 * @return false if passed argements are incorrect
 */
@VisibleForTesting
static boolean parseArguments(String args[], Configuration conf) {
  StartupOption startOpt = StartupOption.REGULAR;
  int i = 0;

  if (args != null && args.length != 0) {
    String cmd = args[i++];
    if ("-r".equalsIgnoreCase(cmd) || "--rack".equalsIgnoreCase(cmd)) {
      LOG.error("-r, --rack arguments are not supported anymore. RackID " +
          "resolution is handled by the NameNode.");
      return false;
    } else if (StartupOption.ROLLBACK.getName().equalsIgnoreCase(cmd)) {
      startOpt = StartupOption.ROLLBACK;
    } else if (StartupOption.REGULAR.getName().equalsIgnoreCase(cmd)) {
      startOpt = StartupOption.REGULAR;
    } else {
      return false;
    }
  }

  setStartupOption(conf, startOpt);
  return (args == null || i == args.length);    // Fail if more than one cmd specified!
}
 
Example 3
Source File: JNStorage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
void analyzeAndRecoverStorage(StartupOption startOpt) throws IOException {
  this.state = sd.analyzeStorage(startOpt, this);
  final boolean needRecover = state != StorageState.NORMAL
      && state != StorageState.NON_EXISTENT
      && state != StorageState.NOT_FORMATTED;
  if (state == StorageState.NORMAL && startOpt != StartupOption.ROLLBACK) {
    readProperties(sd);
  } else if (needRecover) {
    sd.doRecover(state);
  }
}
 
Example 4
Source File: TestFileTruncate.java    From hadoop with Apache License 2.0 5 votes vote down vote up
static void restartCluster(StartupOption o)
    throws IOException {
  cluster.shutdown();
  if(StartupOption.ROLLBACK == o)
    NameNode.doRollback(conf, false);
  cluster = new MiniDFSCluster.Builder(conf).numDataNodes(DATANODE_NUM)
      .format(false)
      .nameNodePort(NameNode.DEFAULT_PORT)
      .startupOption(o==StartupOption.ROLLBACK ? StartupOption.REGULAR : o)
      .dnStartupOption(o!=StartupOption.ROLLBACK ? StartupOption.REGULAR : o)
      .build();
  fs = cluster.getFileSystem();
}
 
Example 5
Source File: JNStorage.java    From big-c with Apache License 2.0 5 votes vote down vote up
void analyzeAndRecoverStorage(StartupOption startOpt) throws IOException {
  this.state = sd.analyzeStorage(startOpt, this);
  final boolean needRecover = state != StorageState.NORMAL
      && state != StorageState.NON_EXISTENT
      && state != StorageState.NOT_FORMATTED;
  if (state == StorageState.NORMAL && startOpt != StartupOption.ROLLBACK) {
    readProperties(sd);
  } else if (needRecover) {
    sd.doRecover(state);
  }
}
 
Example 6
Source File: TestFileTruncate.java    From big-c with Apache License 2.0 5 votes vote down vote up
static void restartCluster(StartupOption o)
    throws IOException {
  cluster.shutdown();
  if(StartupOption.ROLLBACK == o)
    NameNode.doRollback(conf, false);
  cluster = new MiniDFSCluster.Builder(conf).numDataNodes(DATANODE_NUM)
      .format(false)
      .nameNodePort(NameNode.DEFAULT_PORT)
      .startupOption(o==StartupOption.ROLLBACK ? StartupOption.REGULAR : o)
      .dnStartupOption(o!=StartupOption.ROLLBACK ? StartupOption.REGULAR : o)
      .build();
  fs = cluster.getFileSystem();
}
 
Example 7
Source File: FSImage.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * For each storage directory, performs recovery of incomplete transitions
 * (eg. upgrade, rollback, checkpoint) and inserts the directory's storage
 * state into the dataDirStates map.
 * @param dataDirStates output of storage directory states
 * @return true if there is at least one valid formatted storage directory
 */
public static boolean recoverStorageDirs(StartupOption startOpt,
    NNStorage storage, Map<StorageDirectory, StorageState> dataDirStates)
    throws IOException {
  boolean isFormatted = false;
  // This loop needs to be over all storage dirs, even shared dirs, to make
  // sure that we properly examine their state, but we make sure we don't
  // mutate the shared dir below in the actual loop.
  for (Iterator<StorageDirectory> it = 
                    storage.dirIterator(); it.hasNext();) {
    StorageDirectory sd = it.next();
    StorageState curState;
    if (startOpt == StartupOption.METADATAVERSION) {
      /* All we need is the layout version. */
      storage.readProperties(sd);
      return true;
    }

    try {
      curState = sd.analyzeStorage(startOpt, storage);
      // sd is locked but not opened
      switch(curState) {
      case NON_EXISTENT:
        // name-node fails if any of the configured storage dirs are missing
        throw new InconsistentFSStateException(sd.getRoot(),
                    "storage directory does not exist or is not accessible.");
      case NOT_FORMATTED:
        break;
      case NORMAL:
        break;
      default:  // recovery is possible
        sd.doRecover(curState);
      }
      if (curState != StorageState.NOT_FORMATTED 
          && startOpt != StartupOption.ROLLBACK) {
        // read and verify consistency with other directories
        storage.readProperties(sd, startOpt);
        isFormatted = true;
      }
      if (startOpt == StartupOption.IMPORT && isFormatted)
        // import of a checkpoint is allowed only into empty image directories
        throw new IOException("Cannot import image from a checkpoint. " 
            + " NameNode already contains an image in " + sd.getRoot());
    } catch (IOException ioe) {
      sd.unlock();
      throw ioe;
    }
    dataDirStates.put(sd,curState);
  }
  return isFormatted;
}
 
Example 8
Source File: FSImage.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * For each storage directory, performs recovery of incomplete transitions
 * (eg. upgrade, rollback, checkpoint) and inserts the directory's storage
 * state into the dataDirStates map.
 * @param dataDirStates output of storage directory states
 * @return true if there is at least one valid formatted storage directory
 */
public static boolean recoverStorageDirs(StartupOption startOpt,
    NNStorage storage, Map<StorageDirectory, StorageState> dataDirStates)
    throws IOException {
  boolean isFormatted = false;
  // This loop needs to be over all storage dirs, even shared dirs, to make
  // sure that we properly examine their state, but we make sure we don't
  // mutate the shared dir below in the actual loop.
  for (Iterator<StorageDirectory> it = 
                    storage.dirIterator(); it.hasNext();) {
    StorageDirectory sd = it.next();
    StorageState curState;
    if (startOpt == StartupOption.METADATAVERSION) {
      /* All we need is the layout version. */
      storage.readProperties(sd);
      return true;
    }

    try {
      curState = sd.analyzeStorage(startOpt, storage);
      // sd is locked but not opened
      switch(curState) {
      case NON_EXISTENT:
        // name-node fails if any of the configured storage dirs are missing
        throw new InconsistentFSStateException(sd.getRoot(),
                    "storage directory does not exist or is not accessible.");
      case NOT_FORMATTED:
        break;
      case NORMAL:
        break;
      default:  // recovery is possible
        sd.doRecover(curState);
      }
      if (curState != StorageState.NOT_FORMATTED 
          && startOpt != StartupOption.ROLLBACK) {
        // read and verify consistency with other directories
        storage.readProperties(sd, startOpt);
        isFormatted = true;
      }
      if (startOpt == StartupOption.IMPORT && isFormatted)
        // import of a checkpoint is allowed only into empty image directories
        throw new IOException("Cannot import image from a checkpoint. " 
            + " NameNode already contains an image in " + sd.getRoot());
    } catch (IOException ioe) {
      sd.unlock();
      throw ioe;
    }
    dataDirStates.put(sd,curState);
  }
  return isFormatted;
}