aasha commented on a change in pull request #2043:
URL: https://github.com/apache/hive/pull/2043#discussion_r600202144



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/repl/DirCopyTask.java
##########
@@ -203,4 +213,87 @@ public String getName() {
   public boolean canExecuteInParallel() {
     return true;
   }
+
+  void copyUsingDistCpSnapshots(Path sourcePath, Path targetPath,
+      UserGroupInformation proxyUser) throws IOException {
+
+    DistributedFileSystem sourceFs = SnapshotUtils.getDFS(sourcePath, conf);
+    DistributedFileSystem targetFs = SnapshotUtils.getDFS(targetPath, conf);
+    if (sourceFs == null || targetFs == null) {
+      LOG.error("Source and Destination filesystem are not "
+              + "DistributedFileSystem, using normal copy instead of snapshot "
+              + "copy, Source Path {}, Target Path {}, Source fs is {}, and "
+              + "Target fs {}", sourcePath, targetPath,
+          sourcePath.getFileSystem(conf).getClass(),
+          targetPath.getFileSystem(conf).getClass());
+      FileUtils.distCp(sourcePath.getFileSystem(conf), // source file system
+          Collections.singletonList(sourcePath), // list of source paths
+          targetPath, false, proxyUser, conf, ShimLoader.getHadoopShims());
+      // Since source/dest aren't DFS, no point trying to create snapshot at
+      // target, return from here.
+      return;
+    }
+    String prefix = conf.getVar(
+        HiveConf.ConfVars.REPL_SNAPSHOT_PREFIX_FOR_EXTERNAL_TABLE_COPY);
+    if (getWork().getCopyMode()
+        .equals(SnapshotUtils.SnapshotCopyMode.DIFF_COPY)) {
+      LOG.info("Using snapshot diff copy for source: {} and target: {}",
+          sourcePath, targetPath);
+      boolean result = FileUtils
+          .distCpWithSnapshot(sourceFs, prefix + "old", prefix + "initial",
+              Collections.singletonList(sourcePath), targetPath, proxyUser,
+              conf, ShimLoader.getHadoopShims());
+      if (!result) {
+        LOG.error("Can not copy using snapshot diff for source: {} and "
+                + "target: {}. Falling back to normal copy.", sourcePath,
+            targetPath);
+        FileUtils.distCp(sourcePath.getFileSystem(conf), // source file system

Review comment:
       this method is called for each !result. Can be cleaned up




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to