Package javax.batch.operations

Examples of javax.batch.operations.JobOperator


     *
     * @throws Exception an exception if the batch could not complete successfully.
     */
    @Test
    public void testBatchChunkPartition() 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());

                // <1> The read count should be 20 elements. Check +MyItemReader+.
View Full Code Here


     *
     * @throws Exception an exception if the batch could not complete successfully.
     */
    @Test
    public void testBatchFlow() 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());

            if (stepExecution.getStepName().equals("step2")) {
View Full Code Here

  * @return JobOperator instance.
  */
 
  public static JobOperator getJobOperator() {
   
    JobOperator operator = null;
    ServiceLoader<JobOperator> loader = ServiceLoader.load(JobOperator.class);
    for (JobOperator provider : loader) {
      if (provider != null) {
        if (logger.isLoggable(Level.FINE)) {
          logger.fine("Loaded BatchContainerServiceProvider with className = " + provider.getClass().getCanonicalName());
View Full Code Here

        return new String[] {NAME, STEP_ID, START_TIME, END_TIME, BATCH_STATUS, EXIT_STATUS};
    }

    private List<StepExecution> findStepExecutions()
        throws JobSecurityException, NoSuchJobExecutionException {
        JobOperator jobOperator = AbstractListCommand.getJobOperatorFromBatchRuntime();
        JobExecution je = jobOperator.getJobExecution(Long.valueOf(executionId));
        if (!glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
            throw new NoSuchJobExecutionException("No job execution exists for job execution id: " + executionId);

        List<StepExecution> stepExecutions = jobOperator.getStepExecutions(Long.valueOf(executionId));
        if (stepExecutions == null || stepExecutions.size() == 0)
            throw new NoSuchJobExecutionException("No job execution exists for job execution id: " + executionId);

        return stepExecutions;
    }
View Full Code Here

        return jobToInstanceCountMap;
    }
    private List<JobExecution> findJobExecutions() {
        List<JobExecution> jobExecutions = new ArrayList<JobExecution>();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        if (executionId != null) {
            JobExecution jobExecution = jobOperator.getJobExecution(Long.valueOf(executionId));
            if (jobExecution != null)
                jobExecutions.add(jobExecution);
        } else if (instanceId != null) {
            jobExecutions.addAll(getJobExecutionForInstance(Long.valueOf(instanceId)));
        } else 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

        return jobExecutions;
    }

    private static List<JobExecution> getJobExecutionForInstance(long instId) {
        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;
View Full Code Here

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

        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()).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

*/
@WebServlet("/batch")
public class BatchServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        JobOperator jo = BatchRuntime.getJobOperator();
        long jid = jo.start("myJob", new Properties());

        resp.getWriter().printf("Batch job with id %d started %n", jid);
        resp.getWriter().flush();
    }
View Full Code Here

            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>");
            long jid = jo.start("myJob", new Properties());
            out.println("Job submitted: " + jid + "<br>");
            out.println(jo.getJobInstanceCount("myJob") + " job instance found<br/>");
            JobExecution je = jo.getJobExecution(jid);
//            jo.abandon(jid);
            out.println("Job created on: " + je.getCreateTime() + "<br>");
            out.println("Job started on: " + je.getStartTime() + "<br>");
            out.println("Found: " + jo.getJobNames().size() + " jobs<br>");
            for (String j : jo.getJobNames()) {
                out.println("--> " + j + "<br>");
            }
            out.println("<br><br>Check server.log for output, also look at \"myJob.xml\" for Job XML.");
            out.println("</body>");
            out.println("</html>");
View Full Code Here

            out.println("<title>Batch Decision</title>");           
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Batch Decision</h1>");
            out.println("About to start the job<br>");
            JobOperator jo = BatchRuntime.getJobOperator();
            out.println("Got the job operator: " + jo + "<br>");
            jo.start("myJob", new Properties());
            out.println("Job submitted<br>");
            out.println("<br><br>Check server.log for output, also look at \"myJob.xml\" for Job XML.");
            out.println("</body>");
            out.println("</html>");
        } catch (JobStartException | JobSecurityException ex) {
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.