use of org.apache.oozie.executor.jpa.CoordJobsGetFromParentIdJPAExecutor in project oozie by apache.
the class TestBulkMonitorWebServiceAPI method testBundleIdWithCoordId.
public void testBundleIdWithCoordId() throws Exception {
// fetching coord Ids
JPAService jpaService = Services.get().get(JPAService.class);
List<String> coordIds = jpaService.execute(new CoordJobsGetFromParentIdJPAExecutor(bundleId, 10));
// there are 3 coordinators but giving range as only two of them
final String coordIdsStr = coordIds.get(0) + "," + coordIds.get(1);
runTest("/v1/jobs", V1JobsServlet.class, false, new Callable<Void>() {
public Void call() throws Exception {
// giving range as 2 of the total 3 coordinators
String bulkRequest = "bundle=" + bundleId + ";coordinators=" + coordIdsStr + ";actionstatus=KILLED";
JSONArray array = _requestToServer(bulkRequest);
assertEquals(2, array.size());
JSONObject jbundle = (JSONObject) ((JSONObject) array.get(0)).get(JsonTags.BULK_RESPONSE_BUNDLE);
JSONObject jaction1 = (JSONObject) ((JSONObject) array.get(0)).get(JsonTags.BULK_RESPONSE_ACTION);
JSONObject jaction2 = (JSONObject) ((JSONObject) array.get(1)).get(JsonTags.BULK_RESPONSE_ACTION);
assertEquals(jaction1.get(JsonTags.COORDINATOR_ACTION_ID), "Coord1@2");
assertEquals(jaction2.get(JsonTags.COORDINATOR_ACTION_ID), "Coord2@1");
return null;
}
});
}
use of org.apache.oozie.executor.jpa.CoordJobsGetFromParentIdJPAExecutor in project oozie by apache.
the class PurgeXCommand method processBundles.
/**
* Process bundles to purge them and their children
*
* @param bundles List of bundles to process
* @throws JPAExecutorException If a JPA executor has a problem
*/
private void processBundles(List<String> bundles) throws JPAExecutorException {
List<String> coordsToPurge = new ArrayList<String>();
List<String> bundlesToPurge = new ArrayList<String>();
for (Iterator<String> it = bundles.iterator(); it.hasNext(); ) {
String bundleId = it.next();
// We only purge the bundle and its children if they are all ready to be purged
long numChildrenNotReady = jpaService.execute(new CoordJobsCountNotForPurgeFromParentIdJPAExecutor(coordOlderThan, bundleId));
if (numChildrenNotReady == 0) {
bundlesToPurge.add(bundleId);
LOG.debug("Purging bundle " + bundleId);
// Get all of the direct children for this bundle
List<String> children = new ArrayList<String>();
int size;
do {
size = children.size();
children.addAll(jpaService.execute(new CoordJobsGetFromParentIdJPAExecutor(bundleId, children.size(), limit)));
} while (size != children.size());
coordsToPurge.addAll(children);
}
}
// Process the children
processCoordinators(coordsToPurge);
// Now that all children have been purged, we can purge the bundles
purgeBundles(bundlesToPurge);
}
Aggregations