Search in sources :

Example 61 with BundleActionBean

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

the class TestBundleSubmitXCommand method testCoordJobNameParameterization.

public void testCoordJobNameParameterization() throws Exception {
    final XConfiguration jobConf = setUpBundle();
    jobConf.set("coordName1", "coord1");
    jobConf.set("coordName2", "coord2");
    jobConf.set("coord1.starttime", "2009-02-01T00:00Z");
    BundleSubmitXCommand command = new BundleSubmitXCommand(jobConf);
    final BundleJobBean bundleBean = (BundleJobBean) command.getJob();
    bundleBean.setStartTime(new Date());
    bundleBean.setEndTime(new Date());
    final String jobId = command.call();
    sleep(2000);
    new BundleStartXCommand(jobId).call();
    waitFor(200000, new Predicate() {

        public boolean evaluate() throws Exception {
            List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, jobId);
            return actions.get(0).getStatus().equals(Job.Status.RUNNING);
        }
    });
    final List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, jobId);
    assertEquals(actions.get(0).getCoordName(), "coord1");
    assertEquals(actions.get(1).getCoordName(), "coord2");
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) BundleJobBean(org.apache.oozie.BundleJobBean) List(java.util.List) BundleActionBean(org.apache.oozie.BundleActionBean) Date(java.util.Date) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 62 with BundleActionBean

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

the class TestBundleJobQueryExecutor method testBundleIDsForStatusTransit.

public void testBundleIDsForStatusTransit() throws Exception {
    BundleJobBean job1 = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    BundleJobBean job2 = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    BundleJobBean job3 = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    BundleActionBean bean1 = this.addRecordToBundleActionTable(job1.getId(), "coord1", 0, Job.Status.PREP);
    BundleActionBean bean2 = this.addRecordToBundleActionTable(job2.getId(), "coord2", 1, Job.Status.RUNNING);
    BundleActionBean bean3 = this.addRecordToBundleActionTable(job3.getId(), "coord3", 1, Job.Status.RUNNING);
    // GET_BUNDLE_ACTIONS_BY_LAST_MODIFIED_TIME
    Date timeBefore = new Date(bean1.getLastModifiedTime().getTime() - 1000 * 60);
    List<BundleJobBean> jobBean = BundleJobQueryExecutor.getInstance().getList(BundleJobQuery.GET_BUNDLE_IDS_FOR_STATUS_TRANSIT, timeBefore);
    assertEquals(3, jobBean.size());
    Date timeAfter = new Date(bean3.getLastModifiedTime().getTime() + 100 * 60);
    jobBean = BundleJobQueryExecutor.getInstance().getList(BundleJobQuery.GET_BUNDLE_IDS_FOR_STATUS_TRANSIT, timeAfter);
    assertEquals(0, jobBean.size());
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionBean(org.apache.oozie.BundleActionBean) Date(java.util.Date)

Example 63 with BundleActionBean

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

the class TestBundleJobsDeleteJPAExecutor method testDeleteBundles.

public void testDeleteBundles() throws Exception {
    BundleJobBean jobA = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    BundleActionBean actionA1 = addRecordToBundleActionTable(jobA.getId(), "actionA1", 0, Job.Status.SUCCEEDED);
    BundleActionBean actionA2 = addRecordToBundleActionTable(jobA.getId(), "actionA2", 0, Job.Status.SUCCEEDED);
    BundleJobBean jobB = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    BundleActionBean actionB1 = addRecordToBundleActionTable(jobB.getId(), "actionB1", 0, Job.Status.SUCCEEDED);
    BundleActionBean actionB2 = addRecordToBundleActionTable(jobB.getId(), "actionB2", 0, Job.Status.SUCCEEDED);
    BundleJobBean jobC = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    BundleActionBean actionC1 = addRecordToBundleActionTable(jobC.getId(), "actionC1", 0, Job.Status.SUCCEEDED);
    BundleActionBean actionC2 = addRecordToBundleActionTable(jobC.getId(), "actionC2", 0, Job.Status.SUCCEEDED);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    List<String> deleteList = new ArrayList<String>();
    deleteList.add(jobA.getId());
    deleteList.add(jobB.getId());
    deleteList.add(jobC.getId());
    jpaService.execute(new BundleJobsDeleteJPAExecutor(deleteList));
    try {
        jpaService.execute(new BundleJobGetJPAExecutor(jobA.getId()));
        fail("Bundle Job A should have been deleted");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionA1.getBundleId(), actionA1.getCoordName()));
        fail("Bundle Action A1 should have been deleted");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionA2.getBundleId(), actionA2.getCoordName()));
        fail("Bundle Action A2 should have been deleted");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(new BundleJobGetJPAExecutor(jobB.getId()));
        fail("Bundle Job B should have been deleted");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionB1.getBundleId(), actionB1.getCoordName()));
        fail("Bundle Action B1 should have been deleted");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionB2.getBundleId(), actionB2.getCoordName()));
        fail("Bundle Action B2 should have been deleted");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(new BundleJobGetJPAExecutor(jobC.getId()));
        fail("Bundle Job C should have been deleted");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionC1.getBundleId(), actionC1.getCoordName()));
        fail("Bundle Action C1 should have been deleted");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionC2.getBundleId(), actionC2.getCoordName()));
        fail("Bundle Action C2 should have been deleted");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) ArrayList(java.util.ArrayList) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 64 with BundleActionBean

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

