Search in sources :

Example 6 with UpdatedFlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder 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 7 with UpdatedFlowBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder in project openflowplugin by opendaylight.

the class FlowConvertorTest method testOnlyModifyStrictCommand.

/**
 * Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testOnlyModifyStrictCommand() {
    UpdatedFlowBuilder flowBuilder = new UpdatedFlowBuilder();
    flowBuilder.setStrict(true);
    UpdatedFlow flow = flowBuilder.build();
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    data.setDatapathId(new BigInteger("42"));
    List<FlowModInputBuilder> flowMod = convert(flow, data);
    Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());
    Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());
}
Also used : UpdatedFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) BigInteger(java.math.BigInteger) FlowModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder) UpdatedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder) Test(org.junit.Test)

Aggregations

UpdatedFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder)7 OriginalFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder)5 UpdateFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder)3 UpdatedFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow)3 FlowRef (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 BigInteger (java.math.BigInteger)2 Test (org.junit.Test)2 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)2 UpdateFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)2 OriginalFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow)2 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)1 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)1 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)1 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)1 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)1