Author: kamrul
Date: Fri Feb  3 08:53:00 2012
New Revision: 1240031

URL: http://svn.apache.org/viewvc?rev=1240031&view=rev
Log:
OOZIE-673: Offset and len option not working as expected.(Virag via Mohammad)

Modified:
    
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
    
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordJobXCommand.java
    
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordJobGetActionsSubsetJPAExecutor.java
    
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
    incubator/oozie/trunk/core/src/main/resources/oozie-default.xml
    
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsSubsetJPAExecutor.java
    incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki
    incubator/oozie/trunk/release-log.txt

Modified: 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java?rev=1240031&r1=1240030&r2=1240031&view=diff
==============================================================================
--- 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
 (original)
+++ 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java
 Fri Feb  3 08:53:00 2012
@@ -80,7 +80,8 @@ import org.apache.openjpa.persistence.jd
         @NamedQuery(name = "GET_COORD_ACTIONS_PENDING_FALSE_STATUS_COUNT", 
query = "select count(a) from CoordinatorActionBean a where a.jobId = :jobId 
AND a.pending = 0 AND a.status = :status"),
 
         @NamedQuery(name = "GET_ACTIONS_FOR_COORD_JOB", query = "select 
OBJECT(a) from CoordinatorActionBean a where a.jobId = :jobId"),
-
+        // Query to retrieve Coordinator actions sorted by nominal time
+        @NamedQuery(name = "GET_ACTIONS_FOR_COORD_JOB_ORDER_BY_NOMINAL_TIME", 
query = "select OBJECT(a) from CoordinatorActionBean a where a.jobId = :jobId 
order by a.nominalTimestamp"),
         // Query to retrieve action id, action status, pending status and 
external Id of not completed Coordinator actions
         @NamedQuery(name = "GET_COORD_ACTIONS_NOT_COMPLETED", query = "select 
a.id, a.status, a.pending, a.externalId from CoordinatorActionBean a where 
a.jobId = :jobId AND a.status <> 'FAILED' AND a.status <> 'TIMEDOUT' AND 
a.status <> 'SUCCEEDED' AND a.status <> 'KILLED'"),
 
@@ -131,6 +132,7 @@ public class CoordinatorActionBean exten
     private String status = null;
 
     @Basic
+    @Index
     @Column(name = "nominal_time")
     private java.sql.Timestamp nominalTimestamp = null;
 

Modified: 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordJobXCommand.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordJobXCommand.java?rev=1240031&r1=1240030&r2=1240031&view=diff
==============================================================================
--- 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordJobXCommand.java
 (original)
+++ 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordJobXCommand.java
 Fri Feb  3 08:53:00 2012
@@ -6,9 +6,9 @@
  * 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.
@@ -26,6 +26,7 @@ import org.apache.oozie.XException;
 import org.apache.oozie.command.CommandException;
 import org.apache.oozie.command.PreconditionException;
 import org.apache.oozie.executor.jpa.CoordActionsSubsetGetForJobJPAExecutor;
+import org.apache.oozie.executor.jpa.CoordJobGetActionsSubsetJPAExecutor;
 import org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor;
 import org.apache.oozie.service.JPAService;
 import org.apache.oozie.service.Services;
@@ -118,7 +119,7 @@ public class CoordJobXCommand extends Co
                 coordJob = jpaService.execute(new CoordJobGetJPAExecutor(id));
                 if (getActionInfo) {
                     List<CoordinatorActionBean> coordActions = jpaService
-                            .execute(new 
CoordActionsSubsetGetForJobJPAExecutor(id, start, len));
+                            .execute(new 
CoordJobGetActionsSubsetJPAExecutor(id, start, len));
                     coordJob.setActions(coordActions);
                 }
             }

Modified: 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordJobGetActionsSubsetJPAExecutor.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordJobGetActionsSubsetJPAExecutor.java?rev=1240031&r1=1240030&r2=1240031&view=diff
==============================================================================
--- 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordJobGetActionsSubsetJPAExecutor.java
 (original)
+++ 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordJobGetActionsSubsetJPAExecutor.java
 Fri Feb  3 08:53:00 2012
@@ -6,9 +6,9 @@
  * 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.
@@ -58,7 +58,7 @@ public class CoordJobGetActionsSubsetJPA
         List<CoordinatorActionBean> actions;
         List<CoordinatorActionBean> actionList = new 
ArrayList<CoordinatorActionBean>();
         try {
-            Query q = em.createNamedQuery("GET_ACTIONS_FOR_COORD_JOB");
+            Query q = 
em.createNamedQuery("GET_ACTIONS_FOR_COORD_JOB_ORDER_BY_NOMINAL_TIME");
             q.setParameter("jobId", coordJobId);
             q.setFirstResult(start - 1);
             q.setMaxResults(len);

Modified: 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java?rev=1240031&r1=1240030&r2=1240031&view=diff
==============================================================================
--- 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
 (original)
+++ 
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
 Fri Feb  3 08:53:00 2012
@@ -53,6 +53,7 @@ import org.json.simple.JSONObject;
 public class V1JobServlet extends BaseJobServlet {
 
     private static final String INSTRUMENTATION_NAME = "v1job";
+    public static final String COORD_ACTIONS_DEFAULT_LENGTH = 
"oozie.coord.actions.default.length";
 
     public V1JobServlet() {
         super(INSTRUMENTATION_NAME);
@@ -716,9 +717,11 @@ public class V1JobServlet extends BaseJo
         String lenStr = request.getParameter(RestConstants.LEN_PARAM);
         int start = (startStr != null) ? Integer.parseInt(startStr) : 1;
         start = (start < 1) ? 1 : start;
+        // Get default number of coordinator actions to be retrieved
+        int defaultLen = 
Services.get().getConf().getInt(COORD_ACTIONS_DEFAULT_LENGTH, 1000);
         int len = (lenStr != null) ? Integer.parseInt(lenStr) : 0;
-        len = (len < 1) ? Integer.MAX_VALUE : len;
-        try {
+        len = (len < 1) ? defaultLen : len;
+    try {
             JsonCoordinatorJob coordJob = coordEngine.getCoordJob(jobId, 
start, len);
             jobBean = coordJob;
         }

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=1240031&r1=1240030&r2=1240031&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/resources/oozie-default.xml (original)
+++ incubator/oozie/trunk/core/src/main/resources/oozie-default.xml Fri Feb  3 
08:53:00 2012
@@ -1513,5 +1513,13 @@
             Referring to the same keytab file Oozie uses for its Kerberos 
credentials for Hadoop.
         </description>
     </property>
+       <!-- Coordinator Actions default length -->
+       <property>
+               <name>oozie.coord.actions.default.length</name>
+               <value>1000</value>
+               <description>
+                       Default number of coordinator actions to be retrieved 
by the info command
+               </description>
+       </property>
 
 </configuration>

Modified: 
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsSubsetJPAExecutor.java
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsSubsetJPAExecutor.java?rev=1240031&r1=1240030&r2=1240031&view=diff
==============================================================================
--- 
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsSubsetJPAExecutor.java
 (original)
+++ 
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsSubsetJPAExecutor.java
 Fri Feb  3 08:53:00 2012
@@ -6,9 +6,9 @@
  * 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.
@@ -64,4 +64,25 @@ public class TestCoordJobGetActionsSubse
         assertEquals(actions.get(0).getId(), actionId);
     }
 
+    // Check the ordering of actions by nominal time
+    public void testCoordActionOrderBy() throws Exception {
+        CoordinatorJobBean job = 
addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
+        // Add Coordinator action with nominal time: 2009-12-15T01:00Z
+        CoordinatorActionBean action = 
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.WAITING, 
"coord-action-get.xml", 0);
+        // Add Coordinator action with nominal time: 2009-02-01T23:59Z
+        CoordinatorActionBean action1 = 
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.WAITING, 
"coord-action-for-action-input-check.xml", 0);
+        // test for the expected action number
+        _testGetActionsSubsetOrderBy(job.getId(), 2, 1, 2);
+    }
+
+   private void _testGetActionsSubsetOrderBy(String jobId, int actionNum, int 
start, int len) throws Exception {
+        JPAService jpaService = Services.get().get(JPAService.class);
+        assertNotNull(jpaService);
+        CoordJobGetActionsSubsetJPAExecutor actionGetCmd = new 
CoordJobGetActionsSubsetJPAExecutor(jobId, start, len);
+        List<CoordinatorActionBean> actions = jpaService.execute(actionGetCmd);
+        assertEquals(actions.size(), 2);
+        // As actions are sorted by nominal time, the first action should be 
with action number 2
+        assertEquals(actions.get(0).getActionNumber(), actionNum);
+    }
+
 }

Modified: incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki?rev=1240031&r1=1240030&r2=1240031&view=diff
==============================================================================
--- incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki 
(original)
+++ incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki Fri Feb  
3 08:53:00 2012
@@ -360,8 +360,9 @@ hadoop1                 map-reduce  OK  
 </verbatim>
 
 The =info= option can display information about a workflow job or coordinator 
job or coordinator action.
+The =info= option for a Coordinator job will retrieve the Coordinator actions 
ordered by nominal time. However, the =info= command may timeout if the number 
of Coordinator actions are very high. In that case, =info= should be used with 
=offset= and =len= option.
 
-The =offset= and =len= option specified the offset and number of actions to 
display, if checking a workflow job or coordinator job.
+The =offset= and =len= option specifies the offset and number of actions to 
display, if checking a workflow job or coordinator job.
 
 The =localtime= option displays times in local time, if not specified times 
are displayed in GMT.
 

Modified: incubator/oozie/trunk/release-log.txt
URL: 
http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1240031&r1=1240030&r2=1240031&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Fri Feb  3 08:53:00 2012
@@ -1,6 +1,7 @@
 -- Oozie 3.2.0 release
 
-OOZIE-668 Adding license header into minitest/pom.xml.
+OOZIE-673: Offset and len option not working as expected.(Virag)
+OOZIE-668 Adding license header into minitest/pom.xml.(Mohammad)
 OOZIE-665 Shell action doesn't capture multiple key-value pairs.(Mohammad)
 OOZIE-666 Oozie's Tomcat admin port is hardcoded. (tucu)
 OOZIE-662 Unit test failing: TestHostnameFilter. (tucu)


Reply via email to