the class TestBundleJobsDeleteJPAExecutor method testDeleteBundlesRollback.

public void testDeleteBundlesRollback() throws Exception {
    BundleJobBean jobA = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    BundleActionBean actionA1 = addRecordToBundleActionTable(jobA.getId(), "actionA1", 0, Job.Status.SUCCEEDED);
    BundleActionBean actionA2 = addRecordToBundleActionTable(jobA.getId(), "actionA2", 0, Job.Status.SUCCEEDED);
    BundleJobBean jobB = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    BundleActionBean actionB1 = addRecordToBundleActionTable(jobB.getId(), "actionB1", 0, Job.Status.SUCCEEDED);
    BundleActionBean actionB2 = addRecordToBundleActionTable(jobB.getId(), "actionB2", 0, Job.Status.SUCCEEDED);
    BundleJobBean jobC = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    BundleActionBean actionC1 = addRecordToBundleActionTable(jobC.getId(), "actionC1", 0, Job.Status.SUCCEEDED);
    BundleActionBean actionC2 = addRecordToBundleActionTable(jobC.getId(), "actionC2", 0, Job.Status.SUCCEEDED);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    try {
        // set fault injection to true, so transaction is roll backed
        setSystemProperty(FaultInjection.FAULT_INJECTION, "true");
        setSystemProperty(SkipCommitFaultInjection.ACTION_FAILOVER_FAULT_INJECTION, "true");
        List<String> deleteList = new ArrayList<String>();
        deleteList.add(jobA.getId());
        deleteList.add(jobB.getId());
        deleteList.add(jobC.getId());
        try {
            jpaService.execute(new BundleJobsDeleteJPAExecutor(deleteList));
            fail("Should have skipped commit for failover testing");
        } catch (JPAExecutorException jee) {
            assertTrue(jee.getMessage().contains("Skipping Commit for Failover Testing"));
        }
    } finally {
        // Remove fault injection
        FaultInjection.deactivate("org.apache.oozie.command.SkipCommitFaultInjection");
    }
    try {
        jpaService.execute(new BundleJobGetJPAExecutor(jobA.getId()));
    } catch (JPAExecutorException je) {
        fail("Bundle Job A should not have been deleted");
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionA1.getBundleId(), actionA1.getCoordName()));
    } catch (JPAExecutorException je) {
        fail("Bundle Action A1 should not have been deleted");
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionA2.getBundleId(), actionA2.getCoordName()));
    } catch (JPAExecutorException je) {
        fail("Bundle Action A2 should not have been deleted");
    }
    try {
        jpaService.execute(new BundleJobGetJPAExecutor(jobB.getId()));
    } catch (JPAExecutorException je) {
        fail("Bundle Job B should not have been deleted");
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionB1.getBundleId(), actionB1.getCoordName()));
    } catch (JPAExecutorException je) {
        fail("Bundle Action B1 should not have been deleted");
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionB2.getBundleId(), actionB2.getCoordName()));
    } catch (JPAExecutorException je) {
        fail("Bundle Action B2 should not have been deleted");
    }
    try {
        jpaService.execute(new BundleJobGetJPAExecutor(jobC.getId()));
    } catch (JPAExecutorException je) {
        fail("Bundle Job C should not have been deleted");
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionC1.getBundleId(), actionC1.getCoordName()));
    } catch (JPAExecutorException je) {
        fail("Bundle Action C1 should not have been deleted");
    }
    try {
        jpaService.execute(new BundleActionGetJPAExecutor(actionC2.getBundleId(), actionC2.getCoordName()));
    } catch (JPAExecutorException je) {
        fail("Bundle Action C2 should not have been deleted");
    }
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) ArrayList(java.util.ArrayList) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 65 with BundleActionBean

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

