You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by mo...@apache.org on 2012/10/31 21:58:56 UTC

svn commit: r1404347 - in /oozie/trunk: ./ core/src/main/java/org/apache/oozie/ core/src/main/java/org/apache/oozie/command/coord/ core/src/main/java/org/apache/oozie/executor/jpa/ core/src/test/java/org/apache/oozie/command/coord/

Author: mona
Date: Wed Oct 31 20:58:55 2012
New Revision: 1404347

URL: http://svn.apache.org/viewvc?rev=1404347&view=rev
Log:
OOZIE-1014 Coordinator action failure error not propagated (mona)

Modified:
    oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
    oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java
    oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java
    oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java
    oozie/trunk/release-log.txt

Modified: oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java?rev=1404347&r1=1404346&r2=1404347&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java Wed Oct 31 20:58:55 2012
@@ -57,7 +57,7 @@ import org.apache.openjpa.persistence.jd
         // Update query for InputCheck
         @NamedQuery(name = "UPDATE_COORD_ACTION_FOR_INPUTCHECK", query = "update CoordinatorActionBean w set w.status = :status, w.lastModifiedTimestamp = :lastModifiedTime, w.actionXml = :actionXml, w.missingDependencies = :missingDependencies where w.id = :id"),
         // Update query for Start
-        @NamedQuery(name = "UPDATE_COORD_ACTION_FOR_START", query = "update CoordinatorActionBean w set w.status =:status, w.lastModifiedTimestamp = :lastModifiedTime, w.runConf = :runConf, w.externalId = :externalId, w.pending = :pending  where w.id = :id"),
+        @NamedQuery(name = "UPDATE_COORD_ACTION_FOR_START", query = "update CoordinatorActionBean w set w.status =:status, w.lastModifiedTimestamp = :lastModifiedTime, w.runConf = :runConf, w.externalId = :externalId, w.pending = :pending, w.errorCode = :errorCode, w.errorMessage = :errorMessage  where w.id = :id"),
 
         @NamedQuery(name = "DELETE_COMPLETED_ACTIONS_FOR_COORDINATOR", query = "delete from CoordinatorActionBean a where a.jobId = :jobId and (a.status = 'SUCCEEDED' OR a.status = 'FAILED' OR a.status= 'KILLED')"),
 

Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java?rev=1404347&r1=1404346&r2=1404347&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java Wed Oct 31 20:58:55 2012
@@ -203,7 +203,7 @@ public class CoordActionStartXCommand ex
             }
             catch (DagEngineException dee) {
                 errMsg = dee.getMessage();
-                errCode = "E1005";
+                errCode = dee.getErrorCode().toString();
                 log.warn("can not create DagEngine for submitting jobs", dee);
             }
             catch (CommandException ce) {
@@ -223,7 +223,7 @@ public class CoordActionStartXCommand ex
             }
             finally {
                 if (makeFail == true) { // No DB exception occurs
-                    log.warn("Failing the action " + coordAction.getId() + ". Because " + errCode + " : " + errMsg);
+                    log.error("Failing the action " + coordAction.getId() + ". Because " + errCode + " : " + errMsg);
                     coordAction.setStatus(CoordinatorAction.Status.FAILED);
                     if (errMsg.length() > 254) { // Because table column size is 255
                         errMsg = errMsg.substring(0, 255);

Modified: oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java?rev=1404347&r1=1404346&r2=1404347&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java Wed Oct 31 20:58:55 2012
@@ -110,6 +110,8 @@ public class BulkUpdateInsertForCoordAct
                         q.setParameter("runConf", action.getRunConf());
                         q.setParameter("externalId", action.getExternalId());
                         q.setParameter("pending", action.getPending());
+                        q.setParameter("errorCode", action.getErrorCode());
+                        q.setParameter("errorMessage", action.getErrorMessage());
                         q.executeUpdate();
                     }
                     else {

Modified: oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java?rev=1404347&r1=1404346&r2=1404347&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java Wed Oct 31 20:58:55 2012
@@ -36,6 +36,7 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.oozie.CoordinatorActionBean;
 import org.apache.oozie.CoordinatorJobBean;
+import org.apache.oozie.ErrorCode;
 import org.apache.oozie.WorkflowActionBean;
 import org.apache.oozie.WorkflowJobBean;
 import org.apache.oozie.action.hadoop.MapperReducerForTest;
@@ -44,6 +45,7 @@ import org.apache.oozie.client.Coordinat
 import org.apache.oozie.client.OozieClient;
 import org.apache.oozie.client.CoordinatorAction.Status;
 import org.apache.oozie.command.CommandException;
+import org.apache.oozie.executor.jpa.CoordActionGetForStartJPAExecutor;
 import org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor;
 import org.apache.oozie.executor.jpa.CoordActionInsertJPAExecutor;
 import org.apache.oozie.executor.jpa.JPAExecutorException;
@@ -74,14 +76,47 @@ public class TestCoordActionStartXComman
         super.tearDown();
     }
 
+    /**
+     * Test the working of CoordActionStartXCommand with standard coord action
+     * XML and then check the action
+     *
+     * @throws IOException
+     * @throws JPAExecutorException
+     * @throws CommandException
+     */
     public void testActionStartCommand() throws IOException, JPAExecutorException, CommandException {
         String actionId = new Date().getTime() + "-COORD-ActionStartCommand-C@1";
-        addRecordToActionTable(actionId, 1);
+        addRecordToActionTable(actionId, 1, null);
         new CoordActionStartXCommand(actionId, "me", "mytoken", "myjob").call();
         checkCoordAction(actionId);
     }
 
     /**
+     * Coord action XML contains non-supported parameterized action name and
+     * test that CoordActionStartXCommand stores error code and error message in
+     * action's table during error handling
+     *
+     * @throws IOException
+     * @throws JPAExecutorException
+     * @throws CommandException
+     */
+    public void testActionStartWithErrorReported() throws IOException, JPAExecutorException, CommandException {
+        String actionId = new Date().getTime() + "-COORD-ActionStartCommand-C@1";
+        String wfApp = "<start to='${someParam}' />";
+        addRecordToActionTable(actionId, 1, wfApp);
+        new CoordActionStartXCommand(actionId, "me", "mytoken", "myjob").call();
+        final JPAService jpaService = Services.get().get(JPAService.class);
+        CoordinatorActionBean action = jpaService.execute(new CoordActionGetForStartJPAExecutor(actionId));
+        if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) {
+            fail("Expected status was FAILED due to incorrect XML element");
+        }
+        assertEquals(action.getErrorCode(), ErrorCode.E0701.toString());
+        assertTrue(action.getErrorMessage().contains(
+                "XML schema error, cvc-pattern-valid: Value '${someParam}' "
+                        + "is not facet-valid with respect to pattern"));
+    }
+
+    /**
      * Test : configuration contains url string which should be escaped before put into the evaluator.
      * If not escape, the error 'SAXParseException' will be thrown and workflow job will not be submitted.
      *
@@ -174,7 +209,8 @@ public class TestCoordActionStartXComman
         return new XConfiguration(jobConf);
     }
 
-    private void addRecordToActionTable(String actionId, int actionNum) throws IOException, JPAExecutorException {
+    private void addRecordToActionTable(String actionId, int actionNum, String wfParam)
+            throws IOException, JPAExecutorException {
         final JPAService jpaService = Services.get().get(JPAService.class);
         CoordinatorActionBean action = new CoordinatorActionBean();
         action.setJobId(actionId);
@@ -249,7 +285,14 @@ public class TestCoordActionStartXComman
         action.setCreatedConf(createdConf);
         jpaService.execute(new CoordActionInsertJPAExecutor(action));
         String content = "<workflow-app xmlns='uri:oozie:workflow:0.2'  xmlns:sla='uri:oozie:sla:0.1' name='no-op-wf'>";
-        content += "<start to='end' />";
+        if (wfParam != null) {
+            if (!wfParam.isEmpty()) {
+                content += wfParam;
+            }
+        }
+        else {
+            content += "<start to='end' />";
+        }
         String slaXml2 = " <sla:info>"
                 // + " <sla:client-id>axonite-blue</sla:client-id>"
                 + " <sla:app-name>test-app</sla:app-name>" + " <sla:nominal-time>2009-03-06T10:00Z</sla:nominal-time>"

Modified: oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1404347&r1=1404346&r2=1404347&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Wed Oct 31 20:58:55 2012
@@ -1,5 +1,5 @@
 -- Oozie 3.4.0 release (trunk - unreleased)
-
+OOZIE-1014 Coordinator action failure error not propagated (mona)
 OOZIE-1029 MiniMRCluster fails to start when used against YARN (rkanter via tucu)
 OOZIE-1011 Tests from OOZIE-994 fail when run against Hadoop trunk (rkanter via tucu)
 OOZIE-1027 XTestCase.delete() can cause tests to fail if it runs into a dangling symlink (rkanter via tucu)