Repository: oozie Updated Branches: refs/heads/master 6143d949c -> 0050d03eb
OOZIE-1773 bulk API returns total = 0 when it's not (ryota) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/0050d03e Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/0050d03e Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/0050d03e Branch: refs/heads/master Commit: 0050d03ebb7c51b2792106bbc632ea48442bb3a6 Parents: 6143d94 Author: egashira <[email protected]> Authored: Fri Apr 11 10:47:59 2014 -0700 Committer: egashira <[email protected]> Committed: Fri Apr 11 10:47:59 2014 -0700 ---------------------------------------------------------------------- .../oozie/executor/jpa/BulkJPAExecutor.java | 9 ++++-- .../jpa/TestBulkMonitorJPAExecutor.java | 34 ++++++++++++++------ release-log.txt | 1 + 3 files changed, 32 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/0050d03e/core/src/main/java/org/apache/oozie/executor/jpa/BulkJPAExecutor.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/executor/jpa/BulkJPAExecutor.java b/core/src/main/java/org/apache/oozie/executor/jpa/BulkJPAExecutor.java index 60e5624..8327aee 100644 --- a/core/src/main/java/org/apache/oozie/executor/jpa/BulkJPAExecutor.java +++ b/core/src/main/java/org/apache/oozie/executor/jpa/BulkJPAExecutor.java @@ -85,7 +85,7 @@ public class BulkJPAExecutor implements JPAExecutor<BulkResponseInfo> { String conditions = actionQuery(em, bundleBeans, actionTimes, responseList); // Query to get the count of records - long total = countQuery(conditions, em, bundleBeans); + long total = countQuery(conditions, em, bundleBeans, actionTimes); BulkResponseInfo bulk = new BulkResponseInfo(responseList, start, len, total); return bulk; @@ -217,7 +217,7 @@ public class BulkJPAExecutor implements JPAExecutor<BulkResponseInfo> { * @param bundles * @return total count of coord actions */ - private long countQuery(String clause, EntityManager em, List<BundleJobBean> bundles) { + private long countQuery(String clause, EntityManager em, List<BundleJobBean> bundles, Map<String, Timestamp> times) { Query q = em.createNamedQuery("BULK_MONITOR_COUNT_QUERY"); StringBuilder getTotal = new StringBuilder(q.toString() + " "); // Query: select COUNT(a) from CoordinatorActionBean a, CoordinatorJobBean c @@ -233,6 +233,11 @@ public class BulkJPAExecutor implements JPAExecutor<BulkResponseInfo> { // AND c.bundleId IN (... list of bundle ids) i.e. replace single :bundleId with list getTotal = getTotal.replace(offset - 6, offset + 20, inClause(bundleIds, "bundleId", 'c').toString()); q = em.createQuery(getTotal.toString()); + Iterator<Entry<String, Timestamp>> iter = times.entrySet().iterator(); + while (iter.hasNext()) { + Entry<String, Timestamp> time = iter.next(); + q.setParameter(time.getKey(), time.getValue()); + } long total = ((Long) q.getSingleResult()).longValue(); return total; } http://git-wip-us.apache.org/repos/asf/oozie/blob/0050d03e/core/src/test/java/org/apache/oozie/executor/jpa/TestBulkMonitorJPAExecutor.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/executor/jpa/TestBulkMonitorJPAExecutor.java b/core/src/test/java/org/apache/oozie/executor/jpa/TestBulkMonitorJPAExecutor.java index 4536398..b20a8e5 100644 --- a/core/src/test/java/org/apache/oozie/executor/jpa/TestBulkMonitorJPAExecutor.java +++ b/core/src/test/java/org/apache/oozie/executor/jpa/TestBulkMonitorJPAExecutor.java @@ -56,11 +56,14 @@ public class TestBulkMonitorJPAExecutor extends XDataTestCase { public void testSingleRecord() throws Exception { String request = "bundle=" + bundleName + ";actionstatus=FAILED;" - + "startcreatedtime=2012-07-21T00:00Z;endcreatedtime=2012-07-22T02:00Z"; + + "startcreatedtime=2012-07-21T00:00Z;endcreatedtime=2012-07-22T02:00Z;" + + "startscheduledtime=2012-07-20T23:00Z;endscheduledtime=2012-07-22T03:00Z"; - List<BulkResponseImpl> brList = _execQuery(request); + BulkResponseInfo response = _execQuery(request); + List<BulkResponseImpl> brList = response.getResponses(); assertEquals(1, brList.size()); // only 1 action satisfies the // conditions + assertEquals(1, response.getTotal()); BulkResponseImpl br = brList.get(0); assertEquals(bundleName, br.getBundle().getAppName()); assertEquals("Coord1", br.getCoordinator().getAppName()); @@ -71,10 +74,13 @@ public class TestBulkMonitorJPAExecutor extends XDataTestCase { public void testMultipleRecords() throws Exception { String request = "bundle=" + bundleName + ";actionstatus=FAILED,KILLED;" - + "startcreatedtime=2012-07-21T00:00Z;endcreatedtime=2012-07-22T02:00Z"; + + "startcreatedtime=2012-07-21T00:00Z;endcreatedtime=2012-07-22T02:00Z;" + + "startscheduledtime=2012-07-20T23:00Z;endscheduledtime=2012-07-22T03:00Z"; - List<BulkResponseImpl> brList = _execQuery(request); + BulkResponseInfo response = _execQuery(request); + List<BulkResponseImpl> brList = response.getResponses(); assertEquals(3, brList.size()); // 3 actions satisfy the conditions + assertEquals(3, response.getTotal()); List<String> possibleStatus = new ArrayList<String>(Arrays.asList("KILLED", "FAILED")); List<String> resultStatus = new ArrayList<String>(); resultStatus.add(brList.get(0).getAction().getStatus().toString()); @@ -100,8 +106,10 @@ public class TestBulkMonitorJPAExecutor extends XDataTestCase { public void testMultipleCoordinators() throws Exception { // there are 3 coordinators but giving range as only two of them String request = "bundle=" + bundleName + ";coordinators=Coord1,Coord2;actionstatus=KILLED"; - List<BulkResponseImpl> brList = _execQuery(request); + BulkResponseInfo response = _execQuery(request); + List<BulkResponseImpl> brList = response.getResponses(); assertEquals(2, brList.size()); // 2 actions satisfy the conditions + assertEquals(2, response.getTotal()); assertEquals(brList.get(0).getAction().getId(), "Coord1@2"); assertEquals(brList.get(1).getAction().getId(), "Coord2@1"); } @@ -111,8 +119,10 @@ public class TestBulkMonitorJPAExecutor extends XDataTestCase { addRecordToCoordActionTable("Coord3", 1, CoordinatorAction.Status.FAILED, "coord-action-get.xml", 0); String request = "bundle=" + bundleName + ";"; - List<BulkResponseImpl> brList = _execQuery(request); + BulkResponseInfo response = _execQuery(request); + List<BulkResponseImpl> brList = response.getResponses(); assertEquals(4, brList.size()); // 4 actions satisfy the conditions + assertEquals(4, response.getTotal()); List<String> possibleStatus = new ArrayList<String>(Arrays.asList("FAILED", "KILLED")); List<String> resultStatus = new ArrayList<String>(); resultStatus.add(brList.get(0).getAction().getStatus().toString()); @@ -144,9 +154,11 @@ public class TestBulkMonitorJPAExecutor extends XDataTestCase { String request = "bundle=" + bundleId + ";actionstatus=FAILED;" + "startcreatedtime=2012-07-21T00:00Z;endcreatedtime=2012-07-22T02:00Z"; - List<BulkResponseImpl> brList = _execQuery(request); + BulkResponseInfo response = _execQuery(request); + List<BulkResponseImpl> brList = response.getResponses(); assertEquals(1, brList.size()); // only 1 action satisfies the // conditions + assertEquals(1, response.getTotal()); BulkResponseImpl br = brList.get(0); assertEquals(bundleId, br.getBundle().getId()); assertEquals("Coord1", br.getCoordinator().getAppName()); @@ -162,17 +174,19 @@ public class TestBulkMonitorJPAExecutor extends XDataTestCase { // there are 3 coordinators but giving range as only two of them String coordIdsStr = coordIds.get(0) + "," + coordIds.get(1); String request = "bundle=" + bundleId + ";coordinators=" + coordIdsStr + ";actionstatus=KILLED"; - List<BulkResponseImpl> brList = _execQuery(request); + BulkResponseInfo response = _execQuery(request); + List<BulkResponseImpl> brList = response.getResponses(); assertEquals(2, brList.size()); // 2 actions satisfy the conditions + assertEquals(2, response.getTotal()); assertEquals(brList.get(0).getAction().getId(), "Coord1@2"); assertEquals(brList.get(1).getAction().getId(), "Coord2@1"); } - private List<BulkResponseImpl> _execQuery(String request) throws JPAExecutorException, BundleEngineException { + private BulkResponseInfo _execQuery(String request) throws JPAExecutorException, BundleEngineException { BulkJPAExecutor bulkjpa = new BulkJPAExecutor(BundleEngine.parseBulkFilter(request), 1, 10); BulkResponseInfo response = jpaService.execute(bulkjpa); assertNotNull(response); - return response.getResponses(); + return response; } } http://git-wip-us.apache.org/repos/asf/oozie/blob/0050d03e/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index a0e5723..8cff400 100644 --- a/release-log.txt +++ b/release-log.txt @@ -1,5 +1,6 @@ -- Oozie 4.1.0 release (trunk - unreleased) +OOZIE-1773 bulk API returns total = 0 when it's not (ryota) OOZIE-1774 Expected/Actual Duration on UI SLA Tab doesn't show correct information (ryota) OOZIE-1754 add order(sort) option and exclude filter for coord job Info (ryota) OOZIE-1761 Improve sharelib purging logic (puru via rohini)
