/** * Move the src file to the target using * {@link Storage#rename(File, File)}. * * @param volume target volume. null if unavailable. * @param src source path. * @param target target path. * @throws IOException */ public void rename( @Nullable FsVolumeSpi volume, File src, File target) throws IOException { final long begin = profilingEventHook.beforeMetadataOp(volume, MOVE); try { faultInjectorEventHook.beforeMetadataOp(volume, MOVE); Storage.rename(src, target); profilingEventHook.afterMetadataOp(volume, MOVE, begin); } catch(Exception e) { onFailure(volume, begin); throw e; } }
LOG.info("Completing previous upgrade for storage directory {}", rootPath); rename(getPreviousTmp(), getPreviousDir()); return; case RECOVER_UPGRADE: // mv previous.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getPreviousTmp(), curDir); return; case COMPLETE_ROLLBACK: // rm removed.tmp LOG.info("Recovering storage directory {} from previous rollback", rootPath); rename(getRemovedTmp(), curDir); return; case COMPLETE_FINALIZE: // rm finalized.tmp if (prevCkptDir.exists()) deleteDir(prevCkptDir); rename(getLastCheckpointTmp(), prevCkptDir); return; case RECOVER_CHECKPOINT: // mv lastcheckpoint.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getLastCheckpointTmp(), curDir); return; default:
LOG.info("Completing previous upgrade for storage directory " + rootPath); rename(getPreviousTmp(), getPreviousDir()); return; case RECOVER_UPGRADE: // mv previous.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getPreviousTmp(), curDir); return; case COMPLETE_ROLLBACK: // rm removed.tmp LOG.info("Recovering storage directory " + rootPath + " from previous rollback"); rename(getRemovedTmp(), curDir); return; case COMPLETE_FINALIZE: // rm finalized.tmp if (prevCkptDir.exists()) deleteDir(prevCkptDir); rename(getLastCheckpointTmp(), prevCkptDir); return; case RECOVER_CHECKPOINT: // mv lastcheckpoint.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getLastCheckpointTmp(), curDir); return; default:
LOG.info("Completing previous upgrade for storage directory " + rootPath + "."); rename(getPreviousTmp(), getPreviousDir()); return; case RECOVER_UPGRADE: // mv previous.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getPreviousTmp(), curDir); return; case COMPLETE_ROLLBACK: // rm removed.tmp LOG.info("Recovering storage directory " + rootPath + " from previous rollback."); rename(getRemovedTmp(), curDir); return; case COMPLETE_FINALIZE: // rm finalized.tmp if (prevCkptDir.exists()) deleteDir(prevCkptDir); rename(getLastCheckpointTmp(), prevCkptDir); return; case RECOVER_CHECKPOINT: // mv lastcheckpoint.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getLastCheckpointTmp(), curDir); return; default:
LOG.info("Completing previous upgrade for storage directory " + rootPath + "."); rename(getPreviousTmp(), getPreviousDir()); return; case RECOVER_UPGRADE: // mv previous.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getPreviousTmp(), curDir); return; case COMPLETE_ROLLBACK: // rm removed.tmp LOG.info("Recovering storage directory " + rootPath + " from previous rollback."); rename(getRemovedTmp(), curDir); return; case COMPLETE_FINALIZE: // rm finalized.tmp if (prevCkptDir.exists()) deleteDir(prevCkptDir); rename(getLastCheckpointTmp(), prevCkptDir); return; case RECOVER_CHECKPOINT: // mv lastcheckpoint.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getLastCheckpointTmp(), curDir); return; default:
LOG.info("Completing previous upgrade for storage directory " + rootPath); rename(getPreviousTmp(), getPreviousDir()); return; case RECOVER_UPGRADE: // mv previous.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getPreviousTmp(), curDir); return; case COMPLETE_ROLLBACK: // rm removed.tmp LOG.info("Recovering storage directory " + rootPath + " from previous rollback"); rename(getRemovedTmp(), curDir); return; case COMPLETE_FINALIZE: // rm finalized.tmp if (prevCkptDir.exists()) deleteDir(prevCkptDir); rename(getLastCheckpointTmp(), prevCkptDir); return; case RECOVER_CHECKPOINT: // mv lastcheckpoint.tmp -> current if (curDir.exists()) deleteDir(curDir); rename(getLastCheckpointTmp(), curDir); return; default:
assert !tmpDir.exists() : "previous.tmp directory must not exist."; rename(curDir, tmpDir);