/** * Move {@code lastcheckpoint.tmp} to {@code previous.checkpoint} * * @see org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory# * getPreviousCheckpoint() * @see org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory# * getLastCheckpointTmp() */ protected void moveLastCheckpoint(StorageDirectory sd) throws IOException { File tmpCkptDir = sd.getLastCheckpointTmp(); File prevCkptDir = sd.getPreviousCheckpoint(); // remove previous.checkpoint if (prevCkptDir.exists()) deleteDir(prevCkptDir); // rename lastcheckpoint.tmp -> previous.checkpoint if (tmpCkptDir.exists()) rename(tmpCkptDir, prevCkptDir); }
/** * Deletes the checkpoint file in given storage directory. * Moves lastcheckpoint.tmp -> current */ private void deleteCancelledChecpointDir(StorageDirectory sd, Collection<StorageDirectory> errorDirs) throws IOException { LOG.info("Reverting checkpoint for : " + sd.getCurrentDir()); try { File tmpCkptDir = sd.getLastCheckpointTmp(); File curDir = sd.getCurrentDir(); if (!tmpCkptDir.exists()) { LOG.warn("Reverting checkpoint - lastcheckpoint.tmp " + "does not exist for storage directory: " + sd); errorDirs.add(sd); return; } // remove current if (curDir.exists()) deleteDir(curDir); // rename lastcheckpoint.tmp -> current rename(tmpCkptDir, curDir); } catch (IOException e) { LOG.warn("Unable to revet checkpoint for : " + sd.getCurrentDir()); errorDirs.add(sd); } }
private 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 for storage directory " + sd.getRoot() + "." + (getLayoutVersion()==0 ? "" : "\n cur LV = " + this.getLayoutVersion() + "; cur CTime = " + this.getCTime())); assert sd.getCurrentDir().exists() : "Current directory must exist."; final File tmpDir = sd.getFinalizedTmp(); // rename previous to tmp and remove rename(prevDir, tmpDir); deleteDir(tmpDir); LOG.info("Finalize upgrade for " + sd.getRoot()+ " is complete."); }
private 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 for storage directory " + sd.getRoot() + "." + (getLayoutVersion()==0 ? "" : "\n cur LV = " + this.getLayoutVersion() + "; cur CTime = " + this.getCTime())); assert sd.getCurrentDir().exists() : "Current directory must exist."; final File tmpDir = sd.getFinalizedTmp(); // rename previous to tmp and remove rename(prevDir, tmpDir); deleteDir(tmpDir); isUpgradeFinalized = true; LOG.info("Finalize upgrade for " + sd.getRoot()+ " is complete."); }
deleteDir(tmpDir); LOG.info("Rollback of " + sd.getRoot()+ " is complete.");
deleteDir(tmpDir); LOG.info("Rollback of " + sd.getRoot()+ " is complete.");