Author: mona
Date: Thu Jan 31 05:55:20 2013
New Revision: 1440858

URL: http://svn.apache.org/viewvc?rev=1440858&view=rev
Log:
OOZIE-1179 coord action in WAITING when no definition of dataset in coord job 
xml (mona)

Added:
    oozie/trunk/core/src/test/resources/wf-no-op.xml
Modified:
    
oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
    
oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java
    
oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
    
oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java
    oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java?rev=1440858&r1=1440857&r2=1440858&view=diff
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
 (original)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
 Thu Jan 31 05:55:20 2013
@@ -35,6 +35,7 @@ import org.apache.oozie.command.Precondi
 import org.apache.oozie.coord.CoordELEvaluator;
 import org.apache.oozie.coord.CoordELFunctions;
 import org.apache.oozie.executor.jpa.CoordActionGetForInputCheckJPAExecutor;
+import org.apache.oozie.executor.jpa.CoordActionUpdateForInputCheckJPAExecutor;
 import 
org.apache.oozie.executor.jpa.CoordActionUpdateForModifiedTimeJPAExecutor;
 import org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor;
 import org.apache.oozie.executor.jpa.JPAExecutorException;
@@ -98,7 +99,7 @@ public class CoordActionInputCheckXComma
             // update lastModifiedTime
             coordAction.setLastModifiedTime(new Date());
             try {
-                jpaService.execute(new 
org.apache.oozie.executor.jpa.CoordActionUpdateForInputCheckJPAExecutor(coordAction));
+                jpaService.execute(new 
CoordActionUpdateForInputCheckJPAExecutor(coordAction));
             }
             catch (JPAExecutorException e) {
                 throw new CommandException(e);
@@ -138,7 +139,8 @@ public class CoordActionInputCheckXComma
                 
nonExistList.append(CoordCommandUtils.RESOLVED_UNRESOLVED_SEPARATOR).append(nonResolvedList);
             }
             String nonExistListStr = nonExistList.toString();
