@Override
public FlowOnNode readFlow(String container, Node node, Flow flow, boolean cached) {
if (controller == null) {
logger.error("Internal plugin error");
return null;
}
long sid = (Long) node.getID();
OFMatch ofMatch = new FlowConverter(flow).getOFMatch();
List<OFStatistics> ofList;
if (cached == true){
ofList = statsMgr.getOFFlowStatistics(sid, ofMatch, flow.getPriority());
} else {
ofList = statsMgr.queryStatistics(sid, OFStatisticsType.FLOW, ofMatch);
for (OFStatistics ofStat : ofList) {
if (((OFFlowStatisticsReply)ofStat).getPriority() == flow.getPriority()){
ofList = new ArrayList<OFStatistics>(1);
ofList.add(ofStat);
break;
}
}
}
List<FlowOnNode> flowOnNodeList = new FlowStatisticsConverter(ofList).getFlowOnNodeList(node);
List<FlowOnNode> filteredList = filterFlowListPerContainer(container, node, flowOnNodeList);
return (filteredList.isEmpty()) ? null : filteredList.get(0);
}