Search in sources :

Example 11 with AddFlowOutput

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

the class FlowForwarderTest method addTest.

@Test
public void addTest() throws Exception {
    Mockito.when(salFlowService.addFlow(addFlowInputCpt.capture())).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().setTransactionId(new TransactionId(BigInteger.ONE)).build()).buildFuture());
    final Future<RpcResult<AddFlowOutput>> addResult = flowForwarder.add(flowPath, flow, flowCapableNodePath);
    Mockito.verify(salFlowService).addFlow(Matchers.<AddFlowInput>any());
    final AddFlowInput flowInput = addFlowInputCpt.getValue();
    Assert.assertEquals(2, flowInput.getTableId().shortValue());
    Assert.assertEquals(emptyMatch, flowInput.getMatch());
    Assert.assertEquals(null, flowInput.getInstructions());
    Assert.assertEquals(nodePath, flowInput.getNode().getValue());
    Assert.assertEquals(flowPath, flowInput.getFlowRef().getValue());
    Assert.assertEquals(null, flowInput.isStrict());
    final RpcResult<AddFlowOutput> addFlowOutputRpcResult = addResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(addFlowOutputRpcResult.isSuccessful());
    final AddFlowOutput resultValue = addFlowOutputRpcResult.getResult();
    Assert.assertEquals(1, resultValue.getTransactionId().getValue().intValue());
}
Also used : AddFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) AddFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder) TransactionId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId) Test(org.junit.Test)

Example 12 with AddFlowOutput

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

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)12 AddFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)8 AddFlowOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput)7 AddFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)6 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 ArrayList (java.util.ArrayList)3 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)3 FlowRef (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef)3 ExecutionException (java.util.concurrent.ExecutionException)2 Test (org.junit.Test)2 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)2 FlowTableRef (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 BigInteger (java.math.BigInteger)1 UnknownHostException (java.net.UnknownHostException)1 Map (java.util.Map)1 Future (java.util.concurrent.Future)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1