Search in sources :

Example 6 with BatchPlanStep

use of org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep in project openflowplugin by opendaylight.

the class SalFlatBatchServiceImplTest method testPrepareBatchPlan_success.

@Test
public void testPrepareBatchPlan_success() throws Exception {
    final FlatBatchAddFlow flatBatchAddFlow = new FlatBatchAddFlowBuilder().setFlowId(new FlowId("f1")).build();
    final BatchPlanStep batchPlanStep = new BatchPlanStep(BatchStepType.FLOW_ADD);
    batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow, flatBatchAddFlow));
    final List<BatchPlanStep> batchPlan = Lists.newArrayList(batchPlanStep);
    final List<BatchStepJob> batchChain = salFlatBatchService.prepareBatchChain(batchPlan, NODE_REF, true);
    Assert.assertEquals(1, batchChain.size());
    Mockito.when(salFlowsBatchService.addFlowsBatch(Matchers.<AddFlowsBatchInput>any())).thenReturn(RpcResultBuilder.success(new AddFlowsBatchOutputBuilder().build()).buildFuture());
    final Future<RpcResult<ProcessFlatBatchOutput>> rpcResultFuture = salFlatBatchService.executeBatchPlan(batchChain);
    Assert.assertTrue(rpcResultFuture.isDone());
    final RpcResult<ProcessFlatBatchOutput> rpcResult = rpcResultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(0, rpcResult.getErrors().size());
    Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size());
    Mockito.verify(salFlowsBatchService).addFlowsBatch(Matchers.<AddFlowsBatchInput>any());
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) BatchStepJob(org.opendaylight.openflowplugin.impl.services.batch.BatchStepJob) FlatBatchAddFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BatchPlanStep(org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep) AddFlowsBatchOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchOutputBuilder) FlatBatchAddFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput) Test(org.junit.Test)

Example 7 with BatchPlanStep

use of org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep in project openflowplugin by opendaylight.

the class FlatBatchUtil method assembleBatchPlan.

public static List<BatchPlanStep> assembleBatchPlan(List<Batch> batches) {
    final List<BatchPlanStep> plan = new ArrayList<>();
    BatchPlanStep planStep;
    for (Batch batch : batches) {
        final BatchStepType nextStepType = detectBatchStepType(batch.getBatchChoice());
        planStep = new BatchPlanStep(nextStepType);
        planStep.getTaskBag().addAll(extractBatchData(planStep.getStepType(), batch.getBatchChoice()));
        if (!planStep.isEmpty()) {
            plan.add(planStep);
        }
    }
    return plan;
}
Also used : Batch(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch) ArrayList(java.util.ArrayList) BatchPlanStep(org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep) BatchStepType(org.opendaylight.openflowplugin.impl.services.batch.BatchStepType)

Aggregations

BatchPlanStep (org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep)7 Test (org.junit.Test)4 BatchStepJob (org.opendaylight.openflowplugin.impl.services.batch.BatchStepJob)4 ProcessFlatBatchOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 ArrayList (java.util.ArrayList)2 BatchStepType (org.opendaylight.openflowplugin.impl.services.batch.BatchStepType)2 Batch (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch)2 FlatBatchAddFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow)2 FlatBatchAddFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder)2 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)2 AddFlowsBatchOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchOutput)2 AddFlowsBatchOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchOutputBuilder)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 List (java.util.List)1 Future (java.util.concurrent.Future)1