Search in sources :

Example 1 with BatchFailedFlowsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput in project openflowplugin by opendaylight.

the class SalFlowsBatchServiceImpl method updateFlowsBatch.

@Override
public Future<RpcResult<UpdateFlowsBatchOutput>> updateFlowsBatch(final UpdateFlowsBatchInput input) {
    LOG.trace("Updating flows @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchUpdateFlows().size());
    final ArrayList<ListenableFuture<RpcResult<UpdateFlowOutput>>> resultsLot = new ArrayList<>();
    for (BatchUpdateFlows batchFlow : input.getBatchUpdateFlows()) {
        final UpdateFlowInput updateFlowInput = new UpdateFlowInputBuilder(input).setOriginalFlow(new OriginalFlowBuilder(batchFlow.getOriginalBatchedFlow()).build()).setUpdatedFlow(new UpdatedFlowBuilder(batchFlow.getUpdatedBatchedFlow()).build()).setFlowRef(createFlowRef(input.getNode(), batchFlow)).setNode(input.getNode()).build();
        resultsLot.add(JdkFutureAdapters.listenInPoolThread(salFlowService.updateFlow(updateFlowInput)));
    }
    final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult = Futures.transform(Futures.successfulAsList(resultsLot), FlowUtil.<UpdateFlowOutput>createCumulatingFunction(input.getBatchUpdateFlows()), MoreExecutors.directExecutor());
    ListenableFuture<RpcResult<UpdateFlowsBatchOutput>> updateFlowsBulkFuture = Futures.transform(commonResult, FlowUtil.FLOW_UPDATE_TRANSFORM, MoreExecutors.directExecutor());
    if (input.isBarrierAfter()) {
        updateFlowsBulkFuture = BarrierUtil.chainBarrier(updateFlowsBulkFuture, input.getNode(), transactionService, FlowUtil.FLOW_UPDATE_COMPOSING_TRANSFORM);
    }
    return updateFlowsBulkFuture;
}
Also used : BatchFailedFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BatchUpdateFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows) UpdateFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder) UpdateFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) UpdateFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput) OriginalFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder) UpdatedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder)

Example 2 with BatchFailedFlowsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput in project openflowplugin by opendaylight.

the class SalFlowsBatchServiceImpl method removeFlowsBatch.

@Override
public Future<RpcResult<RemoveFlowsBatchOutput>> removeFlowsBatch(final RemoveFlowsBatchInput input) {
    LOG.trace("Removing flows @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchRemoveFlows().size());
    final ArrayList<ListenableFuture<RpcResult<RemoveFlowOutput>>> resultsLot = new ArrayList<>();
    for (BatchFlowInputGrouping batchFlow : input.getBatchRemoveFlows()) {
        final RemoveFlowInput removeFlowInput = new RemoveFlowInputBuilder(batchFlow).setFlowRef(createFlowRef(input.getNode(), batchFlow)).setNode(input.getNode()).build();
        resultsLot.add(JdkFutureAdapters.listenInPoolThread(salFlowService.removeFlow(removeFlowInput)));
    }
    final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult = Futures.transform(Futures.successfulAsList(resultsLot), FlowUtil.<RemoveFlowOutput>createCumulatingFunction(input.getBatchRemoveFlows()), MoreExecutors.directExecutor());
    ListenableFuture<RpcResult<RemoveFlowsBatchOutput>> removeFlowsBulkFuture = Futures.transform(commonResult, FlowUtil.FLOW_REMOVE_TRANSFORM, MoreExecutors.directExecutor());
    if (input.isBarrierAfter()) {
        removeFlowsBulkFuture = BarrierUtil.chainBarrier(removeFlowsBulkFuture, input.getNode(), transactionService, FlowUtil.FLOW_REMOVE_COMPOSING_TRANSFORM);
    }
    return removeFlowsBulkFuture;
}
Also used : RemoveFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput) BatchFlowInputGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowInputGrouping) RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) BatchFailedFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RemoveFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder)

Example 3 with BatchFailedFlowsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput in project openflowplugin by opendaylight.

the class SalFlowsBatchServiceImpl method addFlowsBatch.

@Override
public Future<RpcResult<AddFlowsBatchOutput>> addFlowsBatch(final AddFlowsBatchInput input) {
    LOG.trace("Adding flows @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchAddFlows().size());
    final ArrayList<ListenableFuture<RpcResult<AddFlowOutput>>> resultsLot = new ArrayList<>();
    for (BatchFlowInputGrouping batchFlow : input.getBatchAddFlows()) {
        final AddFlowInput addFlowInput = new AddFlowInputBuilder(batchFlow).setFlowRef(createFlowRef(input.getNode(), batchFlow)).setNode(input.getNode()).build();
        resultsLot.add(JdkFutureAdapters.listenInPoolThread(salFlowService.addFlow(addFlowInput)));
    }
    final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult = Futures.transform(Futures.successfulAsList(resultsLot), FlowUtil.<AddFlowOutput>createCumulatingFunction(input.getBatchAddFlows()), MoreExecutors.directExecutor());
    ListenableFuture<RpcResult<AddFlowsBatchOutput>> addFlowsBulkFuture = Futures.transform(commonResult, FlowUtil.FLOW_ADD_TRANSFORM, MoreExecutors.directExecutor());
    if (input.isBarrierAfter()) {
        addFlowsBulkFuture = BarrierUtil.chainBarrier(addFlowsBulkFuture, input.getNode(), transactionService, FlowUtil.FLOW_ADD_COMPOSING_TRANSFORM);
    }
    return addFlowsBulkFuture;
}
Also used : AddFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput) BatchFlowInputGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowInputGrouping) BatchFailedFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput) ArrayList(java.util.ArrayList) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)

Example 4 with BatchFailedFlowsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput in project openflowplugin by opendaylight.

the class FlatBatchFlowAdapters method wrapBatchFlowFailuresForFlat.

private static <T extends BatchFlowOutputListGrouping> List<BatchFailure> wrapBatchFlowFailuresForFlat(final RpcResult<T> input, final int stepOffset) {
    final List<BatchFailure> batchFailures = new ArrayList<>();
    if (input.getResult().getBatchFailedFlowsOutput() != null) {
        for (BatchFailedFlowsOutput stepOutput : input.getResult().getBatchFailedFlowsOutput()) {
            final BatchFailure batchFailure = new BatchFailureBuilder().setBatchOrder(stepOffset + stepOutput.getBatchOrder()).setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder().setFlowId(stepOutput.getFlowId()).build()).build();
            batchFailures.add(batchFailure);
        }
    }
    return batchFailures;
}
Also used : BatchFailure(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure) BatchFailureBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder) BatchFailedFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput) ArrayList(java.util.ArrayList) FlatBatchFailureFlowIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureFlowIdCaseBuilder)

Aggregations

ArrayList (java.util.ArrayList)4 BatchFailedFlowsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 BatchFlowInputGrouping (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowInputGrouping)2 BatchFailure (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure)1 BatchFailureBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder)1 FlatBatchFailureFlowIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureFlowIdCaseBuilder)1 AddFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)1 AddFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)1 AddFlowOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput)1 RemoveFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)1 RemoveFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder)1 RemoveFlowOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput)1 UpdateFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)1 UpdateFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder)1 UpdateFlowOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput)1 OriginalFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder)1 UpdatedFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder)1 BatchUpdateFlows (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows)1