You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/03/12 09:50:22 UTC

[GitHub] [hive] ArkoSharma opened a new pull request #2067: HIVE-24878: ClassNotFound exception for function replication

ArkoSharma opened a new pull request #2067:
URL: https://github.com/apache/hive/pull/2067


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2067: HIVE-24878: ClassNotFound exception for function replication

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2067:
URL: https://github.com/apache/hive/pull/2067#discussion_r596464219



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/CreateFunctionHandler.java
##########
@@ -206,7 +206,7 @@ ResourceUri destinationResourceUri(ResourceUri resourceUri)
         return ReplCopyTask.getLoadCopyTask(metadata.getReplicationSpec(), new Path(sourceUri), dest, context.hiveConf,
                 context.getDumpDirectory(), context.getMetricCollector());
       } else {
-        return TaskFactory.get(new CopyWork(new Path(sourceUri), dest, true, false,
+        return TaskFactory.get(new CopyWork(new Path(sourceUri), dest.getParent(), true, false,

Review comment:
       Just wondering how was this working earlier.

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
##########
@@ -2237,4 +2242,27 @@ private void assertExternalFileInfo(List<String> expected, String dumplocation,
     }
     ReplicationTestUtils.assertExternalFileInfo(warehouseInstance, expected, externalTableInfoFile);
   }
+
+  private void assertFunctionJarsOnTarget(String functionName, List<String> expectedJars) throws IOException {
+    //correct location of jars on target is functionRoot/dbName/funcName/nanoTs/jarFile
+    FileStatus[] fileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+               new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" +
+                       functionName.toLowerCase() + "/*/*"), path -> path.toString().endsWith("jar")
+            );
+    assertEquals(fileStatuses.length, expectedJars.size());
+    List<String> jars = Arrays.stream(fileStatuses).map(f -> {
+      String[] splits = f.getPath().toString().split("/");
+      return splits[splits.length - 1];

Review comment:
       Do you need just file name from the path? Wouldn't just return f.getPath().getName() be fine

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
##########
@@ -2237,4 +2242,27 @@ private void assertExternalFileInfo(List<String> expected, String dumplocation,
     }
     ReplicationTestUtils.assertExternalFileInfo(warehouseInstance, expected, externalTableInfoFile);
   }
+
+  private void assertFunctionJarsOnTarget(String functionName, List<String> expectedJars) throws IOException {
+    //correct location of jars on target is functionRoot/dbName/funcName/nanoTs/jarFile
+    FileStatus[] fileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+               new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" +
+                       functionName.toLowerCase() + "/*/*"), path -> path.toString().endsWith("jar")
+            );
+    assertEquals(fileStatuses.length, expectedJars.size());
+    List<String> jars = Arrays.stream(fileStatuses).map(f -> {
+      String[] splits = f.getPath().toString().split("/");
+      return splits[splits.length - 1];
+    }).collect(Collectors.toList());
+    assertThat(jars, containsInAnyOrder(expectedJars.toArray()));

Review comment:
       Does this also do a match on size

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
##########
@@ -2237,4 +2242,27 @@ private void assertExternalFileInfo(List<String> expected, String dumplocation,
     }
     ReplicationTestUtils.assertExternalFileInfo(warehouseInstance, expected, externalTableInfoFile);
   }
+
+  private void assertFunctionJarsOnTarget(String functionName, List<String> expectedJars) throws IOException {
+    //correct location of jars on target is functionRoot/dbName/funcName/nanoTs/jarFile
+    FileStatus[] fileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+               new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" +
+                       functionName.toLowerCase() + "/*/*"), path -> path.toString().endsWith("jar")
+            );
+    assertEquals(fileStatuses.length, expectedJars.size());
+    List<String> jars = Arrays.stream(fileStatuses).map(f -> {
+      String[] splits = f.getPath().toString().split("/");
+      return splits[splits.length - 1];
+    }).collect(Collectors.toList());
+    assertThat(jars, containsInAnyOrder(expectedJars.toArray()));
+
+    //confirm no jars in nested directories
+    FileStatus[] nestedFileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+                    new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" + functionName + "/*/*/*")
+                    ,path -> path.toString().endsWith("jar")
+            );
+    assertEquals(nestedFileStatuses.length, 0);

Review comment:
       There should not be any directory itself right?

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
##########
@@ -2237,4 +2242,27 @@ private void assertExternalFileInfo(List<String> expected, String dumplocation,
     }
     ReplicationTestUtils.assertExternalFileInfo(warehouseInstance, expected, externalTableInfoFile);
   }
+
+  private void assertFunctionJarsOnTarget(String functionName, List<String> expectedJars) throws IOException {
+    //correct location of jars on target is functionRoot/dbName/funcName/nanoTs/jarFile
+    FileStatus[] fileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+               new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" +
+                       functionName.toLowerCase() + "/*/*"), path -> path.toString().endsWith("jar")

