javax.batch.operations.NoSuchJobExecutionException Java Examples
The following examples show how to use
javax.batch.operations.NoSuchJobExecutionException.
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: JobOperatorImpl.java From incubator-batchee with Apache License 2.0 | 6 votes |
@Override public List<Long> getRunningExecutions(final String jobName) throws NoSuchJobException, JobSecurityException { final List<Long> jobExecutions = new ArrayList<Long>(); // get the jobexecution ids associated with this job name final Set<Long> executionIds = persistenceManagerService.jobOperatorGetRunningExecutions(jobName); if (executionIds.isEmpty()) { throw new NoSuchJobException("Job Name " + jobName + " not found"); } // for every job instance id for (final long id : executionIds) { try { if (kernelService.isExecutionRunning(id)) { final InternalJobExecution jobEx = kernelService.getJobExecution(id); jobExecutions.add(jobEx.getExecutionId()); } } catch (final NoSuchJobExecutionException e) { throw new IllegalStateException("Just found execution with id = " + id + " in table, but now seeing it as gone", e); } } return jobExecutions; }
Example #2
Source File: JobOperatorImpl.java From incubator-batchee with Apache License 2.0 | 6 votes |
@Override public void abandon(final long executionId) throws NoSuchJobExecutionException, JobExecutionIsRunningException, JobSecurityException { final InternalJobExecution jobEx = persistenceManagerService.jobOperatorGetJobExecution(executionId); // if it is not in STARTED or STARTING state, mark it as ABANDONED BatchStatus status = jobEx.getBatchStatus(); if (status == BatchStatus.STARTING || status == BatchStatus.STARTED) { throw new JobExecutionIsRunningException("Job Execution: " + executionId + " is still running"); } // update table to reflect ABANDONED state persistenceManagerService.updateBatchStatusOnly(jobEx.getExecutionId(), BatchStatus.ABANDONED, new Timestamp(System.currentTimeMillis())); // Don't forget to update JOBSTATUS table statusManagerService.updateJobBatchStatus(jobEx.getInstanceId(), BatchStatus.ABANDONED); }
Example #3
Source File: SimpleRestController.java From incubator-batchee with Apache License 2.0 | 6 votes |
private void batchMetrics(String batchId, HttpServletRequest req, HttpServletResponse resp) { Long executionId = extractExecutionId(batchId, resp); if (executionId == null) { return; } try { JobExecution jobExecution = jobOperator.getJobExecution(executionId); BatchStatus batchStatus = jobExecution.getBatchStatus(); List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId); reportSuccess(executionId, resp, batchStatus.name()); reportMetricsCsv(resp, stepExecutions); } catch (NoSuchJobExecutionException noSuchJob) { reportFailure(executionId, resp, "NoSuchJob"); } catch (Exception generalException) { StringBuilder msg = new StringBuilder("Failure in BatchExecution"); appendExceptionMsg(msg, generalException); reportFailure(executionId, resp, msg.toString()); } }
Example #4
Source File: JDBCPersistenceManagerService.java From incubator-batchee with Apache License 2.0 | 6 votes |
@Override public Properties getParameters(final long executionId) throws NoSuchJobExecutionException { Connection conn = null; PreparedStatement statement = null; ResultSet rs = null; try { conn = getConnection(); statement = conn.prepareStatement(dictionary.getFindJobExecutionJobProperties()); statement.setLong(1, executionId); rs = statement.executeQuery(); if (rs.next()) { final byte[] buf = rs.getBytes(dictionary.jobExecutionColumns(5)); return PropertyHelper.stringToProperties(buf != null ? new String(buf) : null); } throw new NoSuchJobExecutionException("Did not find table entry for executionID =" + executionId); } catch (final SQLException e) { throw new PersistenceException(e); } finally { cleanupConnection(conn, rs, statement); } }
Example #5
Source File: JDBCPersistenceManagerService.java From incubator-batchee with Apache License 2.0 | 6 votes |
public long getJobInstanceIdByExecutionId(final long executionId) throws NoSuchJobExecutionException { Connection conn = null; PreparedStatement statement = null; ResultSet rs = null; try { conn = getConnection(); statement = conn.prepareStatement(dictionary.getFindJobInstanceFromJobExecution()); statement.setObject(1, executionId); rs = statement.executeQuery(); if (!rs.next()) { throw new NoSuchJobExecutionException("Did not find job instance associated with executionID =" + executionId); } return rs.getLong(dictionary.jobExecutionColumns(8)); } catch (final SQLException e) { throw new PersistenceException(e); } finally { cleanupConnection(conn, rs, statement); } }
Example #6
Source File: SimpleRestController.java From incubator-batchee with Apache License 2.0 | 6 votes |
private void batchStop(String batchId, HttpServletRequest req, HttpServletResponse resp) { Long executionId = extractExecutionId(batchId, resp); if (executionId == null) { return; } try { jobOperator.stop(executionId); reportSuccess(executionId, resp, BatchStatus.STOPPING.toString()); } catch (NoSuchJobExecutionException noSuchJob) { reportFailure(executionId, resp, "NoSuchJob"); } catch (JobExecutionNotRunningException notRunningException) { reportFailure(executionId, resp, "JobExecutionNotRunning"); } catch (Exception generalException) { StringBuilder msg = new StringBuilder("Failure in BatchExecution"); appendExceptionMsg(msg, generalException); reportFailure(executionId, resp, msg.toString()); } }
Example #7
Source File: DefaultBatchKernel.java From incubator-batchee with Apache License 2.0 | 6 votes |
@Override public BatchFlowInSplitWorkUnit buildOnRestartFlowInSplitWorkUnit(final FlowInSplitBuilderConfig config, final JobContextImpl jc) throws JobRestartException, JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException { final JSLJob jobModel = config.getJobModel(); final long execId = getMostRecentSubJobExecutionId(jobModel); final RuntimeFlowInSplitExecution jobExecution; try { jobExecution = JobExecutionHelper.restartFlowInSplit(servicesManager, execId, jobModel); } catch (final NoSuchJobExecutionException e) { throw new IllegalStateException("Caught NoSuchJobExecutionException but this is an internal JobExecution so this shouldn't have happened: execId =" + execId, e); } final BatchFlowInSplitWorkUnit batchWork = new BatchFlowInSplitWorkUnit(jobExecution, config, servicesManager); jobExecution.inheritJobContext(jc); registerCurrentInstanceAndExecution(jobExecution, batchWork.getController()); return batchWork; }
Example #8
Source File: SimpleRestController.java From incubator-batchee with Apache License 2.0 | 6 votes |
private void batchRestart(String batchId, HttpServletRequest req, HttpServletResponse resp) { Long executionId = extractExecutionId(batchId, resp); if (executionId == null) { return; } Properties jobProperties = extractJobProperties(req, resp); try { jobOperator.restart(executionId, jobProperties); } catch (NoSuchJobExecutionException noSuchJob) { reportFailure(executionId, resp, "NoSuchJob"); } catch (JobExecutionAlreadyCompleteException alreadyCompleted) { reportFailure(executionId, resp, "NoSuchJob"); } catch (Exception generalException) { StringBuilder msg = new StringBuilder("Failure in BatchExecution"); appendExceptionMsg(msg, generalException); reportFailure(executionId, resp, msg.toString()); } }
Example #9
Source File: DefaultBatchKernel.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public void stopJob(final long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { final ThreadRootController controller = this.executionId2jobControllerMap.get(executionId); if (controller == null) { throw new JobExecutionNotRunningException("JobExecution with execution id of " + executionId + "is not running."); } controller.stop(); }
Example #10
Source File: JobOperatorImpl.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public List<StepExecution> getStepExecutions(long executionId) throws NoSuchJobExecutionException, JobSecurityException { final InternalJobExecution jobEx = kernelService.getJobExecution(executionId); if (jobEx == null) { throw new NoSuchJobExecutionException("Job Execution: " + executionId + " not found"); } return persistenceManagerService.getStepExecutionsForJobExecution(executionId); }
Example #11
Source File: JobOperatorImpl.java From incubator-batchee with Apache License 2.0 | 5 votes |
private long restartInternal(final long oldExecutionId, final Properties restartParameters) throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException { final StringWriter jobParameterWriter = new StringWriter(); if (restartParameters != null) { try { restartParameters.store(jobParameterWriter, "Job parameters on restart: "); } catch (IOException e) { jobParameterWriter.write("Job parameters on restart: not printable"); } } else { jobParameterWriter.write("Job parameters on restart = null"); } return kernelService.restartJob(oldExecutionId, restartParameters).getExecutionId(); }
Example #12
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 #13
Source File: JobExecutionHelper.java From incubator-batchee with Apache License 2.0 | 5 votes |
private static RuntimeJobExecution restartExecution(final ServicesManager servicesManager, final long executionId, final JSLJob gennedJobModel, final Properties restartJobParameters, final boolean parallelExecution, final boolean flowInSplit) throws JobRestartException, JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException, NoSuchJobExecutionException { final PersistenceManagerService persistenceManagerService = servicesManager.service(PersistenceManagerService.class); final JobStatusManagerService jobStatusManagerService = servicesManager.service(JobStatusManagerService.class); final long jobInstanceId = persistenceManagerService.getJobInstanceIdByExecutionId(executionId); final JobStatus jobStatus = jobStatusManagerService.getJobStatus(jobInstanceId); validateJobExecutionIsMostRecent(persistenceManagerService, jobInstanceId, executionId); validateJobInstanceNotCompleteOrAbandonded(jobStatus); final JobInstanceImpl jobInstance = jobStatus.getJobInstance(); final ModelNavigator<JSLJob> jobNavigator; // If we are in a parallel job that is genned use the regenned JSL. if (gennedJobModel == null) { jobNavigator = getResolvedJobNavigator(jobInstance.getJobXML(), restartJobParameters, parallelExecution); } else { jobNavigator = getResolvedJobNavigator(gennedJobModel, restartJobParameters, parallelExecution); } // JSLJob jobModel = ModelResolverFactory.createJobResolver().resolveModel(jobInstance.getJobXML()); validateRestartableFalseJobsDoNotRestart(jobNavigator.getRootModelElement()); final JobContextImpl jobContext = getJobContext(jobNavigator); final RuntimeJobExecution executionHelper; if (flowInSplit) { executionHelper = persistenceManagerService.createFlowInSplitExecution(jobInstance, jobContext.getBatchStatus()); } else { executionHelper = persistenceManagerService.createJobExecution(jobInstance, restartJobParameters, jobContext.getBatchStatus()); } executionHelper.prepareForExecution(jobContext, jobStatus.getRestartOn()); jobStatusManagerService.updateJobStatusWithNewExecution(jobInstance.getInstanceId(), executionHelper.getExecutionId()); return executionHelper; }
Example #14
Source File: DefaultBatchKernel.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public InternalJobExecution restartJob(final long executionId, final Properties jobOverrideProps) throws JobRestartException, JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException, NoSuchJobExecutionException { final RuntimeJobExecution jobExecution = JobExecutionHelper.restartJob(servicesManager, executionId, jobOverrideProps); final BatchWorkUnit batchWork = new BatchWorkUnit(servicesManager, jobExecution); registerCurrentInstanceAndExecution(jobExecution, batchWork.getController()); executorService.executeTask(batchWork, null); return jobExecution.getJobOperatorJobExecution(); }
Example #15
Source File: MemoryPersistenceManagerService.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public long getJobInstanceIdByExecutionId(final long executionId) throws NoSuchJobExecutionException { final Structures.ExecutionInstanceData executionInstanceData = data.executionInstanceData.get(executionId); if (executionInstanceData == null) { throw new NoSuchJobExecutionException("Execution #" + executionId); } return executionInstanceData.execution.getInstanceId(); }
Example #16
Source File: SynchronousJobOperator.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public long restart(final long id, final Properties properties) throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException { final long newId = getOrCreateDelegate().restart(id, properties); waitEnd(newId); return newId; }
Example #17
Source File: JPAPersistenceManagerService.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public Properties getParameters(final long executionId) throws NoSuchJobExecutionException { final EntityManager em = emProvider.newEntityManager(); try { return em.find(JobExecutionEntity.class, executionId).getJobProperties(); } finally { emProvider.release(em); } }
Example #18
Source File: JPAPersistenceManagerService.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public long getJobInstanceIdByExecutionId(final long executionId) throws NoSuchJobExecutionException { final EntityManager em = emProvider.newEntityManager(); try { final JobExecutionEntity jobExecutionEntity = em.find(JobExecutionEntity.class, executionId); if (jobExecutionEntity == null) { throw new NoSuchJobExecutionException("Execution #" + executionId); } return jobExecutionEntity.getInstance().getJobInstanceId(); } finally { emProvider.release(em); } }
Example #19
Source File: CustomJsrJobOperator.java From spring-boot-starter-batch-web with Apache License 2.0 | 5 votes |
public void remove(org.springframework.batch.core.JobExecution jobExecution) { if (!registry.containsKey(jobExecution.getId())) { throw new NoSuchJobExecutionException("The job execution " + jobExecution.getId() + " was not found"); } else { registry.remove(jobExecution.getId()); } }
Example #20
Source File: SynchronousJobOperator.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public List<StepExecution> getStepExecutions(final long id) throws NoSuchJobExecutionException, JobSecurityException { return getOrCreateDelegate().getStepExecutions(id); }
Example #21
Source File: SynchronousJobOperator.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public void stop(final long id) throws NoSuchJobExecutionException, JobExecutionNotRunningException, JobSecurityException { getOrCreateDelegate().stop(id); waitEnd(id); }
Example #22
Source File: PersistenceManagerServiceTest.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Test public void cleanUpUntil() { for (final PersistenceManagerService service : asList( new JDBCPersistenceManagerService() {{ init(new Properties()); }}, new JPAPersistenceManagerService() {{ init(new Properties()); }}, new MemoryPersistenceManagerService() {{ init(new Properties()); }})) { System.out.println(""); System.out.println(" " + service); System.out.println(""); for (int i = 0; i < 3; i++) { final JobInstance instance = service.createJobInstance("test", "xml"); final RuntimeJobExecution exec = service.createJobExecution(instance, new Properties(), BatchStatus.COMPLETED); final StepExecutionImpl step = service.createStepExecution(exec.getExecutionId(), new StepContextImpl("step")); service.createStepStatus(step.getStepExecutionId()).setBatchStatus(BatchStatus.STARTED); service.setCheckpointData( new CheckpointDataKey(instance.getInstanceId(), "step", CheckpointType.READER), new CheckpointData(instance.getInstanceId(), "step", CheckpointType.READER) {{ setRestartToken("restart".getBytes()); }}); service.createJobStatus(instance.getInstanceId()); service.updateJobStatus(instance.getInstanceId(), new JobStatus(instance) {{ setBatchStatus(BatchStatus.COMPLETED); }}); service.updateWithFinalExecutionStatusesAndTimestamps(exec.getExecutionId(), BatchStatus.COMPLETED, "ok", new Timestamp(System.currentTimeMillis())); // sanity checks we persisted data before deleting them assertNotNull(service.getJobStatus(instance.getInstanceId())); assertNotNull(service.getJobInstanceIdByExecutionId(exec.getExecutionId())); assertNotNull(service.jobOperatorGetJobExecution(exec.getExecutionId())); assertNotNull(service.getStepExecutionByStepExecutionId(step.getStepExecutionId())); assertNotNull(service.getCheckpointData(new CheckpointDataKey(instance.getInstanceId(), "step", CheckpointType.READER))); if (i != 2) { // skip last since we are not there to have a break try { // add some delay Thread.sleep(1000); } catch (final InterruptedException e) { Thread.interrupted(); fail(); } } } // now delete until the first one (+ delta) final List<Long> instances = service.jobOperatorGetJobInstanceIds("test", 0, 10); assertEquals(3, instances.size()); Collections.sort(instances); // we use increments everywhere so should be fine final InternalJobExecution firstExec = service.jobOperatorGetJobExecution(service.getMostRecentExecutionId(instances.iterator().next())); final Date until = new Date(firstExec.getEndTime().getTime() + 100); service.cleanUp(until); assertEquals(2, service.jobOperatorGetJobInstanceIds("test", 0, 10).size()); assertTrue(service.getStepExecutionsForJobExecution(firstExec.getExecutionId()).isEmpty()); assertNull(service.getCheckpointData(new CheckpointDataKey(firstExec.getInstanceId(), "step", CheckpointType.READER))); try { service.getJobInstanceIdByExecutionId(firstExec.getExecutionId()); fail(); } catch (final NoSuchJobExecutionException nsje) { // ok } assertFalse(service.jobOperatorGetJobInstanceIds("test", 0, 10).contains(firstExec.getInstanceId())); } }
Example #23
Source File: SynchronousJobOperator.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public void abandon(final long id) throws NoSuchJobExecutionException, JobExecutionIsRunningException, JobSecurityException { getOrCreateDelegate().abandon(id); waitEnd(id); }
Example #24
Source File: JobOperatorImpl.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public void stop(final long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException, JobSecurityException { kernelService.stopJob(executionId); }
Example #25
Source File: SynchronousJobOperator.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public Properties getParameters(final long id) throws NoSuchJobExecutionException, JobSecurityException { return getOrCreateDelegate().getParameters(id); }
Example #26
Source File: SynchronousJobOperator.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public JobInstance getJobInstance(final long id) throws NoSuchJobExecutionException, JobSecurityException { return getOrCreateDelegate().getJobInstance(id); }
Example #27
Source File: SynchronousJobOperator.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public JobExecution getJobExecution(final long id) throws NoSuchJobExecutionException, JobSecurityException { return getOrCreateDelegate().getJobExecution(id); }
Example #28
Source File: JobExecutionServiceTest.java From spring-batch-rest with Apache License 2.0 | 4 votes |
@Test(expected = NoSuchJobExecutionException.class) public void jobExecutionsIdNotFound() { jobExecutionService.jobExecution(10); }
Example #29
Source File: JobOperatorImpl.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public Properties getParameters(final long executionId) throws NoSuchJobExecutionException, JobSecurityException { final JobInstance requestedJobInstance = kernelService.getJobInstance(executionId); return persistenceManagerService.getParameters(executionId); }
Example #30
Source File: JobOperatorImpl.java From incubator-batchee with Apache License 2.0 | 4 votes |
@Override public JobInstance getJobInstance(long executionId) throws NoSuchJobExecutionException, JobSecurityException { return kernelService.getJobInstance(executionId); }