@Test public void testCompleteSnapshotWithNoSnapshotDirectoryFailure() throws Exception { Path snapshotDir = new Path(root, HConstants.SNAPSHOT_DIR_NAME); Path tmpDir = new Path(snapshotDir, ".tmp"); Path workingDir = new Path(tmpDir, "not_a_snapshot"); assertFalse("Already have working snapshot dir: " + workingDir + " but shouldn't. Test file leak?", fs.exists(workingDir)); SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("snapshot").build(); try { SnapshotDescriptionUtils.completeSnapshot(snapshot, root, workingDir, fs); fail("Shouldn't successfully complete move of a non-existent directory."); } catch (IOException e) { LOG.info("Correctly failed to move non-existant directory: " + e.getMessage()); } }
public static void completeSnapshot(SnapshotDescription snapshot, Path rootdir, Path workingDir, FileSystem fs) throws SnapshotCreationException, IOException { Path finishedDir = getCompletedSnapshotDir(snapshot, rootdir); LOG.debug("Snapshot is done, just moving the snapshot from " + workingDir + " to " + finishedDir); if (!fs.rename(workingDir, finishedDir)) { throw new SnapshotCreationException("Failed to move working directory(" + workingDir + ") to completed directory(" + finishedDir + ").", snapshot); } }
SnapshotDescriptionUtils { public static void completeSnapshot(SnapshotDescription snapshot, Path rootdir, Path workingDir, FileSystem fs) throws SnapshotCreationException, IOException { Path finishedDir = getCompletedSnapshotDir(snapshot, rootdir); LOG.debug("Snapshot is done, just moving the snapshot from " + workingDir + " to " + finishedDir); if (!fs.rename(workingDir, finishedDir)) { throw new SnapshotCreationException("Failed to move working directory(" + workingDir + ") to completed directory(" + finishedDir + ").", snapshot); } } }
SnapshotDescriptionUtils { public static void completeSnapshot(SnapshotDescription snapshot, Path rootdir, Path workingDir, FileSystem fs) throws SnapshotCreationException, IOException { Path finishedDir = getCompletedSnapshotDir(snapshot, rootdir); LOG.debug("Snapshot is done, just moving the snapshot from " + workingDir + " to " + finishedDir); if (!fs.rename(workingDir, finishedDir)) { throw new SnapshotCreationException("Failed to move working directory(" + workingDir + ") to completed directory(" + finishedDir + ").", snapshot); } } private  SnapshotDescriptionUtils(); }
SnapshotDescriptionUtils { public static void completeSnapshot(SnapshotDescription snapshot, Path rootdir, Path workingDir, FileSystem fs) throws SnapshotCreationException, IOException { Path finishedDir = getCompletedSnapshotDir(snapshot, rootdir); LOG.debug("Snapshot is done, just moving the snapshot from " + workingDir + " to " + finishedDir); if (!fs.rename(workingDir, finishedDir)) { throw new SnapshotCreationException("Failed to move working directory(" + workingDir + ") to completed directory(" + finishedDir + ").", snapshot); } } private  SnapshotDescriptionUtils(); static long getMaxMasterTimeout(Configuration conf, SnapshotDescription.Type type,
      long defaultMaxWaitTime); static Path getSnapshotRootDir(final Path rootDir); static Path getCompletedSnapshotDir(final SnapshotDescription snapshot, final Path rootDir); static Path getCompletedSnapshotDir(final String snapshotName, final Path rootDir); static Path getWorkingSnapshotDir(final Path rootDir); static Path getWorkingSnapshotDir(SnapshotDescription snapshot, final Path rootDir); static Path getWorkingSnapshotDir(String snapshotName, final Path rootDir); static final Path getSnapshotsDir(Path rootDir); static SnapshotDescription validate(SnapshotDescription snapshot, Configuration conf); static void writeSnapshotInfo(SnapshotDescription snapshot, Path workingDir, FileSystem fs); static SnapshotDescription readSnapshotInfo(FileSystem fs, Path snapshotDir); static void completeSnapshot(SnapshotDescription snapshot, Path rootdir, Path workingDir,
      FileSystem fs); }
SnapshotDescriptionUtils { public static void completeSnapshot(SnapshotDescription snapshot, Path rootdir, Path workingDir, FileSystem fs) throws SnapshotCreationException, IOException { Path finishedDir = getCompletedSnapshotDir(snapshot, rootdir); LOG.debug("Snapshot is done, just moving the snapshot from " + workingDir + " to " + finishedDir); if (!fs.rename(workingDir, finishedDir)) { throw new SnapshotCreationException("Failed to move working directory(" + workingDir + ") to completed directory(" + finishedDir + ").", snapshot); } } private  SnapshotDescriptionUtils(); static long getMaxMasterTimeout(Configuration conf, SnapshotDescription.Type type,
      long defaultMaxWaitTime); static Path getSnapshotRootDir(final Path rootDir); static Path getCompletedSnapshotDir(final SnapshotDescription snapshot, final Path rootDir); static Path getCompletedSnapshotDir(final String snapshotName, final Path rootDir); static Path getWorkingSnapshotDir(final Path rootDir); static Path getWorkingSnapshotDir(SnapshotDescription snapshot, final Path rootDir); static Path getWorkingSnapshotDir(String snapshotName, final Path rootDir); static final Path getSnapshotsDir(Path rootDir); static SnapshotDescription validate(SnapshotDescription snapshot, Configuration conf); static void writeSnapshotInfo(SnapshotDescription snapshot, Path workingDir, FileSystem fs); static SnapshotDescription readSnapshotInfo(FileSystem fs, Path snapshotDir); static void completeSnapshot(SnapshotDescription snapshot, Path rootdir, Path workingDir,
      FileSystem fs); static final int SNAPSHOT_LAYOUT_VERSION; static final String SNAPSHOTINFO_FILE; static final String SNAPSHOT_TMP_DIR_NAME; static final long NO_SNAPSHOT_START_TIME_SPECIFIED; static final String MASTER_SNAPSHOT_TIMEOUT_MILLIS; static final long DEFAULT_MAX_WAIT_TIME; }