Examples of JobOperator


Examples of javax.batch.operations.JobOperator

            out.println("<title>Servlet TestServlet</title>");           
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
            out.println("About to start the job<br>");
            JobOperator jo = BatchRuntime.getJobOperator();
            out.println("Got the job operator: " + jo + "<br>");
            try {
                jo.start("myJob", new Properties());
            } catch (JobSecurityException ex) {
                Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex);
            }
            out.println("Job submitted<br>");
            out.println("<br><br>Check server.log for output, also look at \"myJob.xml\" for Job XML.");
View Full Code Here

Examples of javax.batch.operations.JobOperator

            out.println("<title>Servlet TestServlet</title>");           
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
            out.println("About to start the job<br>");
            JobOperator jo = BatchRuntime.getJobOperator();
            out.println("Got the job operator: " + jo + "<br>");
            try {
                jo.start("myJob", new Properties());
            } catch (JobSecurityException ex) {
                Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex);
            }
            out.println("Job submitted");
            out.println("<br><br>Check server.log for output, also look at \"myJob.xml\" for Job XML.");
View Full Code Here

Examples of javax.batch.operations.JobOperator

                        if (batchSPIManager != null && batchSPIManager.getBatchJobUtil() != null) {
                            batchSPIManager.getBatchJobUtil().purgeOwnedRepositoryData(tagName);
                            tagNamesRequiringCleanup.remove(tagName);
                        } else if (tagNamesRequiringCleanup.contains(tagName)) {
                            //Force initialization of BatchRuntime
                            JobOperator jobOperator = BatchRuntime.getJobOperator();

                            if (batchSPIManager.getBatchJobUtil() != null) {
                                batchSPIManager.getBatchJobUtil().purgeOwnedRepositoryData(tagName);
                                tagNamesRequiringCleanup.remove(tagName);
                            }
View Full Code Here

Examples of javax.batch.operations.JobOperator

   
    @PersistenceUnit EntityManagerFactory em;
   
    public void runJob() {
        try {
            JobOperator jo = BatchRuntime.getJobOperator();
            long jobId = jo.start("eod-sales", new Properties());
            System.out.println("Started job: with id: " + jobId);
        } catch (JobStartException ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

Examples of javax.batch.operations.JobOperator

        final String jobXml = args[0];
        if (jobXml == null || jobXml.isEmpty()) {
            usage(args);
        }

        final JobOperator jobOperator = BatchRuntime.getJobOperator();
        final long jobExecutionId;
        final long timeout = Long.getLong(JobExecutionImpl.JOB_EXECUTION_TIMEOUT_SECONDS_KEY, JobExecutionImpl.JOB_EXECUTION_TIMEOUT_SECONDS_DEFAULT);
        try {
            jobExecutionId = jobOperator.start(jobXml, null);
            final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
            jobExecution.awaitTermination(timeout, TimeUnit.SECONDS);

            if (!jobExecution.getBatchStatus().equals(BatchStatus.COMPLETED)) {
                throw new BatchRuntimeException(String.format("The job did not complete: %s%n", jobXml));
            }
View Full Code Here

Examples of javax.batch.operations.JobOperator

        final String jobXml = args[0];
        if (jobXml == null || jobXml.isEmpty()) {
            usage(args);
        }

        final JobOperator jobOperator = BatchRuntime.getJobOperator();
        final long jobExecutionId;
        final long timeout = Long.getLong(JobExecutionImpl.JOB_EXECUTION_TIMEOUT_SECONDS_KEY, JobExecutionImpl.JOB_EXECUTION_TIMEOUT_SECONDS_DEFAULT);
        try {
            jobExecutionId = jobOperator.start(jobXml, null);
            final JobExecutionImpl jobExecution = (JobExecutionImpl) jobOperator.getJobExecution(jobExecutionId);
            jobExecution.awaitTerminatioin(timeout, TimeUnit.SECONDS);

            if (!jobExecution.getBatchStatus().equals(BatchStatus.COMPLETED)) {
                throw new BatchRuntimeException(String.format("The job did not complete: %s%n", jobXml));
            }
View Full Code Here

Examples of javax.batch.operations.JobOperator

public class ExceptionHandlingParsingTests extends AbstractJsrTestCase {

  @Test
  public void testSkippable() throws Exception {
    JobOperator jobOperator = BatchRuntime.getJobOperator();

    Properties jobParameters = new Properties();
    jobParameters.setProperty("run", "1");
    JobExecution execution1 = runJob("ExceptionHandlingParsingTests-context", jobParameters, 10000l);

    List<StepExecution> stepExecutions = jobOperator.getStepExecutions(execution1.getExecutionId());
    assertEquals(BatchStatus.FAILED, execution1.getBatchStatus());
    assertEquals(1, stepExecutions.size());
    assertEquals(1, getMetric(stepExecutions.get(0), Metric.MetricType.PROCESS_SKIP_COUNT).getValue());

    jobParameters = new Properties();
    jobParameters.setProperty("run", "2");
    JobExecution execution2 = restartJob(execution1.getExecutionId(), jobParameters, 10000l);
    stepExecutions = jobOperator.getStepExecutions(execution2.getExecutionId());
    assertEquals(BatchStatus.FAILED, execution2.getBatchStatus());
    assertEquals(2, stepExecutions.size());

    jobParameters = new Properties();
    jobParameters.setProperty("run", "3");
    JobExecution execution3 = restartJob(execution2.getExecutionId(), jobParameters, 10000l);
    stepExecutions = jobOperator.getStepExecutions(execution3.getExecutionId());
    assertEquals(BatchStatus.COMPLETED, execution3.getBatchStatus());
    assertEquals(2, stepExecutions.size());

    assertEquals(0, getMetric(stepExecutions.get(1), Metric.MetricType.ROLLBACK_COUNT).getValue());

    jobParameters = new Properties();
    jobParameters.setProperty("run", "4");
    JobExecution execution4 = runJob("ExceptionHandlingParsingTests-context", jobParameters, 10000l);
    stepExecutions = jobOperator.getStepExecutions(execution4.getExecutionId());
    assertEquals(BatchStatus.COMPLETED, execution4.getBatchStatus());
    assertEquals(3, stepExecutions.size());
  }
View Full Code Here

Examples of javax.batch.operations.JobOperator

        Map<String, Object> jobInfo = new HashMap<>();

        int jobParamIndex = -1;
        StringTokenizer st = new StringTokenizer("", "");
        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() <= 0 ? Long.valueOf(instanceId) : je.getInstanceId()).getJobName();
                    break;
                case EXECUTION_ID:
                    data = "" + je.getExecutionId();
                    break;
                case BATCH_STATUS:
                    data = je.getBatchStatus();
                    break;
                case EXIT_STATUS:
                    data = je.getExitStatus();
                    break;
                case START_TIME:
                    data = je.getStartTime().getTime();
                    cfData[index] = je.getStartTime().toString();
                    break;
                case END_TIME:
                    data = je.getEndTime().getTime();
                    cfData[index] = je.getEndTime().toString();
                    break;
                case JOB_PARAMETERS:
                    data = je.getJobParameters() == null ? new Properties() : je.getJobParameters();
                    jobParamIndex = index;
                    ColumnFormatter cf = new ColumnFormatter(new String[]{"KEY", "VALUE"});
                    for (Map.Entry e : ((Properties) data).entrySet())
                        cf.addRow(new String[]{e.getKey().toString(), e.getValue().toString()});
                    st = new StringTokenizer(cf.toString(), "\n");
                    break;
                case STEP_COUNT:
                    long exeId = executionId == null ? je.getExecutionId() : Long.valueOf(executionId);
                    data = jobOperator.getStepExecutions(exeId) == null
                        ? 0 : jobOperator.getStepExecutions(exeId).size();
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
            }
            jobInfo.put(getOutputHeaders()[index], data);
View Full Code Here

Examples of javax.batch.operations.JobOperator

    }

    private List<StepExecution> findStepExecutions()
        throws javax.batch.operations.exception.SecurityException {
        List<StepExecution> stepExecutions = new ArrayList<>();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        List<StepExecution> jobExecution = jobOperator.getStepExecutions(Long.valueOf(executionId));
        if (jobExecution != null)
            stepExecutions.addAll(jobExecution);

        return stepExecutions;
    }
View Full Code Here

Examples of javax.batch.operations.JobOperator

    }

    private List<JobExecution> findJobExecutions()
        throws SecurityException {
        List<JobExecution> jobExecutions = new ArrayList<>();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        if (jobName != null) {
            List<JobInstance> exe = jobOperator.getJobInstances(jobName, 0, Integer.MAX_VALUE - 1);
            if (exe != null) {
                for (JobInstance ji : exe) {
                    jobExecutions.addAll(jobOperator.getExecutions(ji));
                }
            }
        } else {
            Set<String> jobNames = jobOperator.getJobNames();
            if (jobNames != null) {
                for (String jn : jobOperator.getJobNames()) {
                    List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1);
                    if (exe != null) {
                        for (JobInstance ji : exe) {
                            jobExecutions.addAll(jobOperator.getExecutions(ji));
                        }
                    }
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.