Search in sources :

Example 1 with CoordActionsDeleteJPAExecutor

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

the class TestHAPartitionDependencyManagerService method testCheckAfterActionDelete.

public void testCheckAfterActionDelete() throws Exception {
    Services.get().setService(ZKJobsConcurrencyService.class);
    Services.get().get(ConfigurationService.class).getConf().setInt(PartitionDependencyManagerService.CACHE_PURGE_TTL, 0);
    db = "default";
    table1 = "mytbl";
    table2 = "mytb2";
    part1 = "dt=20120101;country=us";
    part2 = "dt=20120102;country=us";
    part3 = "dt=20120103;country=us";
    String newHCatDependency1 = "hcat://" + server + "/" + db + "/" + table1 + "/" + part1;
    String newHCatDependency2 = "hcat://" + server + "/" + db + "/" + table1 + "/" + part2;
    String newHCatDependency3 = "hcat://" + server + "/" + db + "/" + table2 + "/" + part3;
    HCatURI dep1 = new HCatURI(newHCatDependency1);
    HCatURI dep2 = new HCatURI(newHCatDependency2);
    HCatURI dep3 = new HCatURI(newHCatDependency3);
    // create db, table and partitions
    populateTable();
    String actionId1 = addInitRecords(newHCatDependency1);
    String actionId2 = addInitRecords(newHCatDependency2);
    String actionId3 = addInitRecords(newHCatDependency3);
    PartitionDependencyManagerService pdms = Services.get().get(PartitionDependencyManagerService.class);
    pdms.init(Services.get());
    pdms.addMissingDependency(dep1, actionId1);
    pdms.addMissingDependency(dep2, actionId2);
    pdms.addMissingDependency(dep3, actionId3);
    pdms.runCachePurgeWorker();
    assertNotNull((Collection<String>) pdms.getWaitingActions(dep1));
    assertNotNull((Collection<String>) pdms.getWaitingActions(dep2));
    assertNotNull((Collection<String>) pdms.getWaitingActions(dep3));
    List<String> deleteList = new ArrayList<String>();
    deleteList.add(actionId1);
    JPAService jpaService = Services.get().get(JPAService.class);
    jpaService.execute(new CoordActionsDeleteJPAExecutor(deleteList));
    pdms.runCachePurgeWorker();
    assertNull((Collection<String>) pdms.getWaitingActions(dep1));
    assertNotNull((Collection<String>) pdms.getWaitingActions(dep2));
    assertNotNull((Collection<String>) pdms.getWaitingActions(dep3));
    deleteList.clear();
    deleteList.add(actionId2);
    jpaService.execute(new CoordActionsDeleteJPAExecutor(deleteList));
    pdms.runCachePurgeWorker();
    assertNull((Collection<String>) pdms.getWaitingActions(dep1));
    assertNull((Collection<String>) pdms.getWaitingActions(dep2));
    assertNotNull((Collection<String>) pdms.getWaitingActions(dep3));
}
Also used : CoordActionsDeleteJPAExecutor(org.apache.oozie.executor.jpa.CoordActionsDeleteJPAExecutor) ArrayList(java.util.ArrayList) HCatURI(org.apache.oozie.util.HCatURI)

Example 2 with CoordActionsDeleteJPAExecutor

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

the class PurgeXCommand method purgeCoordActions.

/**
 * Purge coordActions of long running coordinators and purge them
 *
 * @param coordActions List of coordActions to purge
 * @throws JPAExecutorException If a JPA executor has a problem
 */
private void purgeCoordActions(List<String> coordActions) throws JPAExecutorException {
    coordActionDel = coordActions.size();
    for (int startIndex = 0; startIndex < coordActions.size(); ) {
        int endIndex = (startIndex + limit < coordActions.size()) ? (startIndex + limit) : coordActions.size();
        List<String> coordActionsForDelete = coordActions.subList(startIndex, endIndex);
        LOG.debug("Deleting coordinator actions: " + StringUtils.join(coordActionsForDelete, ","));
        jpaService.execute(new CoordActionsDeleteJPAExecutor(coordActionsForDelete));
        startIndex = endIndex;
    }
}
Also used : CoordActionsDeleteJPAExecutor(org.apache.oozie.executor.jpa.CoordActionsDeleteJPAExecutor)

Aggregations

CoordActionsDeleteJPAExecutor (org.apache.oozie.executor.jpa.CoordActionsDeleteJPAExecutor)2 ArrayList (java.util.ArrayList)1 HCatURI (org.apache.oozie.util.HCatURI)1