-            if (!missingDeps.equals(nonExistListStr)) {
+            if (!nonExistListStr.equals(missingDeps) || missingDeps.isEmpty()) 
{
+                // missingDeps empty means action should become READY
                 isChangeInDependency = true;
                 coordAction.setMissingDependencies(nonExistListStr);
             }
@@ -170,8 +172,7 @@ public class CoordActionInputCheckXComma
             if(jpaService != null) {
                 try {
                     if (isChangeInDependency) {
-                        jpaService.execute(new 
org.apache.oozie.executor.jpa.CoordActionUpdateForInputCheckJPAExecutor(
-                                coordAction));
+                        jpaService.execute(new 
CoordActionUpdateForInputCheckJPAExecutor(coordAction));
                     }
                     else {
                         jpaService.execute(new 
CoordActionUpdateForModifiedTimeJPAExecutor(coordAction));

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java?rev=1440858&r1=1440857&r2=1440858&view=diff
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java
 (original)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java
 Thu Jan 31 05:55:20 2013
@@ -18,8 +18,6 @@
 package org.apache.oozie.executor.jpa;
 
 import java.sql.Timestamp;
-import java.util.List;
-
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
 

Modified: 
oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java?rev=1440858&r1=1440857&r2=1440858&view=diff
==============================================================================
--- 
oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
 (original)
+++ 
oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
 Thu Jan 31 05:55:20 2013
@@ -445,6 +445,93 @@ public class TestCoordActionInputCheckXC
         assertEquals(testedValue, effectiveValue);
     }
 
+    /**
+     * This test verifies that for a coordinator with no input dependencies
+     * action is not stuck in WAITING
+     *
+     * @throws Exception
+     */
+    public void testNoDatasetDependency() throws Exception {
+        /*
+         * create coordinator job
+         */
+        CoordinatorJobBean coordJob = new CoordinatorJobBean();
+        coordJob.setId("0000000" + new Date().getTime() + 
"-TestCoordActionInputCheckXCommand-C");
+        coordJob.setAppName("testApp");
+        coordJob.setAppPath("testAppPath");
+        coordJob.setStatus(CoordinatorJob.Status.RUNNING);
+        coordJob.setCreatedTime(new Date());
+        coordJob.setLastModifiedTime(new Date());
+        coordJob.setUser("testUser");
+        coordJob.setGroup("testGroup");
+        coordJob.setAuthToken("notoken");
+        coordJob.setTimeZone("UTC");
+        coordJob.setTimeUnit(Timeunit.DAY);
+        coordJob.setMatThrottling(2);
+        try {
+            
coordJob.setStartTime(DateUtils.parseDateOozieTZ("2009-02-01T23:59" + TZ));
+            coordJob.setEndTime(DateUtils.parseDateOozieTZ("2009-02-02T23:59" 
+ TZ));
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            fail("Could not set Date/time");
+        }
+        XConfiguration jobConf = new XConfiguration();
+        jobConf.set(OozieClient.USER_NAME, getTestUser());
+        String confStr = jobConf.toXmlString(false);
+        coordJob.setConf(confStr);
+        String wfXml = IOUtils.getResourceAsString("wf-no-op.xml", -1);
+        writeToFile(wfXml, getFsTestCaseDir(), "workflow.xml");
+        String appXml = "<coordinator-app xmlns='uri:oozie:coordinator:0.2' 
name='NAME' frequency=\"1\" start='2009-02-01T01:00"
+                + TZ + "' end='2009-02-03T23:59" + TZ + "' timezone='UTC' 
freq_timeunit='DAY' end_of_duration='NONE'>";
+        appXml += "<output-events>";
+        appXml += "<data-out name='LOCAL_A' dataset='local_a'>";
+        appXml += "<dataset name='local_a' frequency='7' 
initial-instance='2009-01-01T01:00" + TZ
+                + "' timezone='UTC' freq_timeunit='DAY' 
end_of_duration='NONE'>";
+        appXml += "<uri-template>file://" + getFsTestCaseDir() + 
"/${YEAR}/${MONTH}/${DAY}</uri-template>";
+        appXml += "</dataset>";
+        appXml += "<start-instance>${coord:current(-3)}</start-instance>";
+        appXml += "<instance>${coord:current(0)}</instance>";
+        appXml += "</data-out>";
+        appXml += "</output-events>";
+        appXml += "<action>";
+        appXml += "<workflow>";
+        appXml += "<app-path>" + getFsTestCaseDir() + 
"/workflow.xml</app-path>";
+        appXml += "</workflow>";
+        appXml += "</action>";
+        appXml += "</coordinator-app>";
+        coordJob.setJobXml(appXml);
+        coordJob.setLastActionNumber(0);
+        coordJob.setFrequency(1);
+        coordJob.setConcurrency(1);
+        JPAService jpaService = Services.get().get(JPAService.class);
+        if (jpaService != null) {
+            try {
+                jpaService.execute(new CoordJobInsertJPAExecutor(coordJob));
+            }
+            catch (JPAExecutorException e) {
+                throw new CommandException(e);
+            }
+        }
+        else {
+            fail("Unable to insert the test job record to table");
+        }
+        new CoordMaterializeTransitionXCommand(coordJob.getId(), 3600).call();
+        /*
+         * check coord action READY
+         */
+        new CoordActionInputCheckXCommand(coordJob.getId() + "@1", 
coordJob.getId()).call();
+        CoordinatorActionBean action = null;
+        try {
+            jpaService = Services.get().get(JPAService.class);
+            action = jpaService.execute(new 
CoordActionGetJPAExecutor(coordJob.getId() + "@1"));
+        }
+        catch (JPAExecutorException se) {
+            fail("Action ID " + coordJob.getId() + "@1" + " was not stored 
properly in db");
+        }
+        assertEquals(action.getStatus(), CoordinatorAction.Status.READY);
+    }
+
     protected CoordinatorJobBean addRecordToCoordJobTableForWaiting(String 
testFileName, CoordinatorJob.Status status,
             Date start, Date end, boolean pending, boolean doneMatd, int 
lastActionNum) throws Exception {
 

Modified: 
oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java?rev=1440858&r1=1440857&r2=1440858&view=diff
==============================================================================
--- 
oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java
 (original)
+++ 
oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java
 Thu Jan 31 05:55:20 2013
@@ -1101,13 +1101,6 @@ public class TestCoordRerunXCommand exte
         return conf;
     }
 
-    private void writeToFile(String content, Path appPath, String fileName) 
throws IOException {
-        FileSystem fs = getFileSystem();
-        Writer writer = new OutputStreamWriter(fs.create(new Path(appPath, 
fileName), true));
-        writer.write(content);
-        writer.close();
-    }
-
     @SuppressWarnings("unchecked")
     private String[] getActionXmlUrls(Element eAction, String user, String 
group) {
         Element outputList = eAction.getChild("input-events", 
eAction.getNamespace());

Modified: 
oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java?rev=1440858&r1=1440857&r2=1440858&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java 
(original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java Thu 
Jan 31 05:55:20 2013
@@ -927,7 +927,7 @@ public abstract class XDataTestCase exte
         return jobConf;
     }
 
-    private void writeToFile(String content, Path appPath, String fileName) 
throws IOException {
+    protected void writeToFile(String content, Path appPath, String fileName) 
throws IOException {
         FileSystem fs = getFileSystem();
         Writer writer = new OutputStreamWriter(fs.create(new Path(appPath, 
fileName), true));
         writer.write(content);

Added: oozie/trunk/core/src/test/resources/wf-no-op.xml
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/resources/wf-no-op.xml?rev=1440858&view=auto
==============================================================================
--- oozie/trunk/core/src/test/resources/wf-no-op.xml (added)
+++ oozie/trunk/core/src/test/resources/wf-no-op.xml Thu Jan 31 05:55:20 2013
@@ -0,0 +1,21 @@
+<!--
+  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.
+-->
+<workflow-app xmlns="uri:oozie:workflow:0.2" name="no-op-wf">
+    <start to="end"/>
+    <end name="end"/>
+</workflow-app>


Reply via email to