Package org.jberet.runtime

Examples of org.jberet.runtime.JobExecutionImpl


    @Test
    public void testStopWithRestartPoint() throws Exception {
        final Properties params = Batchlet1Test.createParams(Batchlet1.ACTION, Batchlet1.ACTION_STOP);
        System.out.printf("Start with params %s%n", params);
        final long jobExecutionId = jobOperator.start(jobName2, params);
        final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
        jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
        System.out.printf("JobExecution id: %s%n", jobExecution.getExecutionId());
        Assert.assertEquals(BatchStatus.STOPPED, jobExecution.getBatchStatus());
        Assert.assertEquals(Batchlet1.ACTION_STOP, jobExecution.getExitStatus());

        Assert.assertEquals(5, jobExecution.getStepExecutions().size());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(0).getBatchStatus());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(1).getBatchStatus());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(2).getBatchStatus());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(3).getBatchStatus());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(4).getBatchStatus());
        writeOutExecutionId(jobExecutionId, jobName2ExecutionIdSaveTo);
    }
View Full Code Here


        final JobExecutionImpl[] jobExecutions = new JobExecutionImpl[3];
        final Properties params = Batchlet1Test.createParams(Batchlet1.ACTION, Batchlet1.ACTION_EXCEPTION);
        {
            System.out.printf("Start with params %s%n", params);
            long jobExecutionId = jobOperator.start(jobName3, params);
            JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
            jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
            jobExecutions[0] = jobExecution;

            System.out.printf("Restart with params %s%n", params);
            jobExecutionId = jobOperator.restart(jobExecutionId, params);
            jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
            jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
            jobExecutions[1] = jobExecution;

            System.out.printf("Restart with params %s%n", params);
            jobExecutionId = jobOperator.restart(jobExecutionId, params);
            jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
            jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
            jobExecutions[2] = jobExecution;
        }
        for (final JobExecutionImpl e : jobExecutions) {
            System.out.printf("JobExecution id: %s%n", e.getExecutionId());
            Assert.assertEquals(BatchStatus.FAILED, e.getBatchStatus());
View Full Code Here

    @Test
    public void testStepFailWithLongException() throws Exception {
        final Properties params = Batchlet1Test.createParams(Batchlet1.ACTION, Batchlet1.ACTION_LONG_EXCEPTION);
        System.out.printf("Start with params %s%n", params);
        final long jobExecutionId = jobOperator.start(jobName4, params);
        final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
        jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
        Assert.assertEquals(BatchStatus.FAILED, jobExecution.getBatchStatus());
        final StepExecutionImpl stepExecution = (StepExecutionImpl) jobExecution.getStepExecutions().get(0);
        Assert.assertEquals(BatchStatus.FAILED, stepExecution.getBatchStatus());
        Assert.assertEquals(Batchlet1.ACTION_LONG_EXCEPTION, stepExecution.getExitStatus());

        final Exception exception = stepExecution.getException();
        Assert.assertNotNull(exception);
View Full Code Here

    private long startJobMatchOther() throws Exception {
        final Properties params = createParams(Batchlet1.ACTION, Batchlet1.ACTION_OTHER);
        //start the job and complete step1 and step2, not matching any transition element in step2
        System.out.printf("Start with params %s%n", params);
        final long jobExecutionId = jobOperator.start(jobName, params);
        final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
        jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
        System.out.printf("JobExecution id: %s%n", jobExecution.getExecutionId());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
        Assert.assertEquals(BatchStatus.COMPLETED.name(), jobExecution.getExitStatus());

        Assert.assertEquals(2, jobExecution.getStepExecutions().size());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(0).getBatchStatus());
        Assert.assertEquals(BatchStatus.COMPLETED.name(), jobExecution.getStepExecutions().get(0).getExitStatus());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(1).getBatchStatus());
        Assert.assertEquals(Batchlet1.ACTION_OTHER, jobExecution.getStepExecutions().get(1).getExitStatus());
        return jobExecutionId;
    }
View Full Code Here

        params.setProperty(CsvProperties.HEADER_KEY, nameMapping);
        params.setProperty(CsvProperties.WRITE_COMMENTS_KEY, writeComments);
        CsvItemReaderWriterTest.setRandomWriteMode(params);

        final long jobExecutionId = jobOperator.start(jobName, params);
        final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
        jobExecution.awaitTermination(CsvItemReaderWriterTest.waitTimeoutMinutes, TimeUnit.MINUTES);
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());

        CsvItemReaderWriterTest.validate(writeResourceFile, expect, forbid);
    }
View Full Code Here

    private long startJobMatchEnd() throws Exception {
        //start the job and complete step1 and step2, matching <end> element in step2
        final Properties params = createParams(Batchlet1.ACTION, Batchlet1.ACTION_END);
        System.out.printf("Start with params %s%n", params);
        final long jobExecutionId = jobOperator.start(jobName, params);
        final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
        jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
        System.out.printf("JobExecution id: %s%n", jobExecution.getExecutionId());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
        Assert.assertEquals(Batchlet1.ACTION_END, jobExecution.getExitStatus());

        Assert.assertEquals(2, jobExecution.getStepExecutions().size());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(0).getBatchStatus());
        Assert.assertEquals(BatchStatus.COMPLETED.name(), jobExecution.getStepExecutions().get(0).getExitStatus());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(1).getBatchStatus());
        Assert.assertEquals(Batchlet1.ACTION_END, jobExecution.getStepExecutions().get(1).getExitStatus());
        return jobExecutionId;
    }
