@Override
  public boolean runDistCpWithSnapshots(String oldSnapshot, String newSnapshot, List<Path> srcPaths, Path dst,
      boolean overwriteTarget, Configuration conf)
      throws IOException {
    List<String> params = constructDistCpWithSnapshotParams(srcPaths, dst, oldSnapshot, newSnapshot, conf, "-diff");
    try {
      DistCp distcp = new DistCp(conf, null);
      distcp.getConf().setBoolean("mapred.mapper.new-api", true);
      int returnCode = runDistCpInternal(distcp, params);
      if (returnCode == 0) {
        return true;
      } else if (returnCode == DistCpConstants.INVALID_ARGUMENT) {
        // Handling FileNotFoundException, if source got deleted, in that case we don't want to copy either, So it is
        // like a success case, we didn't had anything to copy and we copied nothing, so, we need not to fail.
        LOG.warn("Copy failed with INVALID_ARGUMENT for source: {} to target: {} snapshot1: {} snapshot2: {} "
            + "params: {}", srcPaths, dst, oldSnapshot, newSnapshot, params);
        return true;
      } else if (returnCode == DistCpConstants.UNKNOWN_ERROR && overwriteTarget) {
        // Check if this error is due to target modified.
        if (shouldRdiff(dst, conf, oldSnapshot, overwriteTarget)) {
          LOG.warn("Copy failed due to target modified. Attempting to restore back the target. source: {} target: {} "
              + "snapshot: {}", srcPaths, dst, oldSnapshot);
          List<String> rParams = constructDistCpWithSnapshotParams(srcPaths, dst, ".", oldSnapshot, conf, "-rdiff");
          DistCp rDistcp = new DistCp(conf, null);
          returnCode = runDistCpInternal(rDistcp, rParams);
          if (returnCode == 0) {
            LOG.info("Target restored to previous state.  source: {} target: {} snapshot: {}. Reattempting to copy.",
                srcPaths, dst, oldSnapshot);
            dst.getFileSystem(conf).deleteSnapshot(dst, oldSnapshot);
            dst.getFileSystem(conf).createSnapshot(dst, oldSnapshot);
            returnCode = runDistCpInternal(distcp, params);
            if (returnCode == 0) {
              return true;
            } else {
              LOG.error("Copy failed with after target restore for source: {} to target: {} snapshot1: {} snapshot2: "
                  + "{} params: {}. Return code: {}", srcPaths, dst, oldSnapshot, newSnapshot, params, returnCode);
              return false;
            }
          }
        }
      }
    } catch (Exception e) {
      throw new IOException("Cannot execute DistCp process: ", e);
    }
    return false;
  }
Constructs the params to be passed for using snapshot based replication
@param srcPaths source paths
@param dst destination
@param sourceSnap starting snapshot
@param destSnap end snapshot
@param conf hive configuration
@param diff -diff or -rdiff
@return
shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java