Package javax.batch.operations

Examples of javax.batch.operations.JobOperator


    private Map<String, Object> handleJob(JobExecution je, ColumnFormatter columnFormatter)
        throws  SecurityException {
        Map<String, Object> jobInfo = new HashMap<>();

        String[] cfData = new String[getOutputHeaders().length];
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        for (int index = 0; index < getOutputHeaders().length; index++) {
            Object data = null;
            switch (getOutputHeaders()[index]) {
                case JOB_NAME:
                    data = jobOperator.getJobInstance(je.getInstanceId()).getJobName();
                    break;
                case INSTANCE_COUNT:
                    data = jobOperator.getJobInstanceCount(jobOperator.getJobInstance(je.getInstanceId()).getJobName());
                    break;
                case INSTANCE_ID:
                    data = je.getInstanceId();
                    break;
                case EXECUTION_ID:
View Full Code Here


public class ItemSkipParsingTests extends AbstractJsrTestCase {

  @Test
  public void test() throws Exception {
    javax.batch.runtime.JobExecution execution = runJob("ItemSkipParsingTests-context", new Properties(), 10000l);
    JobOperator jobOperator = BatchRuntime.getJobOperator();

    assertEquals(BatchStatus.FAILED, execution.getBatchStatus());
    List<StepExecution> stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId());
    assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.READ_SKIP_COUNT).getValue());
    assertEquals(1, TestSkipListener.readSkips);
    assertEquals(0, TestSkipListener.processSkips);
    assertEquals(0, TestSkipListener.writeSkips);

    // Process skip and fail
    execution = restartJob(execution.getExecutionId(), new Properties(), 10000l);

    assertEquals(BatchStatus.FAILED, execution.getBatchStatus());
    stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId());
    assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.PROCESS_SKIP_COUNT).getValue());
    assertEquals(0, TestSkipListener.readSkips);
    assertEquals(1, TestSkipListener.processSkips);
    assertEquals(0, TestSkipListener.writeSkips);

    // Write skip and fail
    execution = restartJob(execution.getExecutionId(), new Properties(), 10000l);

    assertEquals(BatchStatus.FAILED, execution.getBatchStatus());
    stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId());
    assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.WRITE_SKIP_COUNT).getValue());
    assertEquals(0, TestSkipListener.readSkips);
    assertEquals(0, TestSkipListener.processSkips);
    assertEquals(1, TestSkipListener.writeSkips);

    // Complete
    execution = restartJob(execution.getExecutionId(), new Properties(), 10000l);

    assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus());
    stepExecutions = jobOperator.getStepExecutions(execution.getExecutionId());
    assertEquals(0, getMetric(stepExecutions.get(0), Metric.MetricType.WRITE_SKIP_COUNT).getValue());
    assertEquals(0, TestSkipListener.readSkips);
    assertEquals(0, TestSkipListener.processSkips);
    assertEquals(0, TestSkipListener.writeSkips);
  }
View Full Code Here

    }

    private List<JobExecution> findJobExecutions(long exeId)
        throws javax.batch.operations.exception.SecurityException {
        List<JobExecution> jobExecutions = new ArrayList<>();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        JobExecution jobExecution = jobOperator.getJobExecution(Long.valueOf(exeId));
        if (jobExecution != null)
            jobExecutions.add(jobExecution);

        return jobExecutions;
    }
View Full Code Here

        return jobExecutions;
    }

    private static List<JobExecution> getJobExecutionForInstance(long instId)
            throws javax.batch.operations.exception.SecurityException {
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        JobInstance jobInstance = null;
        for (String jn : jobOperator.getJobNames()) {
            List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1);
            if (exe != null) {
                for (JobInstance ji : exe) {
                    if (ji.getInstanceId() == instId) {
                        jobInstance = ji;
                        break;
                    }
                }
            }
        }

        List<JobExecution> jeList = new ArrayList<JobExecution>();
        List<JobExecution> lst = BatchRuntime.getJobOperator().getJobExecutions(jobInstance);
        if (lst != null) {
            for (JobExecution je : lst) {
                jeList.add(jobOperator.getJobExecution(je.getExecutionId()));
            }
        }

        return jeList;
    }
View Full Code Here

  @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

  @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

  @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

        assertEquals(sum, collector.getLastSum());
        assertEquals(3, collector.getNumberOfJobs());
    }

    private void runJob() throws InterruptedException {
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        Long executionId = jobOperator.start("jms-job", new Properties());
        JobExecution jobExecution = jobOperator.getJobExecution(executionId);

        BatchTestHelper.keepTestAlive(jobExecution);
    }
View Full Code Here

     *
     * @throws Exception an exception if the batch could not complete successfully.
     */
    @Test
    public void testBatchSplit() throws Exception {
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        Long executionId = jobOperator.start("myJob", new Properties());
        JobExecution jobExecution = jobOperator.getJobExecution(executionId);

        BatchTestHelper.keepTestAlive(jobExecution);

        List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
        List<String> executedSteps = new ArrayList<>();
        for (StepExecution stepExecution : stepExecutions) {
            executedSteps.add(stepExecution.getStepName());
        }

View Full Code Here

     *
     * @throws Exception an exception if the batch could not complete successfully.
     */
    @Test
    public void testBatchListeners() throws Exception {
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        Long executionId = jobOperator.start("myJob", new Properties());
        JobExecution jobExecution = jobOperator.getJobExecution(executionId);

        BatchTestHelper.keepTestAlive(jobExecution);

        List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
        for (StepExecution stepExecution : stepExecutions) {
            if (stepExecution.getStepName().equals("myStep")) {
                Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());

                assertEquals(10L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
View Full Code Here

TOP

Related Classes of javax.batch.operations.JobOperator

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.