Package org.springframework.batch.core.partition

Examples of org.springframework.batch.core.partition.StepExecutionSplitter


  public void testHandleNoReply() throws Exception {
    //execute with no default set
    messageChannelPartitionHandler = new MessageChannelPartitionHandler();
    //mock
    StepExecution masterStepExecution = mock(StepExecution.class);
    StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
    MessagingOperations operations = mock(MessagingOperations.class);
    Message message = mock(Message.class);
    //when
    when(message.getPayload()).thenReturn(Collections.emptyList());
    when(operations.receive((PollableChannel) anyObject())).thenReturn(message);
View Full Code Here


  public void testHandleWithReplyChannel() throws Exception {
    //execute with no default set
    messageChannelPartitionHandler = new MessageChannelPartitionHandler();
    //mock
    StepExecution masterStepExecution = mock(StepExecution.class);
    StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
    MessagingOperations operations = mock(MessagingOperations.class);
    Message message = mock(Message.class);
    PollableChannel replyChannel = mock(PollableChannel.class);
    //when
    when(message.getPayload()).thenReturn(Collections.emptyList());
View Full Code Here

  public void testNoPartitions() throws Exception {
    //execute with no default set
    messageChannelPartitionHandler = new MessageChannelPartitionHandler();
    //mock
    StepExecution masterStepExecution = mock(StepExecution.class);
    StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);

    //execute
    Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, masterStepExecution);
    //verify
    assertNull(executions);
View Full Code Here

  public void testHandleNoReply() throws Exception {
    //execute with no default set
    messageChannelPartitionHandler = new MessageChannelPartitionHandler();
    //mock
    StepExecution masterStepExecution = mock(StepExecution.class);
    StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
    MessagingTemplate operations = mock(MessagingTemplate.class);
    Message message = mock(Message.class);
    //when
    HashSet<StepExecution> stepExecutions = new HashSet<StepExecution>();
    stepExecutions.add(new StepExecution("step1", new JobExecution(5l)));
    when(stepExecutionSplitter.split((StepExecution) anyObject(), eq(1))).thenReturn(stepExecutions);
    when(message.getPayload()).thenReturn(Collections.emptyList());
    when(operations.receive((PollableChannel) anyObject())).thenReturn(message);
    //set
    messageChannelPartitionHandler.setMessagingOperations(operations);
View Full Code Here

  public void testHandleWithReplyChannel() throws Exception {
    //execute with no default set
    messageChannelPartitionHandler = new MessageChannelPartitionHandler();
    //mock
    StepExecution masterStepExecution = mock(StepExecution.class);
    StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
    MessagingTemplate operations = mock(MessagingTemplate.class);
    Message message = mock(Message.class);
    PollableChannel replyChannel = mock(PollableChannel.class);
    //when
    HashSet<StepExecution> stepExecutions = new HashSet<StepExecution>();
    stepExecutions.add(new StepExecution("step1", new JobExecution(5l)));
    when(stepExecutionSplitter.split((StepExecution) anyObject(), eq(1))).thenReturn(stepExecutions);
    when(message.getPayload()).thenReturn(Collections.emptyList());
    when(operations.receive(replyChannel)).thenReturn(message);
    //set
    messageChannelPartitionHandler.setMessagingOperations(operations);
    messageChannelPartitionHandler.setReplyChannel(replyChannel);
View Full Code Here

  public void messageReceiveTimeout() throws Exception {
    //execute with no default set
    messageChannelPartitionHandler = new MessageChannelPartitionHandler();
    //mock
    StepExecution masterStepExecution = mock(StepExecution.class);
    StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
    MessagingTemplate operations = mock(MessagingTemplate.class);
    Message message = mock(Message.class);
    //when
    HashSet<StepExecution> stepExecutions = new HashSet<StepExecution>();
    stepExecutions.add(new StepExecution("step1", new JobExecution(5l)));
    when(stepExecutionSplitter.split((StepExecution) anyObject(), eq(1))).thenReturn(stepExecutions);
    when(message.getPayload()).thenReturn(Collections.emptyList());
    //set
    messageChannelPartitionHandler.setMessagingOperations(operations);

    //execute
View Full Code Here

          partitionStepExecutions = applyPartitionPlan(stepExecution, plan, true);
        }

      } else {
        StepExecutionSplitter stepSplitter = new JsrStepExecutionSplitter(jobRepository, allowStartIfComplete, stepExecution.getStepName(), true);
        partitionStepExecutions = stepSplitter.split(stepExecution, partitions);
      }
    } else {
      if(mapper != null) {
        PartitionPlan plan = mapper.mapPartitions();
        partitionStepExecutions = applyPartitionPlan(stepExecution, plan, true);
      } else {
        StepExecutionSplitter stepSplitter = new JsrStepExecutionSplitter(jobRepository, allowStartIfComplete, stepExecution.getStepName(), true);
        partitionStepExecutions = stepSplitter.split(stepExecution, partitions);
      }
    }
    return partitionStepExecutions;
  }
View Full Code Here

    return partitionStepExecutions;
  }

  private Set<StepExecution> applyPartitionPlan(StepExecution stepExecution,
      PartitionPlan plan, boolean restoreState) throws JobExecutionException {
    StepExecutionSplitter stepSplitter;
    Set<StepExecution> partitionStepExecutions;
    if(plan.getThreads() > 0) {
      threads = plan.getThreads();
    } else if(plan.getPartitions() > 0) {
      threads = plan.getPartitions();
    } else {
      throw new IllegalArgumentException("Either a number of threads or partitions are required");
    }

    stepExecution.getExecutionContext().put("partitionPlanState", new PartitionPlanState(plan));

    stepSplitter = new JsrStepExecutionSplitter(jobRepository, allowStartIfComplete, stepExecution.getStepName(), restoreState);
    partitionStepExecutions = stepSplitter.split(stepExecution, plan.getPartitions());
    registerPartitionProperties(partitionStepExecutions, plan);
    return partitionStepExecutions;
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.partition.StepExecutionSplitter

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.