Review comment:
       endsWith(".jar")?




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha merged pull request #2067: HIVE-24878: ClassNotFound exception for function replication

Posted by GitBox <gi...@apache.org>.
pkumarsinha merged pull request #2067:
URL: https://github.com/apache/hive/pull/2067


   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] ArkoSharma commented on a change in pull request #2067: HIVE-24878: ClassNotFound exception for function replication

Posted by GitBox <gi...@apache.org>.
ArkoSharma commented on a change in pull request #2067:
URL: https://github.com/apache/hive/pull/2067#discussion_r596514205



##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
##########
@@ -2237,4 +2242,27 @@ private void assertExternalFileInfo(List<String> expected, String dumplocation,
     }
     ReplicationTestUtils.assertExternalFileInfo(warehouseInstance, expected, externalTableInfoFile);
   }
+
+  private void assertFunctionJarsOnTarget(String functionName, List<String> expectedJars) throws IOException {
+    //correct location of jars on target is functionRoot/dbName/funcName/nanoTs/jarFile
+    FileStatus[] fileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+               new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" +
+                       functionName.toLowerCase() + "/*/*"), path -> path.toString().endsWith("jar")
+            );
+    assertEquals(fileStatuses.length, expectedJars.size());
+    List<String> jars = Arrays.stream(fileStatuses).map(f -> {
+      String[] splits = f.getPath().toString().split("/");
+      return splits[splits.length - 1];

Review comment:
       That will work, will make this change.

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
##########
@@ -2237,4 +2242,27 @@ private void assertExternalFileInfo(List<String> expected, String dumplocation,
     }
     ReplicationTestUtils.assertExternalFileInfo(warehouseInstance, expected, externalTableInfoFile);
   }
+
+  private void assertFunctionJarsOnTarget(String functionName, List<String> expectedJars) throws IOException {
+    //correct location of jars on target is functionRoot/dbName/funcName/nanoTs/jarFile
+    FileStatus[] fileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+               new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" +
+                       functionName.toLowerCase() + "/*/*"), path -> path.toString().endsWith("jar")
+            );
+    assertEquals(fileStatuses.length, expectedJars.size());
+    List<String> jars = Arrays.stream(fileStatuses).map(f -> {
+      String[] splits = f.getPath().toString().split("/");
+      return splits[splits.length - 1];
+    }).collect(Collectors.toList());
+    assertThat(jars, containsInAnyOrder(expectedJars.toArray()));
+
+    //confirm no jars in nested directories
+    FileStatus[] nestedFileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+                    new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" + functionName + "/*/*/*")
+                    ,path -> path.toString().endsWith("jar")
+            );
+    assertEquals(nestedFileStatuses.length, 0);

Review comment:
       Yes, i think a better check after matching the jar names will just be to confirm none of the files are directories. That will also be sufficient to test there are no nested directories. Will make this change.

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
##########
@@ -2237,4 +2242,27 @@ private void assertExternalFileInfo(List<String> expected, String dumplocation,
     }
     ReplicationTestUtils.assertExternalFileInfo(warehouseInstance, expected, externalTableInfoFile);
   }
+
+  private void assertFunctionJarsOnTarget(String functionName, List<String> expectedJars) throws IOException {
+    //correct location of jars on target is functionRoot/dbName/funcName/nanoTs/jarFile
+    FileStatus[] fileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+               new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" +
+                       functionName.toLowerCase() + "/*/*"), path -> path.toString().endsWith("jar")
+            );
+    assertEquals(fileStatuses.length, expectedJars.size());
+    List<String> jars = Arrays.stream(fileStatuses).map(f -> {
+      String[] splits = f.getPath().toString().split("/");
+      return splits[splits.length - 1];
+    }).collect(Collectors.toList());
+    assertThat(jars, containsInAnyOrder(expectedJars.toArray()));

Review comment:
       This is done in a preceding line : assertEquals(fileStatuses.length, expectedJars.size());

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcrossInstances.java
##########
@@ -2237,4 +2242,27 @@ private void assertExternalFileInfo(List<String> expected, String dumplocation,
     }
     ReplicationTestUtils.assertExternalFileInfo(warehouseInstance, expected, externalTableInfoFile);
   }
+
+  private void assertFunctionJarsOnTarget(String functionName, List<String> expectedJars) throws IOException {
+    //correct location of jars on target is functionRoot/dbName/funcName/nanoTs/jarFile
+    FileStatus[] fileStatuses = replica.miniDFSCluster.getFileSystem()
+            .globStatus(
+               new Path(replica.functionsRoot + "/" + replicatedDbName.toLowerCase() + "/" +
+                       functionName.toLowerCase() + "/*/*"), path -> path.toString().endsWith("jar")

Review comment:
       This check is actually not required, removing it.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org