Author: mona
Date: Wed Nov  7 00:00:18 2012
New Revision: 1406404

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

Modified:
    
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
    
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java
    
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java
    
oozie/branches/hcat-intre/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java

Modified: 
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java?rev=1406404&r1=1406403&r2=1406404&view=diff
==============================================================================
--- 
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
 (original)
+++ 
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
 Wed Nov  7 00:00:18 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/branches/hcat-intre/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java?rev=1406404&r1=1406403&r2=1406404&view=diff
==============================================================================
--- 
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java
 (original)
+++ 
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java
 Wed Nov  7 00:00:18 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/branches/hcat-intre/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java?rev=1406404&r1=1406403&r2=1406404&view=diff
==============================================================================
--- 
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java
 (original)
+++ 
oozie/branches/hcat-intre/core/src/main/java/org/apache/oozie/executor/jpa/BulkUpdateInsertForCoordActionStartJPAExecutor.java
 Wed Nov  7 00:00:18 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/branches/hcat-intre/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/hcat-intre/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java?rev=1406404&r1=1406403&r2=1406404&view=diff
==============================================================================
--- 
oozie/branches/hcat-intre/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java
 (original)
+++ 
oozie/branches/hcat-intre/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionStartXCommand.java
 Wed Nov  7 00:00:18 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>"


Reply via email to