private void preserveDistCpAttributes(Path destPath, Path sourcePath, HiveConf clonedConf, FileStatus status)
      throws IOException {
    String preserveString = getPreserveString(clonedConf);
    LOG.info("Preserving DistCp Attributes: {}", preserveString);
    FileSystem destFs = destPath.getFileSystem(clonedConf);
    // If both preserve user and group are specified.
    if (preserveString.contains("u") && preserveString.contains("g")) {
      destFs.setOwner(destPath, status.getOwner(), status.getGroup());
    } else if (preserveString.contains("u")) {
      // If only preserve user is specified.
      destFs.setOwner(destPath, status.getOwner(), null);
    } else if (preserveString.contains("g")) {
      // If only preserve group is specified.
      destFs.setOwner(destPath, null, status.getGroup());
    }
    // Preserve permissions
    if (preserveString.contains("p")) {
      destFs.setPermission(destPath, status.getPermission());
    }
    // Preserve ACL
    if (preserveString.contains("a")) {
      setAclsToTarget(status, sourcePath, destPath, clonedConf);
    }
  }
DirCopyTask, mainly to be used to copy External table data.
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/DirCopyTask.java