diff --git a/hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf b/hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf index b14c991..9d62725 100644 --- a/hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf +++ b/hcatalog/src/test/e2e/templeton/tests/jobsubmission.conf @@ -377,7 +377,34 @@ $cfg = }, - + { + #test add jar + 'num' => 9, + 'method' => 'POST', + 'url' => ':TEMPLETON_URL:/templeton/v1/hive', + 'post_options' => ['user.name=:UNAME:','execute=add jar piggybank.jar', 'files=:INPDIR_HDFS:/piggybank.jar',], + 'json_field_substr_match' => { 'id' => '\d+'}, + #results + 'status_code' => 200, + 'check_job_created' => 1, + 'check_job_complete' => 'SUCCESS', + 'check_job_exit_value' => 0, + 'check_call_back' => 1, + }, + { + #test add jar when the jar is not shipped + 'num' => 10, + 'method' => 'POST', + 'url' => ':TEMPLETON_URL:/templeton/v1/hive', + 'post_options' => ['user.name=:UNAME:','execute=add jar piggybank.jar',], + 'json_field_substr_match' => { 'id' => '\d+'}, + #results + 'status_code' => 200, + 'check_job_created' => 1, + 'check_job_complete' => 'SUCCESS', + 'check_job_exit_value' => 1, + 'check_call_back' => 1, + }, ] }, diff --git a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/HiveDelegator.java b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/HiveDelegator.java index f472c47..90d834f 100644 --- a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/HiveDelegator.java +++ b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/HiveDelegator.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.net.URISyntaxException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.apache.commons.exec.ExecuteException; @@ -41,24 +42,26 @@ public HiveDelegator(AppConfig appConf) { public EnqueueBean run(String user, String execute, String srcFile, List defines, + List hiveArgs, String otherFiles, String statusdir, String callback, String completedUrl) throws NotAuthorizedException, BadParam, BusyException, QueueException, ExecuteException, IOException, InterruptedException { runAs = user; - List args = makeArgs(execute, srcFile, defines, statusdir, + List args = makeArgs(execute, srcFile, defines, hiveArgs, otherFiles, statusdir, completedUrl); return enqueueController(user, callback, args); } private List makeArgs(String execute, String srcFile, - List defines, String statusdir, String completedUrl) + List defines, List hiveArgs, String otherFiles, + String statusdir, String completedUrl) throws BadParam, IOException, InterruptedException { ArrayList args = new ArrayList(); try { - args.addAll(makeBasicArgs(execute, srcFile, statusdir, completedUrl)); + args.addAll(makeBasicArgs(execute, srcFile, otherFiles, statusdir, completedUrl)); args.add("--"); args.add(appConf.hivePath()); @@ -77,6 +80,7 @@ public EnqueueBean run(String user, args.add("--hiveconf"); args.add(prop); } + args.addAll(hiveArgs); if (TempletonUtils.isset(execute)) { args.add("-e"); args.add(execute); @@ -94,8 +98,8 @@ public EnqueueBean run(String user, return args; } - private List makeBasicArgs(String execute, String srcFile, - String statusdir, String completedUrl) + private List makeBasicArgs(String execute, String srcFile, String otherFiles, + String statusdir, String completedUrl) throws URISyntaxException, FileNotFoundException, IOException, InterruptedException { @@ -106,6 +110,11 @@ public EnqueueBean run(String user, allFiles.add(TempletonUtils.hadoopFsFilename(srcFile, appConf, runAs)); + if (TempletonUtils.isset(otherFiles)) { + String[] ofs = TempletonUtils.hadoopFsListAsArray(otherFiles, appConf, runAs); + allFiles.addAll(Arrays.asList(ofs)); + } + args.addAll(makeLauncherArgs(appConf, statusdir, completedUrl, allFiles)); args.add("-archives"); diff --git a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java index 19621d0..01ff4db 100644 --- a/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java +++ b/hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java @@ -665,6 +665,8 @@ public EnqueueBean pig(@FormParam("execute") String execute, @Produces({MediaType.APPLICATION_JSON}) public EnqueueBean hive(@FormParam("execute") String execute, @FormParam("file") String srcFile, + @FormParam("arg") List hiveArgs, + @FormParam("files") String otherFiles, @FormParam("define") List defines, @FormParam("statusdir") String statusdir, @FormParam("callback") String callback) @@ -675,7 +677,7 @@ public EnqueueBean hive(@FormParam("execute") String execute, throw new BadParam("Either execute or file parameter required"); HiveDelegator d = new HiveDelegator(appConf); - return d.run(getDoAsUser(), execute, srcFile, defines, + return d.run(getDoAsUser(), execute, srcFile, defines, hiveArgs, otherFiles, statusdir, callback, getCompletedUrl()); }