Java Code Examples for org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory#getFinalizedTmp()

The following examples show how to use org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory#getFinalizedTmp() . 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: NNUpgradeUtil.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Finalize the upgrade. The previous dir, if any, will be renamed and
 * removed. After this is completed, rollback is no longer allowed.
 * 
 * @param sd the storage directory to finalize
 * @throws IOException in the event of error
 */
static void doFinalize(StorageDirectory sd) throws IOException {
  File prevDir = sd.getPreviousDir();
  if (!prevDir.exists()) { // already discarded
    LOG.info("Directory " + prevDir + " does not exist.");
    LOG.info("Finalize upgrade for " + sd.getRoot()+ " is not required.");
    return;
  }
  LOG.info("Finalizing upgrade of storage directory " + sd.getRoot());
  Preconditions.checkState(sd.getCurrentDir().exists(),
      "Current directory must exist.");
  final File tmpDir = sd.getFinalizedTmp();
  // rename previous to tmp and remove
  NNStorage.rename(prevDir, tmpDir);
  NNStorage.deleteDir(tmpDir);
  LOG.info("Finalize upgrade for " + sd.getRoot()+ " is complete.");
}
 
Example 2
Source File: NNUpgradeUtil.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Finalize the upgrade. The previous dir, if any, will be renamed and
 * removed. After this is completed, rollback is no longer allowed.
 * 
 * @param sd the storage directory to finalize
 * @throws IOException in the event of error
 */
static void doFinalize(StorageDirectory sd) throws IOException {
  File prevDir = sd.getPreviousDir();
  if (!prevDir.exists()) { // already discarded
    LOG.info("Directory " + prevDir + " does not exist.");
    LOG.info("Finalize upgrade for " + sd.getRoot()+ " is not required.");
    return;
  }
  LOG.info("Finalizing upgrade of storage directory " + sd.getRoot());
  Preconditions.checkState(sd.getCurrentDir().exists(),
      "Current directory must exist.");
  final File tmpDir = sd.getFinalizedTmp();
  // rename previous to tmp and remove
  NNStorage.rename(prevDir, tmpDir);
  NNStorage.deleteDir(tmpDir);
  LOG.info("Finalize upgrade for " + sd.getRoot()+ " is complete.");
}