Ask Your Question
0

How to get the result of adding flows using SalFlowService?

asked 2016-06-02 02:01:24 -0700

Shawn1992 gravatar image

updated 2016-06-02 02:02:11 -0700

I was using SalFlowService to add a flow, the boolean value returned 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;

}

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-03 06:13:18 -0700

karthik330 gravatar image

Have you built the flow properly (which is coming as 1st parameter in this function)? Refer this link , Sample Flow Code . you may get something which you are missing.

edit flag offensive delete publish link more

Comments

The flow is built OK. The problem is why RpcResult.isSuccessful() always returns true even the flow wasn't added successfully.

Shawn1992 ( 2016-06-05 21:02:15 -0700 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Follow
1 follower

Stats

Asked: 2016-06-02 02:01:24 -0700

Seen: 89 times

Last updated: Jun 03 '16