the class TestPurgeService method testPurgeServiceForBundle.

/**
 * Tests the {@link org.apache.oozie.service.PurgeService}.
 * </p>
 * Creates a new Bundle job. Attempts to purge jobs older than a day.
 * Verifies the presence of the job in the system.
 * </p>
 * Sets the end date for the same job to make it qualify for the purge criteria.
 * Calls the purge service, and ensure the job does not exist in the system.
 */
public void testPurgeServiceForBundle() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateOozieTZ("2011-01-01T01:00Z"));
    final String jobId = job.getId();
    this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.SUCCEEDED);
    this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.SUCCEEDED);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(Job.Status.SUCCEEDED, job.getStatus());
    BundleActionGetJPAExecutor bundleActionGetExecutor1 = new BundleActionGetJPAExecutor(job.getId(), "action1");
    BundleActionBean action1 = jpaService.execute(bundleActionGetExecutor1);
    assertEquals(Job.Status.SUCCEEDED, action1.getStatus());
    BundleActionGetJPAExecutor bundleActionGetExecutor2 = new BundleActionGetJPAExecutor(job.getId(), "action2");
    BundleActionBean action2 = jpaService.execute(bundleActionGetExecutor2);
    assertEquals(Job.Status.SUCCEEDED, action2.getStatus());
    Runnable purgeRunnable = new PurgeRunnable(1, 1, 1, 100);
    purgeRunnable.run();
    final BundleEngine engine = new BundleEngine("u");
    waitFor(10000, new Predicate() {

        public boolean evaluate() throws Exception {
            try {
                engine.getBundleJob(jobId).getStatus();
            } catch (Exception ex) {
                return true;
            }
            return false;
        }
    });
    try {
        job = jpaService.execute(bundleJobGetExecutor);
        fail("Job should be purged. Should fail.");
    } catch (JPAExecutorException je) {
    // Job doesn't exist. Exception is expected.
    }
    try {
        jpaService.execute(bundleActionGetExecutor1);
        fail("Action should be purged. Should fail.");
    } catch (JPAExecutorException je) {
    // Job doesn't exist. Exception is expected.
    }
    try {
        jpaService.execute(bundleActionGetExecutor2);
        fail("Action should be purged. Should fail.");
    } catch (JPAExecutorException je) {
    // Job doesn't exist. Exception is expected.
    }
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionGetJPAExecutor(org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor) PurgeRunnable(org.apache.oozie.service.PurgeService.PurgeRunnable) PurgeRunnable(org.apache.oozie.service.PurgeService.PurgeRunnable) BundleEngine(org.apache.oozie.BundleEngine) BundleActionBean(org.apache.oozie.BundleActionBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) DagEngineException(org.apache.oozie.DagEngineException)

Aggregations

BundleActionBean (org.apache.oozie.BundleActionBean)76 BundleJobBean (org.apache.oozie.BundleJobBean)58 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)36 JPAService (org.apache.oozie.service.JPAService)35 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)33 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)30 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)24 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)20 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)20 Date (java.util.Date)19 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)19 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)16 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)13 IOException (java.io.IOException)10 CommandException (org.apache.oozie.command.CommandException)10 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)10 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)9 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)9 XConfiguration (org.apache.oozie.util.XConfiguration)8 ArrayList (java.util.ArrayList)6