Search in sources :

Example 1 with AddFlowsRpcInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput in project openflowplugin by opendaylight.

the class SalBulkFlowServiceImpl method addFlowsRpc.

@Override
public Future<RpcResult<Void>> addFlowsRpc(AddFlowsRpcInput input) {
    List<ListenableFuture<RpcResult<AddFlowOutput>>> bulkResults = new ArrayList<>();
    for (BulkFlowBaseContentGrouping bulkFlow : input.getBulkFlowItem()) {
        AddFlowInputBuilder flowInputBuilder = new AddFlowInputBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) bulkFlow);
        final NodeRef nodeRef = bulkFlow.getNode();
        flowInputBuilder.setNode(nodeRef);
        flowInputBuilder.setTableId(bulkFlow.getTableId());
        Future<RpcResult<AddFlowOutput>> rpcAddFlowResult = flowService.addFlow(flowInputBuilder.build());
        bulkResults.add(JdkFutureAdapters.listenInPoolThread(rpcAddFlowResult));
    }
    return handleResultFuture(Futures.allAsList(bulkResults));
}
Also used : AddFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput) BulkFlowBaseContentGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.BulkFlowBaseContentGrouping) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)

Example 2 with AddFlowsRpcInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput in project openflowplugin by opendaylight.

the class SalBulkFlowServiceImplTest method testAddRemoveFlowsRpc.

@Test
public void testAddRemoveFlowsRpc() throws Exception {
    Mockito.when(mockSalFlowService.addFlow(Matchers.<AddFlowInput>any())).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
    Mockito.when(mockSalFlowService.removeFlow(Matchers.<RemoveFlowInput>any())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
    final BulkFlowItemBuilder bulkFlowItemBuilder = new BulkFlowItemBuilder();
    final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
    bulkFlowItemBuilder.setNode(new NodeRef(nodeId));
    final BulkFlowItem bulkFlowItem = bulkFlowItemBuilder.build();
    final List<BulkFlowItem> bulkFlowItems = new ArrayList<>();
    bulkFlowItems.add(bulkFlowItem);
    final AddFlowsRpcInputBuilder addFlowsRpcInputBuilder = new AddFlowsRpcInputBuilder();
    addFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
    final AddFlowsRpcInput addFlowsRpcInput = addFlowsRpcInputBuilder.build();
    salBulkFlowService.addFlowsRpc(addFlowsRpcInput);
    verify(mockSalFlowService).addFlow(Matchers.<AddFlowInput>any());
    final RemoveFlowsRpcInputBuilder removeFlowsRpcInputBuilder = new RemoveFlowsRpcInputBuilder();
    removeFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
    final RemoveFlowsRpcInput removeFlowsRpcInput = removeFlowsRpcInputBuilder.build();
    salBulkFlowService.removeFlowsRpc(removeFlowsRpcInput);
    verify(mockSalFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
}
Also used : BulkFlowItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItemBuilder) BulkFlowItem(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItem) RemoveFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) AddFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder) RemoveFlowsRpcInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) AddFlowsRpcInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInputBuilder) AddFlowsRpcInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput) RemoveFlowsRpcInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInputBuilder) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Test (org.junit.Test)1 AddFlowsRpcInput (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput)1 AddFlowsRpcInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInputBuilder)1 BulkFlowBaseContentGrouping (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.BulkFlowBaseContentGrouping)1 RemoveFlowsRpcInput (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInput)1 RemoveFlowsRpcInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInputBuilder)1 BulkFlowItem (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItem)1 BulkFlowItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItemBuilder)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 AddFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder)1 RemoveFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1