javax.batch.operations.JobStartException Java Examples
The following examples show how to use
javax.batch.operations.JobStartException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobExecutionHelper.java From incubator-batchee with Apache License 2.0 | 6 votes |
public static RuntimeJobExecution startJob(final ServicesManager servicesManager, final String jobXML, final Properties jobParameters) throws JobStartException { final JSLJob jobModel = new JobModelResolver().resolveModel(jobXML); final ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, jobParameters, false); final JobContextImpl jobContext = getJobContext(jobNavigator); final JobInstance jobInstance = getNewJobInstance(servicesManager, jobNavigator.getRootModelElement().getId(), jobXML); final RuntimeJobExecution executionHelper = servicesManager.service(PersistenceManagerService.class).createJobExecution(jobInstance, jobParameters, jobContext.getBatchStatus()); executionHelper.prepareForExecution(jobContext); final JobStatusManagerService statusManagerService = servicesManager.service(JobStatusManagerService.class); final JobStatus jobStatus = createNewJobStatus(statusManagerService, jobInstance); statusManagerService.updateJobStatus(jobStatus); return executionHelper; }
Example #2
Source File: JobExecutionHelper.java From incubator-batchee with Apache License 2.0 | 6 votes |
public static RuntimeJobExecution startPartition(final ServicesManager servicesManager, final JSLJob jobModel, final Properties jobParameters) throws JobStartException { final ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, jobParameters, true); final JobContextImpl jobContext = getJobContext(jobNavigator); final JobInstance jobInstance = getNewSubJobInstance(servicesManager, jobNavigator.getRootModelElement().getId()); final RuntimeJobExecution executionHelper = servicesManager.service(PersistenceManagerService.class).createJobExecution(jobInstance, jobParameters, jobContext.getBatchStatus()); executionHelper.prepareForExecution(jobContext); final JobStatusManagerService statusManagerService = servicesManager.service(JobStatusManagerService.class); final JobStatus jobStatus = createNewJobStatus(statusManagerService, jobInstance); statusManagerService.updateJobStatus(jobStatus); return executionHelper; }
Example #3
Source File: JobOperatorImpl.java From incubator-batchee with Apache License 2.0 | 6 votes |
private long startInternal(final String jobXMLName, final Properties jobParameters) throws JobStartException, JobSecurityException { final StringWriter jobParameterWriter = new StringWriter(); if (jobParameters != null) { try { jobParameters.store(jobParameterWriter, "Job parameters on start: "); } catch (IOException e) { jobParameterWriter.write("Job parameters on start: not printable"); } } else { jobParameterWriter.write("Job parameters on start = null"); } final String jobXML = xmlLoaderService.loadJSL(jobXMLName); final InternalJobExecution execution = kernelService.startJob(jobXML, jobParameters); return execution.getExecutionId(); }
Example #4
Source File: UserBean.java From javaee8-cookbook with Apache License 2.0 | 5 votes |
public void run() { try { JobOperator job = BatchRuntime.getJobOperator(); long jobId = job.start("acess-user", new Properties()); System.out.println("Job started: " + jobId); } catch (JobStartException ex) { System.out.println(ex.getMessage()); } }
Example #5
Source File: DefaultBatchKernel.java From incubator-batchee with Apache License 2.0 | 5 votes |
/** * Build a list of batch work units and set them up in STARTING state but don't start them yet. */ @Override public List<BatchPartitionWorkUnit> buildNewParallelPartitions(final PartitionsBuilderConfig config, final JobContextImpl jc, final StepContextImpl sc) throws JobRestartException, JobStartException { final List<JSLJob> jobModels = config.getJobModels(); final Properties[] partitionPropertiesArray = config.getPartitionProperties(); final List<BatchPartitionWorkUnit> batchWorkUnits = new ArrayList<BatchPartitionWorkUnit>(jobModels.size()); int instance = 0; for (final JSLJob parallelJob : jobModels) { final Properties partitionProps = (partitionPropertiesArray == null) ? null : partitionPropertiesArray[instance]; final RuntimeJobExecution jobExecution = JobExecutionHelper.startPartition(servicesManager, parallelJob, partitionProps); jobExecution.inheritJobContext(jc); jobExecution.setPartitionInstance(instance); final BatchPartitionWorkUnit batchWork = new BatchPartitionWorkUnit(jobExecution, config, servicesManager); batchWork.inheritStepContext(sc); registerCurrentInstanceAndExecution(jobExecution, batchWork.getController()); batchWorkUnits.add(batchWork); instance++; } return batchWorkUnits; }
Example #6
Source File: JobExecutionHelper.java From incubator-batchee with Apache License 2.0 | 5 votes |
public static RuntimeFlowInSplitExecution startFlowInSplit(final ServicesManager servicesManager, final JSLJob jobModel) throws JobStartException { final ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, null, true); final JobContextImpl jobContext = getJobContext(jobNavigator); final JobInstance jobInstance = getNewSubJobInstance(servicesManager, jobNavigator.getRootModelElement().getId()); final RuntimeFlowInSplitExecution executionHelper = servicesManager.service(PersistenceManagerService.class).createFlowInSplitExecution(jobInstance, jobContext.getBatchStatus()); executionHelper.prepareForExecution(jobContext); final JobStatusManagerService statusManagerService = servicesManager.service(JobStatusManagerService.class); final JobStatus jobStatus = createNewJobStatus(statusManagerService, jobInstance); statusManagerService.updateJobStatus(jobStatus); return executionHelper; }
Example #7
Source File: SplitController.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public SplitExecutionStatus execute() throws JobRestartException, JobStartException, JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException, NoSuchJobExecutionException { // Build all sub jobs from partitioned step buildSubJobBatchWorkUnits(); // kick off the threads executeWorkUnits(); // Deal with the results. return waitForCompletionAndAggregateStatus(); }
Example #8
Source File: PartitionedStepController.java From incubator-batchee with Apache License 2.0 | 5 votes |
private void buildSubJobBatchWorkUnits() throws JobRestartException, JobStartException, JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException { synchronized (subJobs) { //check if we've already issued a stop if (jobExecutionImpl.getJobContext().getBatchStatus().equals(BatchStatus.STOPPING)) { return; } for (int instance = 0; instance < partitions; instance++) { subJobs.add(PartitionedStepBuilder.buildPartitionSubJob(jobExecutionImpl.getInstanceId(), jobExecutionImpl.getJobContext(), step, instance)); } PartitionsBuilderConfig config = new PartitionsBuilderConfig(subJobs, partitionProperties, analyzerStatusQueue, completedWorkQueue, jobExecutionImpl.getExecutionId()); // Then build all the subjobs but do not start them yet if (executionType == ExecutionType.RESTART_NORMAL) { parallelBatchWorkUnits = kernelService.buildOnRestartParallelPartitions(config, jobExecutionImpl.getJobContext(), stepContext); } else { // This case includes RESTART_OVERRIDE and RESTART_AFTER_COMPLETION. // // So we're just going to create new "subjob" job instances in the DB in these cases, // and we'll have to make sure we're dealing with the correct ones, say in a subsequent "normal" restart // (of the current execution which is itself a restart) parallelBatchWorkUnits = kernelService.buildNewParallelPartitions(config, jobExecutionImpl.getJobContext(), stepContext); } // NOTE: At this point I might not have as many work units as I had partitions, since some may have already completed. } }
Example #9
Source File: SimpleRestController.java From incubator-batchee with Apache License 2.0 | 5 votes |
private void startBatch(String batchName, HttpServletRequest req, HttpServletResponse resp) { Properties jobProperties = extractJobProperties(req, resp); if (jobProperties == null) { return; } try { long jobId = jobOperator.start(batchName, jobProperties); reportSuccess(jobId, resp, null); } catch (JobStartException jobStartException) { StringBuilder msg = new StringBuilder("Error while starting job "); msg.append(batchName).append('\n'); appendExceptionMsg(msg, jobStartException); reportFailure(NO_JOB_ID, resp, msg.toString()); } }
Example #10
Source File: JobOperationsController.java From spring-boot-starter-batch-web with Apache License 2.0 | 4 votes |
@ResponseStatus(HttpStatus.NOT_FOUND) @ExceptionHandler({ NoSuchJobException.class, NoSuchJobExecutionException.class, JobStartException.class }) public String handleNotFound(Exception ex) { LOG.warn("Job or JobExecution not found.", ex); return ex.getMessage(); }
Example #11
Source File: PartitionedStepController.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override protected void invokeCoreStep() throws JobRestartException, JobStartException, JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException { this.plan = this.generatePartitionPlan(); //persist the partition plan so on restart we have the same plan to reuse stepStatus.setNumPartitions(plan.getPartitions()); calculateExecutionType(); validateNumberOfPartitions(); /* When true is specified, the partition count from the current run * is used and all results from past partitions are discarded. Any * resource cleanup or back out of work done in the previous run is the * responsibility of the application. The PartitionReducer artifact's * rollbackPartitionedStep method is invoked during restart before any * partitions begin processing to provide a cleanup hook. */ if (executionType == ExecutionType.RESTART_OVERRIDE) { if (this.partitionReducerProxy != null) { try { this.partitionReducerProxy.rollbackPartitionedStep(); } catch (Exception e) { ExceptionConfig.wrapBatchException(e); } } } //Set up a blocking queue to pick up collector data from a partitioned thread if (this.analyzerProxy != null) { this.analyzerStatusQueue = new LinkedBlockingQueue<PartitionDataWrapper>(); } this.completedWorkQueue = new LinkedBlockingQueue<BatchPartitionWorkUnit>(); // Build all sub jobs from partitioned step buildSubJobBatchWorkUnits(); // kick off the threads executeAndWaitForCompletion(); // Deal with the results. checkCompletedWork(); }
Example #12
Source File: SynchronousJobOperator.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public long start(final String name, final Properties properties) throws JobStartException, JobSecurityException { final long id = getOrCreateDelegate().start(name, properties); waitEnd(id); return id; }
Example #13
Source File: DefaultBatchKernel.java From incubator-batchee with Apache License 2.0 | 3 votes |
@Override public InternalJobExecution startJob(final String jobXML, final Properties jobParameters) throws JobStartException { final RuntimeJobExecution jobExecution = JobExecutionHelper.startJob(servicesManager, jobXML, jobParameters); // TODO - register with status manager final BatchWorkUnit batchWork = new BatchWorkUnit(servicesManager, jobExecution); registerCurrentInstanceAndExecution(jobExecution, batchWork.getController()); executorService.executeTask(batchWork, null); return jobExecution.getJobOperatorJobExecution(); }
Example #14
Source File: BatchKernelService.java From incubator-batchee with Apache License 2.0 | votes |
InternalJobExecution startJob(String jobXML, Properties jobParameters) throws JobStartException;
Example #15
Source File: BatchKernelService.java From incubator-batchee with Apache License 2.0 | votes |
List<BatchPartitionWorkUnit> buildNewParallelPartitions(PartitionsBuilderConfig config, JobContextImpl jc, StepContextImpl sc) throws JobRestartException, JobStartException;
Example #16
Source File: BaseStepController.java From incubator-batchee with Apache License 2.0 | votes |
protected abstract void invokeCoreStep() throws JobRestartException, JobStartException, JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException;