本文整理汇总了Java中org.springframework.batch.core.Step类的典型用法代码示例。如果您正苦于以下问题:Java Step类的具体用法?Java Step怎么用?Java Step使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Step类属于org.springframework.batch.core包,在下文中一共展示了Step类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: personEtl
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Bean
Job personEtl(JobBuilderFactory jobBuilderFactory,
StepBuilderFactory stepBuilderFactory,
FlatFileItemReader<Person> reader,
JdbcBatchItemWriter<Person> writer
) {
Step step = stepBuilderFactory.get("file-to-database")
.<Person, Person>chunk(5)
.reader(reader)
.writer(writer)
.build();
return jobBuilderFactory.get("etl")
.start(step)
.build();
}
示例2: importTicketStep
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Bean
public Step importTicketStep(final StepBuilderFactory stepBuilderFactory,
@Qualifier("jpaTransactionManagerForBatch")
final PlatformTransactionManager jpaTransactionManager,
final @Value("${ticket.chunk.size}") int chunkSize,
final ItemReader<Ticket> ticketReader,
final ItemWriter<Ticket> ticketWriter,
final ItemProcessor<Ticket, Ticket> importTicketProcessor) {
return stepBuilderFactory.get("importTicketStep")
.<Ticket, Ticket>chunk(chunkSize)
.reader(ticketReader)
.processor(importTicketProcessor)
.writer(ticketWriter)
.transactionManager(jpaTransactionManager)
.build();
}
示例3: chunkStep
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Bean
public Step chunkStep() {
return stepCreators.get("chunkStep")
.<Department, Department>chunk(5)
.reader(reader())
.processor(processor())
.writer(writer())
.build();
}
示例4: handleTransition
import org.springframework.batch.core.Step; //导入依赖的package包/类
private void handleTransition(Deque<Flow> executionDeque,
TaskAppNode taskAppNode) {
String beanName = getBeanName(taskAppNode);
Step currentStep = this.context.getBean(beanName, Step.class);
FlowBuilder<Flow> builder = new FlowBuilder<Flow>(beanName)
.from(currentStep);
boolean wildCardPresent = false;
for (TransitionNode transitionNode : taskAppNode.getTransitions()) {
String transitionBeanName = getBeanName(transitionNode);
wildCardPresent = transitionNode.getStatusToCheck().equals(WILD_CARD);
Step transitionStep = this.context.getBean(transitionBeanName,
Step.class);
builder.on(transitionNode.getStatusToCheck()).to(transitionStep)
.from(currentStep);
}
if (wildCardPresent && !executionDeque.isEmpty()) {
throw new IllegalStateException(
"Invalid flow following '*' specifier.");
}
else {
//if there are nodes are in the execution Deque. Make sure that
//they are processed as a target of the wildcard instead of the
//whole transition.
if (!executionDeque.isEmpty()) {
Deque<Flow> resultDeque = new LinkedList<>();
handleFlowForSegment(executionDeque, resultDeque);
builder.on(WILD_CARD).to(resultDeque.pop()).from(currentStep);
}
}
executionDeque.push(builder.end());
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:38,代码来源:ComposedRunnerJobFactory.java
示例5: getObject
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Override
public Step getObject() throws Exception {
TaskLauncherTasklet taskLauncherTasklet = new TaskLauncherTasklet(
this.taskOperations, taskConfigurer.getTaskExplorer(),
this.composedTaskProperties, this.taskName);
taskLauncherTasklet.setArguments(this.arguments);
taskLauncherTasklet.setProperties(this.taskSpecificProps);
String stepName = this.taskName;
return this.steps.get(stepName)
.tasklet(taskLauncherTasklet)
.transactionAttribute(getTransactionAttribute())
.listener(this.composedTaskStepExecutionListener)
.build();
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:18,代码来源:ComposedTaskRunnerStepFactory.java
示例6: step1
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Bean
public Step step1() {
return stepBuilderFactory.get("step1")
.tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
// get path of file in src/main/resources
Path xmlDocPath = Paths.get(getFilePath());
// process the file to json
String json = processXML2JSON(xmlDocPath);
// insert json into mongodb
insertToMongo(json);
return RepeatStatus.FINISHED;
}
}).build();
}
示例7: discreteJob
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Bean
public Job discreteJob() {
AbstractJob job = new AbstractJob("discreteRegisteredJob") {
@Override
public Collection<String> getStepNames() {
return Collections.emptySet();
}
@Override
public Step getStep(String stepName) {
return null;
}
@Override
protected void doExecute(JobExecution execution)
throws JobExecutionException {
execution.setStatus(BatchStatus.COMPLETED);
}
};
job.setJobRepository(this.jobRepository);
return job;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:24,代码来源:BatchAutoConfigurationTests.java
示例8: step1
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Bean
@JobScope
public Step step1(
StepBuilderFactory stepBuilderFactory,
DatabaseClientProvider databaseClientProvider,
@Value("#{jobParameters['input_file_path']}") String inputFilePath,
@Value("#{jobParameters['graph_name']}") String graphName) {
RdfTripleItemReader<Map<String, Object>> reader = new RdfTripleItemReader<Map<String, Object>>();
reader.setFileName(inputFilePath);
RdfTripleItemWriter writer = new RdfTripleItemWriter(databaseClientProvider.getDatabaseClient(), graphName);
return stepBuilderFactory.get("step1")
.<Map<String, Object>, Map<String, Object>>chunk(10)
.reader(reader)
.writer(writer)
.build();
}
示例9: createInventoryEntryStep
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Bean
public Step createInventoryEntryStep(final BlockingSphereClient sphereClient,
final ItemReader<ProductProjection> inventoryEntryReader,
final ItemProcessor<ProductProjection, List<InventoryEntryDraft>> inventoryEntryProcessor,
final ItemWriter<List<InventoryEntryDraft>> inventoryEntryWriter) {
final StepBuilder stepBuilder = stepBuilderFactory.get("createInventoryEntryStep");
return stepBuilder
.<ProductProjection, List<InventoryEntryDraft>>chunk(1)
.reader(inventoryEntryReader)
.processor(inventoryEntryProcessor)
.writer(inventoryEntryWriter)
.faultTolerant()
.skip(ErrorResponseException.class)
.skipLimit(1)
.build();
}
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:17,代码来源:InventoryEntryCreationJobConfiguration.java
示例10: deleteProductsStep
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Bean
protected Step deleteProductsStep(final BlockingSphereClient sphereClient,
final ItemWriter<Versioned<Product>> productDeleteWriter) {
return stepBuilderFactory.get("deleteProductsStep")
.<Product, Product>chunk(50)
.reader(ItemReaderFactory.sortedByIdQueryReader(sphereClient, ProductQuery.of()))
.writer(productDeleteWriter)
.build();
}
示例11: testMissingStepExecution
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Test
public void testMissingStepExecution() throws Exception {
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("foo");
when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"foo", "bar", "baz"});
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
try {
this.handler.run();
}
catch (NoSuchStepException nsse) {
assertEquals("No StepExecution could be located for step execution id 2 within job execution 1", nsse.getMessage());
}
}
示例12: testRunSuccessful
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Test
public void testRunSuccessful() throws Exception {
StepExecution workerStep = new StepExecution("workerStep", new JobExecution(1L), 2L);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"workerStep", "foo", "bar"});
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
when(this.jobExplorer.getStepExecution(1L, 2L)).thenReturn(workerStep);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBean("workerStep", Step.class)).thenReturn(this.step);
handler.run();
verify(this.step).execute(workerStep);
verifyZeroInteractions(this.jobRepository);
}
示例13: testJobInterruptedException
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Test
public void testJobInterruptedException() throws Exception {
StepExecution workerStep = new StepExecution("workerStep", new JobExecution(1L), 2L);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"workerStep", "foo", "bar"});
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
when(this.jobExplorer.getStepExecution(1L, 2L)).thenReturn(workerStep);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBean("workerStep", Step.class)).thenReturn(this.step);
doThrow(new JobInterruptedException("expected")).when(this.step).execute(workerStep);
handler.run();
verify(this.jobRepository).update(this.stepExecutionArgumentCaptor.capture());
assertEquals(BatchStatus.STOPPED, this.stepExecutionArgumentCaptor.getValue().getStatus());
}
示例14: testRuntimeException
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Test
public void testRuntimeException() throws Exception {
StepExecution workerStep = new StepExecution("workerStep", new JobExecution(1L), 2L);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"workerStep", "foo", "bar"});
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
when(this.jobExplorer.getStepExecution(1L, 2L)).thenReturn(workerStep);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBean("workerStep", Step.class)).thenReturn(this.step);
doThrow(new RuntimeException("expected")).when(this.step).execute(workerStep);
handler.run();
verify(this.jobRepository).update(this.stepExecutionArgumentCaptor.capture());
assertEquals(BatchStatus.FAILED, this.stepExecutionArgumentCaptor.getValue().getStatus());
}
示例15: chunkStep
import org.springframework.batch.core.Step; //导入依赖的package包/类
@Bean
public Step chunkStep() {
final int chunkSize = 100;
final ItemProcessor<String, String> processor = (item) -> {
Thread.sleep(100);
return item;
};
final ItemWriter<String> writer = (items) -> {
Thread.sleep(1000);
};
return steps.get("Chunk Step") //
.<String, String> chunk(chunkSize) //
.reader(itemReader()) //
.processor(processor) //
.writer(writer) //
.build();
}