Package javax.batch.runtime

Examples of javax.batch.runtime.JobExecution


   * @return the {@link JobExecution} for the final state of the job
   * @throws java.util.concurrent.TimeoutException if the timeout occurs
   */
  public static JobExecution restartJob(long executionId, Properties properties, long timeout) throws TimeoutException {
    long restartId = operator.restart(executionId, properties);
    JobExecution execution = operator.getJobExecution(restartId);

    Date curDate = new Date();
    BatchStatus curBatchStatus = execution.getBatchStatus();

    while(true) {
      if(curBatchStatus == BatchStatus.STOPPED || curBatchStatus == BatchStatus.COMPLETED || curBatchStatus == BatchStatus.FAILED) {
        break;
      }

      if(new Date().getTime() - curDate.getTime() > timeout) {
        throw new TimeoutException("Job processing did not complete in time");
      }

      execution = operator.getJobExecution(restartId);
      curBatchStatus = execution.getBatchStatus();
    }
    return execution;
  }
View Full Code Here


public class ThreadLocalClassloaderBeanPostProcessorTests extends AbstractJsrTestCase {

  @Test
  public void test() throws Exception {
    JobExecution execution = runJob("threadLocalClassloaderBeanPostProcessorTestsJob", null, 10000);

    assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus());
  }
View Full Code Here

* @since 3.0
*/
public class FlowParserTests extends AbstractJsrTestCase {
  @Test
  public void testDuplicateTransitionPatternsAllowed() throws Exception {
    JobExecution stoppedExecution = runJob("FlowParserTests-context", new Properties(), 10000L);
    assertEquals(ExitStatus.STOPPED.getExitCode(), stoppedExecution.getExitStatus());

    JobExecution endedExecution = restartJob(stoppedExecution.getExecutionId(), new Properties(), 10000L);
    assertEquals(ExitStatus.COMPLETED.getExitCode(), endedExecution.getExitStatus());
  }
View Full Code Here

    assertEquals(ExitStatus.COMPLETED.getExitCode(), endedExecution.getExitStatus());
  }

  @Test
  public void testWildcardAddedLastWhenUsedWithNextAttrAndNoTransitionElements() throws Exception {
    JobExecution jobExecution = runJob("FlowParserTestsWildcardAndNextAttrJob", new Properties(), 1000L);
    assertEquals(ExitStatus.FAILED.getExitCode(), jobExecution.getExitStatus());

    JobOperator jobOperator = BatchRuntime.getJobOperator();
    List<StepExecution> stepExecutions = jobOperator.getStepExecutions(jobExecution.getExecutionId());
    assertEquals(1, stepExecutions.size());
    StepExecution failedStep = stepExecutions.get(0);
    assertTrue("step1".equals(failedStep.getStepName()));
  }
View Full Code Here

    assertTrue("step1".equals(failedStep.getStepName()));
  }

  @Test
  public void testStepGetsFailedTransitionWhenNextAttributePresent() throws Exception {
    JobExecution jobExecution = runJob("FlowParserTestsStepGetsFailedTransitionWhenNextAttributePresent", new Properties(), 10000L);
    assertEquals(ExitStatus.FAILED.getExitCode(), jobExecution.getExitStatus());

    JobOperator jobOperator = BatchRuntime.getJobOperator();
    List<StepExecution> stepExecutions = jobOperator.getStepExecutions(jobExecution.getExecutionId());
    assertEquals(1, stepExecutions.size());
    StepExecution failedStep = stepExecutions.get(0);
    assertTrue("failedExitStatusStep".equals(failedStep.getStepName()));
    assertTrue("FAILED".equals(failedStep.getExitStatus()));
  }
View Full Code Here

    assertTrue("FAILED".equals(failedStep.getExitStatus()));
  }

  @Test
  public void testStepNoOverrideWhenNextAndFailedTransitionElementExists() throws Exception {
    JobExecution jobExecution = runJob("FlowParserTestsStepNoOverrideWhenNextAndFailedTransitionElementExists", new Properties(), 10000L);
    assertEquals(ExitStatus.FAILED.getExitCode(), jobExecution.getExitStatus());

    JobOperator jobOperator = BatchRuntime.getJobOperator();
    List<StepExecution> stepExecutions = jobOperator.getStepExecutions(jobExecution.getExecutionId());
    assertEquals(1, stepExecutions.size());
    StepExecution failedStep = stepExecutions.get(0);
    assertTrue("failedExitStatusStepDontOverride".equals(failedStep.getStepName()));
    assertTrue("CUSTOM_FAIL".equals(failedStep.getExitStatus()));
  }
View Full Code Here

   * @return the {@link JobExecution} for the final state of the job
   * @throws java.util.concurrent.TimeoutException if the timeout occurs
   */
  public static JobExecution runJob(String jobName, Properties properties, long timeout) throws TimeoutException{
    long executionId = operator.start(jobName, properties);
    JobExecution execution = operator.getJobExecution(executionId);

    Date curDate = new Date();
    BatchStatus curBatchStatus = execution.getBatchStatus();

    while(true) {
      if(curBatchStatus == BatchStatus.STOPPED || curBatchStatus == BatchStatus.COMPLETED || curBatchStatus == BatchStatus.FAILED) {
        break;
      }

      if(new Date().getTime() - curDate.getTime() > timeout) {
        throw new TimeoutException("Job processing did not complete in time");
      }

      execution = operator.getJobExecution(executionId);
      curBatchStatus = execution.getBatchStatus();
    }
    return execution;
  }
View Full Code Here

   * @return the {@link JobExecution} for the final state of the job
   * @throws java.util.concurrent.TimeoutException if the timeout occurs
   */
  public static JobExecution restartJob(long executionId, Properties properties, long timeout) throws TimeoutException {
    long restartId = operator.restart(executionId, properties);
    JobExecution execution = operator.getJobExecution(restartId);

    Date curDate = new Date();
    BatchStatus curBatchStatus = execution.getBatchStatus();

    while(true) {
      if(curBatchStatus == BatchStatus.STOPPED || curBatchStatus == BatchStatus.COMPLETED || curBatchStatus == BatchStatus.FAILED) {
        break;
      }

      if(new Date().getTime() - curDate.getTime() > timeout) {
        throw new TimeoutException("Job processing did not complete in time");
      }

      execution = operator.getJobExecution(restartId);
      curBatchStatus = execution.getBatchStatus();
    }
    return execution;
  }
View Full Code Here

                preparedStatement.setLong(1, jobInstanceId);
            }
            final ResultSet rs = preparedStatement.executeQuery();
            while (rs.next()) {
                final long i = rs.getLong(TableColumn.JOBEXECUTIONID);
                JobExecution jobExecution1 = jobExecutions.get(i);
                if (jobExecution1 == null) {
                    if (jobInstanceId == 0) {
                        jobInstanceId = rs.getLong(TableColumn.JOBINSTANCEID);
                    }
                    final Properties jobParameters1 = BatchUtil.stringToProperties(rs.getString(TableColumn.JOBPARAMETERS));
View Full Code Here

                    it.remove();
                }
            }
        }
        for (Iterator<Map.Entry<Long, JobExecution>> it = jobExecutions.entrySet().iterator(); it.hasNext();) {
            final JobExecution je = it.next().getValue();
            if (je.getJobName().equals(jobId)) {
                it.remove();
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.batch.runtime.JobExecution

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.