Author: kamrul
Date: Fri Dec  2 03:03:16 2011
New Revision: 1209345

URL: http://svn.apache.org/viewvc?rev=1209345&view=rev
Log:
OOZIE-589 Make the command requeue interval configurable.(Mohammad)

Modified:
    
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
    incubator/oozie/trunk/core/src/main/resources/oozie-default.xml
    
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
    incubator/oozie/trunk/release-log.txt

Modified: 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java?rev=1209345&r1=1209344&r2=1209345&view=diff
==============================================================================
--- 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
 (original)
+++ 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
 Fri Dec  2 03:03:16 2011
@@ -40,6 +40,7 @@ import org.apache.oozie.executor.jpa.JPA
 import org.apache.oozie.service.HadoopAccessorException;
 import org.apache.oozie.service.HadoopAccessorService;
 import org.apache.oozie.service.JPAService;
+import org.apache.oozie.service.Service;
 import org.apache.oozie.service.Services;
 import org.apache.oozie.util.DateUtils;
 import org.apache.oozie.util.ELEvaluator;
@@ -57,7 +58,17 @@ import org.jdom.Element;
 public class CoordActionInputCheckXCommand extends CoordinatorXCommand<Void> {
 
     private final String actionId;
-    private final int COMMAND_REQUEUE_INTERVAL = 60000; // 1 minute
+    /**
+     * Property name of command re-queue interval for coordinator action input 
check in
+     * milliseconds.
+     */
+    public static final String CONF_COORD_INPUT_CHECK_REQUEUE_INTERVAL = 
Service.CONF_PREFIX
+            + "coord.input.check.requeue.interval";
+    /**
+     * Default re-queue interval in ms. It is applied when no value defined in
+     * the oozie configuration.
+     */
+    private final int DEFAULT_COMMAND_REQUEUE_INTERVAL = 60000; // 1 minute
     private CoordinatorActionBean coordAction = null;
     private CoordinatorJobBean coordJob = null;
     private JPAService jpaService = null;
@@ -79,8 +90,8 @@ public class CoordActionInputCheckXComma
         Date nominalTime = coordAction.getNominalTime();
         Date currentTime = new Date();
         if (nominalTime.compareTo(currentTime) > 0) {
-            queue(new CoordActionInputCheckXCommand(coordAction.getId()), 
Math.max(
-                    (nominalTime.getTime() - currentTime.getTime()), 
COMMAND_REQUEUE_INTERVAL));
+            queue(new CoordActionInputCheckXCommand(coordAction.getId()), 
Math.max((nominalTime.getTime() - currentTime
+                    .getTime()), getCoordInputCheckRequeueInterval()));
             // update lastModifiedTime
             coordAction.setLastModifiedTime(new Date());
             try {
@@ -129,7 +140,7 @@ public class CoordActionInputCheckXComma
                     queue(new CoordActionTimeOutXCommand(coordAction), 100);
                 }
                 else {
-                    queue(new 
CoordActionInputCheckXCommand(coordAction.getId()), COMMAND_REQUEUE_INTERVAL);
+                    queue(new 
CoordActionInputCheckXCommand(coordAction.getId()), 
getCoordInputCheckRequeueInterval());
                 }
             }
             coordAction.setLastModifiedTime(new Date());
@@ -144,6 +155,20 @@ public class CoordActionInputCheckXComma
     }
 
     /**
+     * This function reads the value of re-queue interval for coordinator input
+     * check command from the Oozie configuration provided by Configuration
+     * Service. If nothing defined in the configuration, it uses the code
+     * specified default value.
+     *
+     * @return re-queue interval in ms
+     */
+    public long getCoordInputCheckRequeueInterval() {
+        long requeueInterval = 
Services.get().getConf().getLong(CONF_COORD_INPUT_CHECK_REQUEUE_INTERVAL,
+                DEFAULT_COMMAND_REQUEUE_INTERVAL);
+        return requeueInterval;
+    }
+
+    /**
      * To check the list of input paths if all of them exist
      *
      * @param actionXml action xml

Modified: incubator/oozie/trunk/core/src/main/resources/oozie-default.xml
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/resources/oozie-default.xml?rev=1209345&r1=1209344&r2=1209345&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/resources/oozie-default.xml (original)
+++ incubator/oozie/trunk/core/src/main/resources/oozie-default.xml Fri Dec  2 
03:03:16 2011
@@ -321,7 +321,15 @@
                <description>Default maximum timeout for a coordinator action 
input check (in minutes). 86400= 60days
         </description>
        </property>
-       
+
+       <property>
+               <name>oozie.service.coord.input.check.requeue.interval
+               </name>
+               <value>60000</value>
+               <description>Command re-queue interval for coordinator data 
input check (in millisecond).
+        </description>
+       </property>
+
        <property>
                <name>oozie.service.coord.default.concurrency
                </name>

Modified: 
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java?rev=1209345&r1=1209344&r2=1209345&view=diff
==============================================================================
--- 
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
 (original)
+++ 
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
 Fri Dec  2 03:03:16 2011
@@ -141,8 +141,36 @@ public class TestCoordActionInputCheckXC
         checkCoordAction(job.getId() + "@1");
     }
 
-    protected CoordinatorJobBean addRecordToCoordJobTableForWaiting(String 
testFileName, CoordinatorJob.Status status, Date start, Date end,
-            boolean pending, boolean doneMatd, int lastActionNum) throws 
Exception {
+    /**
+     * This test case verifies if getCoordInputCheckRequeueInterval picks up 
the
+     * overridden value. In reality, the value could be overridden in
+     * oozie-site.xml.
+     *
+     * @throws Exception
+     */
+    public void testRequeueInterval() throws Exception {
+        /*
+         * Create a dummy Coordinator Job to pass to
+         * CoordActionInputCheckXCommand constructor.
+         */
+        String jobId = "0000000-" + new Date().getTime() + 
"-TestCoordActionInputCheckXCommand-C";
+        Date startTime = DateUtils.parseDateUTC("2009-02-01T23:59Z");
+        Date endTime = DateUtils.parseDateUTC("2009-02-02T23:59Z");
+        CoordinatorJobBean job = addRecordToCoordJobTable(jobId, startTime, 
endTime);
+        /* Override the property value for testing purpose only. */
+        long testedValue = 12000;
+        
Services.get().getConf().setLong(CoordActionInputCheckXCommand.CONF_COORD_INPUT_CHECK_REQUEUE_INTERVAL,
+                testedValue);
+
+        CoordActionInputCheckXCommand caicc = new 
CoordActionInputCheckXCommand(job.getId() + "@1");
+
+        long effectiveValue = caicc.getCoordInputCheckRequeueInterval();
+        // Verify if two values are same.
+        assertEquals(testedValue, effectiveValue);
+    }
+
+    protected CoordinatorJobBean addRecordToCoordJobTableForWaiting(String 
testFileName, CoordinatorJob.Status status,
+            Date start, Date end, boolean pending, boolean doneMatd, int 
lastActionNum) throws Exception {
 
         String testDir = getTestCaseDir();
         CoordinatorJobBean coordJob = createCoordJob(testFileName, status, 
start, end, pending, doneMatd, lastActionNum);
@@ -172,7 +200,7 @@ public class TestCoordActionInputCheckXC
             return appXml;
         }
         catch (IOException ioe) {
-            throw new RuntimeException(XLog.format("Could not get "+ 
testFileName, ioe));
+            throw new RuntimeException(XLog.format("Could not get " + 
testFileName, ioe));
         }
     }
 

Modified: incubator/oozie/trunk/release-log.txt
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1209345&r1=1209344&r2=1209345&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Fri Dec  2 03:03:16 2011
@@ -1,5 +1,6 @@
 -- Oozie 3.2.0 release
 
+OOZIE-589 Make the command requeue interval configurable.(Mohammad)
 OOZIE-156. Add support for a SQOOP action. (tucu)
 OOZIE-77. Oozie should support Kerberos authentication on its HTTP REST API. 
(tucu)
 OOZIE-622. Remove system sharelib tests from TestLiteWorkflowAppService. (tucu)
@@ -19,6 +20,7 @@ OOZIE-600 Bump-up the version to 3.2.0-S
 
 -- Oozie 3.1.2 release
 
+OOZIE-589 Make the command requeue interval configurable.
 OOZIE-38 LocalOozie example and improvement
 OOZIE-580 use xml element to handle string escape when configure evaluator
 OOZIE-585 Coordinator job fail to retrieve log with date range and action 
range.


Reply via email to