Search in sources :

Example 1 with CoordJobsCountNotForPurgeFromParentIdJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobsCountNotForPurgeFromParentIdJPAExecutor 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);
}
Also used : CoordJobsGetFromParentIdJPAExecutor(org.apache.oozie.executor.jpa.CoordJobsGetFromParentIdJPAExecutor) ArrayList(java.util.ArrayList) CoordJobsCountNotForPurgeFromParentIdJPAExecutor(org.apache.oozie.executor.jpa.CoordJobsCountNotForPurgeFromParentIdJPAExecutor)

Aggregations

ArrayList (java.util.ArrayList)1 CoordJobsCountNotForPurgeFromParentIdJPAExecutor (org.apache.oozie.executor.jpa.CoordJobsCountNotForPurgeFromParentIdJPAExecutor)1 CoordJobsGetFromParentIdJPAExecutor (org.apache.oozie.executor.jpa.CoordJobsGetFromParentIdJPAExecutor)1