Package org.springframework.batch.item

Examples of org.springframework.batch.item.ExecutionContext


   * @param split the split
   * @return the execution context
   * @throws IOException Signals that an I/O exception has occurred.
   */
  protected ExecutionContext createExecutionContext(Path path, Split split) throws IOException {
    ExecutionContext context = new ExecutionContext();
    context.putString(getKeyFileName(), path.toUri().getPath());
    context.putLong(getKeySplitStart(), split.getStart());
    context.putLong(getKeySplitLength(), split.getLength());
    if (split instanceof SplitLocation) {
      context.putString(getKeySplitLocations(), StringUtils.collectionToCommaDelimitedString(Arrays
          .asList(((SplitLocation) split).getLocations())));
    }
    return context;
  }
View Full Code Here


    DataStoreReader<String> reader = new TextFileReader(configuration, path, null, null, null);
    DataStoreItemReader<String> itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());

    ExecutionContext context = new ExecutionContext();
    context.putLong(DataStoreItemReader.READ_POSITION, 150);
    itemReader.open(context);

    int count = 0;
    while (itemReader.read() != null) {
      count++;
View Full Code Here

        assertEquals(secondStepExec, jobRepository.getLastStepExecution(secondJobExec.getJobInstance(), step.getName()));
    }

    @Test
    public void testSaveExecutionContext() throws Exception {
        ExecutionContext ctx = new ExecutionContext();
        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);
View Full Code Here

    DataStoreReader<String> reader = new TextFileReader(configuration, path, null, null, null);
    DataStoreItemReader<String> itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());

    ExecutionContext context = new ExecutionContext();
    context.putLong(DataStoreItemReader.READ_POSITION, 300);
    itemReader.open(context);

    int count = 0;
    while (itemReader.read() != null) {
      count++;
View Full Code Here

    DataStoreReader<String> reader = new TextFileReader(configuration, path, null, null, null);
    DataStoreItemReader<String> itemReader = new DataStoreItemReader<String>();
    itemReader.setDataStoreReader(reader);
    itemReader.setLineDataMapper(new PassThroughLineDataMapper());

    ExecutionContext context = new ExecutionContext();
    context.putLong(DataStoreItemReader.READ_POSITION, 301);
    itemReader.open(context);
  }
View Full Code Here

    while (itemReader.read() != null) {
      count++;
    }
    assertThat(count, is(300));

    ExecutionContext context = new ExecutionContext();
    itemReader.update(context);
    assertThat(context.getLong(DataStoreItemReader.READ_POSITION), is(300l));
  }
View Full Code Here

        // should we throw error if null?
        map.put(key, value);
      }
    }

    return new ExecutionContext(map);
  }
View Full Code Here

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

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

    return stepExecution;
  }
View Full Code Here

      StepExecution convertStepExecutionType = convertStepExecutionType(stepExecutionType);
      stepExecutions.add(convertStepExecutionType);
    }
    jobExecution.addStepExecutions(stepExecutions);

    ExecutionContext executionContext = convertExecutionContextType(type.executionContext);

    jobExecution.setExecutionContext(executionContext);

    return jobExecution;
  }
View Full Code Here

  private static void saveJobStats(Job job, StepExecution stepExecution) {
    if (stepExecution == null) {
      return;
    }
    ExecutionContext executionContext = stepExecution.getExecutionContext();
    String statusPrefix = "Job Status::";
    executionContext.put(statusPrefix + "ID", JobUtils.getJobId(job).toString());
    executionContext.put(statusPrefix + "Name", job.getJobName());
    executionContext.put(statusPrefix + "Tracking URL", job.getTrackingURL());
    executionContext.put(statusPrefix + "State", JobUtils.getStatus(job).toString());
    try {
      for (String cgName : job.getCounters().getGroupNames()) {
        CounterGroup group = job.getCounters().getGroup(cgName);
        Iterator<Counter> ci = group.iterator();
        while (ci.hasNext()) {
          Counter c = ci.next();
          executionContext.put(group.getDisplayName().trim() + "::" + c.getDisplayName().trim(), c.getValue());
        }
      }
    } catch (Exception ignore) {}
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.ExecutionContext

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.