View Full Code Here

    private long startJobMatchFail() throws Exception {
        //start the job and fail at the end of step2, matching <fail> element in step2
        final Properties params = createParams(Batchlet1.ACTION, Batchlet1.ACTION_FAIL);
        System.out.printf("Start with params %s%n", params);
        final long jobExecutionId = jobOperator.start(jobName, params);
        final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
        jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
        System.out.printf("JobExecution id: %s%n", jobExecution.getExecutionId());
        Assert.assertEquals(BatchStatus.FAILED, jobExecution.getBatchStatus());
        Assert.assertEquals(Batchlet1.ACTION_FAIL, jobExecution.getExitStatus())//set by <fail> element

        Assert.assertEquals(2, jobExecution.getStepExecutions().size());
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(0).getBatchStatus());
        Assert.assertEquals(BatchStatus.COMPLETED.name(), jobExecution.getStepExecutions().get(0).getExitStatus());

        // <fail> element does not affect the already-completed step batchlet execution.
        // Although the job FAILED, but step2 still COMPLETED
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(1).getBatchStatus());
        // step2 exit status from batchlet1.process method return value, not from <fail exit-status> element
        Assert.assertEquals(Batchlet1.ACTION_FAIL, jobExecution.getStepExecutions().get(1).getExitStatus());
        return jobExecutionId;
    }
View Full Code Here

        //restart the job and stop at the end of step2, matching <stop> element in step2.
        //next time this job execution is restarted, it should restart from restart-point step2
        final Properties params = createParams(Batchlet1.ACTION, Batchlet1.ACTION_STOP);
        System.out.printf("Restart with params %s%n", params);
        final long jobExecutionId = jobOperator.restart(previousJobExecutionId, params);
        final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
        jobExecution.awaitTermination(waitTimeoutMinutes, TimeUnit.MINUTES);
        System.out.printf("JobExecution id: %s%n", jobExecution.getExecutionId());
        Assert.assertEquals(BatchStatus.STOPPED, jobExecution.getBatchStatus());
        Assert.assertEquals(Batchlet1.ACTION_STOP, jobExecution.getExitStatus());

        Assert.assertEquals(1, jobExecution.getStepExecutions().size());
        // <stop> element does not affect the already-completed step batchlet execution.
        // Although the job STOPPED, but step2 still COMPLETED
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStepExecutions().get(0).getBatchStatus());
        // step2 exit status from batchlet1.process method return value, not from <stop exit-status> element
        Assert.assertEquals(Batchlet1.ACTION_STOP, jobExecution.getStepExecutions().get(0).getExitStatus());
        return jobExecutionId;
    }
View Full Code Here

    public void sleepComplete() throws Exception {
        final int sleepMinutes = 6;
        final Properties params = new Properties();
        params.setProperty("sleep.minutes", String.valueOf(sleepMinutes));
        final long jobExecutionId = operator.start(jobName, params);
        final JobExecutionImpl jobExecution = (JobExecutionImpl) operator.getJobExecution(jobExecutionId);
        jobExecution.awaitTermination(sleepMinutes * 2, TimeUnit.MINUTES);
        Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
        Assert.assertEquals(BatchStatus.COMPLETED.name(), jobExecution.getExitStatus());

        final StepExecution stepExecution = jobExecution.getStepExecutions().get(0);
        System.out.printf("stepExecution id=%s, name=%s, batchStatus=%s, exitStatus=%s%n",
                stepExecution.getStepExecutionId(), stepExecution.getStepName(), stepExecution.getBatchStatus(), stepExecution.getExitStatus());
        Assert.assertEquals(BatchStatus.COMPLETED, stepExecution.getBatchStatus());
        Assert.assertEquals(SleepBatchlet.SLEPT, stepExecution.getExitStatus());
    }
View Full Code Here

    public void sleepStop() throws Exception {
        final int sleepMinutes = 6;
        final Properties params = new Properties();
        params.setProperty("sleep.minutes", String.valueOf(sleepMinutes));
        final long jobExecutionId = operator.start(jobName, params);
        final JobExecutionImpl jobExecution = (JobExecutionImpl) operator.getJobExecution(jobExecutionId);
        operator.stop(jobExecutionId);
        jobExecution.awaitTermination(1, TimeUnit.MINUTES);
        Assert.assertEquals(BatchStatus.STOPPED, jobExecution.getBatchStatus());
        Assert.assertEquals(BatchStatus.STOPPED.name(), jobExecution.getExitStatus());

        final StepExecution stepExecution = jobExecution.getStepExecutions().get(0);
        System.out.printf("stepExecution id=%s, name=%s, batchStatus=%s, exitStatus=%s%n",
                stepExecution.getStepExecutionId(), stepExecution.getStepName(), stepExecution.getBatchStatus(), stepExecution.getExitStatus());
        Assert.assertEquals(BatchStatus.STOPPED, stepExecution.getBatchStatus());
        Assert.assertEquals(BatchStatus.STOPPED.name(), stepExecution.getExitStatus());
    }
View Full Code Here

TOP

Related Classes of org.jberet.runtime.JobExecutionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.