Search in sources :

Example 31 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class TestBulkWorkflowXCommand method testBulkResumeNoOp.

public void testBulkResumeNoOp() throws Exception {
    WorkflowJobBean job1 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action1 = this.addRecordToWfActionTable(job1.getId(), "1", WorkflowAction.Status.RUNNING);
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    List<String> names = new ArrayList<String>();
    names.add("testApp");
    map.put("name", names);
    new BulkWorkflowXCommand(map, 1, 50, OperationType.Resume).call();
    verifyJobStatus(job1.getId(), WorkflowJob.Status.RUNNING);
    verifyActionStatus(action1.getId(), WorkflowAction.Status.RUNNING);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 32 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class TestBulkWorkflowXCommand method testbulkWfKillSuccess.

public void testbulkWfKillSuccess() throws Exception {
    WorkflowJobBean job1 = this.addRecordToWfJobTable(WorkflowJob.Status.SUSPENDED, WorkflowInstance.Status.SUSPENDED);
    WorkflowActionBean action1 = this.addRecordToWfActionTable(job1.getId(), "1", WorkflowAction.Status.RUNNING);
    WorkflowJobBean job2 = this.addRecordToWfJobTable(WorkflowJob.Status.SUSPENDED, WorkflowInstance.Status.SUSPENDED);
    WorkflowActionBean action2 = this.addRecordToWfActionTable(job2.getId(), "1", WorkflowAction.Status.RUNNING);
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    List<String> names = new ArrayList<String>();
    names.add("testApp");
    map.put("name", names);
    new BulkWorkflowXCommand(map, 1, 50, OperationType.Kill).call();
    verifyJobStatus(job1.getId(), WorkflowJob.Status.KILLED);
    verifyJobStatus(job2.getId(), WorkflowJob.Status.KILLED);
    verifyActionStatus(action1.getId(), WorkflowAction.Status.KILLED);
    verifyActionStatus(action2.getId(), WorkflowAction.Status.KILLED);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 33 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class TestBulkWorkflowXCommand method testBulkSuspendNegative.

public void testBulkSuspendNegative() throws Exception {
    WorkflowJobBean job1 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action1 = this.addRecordToWfActionTable(job1.getId(), "1", WorkflowAction.Status.RUNNING);
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    List<String> names = new ArrayList<String>();
    names.add("testApp-new");
    map.put("name", names);
    new BulkWorkflowXCommand(map, 1, 50, OperationType.Suspend).call();
    verifyJobStatus(job1.getId(), WorkflowJob.Status.RUNNING);
    verifyActionStatus(action1.getId(), WorkflowAction.Status.RUNNING);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 34 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class TestBulkWorkflowXCommand method testbulkWfKillNoOp.

public void testbulkWfKillNoOp() throws Exception {
    WorkflowJobBean job1 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action1 = this.addRecordToWfActionTable(job1.getId(), "1", WorkflowAction.Status.RUNNING);
    WorkflowJobBean job2 = this.addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowActionBean action2 = this.addRecordToWfActionTable(job2.getId(), "1", WorkflowAction.Status.DONE);
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    List<String> names = new ArrayList<String>();
    names.add("testApp");
    map.put("name", names);
    new BulkWorkflowXCommand(map, 1, 50, OperationType.Kill).call();
    verifyJobStatus(job1.getId(), WorkflowJob.Status.KILLED);
    verifyJobStatus(job2.getId(), WorkflowJob.Status.SUCCEEDED);
    verifyActionStatus(action1.getId(), WorkflowAction.Status.KILLED);
    verifyActionStatus(action2.getId(), WorkflowAction.Status.DONE);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 35 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class TestCoordWfActionInfoXCommand method createTestData.

/**
 * init the test case.
 * 1 coordJob
 * 5 coordAction created by the coordJob, while the 5th coordAction's workflow instance is null
 * 4 wfJob match the 1st ~ 4th coordAction
 * the 1st - 3rd wfAction has a wfAction named 'aa' each, but the 4th desn't.
 */
private void createTestData() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull("Missing jpa service", jpaService);
    coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    wfJobs = new ArrayList<WorkflowJobBean>();
    coordActions = new ArrayList<CoordinatorActionBean>();
    for (int i = 0; i < 4; i++) {
        WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
        wfJobs.add(wfJob);
    }
    for (int i = 0; i < 4; i++) {
        CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), (i + 1), CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJobs.get(i).getId(), "SUCCEEDED", 0);
        coordActions.add(coordAction);
    }
    // add a coordAction that doesnt create workflow instance yet
    CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 5, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", null, null, 0);
    coordActions.add(coordAction);
    // set the NominalTime,in order to keep the order of the coordAction.
    for (int i = 0; i < 5; i++) {
        setCoordActionNominalTime(coordActions.get(i).getId(), (i + 1) * 1000);
    }
    // create the case that the 4th wfJob doesnt have a action named "aa"
    for (int i = 0; i < 4; i++) {
        String name = (i == 3) ? "bb" : "aa";
        addRecordToWfActionTable(wfJobs.get(i).getId(), name, WorkflowAction.Status.DONE);
    }
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Aggregations

WorkflowJobBean (org.apache.oozie.WorkflowJobBean)304 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)164 JPAService (org.apache.oozie.service.JPAService)95 XConfiguration (org.apache.oozie.util.XConfiguration)94 Configuration (org.apache.hadoop.conf.Configuration)66 Date (java.util.Date)60 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)58 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)57 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)53 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)53 Path (org.apache.hadoop.fs.Path)50 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)47 ArrayList (java.util.ArrayList)46 Test (org.junit.Test)32 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)30 Element (org.jdom.Element)28 WorkflowInstance (org.apache.oozie.workflow.WorkflowInstance)26 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)25 HashMap (java.util.HashMap)23 BundleJobBean (org.apache.oozie.BundleJobBean)21