Examples of StepExecution


Examples of org.springframework.batch.core.StepExecution

  private BaseResponseObject handleUpdateExecutionContext(UpdateExecutionContextReq request) {
    UpdateExecutionContextRes response = null;
    try {
      if(request.stepExecution != null) {
        StepExecution stepExecution = JobRepositoryRpcFactory.convertStepExecutionType(request.stepExecution);
        jobRepository.updateExecutionContext(stepExecution);
      } else if(request.jobExecution != null) {
        JobExecution jobExecution = JobRepositoryRpcFactory.convertJobExecutionType(request.jobExecution);
        jobRepository.updateExecutionContext(jobExecution);
      }
View Full Code Here

Examples of org.springframework.batch.core.StepExecution

        job.setRestartable(true);
        StepSupport step = new StepSupport("restartedStep");

        // first execution
        JobExecution firstJobExec = jobRepository.createJobExecution(job.getName(), jobParameters);
        StepExecution firstStepExec = new StepExecution(step.getName(), firstJobExec);
        jobRepository.add(firstStepExec);

        assertEquals(1, jobRepository.getStepExecutionCount(firstJobExec.getJobInstance(), step.getName()));
        assertEquals(firstStepExec, jobRepository.getLastStepExecution(firstJobExec.getJobInstance(), step.getName()));

        // first execution failed
        firstJobExec.setStartTime(new Date(4));
        firstStepExec.setStartTime(new Date(5));
        firstStepExec.setStatus(BatchStatus.FAILED);
        firstStepExec.setEndTime(new Date(6));
        jobRepository.update(firstStepExec);
        firstJobExec.setStatus(BatchStatus.FAILED);
        firstJobExec.setEndTime(new Date(7));
        jobRepository.update(firstJobExec);

        // second execution
        JobExecution secondJobExec = jobRepository.createJobExecution(job.getName(), jobParameters);
        StepExecution secondStepExec = new StepExecution(step.getName(), secondJobExec);
        jobRepository.add(secondStepExec);

        assertEquals(2, jobRepository.getStepExecutionCount(secondJobExec.getJobInstance(), step.getName()));
        assertEquals(secondStepExec, jobRepository.getLastStepExecution(secondJobExec.getJobInstance(), step.getName()));
    }
View Full Code Here

Examples of org.springframework.batch.core.StepExecution

        ctx.putLong("crashedPosition", 7);
        JobExecution jobExec = jobRepository.createJobExecution(job.getName(), jobParameters);
        jobExec.setStartTime(new Date(0));
        jobExec.setExecutionContext(ctx);
        Step step = new StepSupport("step1");
        StepExecution stepExec = new StepExecution(step.getName(), jobExec);
        stepExec.setExecutionContext(ctx);

        jobRepository.add(stepExec);

        StepExecution retrievedStepExec = jobRepository.getLastStepExecution(jobExec.getJobInstance(), step.getName());
        assertEquals(stepExec, retrievedStepExec);
        assertEquals(ctx, retrievedStepExec.getExecutionContext());

    }
View Full Code Here

Examples of org.springframework.batch.core.StepExecution

   * @param type the step execution type
   * @return converted step execution
   */
  public static StepExecution convertStepExecutionType(StepExecutionType type) {
    JobExecution jobExecution = convertJobExecutionType(type.jobExecution);
    StepExecution stepExecution = type.id != null ? new StepExecution(type.stepName, jobExecution, type.id)
        : new StepExecution(type.stepName, jobExecution);
    stepExecution.setVersion(type.version);
    stepExecution.setStatus(type.status);
    stepExecution.setExitStatus(new ExitStatus(type.exitStatus));
    stepExecution.setReadCount(type.readCount);
    stepExecution.setWriteCount(type.writeCount);
    stepExecution.setCommitCount(type.commitCount);
    stepExecution.setRollbackCount(type.rollbackCount);
    stepExecution.setReadSkipCount(type.readSkipCount);
    stepExecution.setProcessSkipCount(type.processSkipCount);
    stepExecution.setWriteSkipCount(type.writeSkipCount);

    stepExecution.setStartTime(nullsafeToDate(type.startTime));
    stepExecution.setEndTime(nullsafeToDate(type.endTime));
    stepExecution.setLastUpdated(nullsafeToDate(type.lastUpdated));

    if(type.terminateOnly.booleanValue()) {
      stepExecution.setTerminateOnly();
    }
    stepExecution.setFilterCount(type.filterCount);

    ExecutionContext executionContext = convertExecutionContextType(type.executionContext);
    stepExecution.setExecutionContext(executionContext);

    return stepExecution;
  }
View Full Code Here

