Search in sources :

Example 6 with CallableQueueService

use of org.apache.oozie.service.CallableQueueService in project oozie by apache.

the class TestCoordActionInputCheckXCommand method testCoordActionInputCheckXCommandUniqueness.

public void testCoordActionInputCheckXCommandUniqueness() throws Exception {
    Date startTime = DateUtils.parseDateOozieTZ("2009-02-01T23:59" + TZ);
    Date endTime = DateUtils.parseDateOozieTZ("2009-02-02T23:59" + TZ);
    CoordinatorJobBean job = addRecordToCoordJobTableForWaiting("coord-job-for-action-input-check.xml", CoordinatorJob.Status.RUNNING, startTime, endTime, false, true, 3);
    CoordinatorActionBean action1 = addRecordToCoordActionTableForWaiting(job.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-for-action-input-check.xml");
    createTestCaseSubDir("2009/01/29/_SUCCESS".split("/"));
    createTestCaseSubDir("2009/01/22/_SUCCESS".split("/"));
    createTestCaseSubDir("2009/01/15/_SUCCESS".split("/"));
    createTestCaseSubDir("2009/01/08/_SUCCESS".split("/"));
    final MyCoordActionInputCheckXCommand callable1 = new MyCoordActionInputCheckXCommand(action1.getId(), 100, "1");
    final MyCoordActionInputCheckXCommand callable2 = new MyCoordActionInputCheckXCommand(action1.getId(), 100, "2");
    final MyCoordActionInputCheckXCommand callable3 = new MyCoordActionInputCheckXCommand(action1.getId(), 100, "3");
    List<MyCoordActionInputCheckXCommand> callables = Arrays.asList(callable1, callable2, callable3);
    CallableQueueService queueservice = services.get(CallableQueueService.class);
    for (MyCoordActionInputCheckXCommand c : callables) {
        queueservice.queue(c);
    }
    waitFor(200, new Predicate() {

        public boolean evaluate() throws Exception {
            return callable1.executed != 0 && callable2.executed == 0 && callable3.executed == 0;
        }
    });
    assertTrue(callable1.executed != 0);
    assertTrue(callable2.executed == 0);
    assertTrue(callable3.executed == 0);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CallableQueueService(org.apache.oozie.service.CallableQueueService) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException)

Aggregations

CallableQueueService (org.apache.oozie.service.CallableQueueService)6 Date (java.util.Date)3 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)3 CommandException (org.apache.oozie.command.CommandException)3 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)3 IOException (java.io.IOException)2 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)2 XException (org.apache.oozie.XException)2 PreconditionException (org.apache.oozie.command.PreconditionException)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Configuration (org.apache.hadoop.conf.Configuration)1 ElException (org.apache.oozie.coord.ElException)1 CoordInputDependency (org.apache.oozie.coord.input.dependency.CoordInputDependency)1 ActionDependency (org.apache.oozie.dependency.ActionDependency)1 Instrumentation (org.apache.oozie.util.Instrumentation)1 XCallable (org.apache.oozie.util.XCallable)1