Ask is moving to Stack Overflow and Serverfault.com! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode

Revision history [back]

click to hide/show revision 1
initial version

How to get the result of adding flows using SalFlowService?

I was using SalFlowService to add a flow, the boolean value returned fromn RpcResult.isSuccessful() is always true, but the flow wasn't added actually. Can anyone tell me why this happen and how to get the real result of adding flows. Thanks a lot !

private boolean addFlow(Flow flow, InstanceIdentifier<Node> nodeIID) {
boolean isAdded = false;
AddFlowInputBuilder builder = new AddFlowInputBuilder(flow);
InstanceIdentifier<Table> tableIdentifier = createTableIdentifier(nodeIID);
builder.setNode(new NodeRef(nodeIID));
builder.setFlowTable(new FlowTableRef(tableIdentifier));
builder.setFlowRef(new FlowRef(createFlowIID(nodeIID, flow.getId())));
builder.setTransactionUri(new Uri(flow.getId().getValue()));
logger.info("Flow :" + builder.toString());
try {
    Future<RpcResult<AddFlowOutput>> future = salFlowService.addFlow(builder.build());
    RpcResult<AddFlowOutput> rpcResult = future.get();
    logger.info("rpcResult : " + rpcResult);
    isAdded = rpcResult.isSuccessful();
    if (rpcResult.isSuccessful()) {
        logger.info("rpcResult is Successful");
        AddFlowOutput addFlowOutput = rpcResult.getResult();
        logger.info("AddFlowOutput = " + addFlowOutput);
        logger.info("transactionId = " + addFlowOutput.getTransactionId().getValue());
    }
} catch (InterruptedException | ExecutionException e) {
    logger.error("addFlow", e);
}
logger.info(" Add flow : node[" + nodeIID + "], flowBuilder[" + builder.build() + "]"
            + (isAdded ? "  Successfully " : "  Unsuccessfully"));

return isAdded;

}

How to get the result of adding flows using SalFlowService?

I was using SalFlowService to add a flow, the boolean value returned fromn from RpcResult.isSuccessful() is always true, but the flow wasn't added actually. Can anyone tell me why this happen and how to get the real result of adding flows. Thanks a lot !

private boolean addFlow(Flow flow, InstanceIdentifier<Node> nodeIID) {
boolean isAdded = false;
AddFlowInputBuilder builder = new AddFlowInputBuilder(flow);
InstanceIdentifier<Table> tableIdentifier = createTableIdentifier(nodeIID);
builder.setNode(new NodeRef(nodeIID));
builder.setFlowTable(new FlowTableRef(tableIdentifier));
builder.setFlowRef(new FlowRef(createFlowIID(nodeIID, flow.getId())));
builder.setTransactionUri(new Uri(flow.getId().getValue()));
logger.info("Flow :" + builder.toString());
try {
    Future<RpcResult<AddFlowOutput>> future = salFlowService.addFlow(builder.build());
    RpcResult<AddFlowOutput> rpcResult = future.get();
    logger.info("rpcResult : " + rpcResult);
    isAdded = rpcResult.isSuccessful();
    if (rpcResult.isSuccessful()) {
        logger.info("rpcResult is Successful");
        AddFlowOutput addFlowOutput = rpcResult.getResult();
        logger.info("AddFlowOutput = " + addFlowOutput);
        logger.info("transactionId = " + addFlowOutput.getTransactionId().getValue());
    }
} catch (InterruptedException | ExecutionException e) {
    logger.error("addFlow", e);
}
logger.info(" Add flow : node[" + nodeIID + "], flowBuilder[" + builder.build() + "]"
            + (isAdded ? "  Successfully " : "  Unsuccessfully"));

return isAdded;

}