Search in sources :

Example 1 with CoordJobsGetForPurgeJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobsGetForPurgeJPAExecutor in project oozie by apache.

the class PurgeXCommand method loadState.

/* (non-Javadoc)
     * @see org.apache.oozie.command.XCommand#loadState()
     */
@Override
protected void loadState() throws CommandException {
    try {
        jpaService = Services.get().get(JPAService.class);
        if (jpaService != null) {
            // Get the lists of workflows, coordinators, and bundles that can be purged (and have no parents)
            int size;
            do {
                size = wfList.size();
                wfList.addAll(jpaService.execute(new WorkflowJobsGetForPurgeJPAExecutor(wfOlderThan, wfList.size(), limit)));
            } while (size != wfList.size());
            if (purgeOldCoordAction) {
                LOG.debug("Purging workflows of long running coordinators is turned on");
                do {
                    size = coordActionList.size();
                    long olderThan = wfOlderThan;
                    List<WorkflowJobBean> jobBeans = WorkflowJobQueryExecutor.getInstance().getList(WorkflowJobQuery.GET_COMPLETED_COORD_WORKFLOWS_OLDER_THAN, olderThan, coordActionList.size(), limit);
                    for (WorkflowJobBean bean : jobBeans) {
                        coordActionList.add(bean.getParentId());
                        wfList.add(bean.getId());
                    }
                } while (size != coordActionList.size());
            }
            do {
                size = coordList.size();
                coordList.addAll(jpaService.execute(new CoordJobsGetForPurgeJPAExecutor(coordOlderThan, coordList.size(), limit)));
            } while (size != coordList.size());
            do {
                size = bundleList.size();
                bundleList.addAll(jpaService.execute(new BundleJobsGetForPurgeJPAExecutor(bundleOlderThan, bundleList.size(), limit)));
            } while (size != bundleList.size());
        } else {
            throw new CommandException(ErrorCode.E0610);
        }
    } catch (XException ex) {
        throw new CommandException(ex);
    }
}
Also used : CoordJobsGetForPurgeJPAExecutor(org.apache.oozie.executor.jpa.CoordJobsGetForPurgeJPAExecutor) BundleJobsGetForPurgeJPAExecutor(org.apache.oozie.executor.jpa.BundleJobsGetForPurgeJPAExecutor) XException(org.apache.oozie.XException) WorkflowJobsGetForPurgeJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobsGetForPurgeJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Aggregations

WorkflowJobBean (org.apache.oozie.WorkflowJobBean)1 XException (org.apache.oozie.XException)1 BundleJobsGetForPurgeJPAExecutor (org.apache.oozie.executor.jpa.BundleJobsGetForPurgeJPAExecutor)1 CoordJobsGetForPurgeJPAExecutor (org.apache.oozie.executor.jpa.CoordJobsGetForPurgeJPAExecutor)1 WorkflowJobsGetForPurgeJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobsGetForPurgeJPAExecutor)1 JPAService (org.apache.oozie.service.JPAService)1