Author: tucu
Date: Wed Mar 13 01:40:37 2013
New Revision: 1455773

URL: http://svn.apache.org/r1455773
Log:
OOZIE-894 support for hive in Oozie CLI (bowenzhangusa via tucu)

Added:
    
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/ScriptLanguageActionExecutor.java
    
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitHiveXCommand.java
    
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitScriptLanguageXCommand.java
    
oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitHiveXCommand.java
Modified:
    oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
    oozie/trunk/client/src/main/java/org/apache/oozie/client/XOozieClient.java
    oozie/trunk/core/src/main/java/org/apache/oozie/DagEngine.java
    
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/HiveActionExecutor.java
    
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/PigActionExecutor.java
    
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitPigXCommand.java
    oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobsServlet.java
    
oozie/trunk/core/src/test/java/org/apache/oozie/client/TestWorkflowXClient.java
    
oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitPigXCommand.java
    oozie/trunk/release-log.txt

Modified: oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java 
(original)
+++ oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java Wed Mar 
13 01:40:37 2013
@@ -88,6 +88,7 @@ public class OozieCLI {
     public static final String VALIDATE_CMD = "validate";
     public static final String SLA_CMD = "sla";
     public static final String PIG_CMD = "pig";
+    public static final String HIVE_CMD = "hive";
     public static final String MR_CMD = "mapreduce";
     public static final String INFO_CMD = "info";
 
@@ -132,7 +133,7 @@ public class OozieCLI {
     public static final String VERBOSE_DELIMITER = "\t";
     public static final String DEBUG_OPTION = "debug";
 
-    public static final String PIGFILE_OPTION = "file";
+    public static final String SCRIPTFILE_OPTION = "file";
 
     public static final String INFO_TIME_ZONES_OPTION = "timezones";
 
@@ -378,25 +379,25 @@ public class OozieCLI {
     }
 
     /**
-     * Create option for command line option 'pig'
-     * @return pig options
+     * Create option for command line option 'pig' or 'hive'
+     * @return pig or hive options
      */
     @SuppressWarnings("static-access")
-    protected Options createPigOptions() {
+    protected Options createScriptLanguageOptions(String jobType) {
         Option oozie = new Option(OOZIE_OPTION, true, "Oozie URL");
         Option config = new Option(CONFIG_OPTION, true, "job configuration 
file '.properties'");
-        Option pigFile = new Option(PIGFILE_OPTION, true, "Pig script");
+        Option file = new Option(SCRIPTFILE_OPTION, true, jobType + " script");
         Option property = 
OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator().withDescription(
                 "set/override value for given property").create("D");
         Option doAs = new Option(DO_AS_OPTION, true, "doAs user, impersonates 
as the specified user");
-        Options pigOptions = new Options();
-        pigOptions.addOption(oozie);
-        pigOptions.addOption(doAs);
-        pigOptions.addOption(config);
-        pigOptions.addOption(property);
-        pigOptions.addOption(pigFile);
-        addAuthOptions(pigOptions);
-        return pigOptions;
+        Options Options = new Options();
+        Options.addOption(oozie);
+        Options.addOption(doAs);
+        Options.addOption(config);
+        Options.addOption(property);
+        Options.addOption(file);
+        addAuthOptions(Options);
+        return Options;
     }
 
     /**
@@ -455,7 +456,9 @@ public class OozieCLI {
         parser.addCommand(VALIDATE_CMD, "", "validate a workflow XML file", 
new Options(), true);
         parser.addCommand(SLA_CMD, "", "sla operations (Supported in Oozie-2.0 
or later)", createSlaOptions(), false);
         parser.addCommand(PIG_CMD, "-X ", "submit a pig job, everything after 
'-X' are pass-through parameters to pig",
-                createPigOptions(), true);
+                createScriptLanguageOptions(PIG_CMD), true);
+        parser.addCommand(HIVE_CMD, "-X ", "submit a hive job, everything 
after '-X' are pass-through parameters to hive",
+                createScriptLanguageOptions(HIVE_CMD), true);
         parser.addCommand(INFO_CMD, "", "get more detailed info about specific 
topics", createInfoOptions(), false);
         parser.addCommand(MR_CMD, "", "submit a mapreduce job", 
createMROptions(), false);
 
@@ -519,7 +522,10 @@ public class OozieCLI {
             slaCommand(command.getCommandLine());
         }
         else if (command.getName().equals(PIG_CMD)) {
-            pigCommand(command.getCommandLine());
+            scriptLanguageCommand(command.getCommandLine(), PIG_CMD);
+        }
+        else if (command.getName().equals(HIVE_CMD)) {
+            scriptLanguageCommand(command.getCommandLine(), HIVE_CMD);
         }
         else if (command.getName().equals(INFO_CMD)) {
             infoCommand(command.getCommandLine());
@@ -1540,14 +1546,14 @@ public class OozieCLI {
         }
     }
 
-    private void pigCommand(CommandLine commandLine) throws IOException, 
OozieCLIException {
-        List<String> pigArgs = commandLine.getArgList();
-        if (pigArgs.size() > 0) {
+    private void scriptLanguageCommand(CommandLine commandLine, String 
jobType) throws IOException, OozieCLIException {
+        List<String> Args = commandLine.getArgList();
+        if (Args.size() > 0) {
             // checking is a pigArgs starts with -X (because CLIParser cannot 
check this)
-            if (!pigArgs.get(0).equals("-X")) {
-                throw new OozieCLIException("Unrecognized option: " + 
pigArgs.get(0) + " Expecting -X");
+            if (!Args.get(0).equals("-X")) {
+                throw new OozieCLIException("Unrecognized option: " + 
Args.get(0) + " Expecting -X");
             }
-            pigArgs.remove(0);
+            Args.remove(0);
         }
 
         List<String> options = new ArrayList<String>();
@@ -1555,7 +1561,7 @@ public class OozieCLI {
             options.add(option.getOpt());
         }
 
-        if (!options.contains(PIGFILE_OPTION)) {
+        if (!options.contains(SCRIPTFILE_OPTION)) {
             throw new OozieCLIException("Need to specify -file <scriptfile>");
         }
 
@@ -1567,8 +1573,8 @@ public class OozieCLI {
         try {
             XOozieClient wc = createXOozieClient(commandLine);
             Properties conf = getConfiguration(wc, commandLine);
-            String script = commandLine.getOptionValue(PIGFILE_OPTION);
-            System.out.println(JOB_ID_PREFIX + wc.submitPig(conf, script, 
pigArgs.toArray(new String[pigArgs.size()])));
+            String script = commandLine.getOptionValue(SCRIPTFILE_OPTION);
+            System.out.println(JOB_ID_PREFIX + wc.submitScriptLanguage(conf, 
script, Args.toArray(new String[Args.size()]), jobType));
         }
         catch (OozieClientException ex) {
             throw new OozieCLIException(ex.toString(), ex);

Modified: 
oozie/trunk/client/src/main/java/org/apache/oozie/client/XOozieClient.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/client/src/main/java/org/apache/oozie/client/XOozieClient.java?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- oozie/trunk/client/src/main/java/org/apache/oozie/client/XOozieClient.java 
(original)
+++ oozie/trunk/client/src/main/java/org/apache/oozie/client/XOozieClient.java 
Wed Mar 13 01:40:37 2013
@@ -25,6 +25,7 @@ import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
 import java.util.Properties;
 
+import org.apache.oozie.cli.OozieCLI;
 import org.apache.oozie.client.rest.JsonTags;
 import org.apache.oozie.client.rest.RestConstants;
 import org.json.simple.JSONObject;
@@ -48,6 +49,10 @@ public class XOozieClient extends OozieC
 
     public static final String PIG_OPTIONS = "oozie.pig.options";
 
+    public static final String HIVE_SCRIPT = "oozie.hive.script";
+
+    public static final String HIVE_OPTIONS = "oozie.hive.options";
+
     public static final String FILES = "oozie.files";
 
     public static final String ARCHIVES = "oozie.archives";
@@ -66,9 +71,9 @@ public class XOozieClient extends OozieC
         super(oozieUrl);
     }
 
-    private String readPigScript(String script) throws IOException {
+    private String readScript(String script) throws IOException {
         if (!new File(script).exists()) {
-            throw new IOException("Error: Pig script file [" + script + "] 
does not exist");
+            throw new IOException("Error: script file [" + script + "] does 
not exist");
         }
 
         BufferedReader br = null;
@@ -139,28 +144,43 @@ public class XOozieClient extends OozieC
     }
 
     /**
-     * Submit a Pig job via HTTP.
+     * Submit a Pig or Hive job via HTTP.
      *
      * @param conf job configuration.
-     * @param pigScriptFile pig script file.
-     * @param pigArgs pig arguments string.
+     * @param scriptFile  script file.
+     * @param args  arguments string.
      * @return the job Id.
      * @throws OozieClientException thrown if the job could not be submitted.
      */
-    public String submitPig(Properties conf, String pigScriptFile, String[] 
pigArgs) throws IOException, OozieClientException {
+    public String submitScriptLanguage(Properties conf, String scriptFile, 
String[] args, String jobType) throws IOException, OozieClientException {
         if (conf == null) {
             throw new IllegalArgumentException("conf cannot be null");
         }
-        if (pigScriptFile == null) {
-            throw new IllegalArgumentException("pigScriptFile cannot be null");
+        if (scriptFile == null) {
+            throw new IllegalArgumentException("scriptFile cannot be null");
         }
 
         validateHttpSubmitConf(conf);
 
-        conf.setProperty(XOozieClient.PIG_SCRIPT, 
readPigScript(pigScriptFile));
-        setStrings(conf, XOozieClient.PIG_OPTIONS, pigArgs);
+        String script = "";
+        String options = "";
+
+        if (jobType.equals(OozieCLI.HIVE_CMD)) {
+            script = XOozieClient.HIVE_SCRIPT;
+            options = XOozieClient.HIVE_OPTIONS;
+        }
+        else if (jobType.equals(OozieCLI.PIG_CMD)) {
+            script =  XOozieClient.PIG_SCRIPT;
+            options = XOozieClient.PIG_OPTIONS;
+        }
+        else {
+            throw new IllegalArgumentException("jobType must be either pig or 
hive");
+        }
+
+        conf.setProperty(script, readScript(scriptFile));
+        setStrings(conf, options, args);
 
-        return (new HttpJobSubmit(conf, "pig")).call();
+        return (new HttpJobSubmit(conf, jobType)).call();
     }
 
     /**

Modified: oozie/trunk/core/src/main/java/org/apache/oozie/DagEngine.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/DagEngine.java?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/DagEngine.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/DagEngine.java Wed Mar 13 
01:40:37 2013
@@ -34,6 +34,7 @@ import org.apache.oozie.command.wf.KillX
 import org.apache.oozie.command.wf.ReRunXCommand;
 import org.apache.oozie.command.wf.ResumeXCommand;
 import org.apache.oozie.command.wf.StartXCommand;
+import org.apache.oozie.command.wf.SubmitHiveXCommand;
 import org.apache.oozie.command.wf.SubmitHttpXCommand;
 import org.apache.oozie.command.wf.SubmitMRXCommand;
 import org.apache.oozie.command.wf.SubmitPigXCommand;
@@ -139,6 +140,9 @@ public class DagEngine extends BaseEngin
             else if (jobType.equals("mapreduce")) {
                 submit = new SubmitMRXCommand(conf, getAuthToken());
             }
+            else if (jobType.equals("hive")) {
+                submit = new SubmitHiveXCommand(conf, getAuthToken());
+            }
 
             jobId = submit.call();
             start(jobId);

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/HiveActionExecutor.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/HiveActionExecutor.java?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/HiveActionExecutor.java
 (original)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/HiveActionExecutor.java
 Wed Mar 13 01:40:37 2013
@@ -25,11 +25,12 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.fs.Path;
 import org.apache.oozie.action.ActionExecutorException;
 import org.apache.oozie.client.WorkflowAction;
+import org.apache.oozie.client.XOozieClient;
 import org.jdom.Element;
 import org.jdom.JDOMException;
 import org.jdom.Namespace;
 
-public class HiveActionExecutor extends JavaActionExecutor {
+public class HiveActionExecutor extends ScriptLanguageActionExecutor {
 
     public HiveActionExecutor() {
         super("hive");
@@ -38,8 +39,6 @@ public class HiveActionExecutor extends 
     @Override
     protected List<Class> getLauncherClasses() {
         List<Class> classes = super.getLauncherClasses();
-        classes.add(LauncherMain.class);
-        classes.add(MapReduceMain.class);
         classes.add(HiveMain.class);
         return classes;
     }
@@ -50,23 +49,6 @@ public class HiveActionExecutor extends 
     }
 
     @Override
-    protected Configuration setupLauncherConf(Configuration conf, Element 
actionXml, Path appPath, Context context)
-            throws ActionExecutorException {
-        try {
-            super.setupLauncherConf(conf, actionXml, appPath, context);
-            Namespace ns = actionXml.getNamespace();
-
-            String script = actionXml.getChild("script", ns).getTextTrim();
-            String scriptName = new Path(script).getName();
-            addToCache(conf, appPath, script + "#" + scriptName, false);
-            return conf;
-        }
-        catch (Exception ex) {
-            throw convertException(ex);
-        }
-    }
-
-    @Override
     @SuppressWarnings("unchecked")
     Configuration setupActionConf(Configuration actionConf, Context context, 
Element actionXml,
                                   Path appPath) throws ActionExecutorException 
{
@@ -75,7 +57,11 @@ public class HiveActionExecutor extends 
         Namespace ns = actionXml.getNamespace();
         String script = actionXml.getChild("script", ns).getTextTrim();
         String scriptName = new Path(script).getName();
-        addToCache(conf, appPath, script + "#" + scriptName, false);
+        String hiveScriptContent = 
context.getProtoActionConf().get(XOozieClient.HIVE_SCRIPT);
+
+        if (hiveScriptContent == null){
+            addToCache(conf, appPath, script + "#" + scriptName, false);
+        }
 
         List<Element> params = (List<Element>) actionXml.getChildren("param", 
ns);
         String[] strParams = new String[params.size()];
@@ -103,4 +89,8 @@ public class HiveActionExecutor extends 
         return "hive";
     }
 
+    protected String getScriptName() {
+        return XOozieClient.HIVE_SCRIPT;
+    }
+
 }

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/PigActionExecutor.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/PigActionExecutor.java?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/PigActionExecutor.java
 (original)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/PigActionExecutor.java
 Wed Mar 13 01:40:37 2013
@@ -19,7 +19,6 @@ package org.apache.oozie.action.hadoop;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapred.RunningJob;
 import org.apache.oozie.action.ActionExecutorException;
@@ -39,7 +38,7 @@ import java.io.InputStreamReader;
 import java.net.URISyntaxException;
 import java.util.List;
 
-public class PigActionExecutor extends JavaActionExecutor {
+public class PigActionExecutor extends ScriptLanguageActionExecutor {
 
     public PigActionExecutor() {
         super("pig");
@@ -48,8 +47,6 @@ public class PigActionExecutor extends J
     @Override
     protected List<Class> getLauncherClasses() {
         List<Class> classes = super.getLauncherClasses();
-        classes.add(LauncherMain.class);
-        classes.add(MapReduceMain.class);
         classes.add(PigMain.class);
         classes.add(OoziePigStats.class);
         return classes;
@@ -66,50 +63,6 @@ public class PigActionExecutor extends J
     }
 
     @Override
-    protected Configuration setupLauncherConf(Configuration conf, Element 
actionXml, Path appPath, Context context)
-            throws ActionExecutorException {
-        super.setupLauncherConf(conf, actionXml, appPath, context);
-        Namespace ns = actionXml.getNamespace();
-        String script = actionXml.getChild("script", ns).getTextTrim();
-        String pigName = new Path(script).getName();
-        String pigScriptContent = 
context.getProtoActionConf().get(XOozieClient.PIG_SCRIPT);
-
-        Path pigScriptFile = null;
-        if (pigScriptContent != null) { // Create pig script on hdfs if this is
-            // an http submission pig job;
-            FSDataOutputStream dos = null;
-            try {
-                Path actionPath = context.getActionDir();
-                pigScriptFile = new Path(actionPath, script);
-                FileSystem fs = context.getAppFileSystem();
-                dos = fs.create(pigScriptFile);
-                dos.writeBytes(pigScriptContent);
-
-                addToCache(conf, actionPath, script + "#" + pigName, false);
-            }
-            catch (Exception ex) {
-                throw new 
ActionExecutorException(ActionExecutorException.ErrorType.ERROR, 
"FAILED_OPERATION", XLog
-                        .format("Not able to write pig script file {0} on 
hdfs", pigScriptFile), ex);
-            }
-            finally {
-                try {
-                    if (dos != null) {
-                        dos.close();
-                    }
-                }
-                catch (IOException ex) {
-                    XLog.getLog(getClass()).error("Error: " + ex.getMessage());
-                }
-            }
-        }
-        else {
-            addToCache(conf, appPath, script + "#" + pigName, false);
-        }
-
-        return conf;
-    }
-
-    @Override
     @SuppressWarnings("unchecked")
     Configuration setupActionConf(Configuration actionConf, Context context, 
Element actionXml, Path appPath)
             throws ActionExecutorException {
@@ -216,4 +169,8 @@ public class PigActionExecutor extends J
         return "pig";
     }
 
+    protected String getScriptName() {
+        return XOozieClient.PIG_SCRIPT;
+    }
+
 }

Added: 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/ScriptLanguageActionExecutor.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/ScriptLanguageActionExecutor.java?rev=1455773&view=auto
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/ScriptLanguageActionExecutor.java
 (added)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/ScriptLanguageActionExecutor.java
 Wed Mar 13 01:40:37 2013
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.action.hadoop;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.oozie.action.ActionExecutorException;
+import org.apache.oozie.util.XLog;
+import org.jdom.Element;
+import org.jdom.Namespace;
+
+import java.io.IOException;
+import java.util.List;
+
+public abstract class ScriptLanguageActionExecutor extends JavaActionExecutor {
+
+    public ScriptLanguageActionExecutor(String type) {
+        super(type);
+    }
+
+    @Override
+    protected List<Class> getLauncherClasses() {
+        List<Class> classes = super.getLauncherClasses();
+        classes.add(LauncherMain.class);
+        classes.add(MapReduceMain.class);
+        return classes;
+    }
+
+    @Override
+    protected Configuration setupLauncherConf(Configuration conf, Element 
actionXml, Path appPath, Context context)
+            throws ActionExecutorException {
+        super.setupLauncherConf(conf, actionXml, appPath, context);
+        Namespace ns = actionXml.getNamespace();
+        String script = actionXml.getChild("script", ns).getTextTrim();
+        String name = new Path(script).getName();
+        String scriptContent = 
context.getProtoActionConf().get(this.getScriptName());
+
+        Path scriptFile = null;
+        if (scriptContent != null) { // Create script on filesystem if this is
+            // an http submission job;
+            FSDataOutputStream dos = null;
+            try {
+                Path actionPath = context.getActionDir();
+                scriptFile = new Path(actionPath, script);
+                FileSystem fs = context.getAppFileSystem();
+                dos = fs.create(scriptFile);
+                dos.writeBytes(scriptContent);
+
+                addToCache(conf, actionPath, script + "#" + name, false);
+            }
+            catch (Exception ex) {
+                throw new 
ActionExecutorException(ActionExecutorException.ErrorType.ERROR, 
"FAILED_OPERATION", XLog
+                        .format("Not able to write script file {0} on hdfs", 
scriptFile), ex);
+            }
+            finally {
+                try {
+                    if (dos != null) {
+                        dos.close();
+                    }
+                }
+                catch (IOException ex) {
+                    XLog.getLog(getClass()).error("Error: " + ex.getMessage());
+                }
+            }
+        }
+        else {
+            addToCache(conf, appPath, script + "#" + name, false);
+        }
+
+        return conf;
+    }
+
+    protected abstract String getScriptName();
+}

Added: 
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitHiveXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitHiveXCommand.java?rev=1455773&view=auto
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitHiveXCommand.java
 (added)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitHiveXCommand.java
 Wed Mar 13 01:40:37 2013
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.command.wf;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.oozie.client.XOozieClient;
+import org.jdom.Namespace;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: bzhang
+ * Date: 12/26/12
+ * Time: 2:49 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SubmitHiveXCommand extends SubmitScriptLanguageXCommand {
+    public SubmitHiveXCommand(Configuration conf, String authToken) {
+        super("submitHive", "submitHive", conf, authToken);
+    }
+
+    protected String getLanguageName(){
+        return "hive";
+    }
+
+    protected String getOptions(){
+        return XOozieClient.HIVE_OPTIONS;
+    }
+
+    protected Namespace getSectionNamespace(){
+        return Namespace.getNamespace("uri:oozie:hive-action:0.2");
+    }
+}

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitPigXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitPigXCommand.java?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitPigXCommand.java
 (original)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitPigXCommand.java
 Wed Mar 13 01:40:37 2013
@@ -18,166 +18,18 @@
 package org.apache.oozie.command.wf;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.oozie.util.XmlUtils;
-import org.jdom.Element;
-import org.jdom.Namespace;
-import org.apache.oozie.action.hadoop.MapReduceMain;
 import org.apache.oozie.client.XOozieClient;
-import org.apache.oozie.command.CommandException;
 
-import java.util.ArrayList;
-import java.util.List;
-
-public class SubmitPigXCommand extends SubmitHttpXCommand {
+public class SubmitPigXCommand extends SubmitScriptLanguageXCommand {
     public SubmitPigXCommand(Configuration conf, String authToken) {
         super("submitPig", "submitPig", conf, authToken);
     }
 
-    private Element generatePigSection(Configuration conf, Namespace ns) {
-        Element pig = new Element("pig", ns);
-        Element jt = new Element("job-tracker", ns);
-        jt.addContent(conf.get(XOozieClient.JT));
-        pig.addContent(jt);
-        Element nn = new Element("name-node", ns);
-        nn.addContent(conf.get(XOozieClient.NN));
-        pig.addContent(nn);
-
-        List<String> Dargs = new ArrayList<String>();
-        List<String> otherArgs = new ArrayList<String>();
-        String[] pigArgs = MapReduceMain.getStrings(conf, 
XOozieClient.PIG_OPTIONS);
-        for (String arg : pigArgs) {
-            if (arg.startsWith("-D")) {
-                Dargs.add(arg);
-            }
-            else {
-                otherArgs.add(arg);
-            }
-        }
-
-        // configuration section
-        if (Dargs.size() > 0) {
-            Element configuration = generateConfigurationSection(Dargs, ns);
-            pig.addContent(configuration);
-        }
-
-        Element script = new Element("script", ns);
-        script.addContent("dummy.pig");
-        pig.addContent(script);
-
-        // argument section
-        for (String arg : otherArgs) {
-            Element argument = new Element("argument", ns);
-            argument.addContent(arg);
-            pig.addContent(argument);
-        }
-
-        // file section
-        addFileSection(pig, conf, ns);
-
-        // archive section
-        addArchiveSection(pig, conf, ns);
-
-        return pig;
-    }
-
-    private Element generateConfigurationSection(List<String> Dargs, Namespace 
ns) {
-        Element configuration = new Element("configuration", ns);
-        for (String arg : Dargs) {
-            String name = null, value = null;
-            int pos = arg.indexOf("=");
-            if (pos == -1) { // "-D<name>" or "-D" only
-                name = arg.substring(2, arg.length());
-                value = "";
-            }
-            else { // "-D<name>=<value>"
-                name = arg.substring(2, pos);
-                value = arg.substring(pos + 1, arg.length());
-            }
-
-            Element property = new Element("property", ns);
-            Element nameElement = new Element("name", ns);
-            nameElement.addContent(name);
-            property.addContent(nameElement);
-            Element valueElement = new Element("value", ns);
-            valueElement.addContent(value);
-            property.addContent(valueElement);
-            configuration.addContent(property);
-        }
-
-        return configuration;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache
-     * .hadoop.conf.Configuration)
-     */
-    @Override
-    protected String getWorkflowXml(Configuration conf) {
-        for (String key : MANDATORY_OOZIE_CONFS) {
-            String value = conf.get(key);
-            if (value == null) {
-                throw new RuntimeException(key + " is not specified");
-            }
-        }
-
-        Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2");
-        Element root = new Element("workflow-app", ns);
-        root.setAttribute("name", "oozie-pig");
-
-        Element start = new Element("start", ns);
-        start.setAttribute("to", "pig1");
-        root.addContent(start);
-
-        Element action = new Element("action", ns);
-        action.setAttribute("name", "pig1");
-
-        Element pig = generatePigSection(conf, ns);
-        action.addContent(pig);
-
-        Element ok = new Element("ok", ns);
-        ok.setAttribute("to", "end");
-        action.addContent(ok);
-
-        Element error = new Element("error", ns);
-        error.setAttribute("to", "fail");
-        action.addContent(error);
-
-        root.addContent(action);
-
-        Element kill = new Element("kill", ns);
-        kill.setAttribute("name", "fail");
-        Element message = new Element("message", ns);
-        message.addContent("Pig failed, error 
message[${wf:errorMessage(wf:lastErrorNode())}]");
-        kill.addContent(message);
-        root.addContent(kill);
-
-        Element end = new Element("end", ns);
-        end.setAttribute("name", "end");
-        root.addContent(end);
-
-        return XmlUtils.prettyPrint(root).toString();
-    }
-
-    @Override
-    public String getEntityKey() {
-        return null;
-    }
-
-    @Override
-    protected boolean isLockRequired() {
-        return false;
+    protected String getLanguageName(){
+        return "pig";
     }
 
-    @Override
-    protected void loadState() {
-
-    }
-
-    @Override
-    protected void verifyPrecondition() throws CommandException {
-
+    protected String getOptions(){
+        return XOozieClient.PIG_OPTIONS;
     }
-}
+}
\ No newline at end of file

Added: 
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitScriptLanguageXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitScriptLanguageXCommand.java?rev=1455773&view=auto
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitScriptLanguageXCommand.java
 (added)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitScriptLanguageXCommand.java
 Wed Mar 13 01:40:37 2013
@@ -0,0 +1,204 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.command.wf;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.oozie.action.hadoop.MapReduceMain;
+import org.apache.oozie.client.XOozieClient;
+import org.apache.oozie.command.CommandException;
+import org.apache.oozie.util.XmlUtils;
+import org.jdom.Element;
+import org.jdom.Namespace;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: bzhang
+ * Date: 12/26/12
+ * Time: 2:27 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SubmitScriptLanguageXCommand extends SubmitHttpXCommand {
+    public SubmitScriptLanguageXCommand(String name, String type, 
Configuration conf, String authToken) {
+        super(name, type, conf, authToken);
+    }
+
+    protected String getLanguageName() throws UnsupportedOperationException{
+        throw new UnsupportedOperationException("subclass needs to implement 
this method");
+    }
+
+    protected String getOptions() throws UnsupportedOperationException{
+        throw new UnsupportedOperationException("subclass needs to implement 
this method");
+    }
+
+    protected Namespace getSectionNamespace(){
+        return Namespace.getNamespace("uri:oozie:workflow:0.2");
+    }
+    private Element generateSection(Configuration conf, Namespace ns) {
+        String name = getLanguageName();
+        Element ele = new Element(name, ns);
+        Element jt = new Element("job-tracker", ns);
+        jt.addContent(conf.get(XOozieClient.JT));
+        ele.addContent(jt);
+        Element nn = new Element("name-node", ns);
+        nn.addContent(conf.get(XOozieClient.NN));
+        ele.addContent(nn);
+
+        List<String> Dargs = new ArrayList<String>();
+        List<String> otherArgs = new ArrayList<String>();
+        String[] Args = MapReduceMain.getStrings(conf, getOptions());
+        for (String arg : Args) {
+            if (arg.startsWith("-D")) {
+                Dargs.add(arg);
+            }
+            else {
+                otherArgs.add(arg);
+            }
+        }
+
+        // configuration section
+        if (Dargs.size() > 0) {
+            Element configuration = generateConfigurationSection(Dargs, ns);
+            ele.addContent(configuration);
+        }
+
+        Element script = new Element("script", ns);
+        script.addContent("dummy." + name);
+        ele.addContent(script);
+
+        // argument section
+        for (String arg : otherArgs) {
+            Element argument = new Element("argument", ns);
+            argument.addContent(arg);
+            ele.addContent(argument);
+        }
+
+        // file section
+        addFileSection(ele, conf, ns);
+
+        // archive section
+        addArchiveSection(ele, conf, ns);
+
+        return ele;
+    }
+
+    private Element generateConfigurationSection(List<String> Dargs, Namespace 
ns) {
+        Element configuration = new Element("configuration", ns);
+        for (String arg : Dargs) {
+            String name = null, value = null;
+            int pos = arg.indexOf("=");
+            if (pos == -1) { // "-D<name>" or "-D" only
+                name = arg.substring(2, arg.length());
+                value = "";
+            }
+            else { // "-D<name>=<value>"
+                name = arg.substring(2, pos);
+                value = arg.substring(pos + 1, arg.length());
+            }
+
+            Element property = new Element("property", ns);
+            Element nameElement = new Element("name", ns);
+            nameElement.addContent(name);
+            property.addContent(nameElement);
+            Element valueElement = new Element("value", ns);
+            valueElement.addContent(value);
+            property.addContent(valueElement);
+            configuration.addContent(property);
+        }
+
+        return configuration;
+    }
+
+    /*
+    * (non-Javadoc)
+    *
+    * @see
+    * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache
+    * .hadoop.conf.Configuration)
+    */
+    @Override
+    protected String getWorkflowXml(Configuration conf) {
+        for (String key : MANDATORY_OOZIE_CONFS) {
+            String value = conf.get(key);
+            if (value == null) {
+                throw new RuntimeException(key + " is not specified");
+            }
+        }
+
+        Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2");
+        Element root = new Element("workflow-app", ns);
+        root.setAttribute("name", "oozie-" + getLanguageName());
+
+        Element start = new Element("start", ns);
+        String name = getLanguageName();
+        String nodeName = name + "1";
+        start.setAttribute("to", nodeName);
+        root.addContent(start);
+
+        Element action = new Element("action", ns);
+        action.setAttribute("name", nodeName);
+
+        Element ele = generateSection(conf, getSectionNamespace());
+        action.addContent(ele);
+
+        Element ok = new Element("ok", ns);
+        ok.setAttribute("to", "end");
+        action.addContent(ok);
+
+        Element error = new Element("error", ns);
+        error.setAttribute("to", "fail");
+        action.addContent(error);
+
+        root.addContent(action);
+
+        Element kill = new Element("kill", ns);
+        kill.setAttribute("name", "fail");
+        Element message = new Element("message", ns);
+        message.addContent(name + " failed, error 
message[${wf:errorMessage(wf:lastErrorNode())}]");
+        kill.addContent(message);
+        root.addContent(kill);
+
+        Element end = new Element("end", ns);
+        end.setAttribute("name", "end");
+        root.addContent(end);
+
+        return XmlUtils.prettyPrint(root).toString();
+    }
+
+    @Override
+    public String getEntityKey() {
+        return null;
+    }
+
+    @Override
+    protected boolean isLockRequired() {
+        return false;
+    }
+
+    @Override
+    protected void loadState() {
+
+    }
+
+    @Override
+    protected void verifyPrecondition() throws CommandException {
+
+    }
+}

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobsServlet.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobsServlet.java?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobsServlet.java 
(original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobsServlet.java 
Wed Mar 13 01:40:37 2013
@@ -18,7 +18,9 @@
 package org.apache.oozie.servlet;
 
 import java.io.IOException;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -39,7 +41,9 @@ import org.apache.oozie.DagEngineExcepti
 import org.apache.oozie.ErrorCode;
 import org.apache.oozie.WorkflowJobBean;
 import org.apache.oozie.WorkflowsInfo;
+import org.apache.oozie.cli.OozieCLI;
 import org.apache.oozie.client.OozieClient;
+import org.apache.oozie.client.XOozieClient;
 import org.apache.oozie.client.rest.BulkResponseImpl;
 import org.apache.oozie.client.rest.JsonTags;
 import org.apache.oozie.client.rest.RestConstants;
@@ -54,6 +58,11 @@ import org.json.simple.JSONObject;
 public class V1JobsServlet extends BaseJobsServlet {
 
     private static final String INSTRUMENTATION_NAME = "v1jobs";
+    private static final Set<String> httpJobType = new HashSet<String>(){{
+        this.add(OozieCLI.HIVE_CMD);
+        this.add(OozieCLI.PIG_CMD);
+        this.add(OozieCLI.MR_CMD);
+    }};
 
     public V1JobsServlet() {
         super(INSTRUMENTATION_NAME);
@@ -87,7 +96,7 @@ public class V1JobsServlet extends BaseJ
             }
         }
         else { // This is a http submission job
-            if (jobType.equals("pig") || jobType.equals("mapreduce")) {
+            if (httpJobType.contains(jobType)) {
                 json = submitHttpJob(request, conf, jobType);
             }
             else {

Modified: 
oozie/trunk/core/src/test/java/org/apache/oozie/client/TestWorkflowXClient.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/client/TestWorkflowXClient.java?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- 
oozie/trunk/core/src/test/java/org/apache/oozie/client/TestWorkflowXClient.java 
(original)
+++ 
oozie/trunk/core/src/test/java/org/apache/oozie/client/TestWorkflowXClient.java 
Wed Mar 13 01:40:37 2013
@@ -67,7 +67,37 @@ public class TestWorkflowXClient extends
                 writer.write("a = load 'input.txt';\n dump a;");
                 writer.close();
                 assertEquals(MockDagEngineService.JOB_ID + wfCount + 
MockDagEngineService.JOB_ID_END,
-                             wc.submitPig(conf, pigScriptFile, null));
+                             wc.submitScriptLanguage(conf, pigScriptFile, 
null, "pig"));
+
+                assertTrue(MockDagEngineService.started.get(wfCount));
+                return null;
+            }
+        });
+    }
+
+    public void testSubmitHive() throws Exception {
+        runTest(END_POINTS, SERVLET_CLASSES, IS_SECURITY_ENABLED, new 
Callable<Void>() {
+            public Void call() throws Exception {
+                String oozieUrl = getContextURL();
+                int wfCount = MockDagEngineService.INIT_WF_COUNT;
+                XOozieClient wc = new XOozieClient(oozieUrl);
+                Properties conf = wc.createConfiguration();
+                Path libPath = new Path(getFsTestCaseDir(), "lib");
+                getFileSystem().mkdirs(libPath);
+                System.out.println(libPath.toString());
+                conf.setProperty(OozieClient.LIBPATH, libPath.toString());
+                conf.setProperty(XOozieClient.JT, "localhost:9001");
+                conf.setProperty(XOozieClient.NN, "hdfs://localhost:9000");
+
+
+
+                String hiveScriptFile = getTestCaseDir() + "/test";
+                System.out.println(hiveScriptFile);
+                BufferedWriter writer = new BufferedWriter(new 
FileWriter(hiveScriptFile));
+                writer.write("CREATE EXTERNAL TABLE test (a INT);");
+                writer.close();
+                assertEquals(MockDagEngineService.JOB_ID + wfCount + 
MockDagEngineService.JOB_ID_END,
+                        wc.submitScriptLanguage(conf, hiveScriptFile, null, 
"hive"));
 
                 assertTrue(MockDagEngineService.started.get(wfCount));
                 return null;

Added: 
oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitHiveXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitHiveXCommand.java?rev=1455773&view=auto
==============================================================================
--- 
oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitHiveXCommand.java
 (added)
+++ 
oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitHiveXCommand.java
 Wed Mar 13 01:40:37 2013
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.command.wf;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.oozie.client.OozieClient;
+import org.apache.oozie.local.LocalOozie;
+import org.apache.oozie.action.hadoop.MapReduceMain;
+import org.apache.oozie.client.XOozieClient;
+import org.apache.oozie.test.XFsTestCase;
+import org.apache.oozie.util.XLog;
+import org.apache.oozie.util.XmlUtils;
+import org.apache.oozie.service.XLogService;
+import org.jdom.Element;
+public class TestSubmitHiveXCommand extends XFsTestCase {
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        setSystemProperty(XLogService.LOG4J_FILE, "oozie-log4j.properties");
+        LocalOozie.start();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        LocalOozie.stop();
+        super.tearDown();
+    }
+
+    public void testWFXmlGeneration() throws Exception {
+        Configuration conf = new Configuration();
+
+        conf.set(XOozieClient.JT, "jobtracker");
+        conf.set(XOozieClient.NN, "namenode");
+        conf.set(OozieClient.LIBPATH, "libpath");
+
+        conf.set(XOozieClient.FILES, 
"/user/oozie/input1.txt,/user/oozie/input2.txt#my.txt");
+        conf.set(XOozieClient.ARCHIVES, 
"/user/oozie/udf1.jar,/user/oozie/udf2.jar#my.jar");
+
+        String hiveArgsStr = "-a aaa -b bbb -c ccc -M -Da=aaa -Db=bbb -param 
input=abc";
+        String[] args = hiveArgsStr.split(" ");
+        MapReduceMain.setStrings(conf, XOozieClient.HIVE_OPTIONS, args);
+
+        SubmitHiveXCommand submitHiveCmd = new SubmitHiveXCommand(conf, 
"token");
+        String xml = submitHiveCmd.getWorkflowXml(conf);
+
+        XLog.getLog(getClass()).info("xml = " + xml);
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("<workflow-app xmlns=\"uri:oozie:workflow:0.2\" 
name=\"oozie-hive\">");
+        sb.append("<start to=\"hive1\" />");
+        sb.append("<action name=\"hive1\">");
+        sb.append("<hive xmlns=\"uri:oozie:hive-action:0.2\">");
+        sb.append("<job-tracker>jobtracker</job-tracker>");
+        sb.append("<name-node>namenode</name-node>");
+        sb.append("<configuration>");
+        sb.append("<property>");
+        sb.append("<name>a</name>");
+        sb.append("<value>aaa</value>");
+        sb.append("</property>");
+        sb.append("<property>");
+        sb.append("<name>b</name>");
+        sb.append("<value>bbb</value>");
+        sb.append("</property>");
+        sb.append("</configuration>");
+        sb.append("<script>dummy.hive</script>");
+        sb.append("<argument>-a</argument>");
+        sb.append("<argument>aaa</argument>");
+        sb.append("<argument>-b</argument>");
+        sb.append("<argument>bbb</argument>");
+        sb.append("<argument>-c</argument>");
+        sb.append("<argument>ccc</argument>");
+        sb.append("<argument>-M</argument>");
+        sb.append("<argument>-param</argument>");
+        sb.append("<argument>input=abc</argument>");
+        sb.append("<file>/user/oozie/input1.txt#input1.txt</file>");
+        sb.append("<file>/user/oozie/input2.txt#my.txt</file>");
+        sb.append("<archive>/user/oozie/udf1.jar#udf1.jar</archive>");
+        sb.append("<archive>/user/oozie/udf2.jar#my.jar</archive>");
+        sb.append("</hive>");
+        sb.append("<ok to=\"end\" />");
+        sb.append("<error to=\"fail\" />");
+        sb.append("</action>");
+        sb.append("<kill name=\"fail\">");
+        sb.append("<message>hive failed, error 
message[${wf:errorMessage(wf:lastErrorNode())}]</message>");
+        sb.append("</kill>");
+        sb.append("<end name=\"end\" />");
+        sb.append("</workflow-app>");
+
+        Element root = XmlUtils.parseXml(sb.toString());
+        String reference = XmlUtils.prettyPrint(root).toString();
+
+        XLog.getLog(getClass()).info("reference xml = " + reference);
+        assertTrue(xml.equals(reference));
+    }
+}

Modified: 
oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitPigXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitPigXCommand.java?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- 
oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitPigXCommand.java
 (original)
+++ 
oozie/trunk/core/src/test/java/org/apache/oozie/command/wf/TestSubmitPigXCommand.java
 Wed Mar 13 01:40:37 2013
@@ -97,7 +97,7 @@ public class TestSubmitPigXCommand exten
         sb.append("<error to=\"fail\" />");
         sb.append("</action>");
         sb.append("<kill name=\"fail\">");
-        sb.append("<message>Pig failed, error 
message[${wf:errorMessage(wf:lastErrorNode())}]</message>");
+        sb.append("<message>pig failed, error 
message[${wf:errorMessage(wf:lastErrorNode())}]</message>");
         sb.append("</kill>");
         sb.append("<end name=\"end\" />");
         sb.append("</workflow-app>");
@@ -148,7 +148,7 @@ public class TestSubmitPigXCommand exten
         sb.append("<error to=\"fail\" />");
         sb.append("</action>");
         sb.append("<kill name=\"fail\">");
-        sb.append("<message>Pig failed, error 
message[${wf:errorMessage(wf:lastErrorNode())}]</message>");
+        sb.append("<message>pig failed, error 
message[${wf:errorMessage(wf:lastErrorNode())}]</message>");
         sb.append("</kill>");
         sb.append("<end name=\"end\" />");
         sb.append("</workflow-app>");

Modified: oozie/trunk/release-log.txt
URL: 
http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1455773&r1=1455772&r2=1455773&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Wed Mar 13 01:40:37 2013
@@ -1,5 +1,6 @@
 -- Oozie 4.1.0 release (trunk - unreleased)
 
+OOZIE-894 support for hive in Oozie CLI (bowenzhangusa via tucu)
 OOZIE-1239 Bump up trunk to 4.1.0-SNAPSHOT (virag)
 
 -- Oozie 4.0.0 (unreleased)


Reply via email to