You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by tu...@apache.org on 2012/06/18 23:37:55 UTC

svn commit: r1351496 - in /incubator/oozie/trunk: core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java release-log.txt

Author: tucu
Date: Mon Jun 18 21:37:55 2012
New Revision: 1351496

URL: http://svn.apache.org/viewvc?rev=1351496&view=rev
Log:
OOZIE-801 Accepts coordinator with start time > end time (svenkat via tucu)

Modified:
    incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
    incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java
    incubator/oozie/trunk/release-log.txt

Modified: incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java?rev=1351496&r1=1351495&r2=1351496&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java (original)
+++ incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java Mon Jun 18 21:37:55 2012
@@ -222,6 +222,8 @@ public class CoordSubmitXCommand extends
             initEvaluators();
             Element eJob = basicResolveAndIncludeDS(appXml, conf, coordJob);
 
+            validateCoordinatorJob();
+
             // checking if the coordinator application data input/output events
             // specify multiple data instance values in erroneous manner
             checkMultipleTimeInstances(eJob, COORD_INPUT_EVENTS, COORD_INPUT_EVENTS_DATA_IN);
@@ -295,10 +297,20 @@ public class CoordSubmitXCommand extends
         return jobId;
     }
 
-    /*
-     * Check against multiple data instance values inside a single <instance> tag
-     * If found, the job is not submitted and user is informed to correct the error, instead of defaulting to the first instance value in the list
+    /**
+     * Method that validates values in the definition for correctness. Placeholder to add more.
      */
+    private void validateCoordinatorJob() {
+        // check if startTime < endTime
+        if (coordJob.getStartTime().after(coordJob.getEndTime())) {
+            throw new IllegalArgumentException("Coordinator Start Time cannot be greater than End Time.");
+        }
+    }
+
+  /*
+  * Check against multiple data instance values inside a single <instance> tag
+  * If found, the job is not submitted and user is informed to correct the error, instead of defaulting to the first instance value in the list
+  */
     private void checkMultipleTimeInstances(Element eCoordJob, String eventType, String dataType) throws CoordinatorJobException {
         Element eventsSpec, dataSpec, instance;
         List<Element> instanceSpecList;

Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java?rev=1351496&r1=1351495&r2=1351496&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordSubmitXCommand.java Mon Jun 18 21:37:55 2012
@@ -97,6 +97,40 @@ public class TestCoordSubmitXCommand ext
                 "oozie.service.coord.default.concurrency", 1));
     }
 
+    public void testBasicSubmitWithStartTimeAfterEndTime() throws Exception {
+        Configuration conf = new XConfiguration();
+        String appPath = "file://" + getTestCaseDir() + File.separator + "coordinator.xml";
+        String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2010-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" "
+                + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> "
+                + "<execution>LIFO</execution> </controls> <datasets> "
+                + "<dataset name=\"a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" "
+                + "timezone=\"UTC\"> <uri-template>file:///tmp/coord/workflows/${YEAR}/${DAY}</uri-template> </dataset> "
+                + "<dataset name=\"local_a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" "
+                + "timezone=\"UTC\"> <uri-template>file:///tmp/coord/workflows/${YEAR}/${DAY}</uri-template> </dataset> "
+                + "</datasets> <input-events> "
+                + "<data-in name=\"A\" dataset=\"a\"> <instance>${coord:latest(0)}</instance> </data-in>  "
+                + "</input-events> "
+                + "<output-events> <data-out name=\"LOCAL_A\" dataset=\"local_a\"> "
+                + "<instance>${coord:current(-1)}</instance> </data-out> </output-events> <action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> "
+                + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> "
+                + "<property> <name>inputB</name> <value>${coord:dataOut('LOCAL_A')}</value> "
+                + "</property></configuration> </workflow> </action> </coordinator-app>";
+        writeToFile(appXml, appPath);
+        conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
+        conf.set(OozieClient.USER_NAME, getTestUser());
+        CoordSubmitXCommand sc = new CoordSubmitXCommand(conf, "UNIT_TESTING");
+
+        try {
+            sc.call();
+            fail("Expected to catch errors due to incorrectly specified Start and End Time");
+        }
+        catch (CommandException e) {
+            assertEquals(sc.getJob().getStatus(), Job.Status.FAILED);
+            assertEquals(e.getErrorCode(), ErrorCode.E1003);
+            assertTrue(e.getMessage().contains("Coordinator Start Time cannot be greater than End Time."));
+        }
+    }
+
     /**
      * Testing for when user tries to submit a coordinator application having data-in events
      * that erroneously specify multiple input data instances inside a single <instance> tag.

Modified: incubator/oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1351496&r1=1351495&r2=1351496&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Mon Jun 18 21:37:55 2012
@@ -1,5 +1,6 @@
 -- Oozie 3.3.0 release (trunk - unreleased)
 
+OOZIE-801 Accepts coordinator with start time > end time (svenkat via tucu)
 OOZIE-867 Unit test to account for log retrieval from multiple gzipped oozie.log files (mona via tucu)
 OOZIE-649 Fail fast when a date doesn't parse correctly (rkanter via tucu)
 OOZIE-871 actions from subworkflows that use oozie.libpath have duplicate classpath (tucu)