Search in sources :

Example 26 with JPAExecutorException

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

the class TestCoordChangeXCommand method checkCoordJobs.

private void checkCoordJobs(String jobId, Date endTime, Integer concurrency, Date pauseTime, boolean checkPauseTime) throws StoreException {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(jobId);
        CoordinatorJobBean job = null;
        job = jpaService.execute(coordGetCmd);
        if (endTime != null) {
            Date d = job.getEndTime();
            if (d.compareTo(endTime) != 0) {
                fail("Endtime is not updated properly job_end_time=" + d + ", expected_end_time=" + endTime);
            }
            CoordinatorJob.Status status = job.getStatus();
            if (status != CoordinatorJob.Status.RUNNING) {
                fail("Coordinator job's status is not updated properly");
            }
        }
        if (concurrency != null) {
            int c = job.getConcurrency();
            if (c != concurrency) {
                fail("Concurrency is not updated properly");
            }
        }
        if (checkPauseTime) {
            Date d = job.getPauseTime();
            if (pauseTime == null) {
                if (d != null) {
                    fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time=" + pauseTime);
                }
            } else {
                if (d.compareTo(pauseTime) != 0) {
                    fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time=" + pauseTime);
                }
            }
        }
    } catch (JPAExecutorException e) {
        e.printStackTrace();
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorJob(org.apache.oozie.client.CoordinatorJob) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Example 27 with JPAExecutorException

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

the class TestCoordChangeXCommand method addRecordToCoordJobTableForPauseTimeTest.

protected CoordinatorJobBean addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status status, Date start, Date end, Date lastActionTime, boolean pending, boolean doneMatd, int lastActionNum) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, start, end, pending, doneMatd, lastActionNum);
    coordJob.setFrequency("1");
    coordJob.setTimeUnit(Timeunit.HOUR);
    coordJob.setLastActionNumber(lastActionNum);
    coordJob.setLastActionTime(lastActionTime);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
        jpaService.execute(coordInsertCmd);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test coord job record to table");
        throw je;
    }
    return coordJob;
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 28 with JPAExecutorException

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

the class TestCoordCommandUtils method addRecordToCoordJobTable.

protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date startTime, Date endTime, String freq) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, startTime, endTime, false, false, 0);
    coordJob.setStartTime(startTime);
    coordJob.setEndTime(endTime);
    coordJob.setFrequency(freq);
    coordJob.setTimeUnit(CoordinatorJob.Timeunit.MINUTE);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
        jpaService.execute(coordInsertCmd);
    } catch (JPAExecutorException ex) {
        ex.printStackTrace();
        fail("Unable to insert the test coord job record to table");
        throw ex;
    }
    return coordJob;
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 29 with JPAExecutorException

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

the class TestCoordMaterializeTransitionXCommand method testActionMaterWithCronFrequency3.

public void testActionMaterWithCronFrequency3() throws Exception {
    Date startTime = DateUtils.parseDateOozieTZ("2013-07-18T00:00Z");
    Date endTime = DateUtils.parseDateOozieTZ("2013-07-18T01:00Z");
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, null, "0/15 2 * 5-7 4,5");
    new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
    final int expectedNominalTimeCount = 0;
    checkCoordActionsNominalTime(job.getId(), expectedNominalTimeCount, new Date[] {});
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
        assertTrue(job.isDoneMaterialization());
        assertEquals(job.getLastActionNumber(), expectedNominalTimeCount);
        assertEquals(job.getNextMaterializedTime(), DateUtils.parseDateOozieTZ("2013-07-18T02:00Z"));
    } catch (JPAExecutorException se) {
        se.printStackTrace();
        fail("Job ID " + job.getId() + " was not stored properly in db");
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Example 30 with JPAExecutorException

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

the class TestCoordMaterializeTransitionXCommand method checkTwoActionsAfterCatchup.

private void checkTwoActionsAfterCatchup(CoordinatorJobBean job) throws ParseException {
    try {
        final JPAService jpaService = Services.get().get(JPAService.class);
        job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
        assertTrue("coordinator job should have already been materialized", job.isDoneMaterialization());
        assertEquals("coordinator action count mismatch", 2, job.getLastActionNumber());
        final String startPlusThreeHours = "2013-03-10T10:00Z";
        assertEquals("coordinator next materialization time mismatch", DateUtils.parseDateOozieTZ(startPlusThreeHours), job.getNextMaterializedTime());
    } catch (final JPAExecutorException se) {
        se.printStackTrace();
        fail("Job ID " + job.getId() + " was not stored properly in db");
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Aggregations

JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)195 JPAService (org.apache.oozie.service.JPAService)137 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)65 CommandException (org.apache.oozie.command.CommandException)63 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)55 Date (java.util.Date)53 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)49 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)45 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)43 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)37 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)33 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)31 IOException (java.io.IOException)26 BundleJobBean (org.apache.oozie.BundleJobBean)24 CoordJobInsertJPAExecutor (org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor)19 BundleActionBean (org.apache.oozie.BundleActionBean)18 Configuration (org.apache.hadoop.conf.Configuration)15 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)15 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)14 XConfiguration (org.apache.oozie.util.XConfiguration)14