@Override protected StepExecutionDao createStepExecutionDao() throws Exception { stepExecutionDao = new MapStepExecutionDao(); return stepExecutionDao; }
/** * Convenience method to clear all the map DAOs globally, removing all * entities. */ public void clear() { jobInstanceDao.clear(); jobExecutionDao.clear(); stepExecutionDao.clear(); executionContextDao.clear(); }
@Override public void addStepExecutions(JobExecution jobExecution) { Map<Long, StepExecution> executions = executionsByJobExecutionId.get(jobExecution.getId()); if (executions == null || executions.isEmpty()) { return; } List<StepExecution> result = new ArrayList<>(executions.values()); Collections.sort(result, new Comparator<Entity>() { @Override public int compare(Entity o1, Entity o2) { return Long.signum(o2.getId() - o1.getId()); } }); List<StepExecution> copy = new ArrayList<>(result.size()); for (StepExecution exec : result) { copy.add(copy(exec)); } jobExecution.addStepExecutions(copy); }
@Override public void saveStepExecutions(Collection<StepExecution> stepExecutions) { Assert.notNull(stepExecutions,"Attempt to save an null collect of step executions"); for (StepExecution stepExecution: stepExecutions) { saveStepExecution(stepExecution); } } }
@Override public void saveStepExecutions(Collection<StepExecution> stepExecutions) { Assert.notNull(stepExecutions,"Attempt to save an null collect of step executions"); for (StepExecution stepExecution: stepExecutions) { saveStepExecution(stepExecution); } } }
@Override protected StepExecutionDao getStepExecutionDao() { return new MapStepExecutionDao(); }
@Override public void saveStepExecution(StepExecution stepExecution) { Assert.isTrue(stepExecution.getId() == null, "stepExecution id was not null"); Assert.isTrue(stepExecution.getVersion() == null, "stepExecution version was not null"); Assert.notNull(stepExecution.getJobExecutionId(), "JobExecution must be saved already."); Map<Long, StepExecution> executions = executionsByJobExecutionId.get(stepExecution.getJobExecutionId()); if (executions == null) { executions = new ConcurrentHashMap<>(); executionsByJobExecutionId.put(stepExecution.getJobExecutionId(), executions); } stepExecution.setId(currentId.incrementAndGet()); stepExecution.incrementVersion(); StepExecution copy = copy(stepExecution); executions.put(stepExecution.getId(), copy); executionsByStepExecutionId.put(stepExecution.getId(), copy); }
/** * Convenience method to clear all the map DAOs globally, removing all * entities. */ public void clear() { jobInstanceDao.clear(); jobExecutionDao.clear(); stepExecutionDao.clear(); executionContextDao.clear(); }
@Override public void saveStepExecutions(Collection<StepExecution> stepExecutions) { Assert.notNull(stepExecutions,"Attempt to save an null collect of step executions"); for (StepExecution stepExecution: stepExecutions) { saveStepExecution(stepExecution); } } }
@Override protected StepExecutionDao getStepExecutionDao() { return new MapStepExecutionDao(); }
@Override public void updateStepExecution(StepExecution stepExecution) { Assert.notNull(stepExecution.getJobExecutionId(), "jobExecution id is null"); Map<Long, StepExecution> executions = executionsByJobExecutionId.get(stepExecution.getJobExecutionId()); Assert.notNull(executions, "step executions for given job execution are expected to be already saved"); final StepExecution persistedExecution = executionsByStepExecutionId.get(stepExecution.getId()); Assert.notNull(persistedExecution, "step execution is expected to be already saved"); synchronized (stepExecution) { if (!persistedExecution.getVersion().equals(stepExecution.getVersion())) { throw new OptimisticLockingFailureException("Attempt to update step execution id=" + stepExecution.getId() + " with wrong version (" + stepExecution.getVersion() + "), where current version is " + persistedExecution.getVersion()); } stepExecution.incrementVersion(); StepExecution copy = new StepExecution(stepExecution.getStepName(), stepExecution.getJobExecution()); copy(stepExecution, copy); executions.put(stepExecution.getId(), copy); executionsByStepExecutionId.put(stepExecution.getId(), copy); } }
/** * Convenience method to clear all the map daos globally, removing all * entities. */ public void clear() { jobInstanceDao.clear(); jobExecutionDao.clear(); stepExecutionDao.clear(); executionContextDao.clear(); }
@Override public void saveStepExecutions(Collection<StepExecution> stepExecutions) { Assert.notNull(stepExecutions,"Attempt to save an null collect of step executions"); for (StepExecution stepExecution: stepExecutions) { saveStepExecution(stepExecution); } } }
@Override protected JobRepository getJobRepository() { return new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(), new MapExecutionContextDao()); }
public void addStepExecutions(JobExecution jobExecution) { Map<Long, StepExecution> executions = executionsByJobExecutionId.get(jobExecution.getId()); if (executions == null || executions.isEmpty()) { return; } List<StepExecution> result = new ArrayList<StepExecution>(executions.values()); Collections.sort(result, new Comparator<Entity>() { public int compare(Entity o1, Entity o2) { return Long.signum(o2.getId() - o1.getId()); } }); List<StepExecution> copy = new ArrayList<StepExecution>(result.size()); for (StepExecution exec : result) { copy.add(copy(exec)); } jobExecution.addStepExecutions(copy); } }
/** * Convenience method to clear all the map DAOs globally, removing all * entities. */ public void clear() { jobInstanceDao.clear(); jobExecutionDao.clear(); stepExecutionDao.clear(); executionContextDao.clear(); }
@Before public void setUp() throws Exception { jobRepository = new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(), new MapExecutionContextDao()); }
@Override public void addStepExecutions(JobExecution jobExecution) { Map<Long, StepExecution> executions = executionsByJobExecutionId.get(jobExecution.getId()); if (executions == null || executions.isEmpty()) { return; } List<StepExecution> result = new ArrayList<StepExecution>(executions.values()); Collections.sort(result, new Comparator<Entity>() { @Override public int compare(Entity o1, Entity o2) { return Long.signum(o2.getId() - o1.getId()); } }); List<StepExecution> copy = new ArrayList<StepExecution>(result.size()); for (StepExecution exec : result) { copy.add(copy(exec)); } jobExecution.addStepExecutions(copy); }
/** * Convenience method to clear all the map DAOs globally, removing all * entities. */ public void clear() { jobInstanceDao.clear(); jobExecutionDao.clear(); stepExecutionDao.clear(); executionContextDao.clear(); }
@Test public void testRepository() throws Exception { SimpleJobRepository repository = new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(), new MapExecutionContextDao()); step.setJobRepository(repository); JobExecution jobExecution = repository.createJobExecution(job.getName(), jobParameters); StepExecution stepExecution = new StepExecution(step.getName(), jobExecution); repository.add(stepExecution); step.execute(stepExecution); assertEquals(1, processed.size()); }