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());
}
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;
}
Aggregations