public static void cleanupSnapshots(Path dumpRoot, String snapshotPrefix, HiveConf conf,
      ReplSnapshotCount snapshotCount, boolean isLoad) throws IOException, SemanticException {
    DistributedFileSystem dumpDfs = (DistributedFileSystem) dumpRoot.getFileSystem(conf);
    if (dumpDfs.exists(new Path(dumpRoot, EximUtil.FILE_LIST_EXTERNAL_SNAPSHOT_OLD))) {
      FileList snapOld = createTableFileList(dumpRoot, EximUtil.FILE_LIST_EXTERNAL_SNAPSHOT_OLD, conf);
      FileList snapNew = createTableFileList(dumpRoot, EximUtil.FILE_LIST_EXTERNAL_SNAPSHOT_CURRENT, conf);
      ArrayList<String> oldPaths = SnapshotUtils.getListFromFileList(snapOld);
      ArrayList<String> newPaths = SnapshotUtils.getListFromFileList(snapNew);
      ArrayList<String> diffList = SnapshotUtils.getDiffList(newPaths, oldPaths, conf, isLoad);
      SnapshotUtils.cleanUpSnapshots(diffList, snapshotPrefix, snapshotCount, conf);
    }
    if (isLoad) {
      try {
        dumpDfs.delete((new Path(dumpRoot, EximUtil.FILE_LIST_EXTERNAL_SNAPSHOT_OLD)), true);
      } catch (FileNotFoundException fnf) {
        // ignore
        LOG.warn("Failed to clean up snapshot " + EximUtil.FILE_LIST_EXTERNAL_SNAPSHOT_OLD, fnf);
      }
      try {
        dumpDfs.rename(new Path(dumpRoot, EximUtil.FILE_LIST_EXTERNAL_SNAPSHOT_CURRENT),
            new Path(dumpRoot, EximUtil.FILE_LIST_EXTERNAL_SNAPSHOT_OLD), Options.Rename.OVERWRITE);
      } catch (FileNotFoundException fnf) {
        // ignore
        LOG.warn("Failed to clean up snapshot " + EximUtil.FILE_LIST_EXTERNAL_SNAPSHOT_CURRENT, fnf);
      }
    }
  }
Cleans up any snapshots by computing diff between the list of snapshots between two replication dumps.
@param dumpRoot Root of the dump
@param snapshotPrefix prefix used by the snapshot
@param conf Hive Configuration.
@param snapshotCount the counter to store number of deleted snapshots.
@param isLoad If this is called for clearing up snapshots at target cluster, In case of load it renames the
              snapshot file as well.
@throws IOException
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/util/SnapshotUtils.java