Examples of org.springframework.batch.core.StepExecution

    jobExecution.setLastUpdated(nullsafeToDate(type.lastUpdated));
    jobExecution.setExitStatus(new ExitStatus(type.exitStatus));

    List<StepExecution> stepExecutions = new ArrayList<StepExecution>();
    for(StepExecutionType stepExecutionType : type.stepExecutions) {
      StepExecution convertStepExecutionType = convertStepExecutionType(stepExecutionType);
      stepExecutions.add(convertStepExecutionType);
    }
    jobExecution.addStepExecutions(stepExecutions);

    ExecutionContext executionContext = convertExecutionContextType(type.executionContext);
View Full Code Here

Examples of org.springframework.batch.core.StepExecution


  public RepeatStatus execute(final StepContribution contribution, ChunkContext chunkContext) throws Exception {

    StepContext context = StepSynchronizationManager.getContext();
    final StepExecution stepExecution = (context != null) ? context.getStepExecution() : null;

    final AtomicBoolean done = new AtomicBoolean(false);

    final JobListener jobListener = new JobListener() {

      @Override
      public Object beforeAction() {
        // double check the underlying thread to see whether it is aware of a step execution
        if (StepSynchronizationManager.getContext() == null) {
          StepSynchronizationManager.register(stepExecution);
          return Boolean.TRUE;
        }
        return Boolean.FALSE;
      }

      @Override
      public void afterAction(Object state) {
        if (Boolean.TRUE.equals(state)) {
          StepSynchronizationManager.close();
        }
        done.set(true);
        synchronized (done) {
          done.notify();
        }
      }

      @Override
      public void jobKilled(Job job) {
        saveCounters(job, contribution);
        saveJobStats(job, stepExecution);
      }

      @Override
      public void jobFinished(Job job) {
        saveCounters(job, contribution);
        saveJobStats(job, stepExecution);
      }
    };

    startJobs(jobListener);

    boolean stopped = false;
    // check status (if we have to wait)
    if (isWaitForCompletion()) {
      while (!done.get() && !stopped) {
        if (stepExecution.isTerminateOnly()) {
          log.info("Cancelling job tasklet");
          stopped = true;
          stopJobs(jobListener);

          // wait for stopping to properly occur
View Full Code Here

Examples of org.springframework.batch.core.StepExecution

    if(log.isDebugEnabled()) {
      log.debug("Requesting StepExecution: " + jobExecutionId + " / " + stepExecutionId);
    }

    StepExecution stepExecution = getJobExplorer().getStepExecution(jobExecutionId, stepExecutionId);
    if (stepExecution == null) {
      throw new NoSuchStepException("No StepExecution could be located for this request: ");
    }

    if(log.isDebugEnabled()) {
      log.debug("Got StepExecution: " + stepExecution);
      log.debug("Locating Step: " + stepName);
    }

    Step step = getStepLocator().getStep(stepName);
    if(log.isDebugEnabled()) {
      log.debug("Located step: " + step);
    }

    if (step == null) {
      throw new NoSuchStepException(String.format("No Step with name [%s] could be located.", stepName));
    }

    try {
      if(log.isDebugEnabled()) {
        log.debug("Executing step: " + step + " / " + stepExecution);
      }
      step.execute(stepExecution);
    } catch (JobInterruptedException e) {
      log.error("error executing step 1", e);
      stepExecution.setStatus(BatchStatus.STOPPED);
    } catch (Throwable e) {
      log.error("error executing step 2", e);
      stepExecution.addFailureException(e);
      stepExecution.setStatus(BatchStatus.FAILED);
    }

    if(log.isDebugEnabled()) {
      log.info("Finished remote step stepExecution=[" + stepExecution + "]");
    }
View Full Code Here

Examples of org.springframework.batch.core.StepExecution

    // find a well distributed union of hosts.
    ContainerAllocateData containerAllocateData = new ContainerAllocateData();
    int countNeeded = 0;
    HashSet<String> hostUnion = new HashSet<String>();
    for (Entry<StepExecution, ContainerRequestHint> entry : resourceRequests.entrySet()) {
      StepExecution se = entry.getKey();
      ContainerRequestHint crd = entry.getValue();

      requestData.put(se, crd);
      remoteStepNames.put(se, remoteStepName);
View Full Code Here

Examples of org.springframework.batch.core.StepExecution

    List<JobExecution> startJobs = JobsTrigger.startJobs(ctx, params);
    assertFalse(startJobs.isEmpty());

    // check records
    Collection<StepExecution> steps = startJobs.get(0).getStepExecutions();
    StepExecution mrStep = null;
    for (StepExecution stepExecution : steps) {
      if ("do-mr".equals(stepExecution.getStepName())) {
        assertTrue(stepExecution.getReadCount() > 0);
        mrStep = stepExecution;
      }
View Full Code Here

Examples of org.springframework.batch.core.StepExecution

    @Override
    public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
      SimpleAsyncTaskExecutor asyncTX = new SimpleAsyncTaskExecutor();

      StepContext context = StepSynchronizationManager.getContext();
      final StepExecution stepExecution = (context != null) ? context.getStepExecution() : null;

      final AtomicBoolean done = new AtomicBoolean(false);

      final Thread[] th = new Thread[1];
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.