import org.opendaylight.controller.sal.action.ActionType;
import org.opendaylight.controller.sal.action.Output;
import org.opendaylight.controller.sal.core.ContainerFlow;
+import org.opendaylight.controller.sal.core.IContainerAware;
import org.opendaylight.controller.sal.core.IContainerListener;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
* Read Service shim layer which is in charge of filtering the flow statistics
* based on container. It is a Global instance.
*/
-public class ReadServiceFilter implements IReadServiceFilter, IContainerListener, IOFStatisticsListener {
+public class ReadServiceFilter implements IReadServiceFilter, IContainerListener, IOFStatisticsListener, IContainerAware {
private static final Logger logger = LoggerFactory
.getLogger(ReadServiceFilter.class);
private IController controller = null;
List<FlowOnNode> flowOnNodeList = new FlowStatisticsConverter(ofList).getFlowOnNodeList(node);
List<FlowOnNode> filteredList = filterFlowListPerContainer(container, node, flowOnNodeList);
- return (filteredList == null || filteredList.isEmpty()) ? null : filteredList.get(0);
+ return (filteredList.isEmpty()) ? null : filteredList.get(0);
}
@Override
// Convert and filter the statistics per container
List<FlowOnNode> flowOnNodeList = new FlowStatisticsConverter(ofList).getFlowOnNodeList(node);
- List<FlowOnNode> filteredList = filterFlowListPerContainer(container, node, flowOnNodeList);
-
- return (filteredList == null) ? null : filteredList;
+ return filterFlowListPerContainer(container, node, flowOnNodeList);
}
@Override
* @param list
* @return
*/
- public List<FlowOnNode> filterFlowListPerContainer(String container,
+ private List<FlowOnNode> filterFlowListPerContainer(String container,
Node nodeId, List<FlowOnNode> list) {
if (list == null) {
- return null;
+ return Collections.emptyList();
}
// Create new filtered list of flows
* @param list
* @return
*/
- public List<OFStatistics> filterPortListPerContainer(String container, long switchId, List<OFStatistics> list) {
+ private List<OFStatistics> filterPortListPerContainer(String container, long switchId, List<OFStatistics> list) {
if (list == null) {
- return null;
+ return Collections.emptyList();
}
// Create new filtered list of flows
}
- public List<OFStatistics> filterTableListPerContainer(
+ private List<OFStatistics> filterTableListPerContainer(
String container, long switchId, List<OFStatistics> list) {
if (list == null) {
- return null;
+ return Collections.emptyList();
}
// Create new filtered list of node tables
long sid = (Long) node.getID();
List<OFStatistics> ofList = (cached == true) ? statsMgr
.getOFPortStatistics(sid) : statsMgr.queryStatistics(sid,
- OFStatisticsType.FLOW, null);
+ OFStatisticsType.PORT, null);
List<OFStatistics> filteredList = filterPortListPerContainer(containerName, sid, ofList);
public List<NodeTableStatistics> readAllNodeTable(String containerName, Node node, boolean cached) {
long sid = (Long) node.getID();
List<OFStatistics> ofList = (cached == true) ?
- statsMgr.getOFTableStatistics(sid) : statsMgr.queryStatistics(sid, OFStatisticsType.FLOW, null);
+ statsMgr.getOFTableStatistics(sid) : statsMgr.queryStatistics(sid, OFStatisticsType.TABLE, null);
List<OFStatistics> filteredList = filterTableListPerContainer(containerName, sid, ofList);
l.getValue().nodeTableStatisticsUpdated(node, tableStatsList);
}
}
+
+ @Override
+ public void containerCreate(String containerName) {
+ // do nothing
+ }
+
+ @Override
+ public void containerDestroy(String containerName) {
+ containerToNc.remove(containerName);
+ containerToNode.remove(containerName);
+ containerToNt.remove(containerName);
+ containerFlows.remove(containerName);
+ }
}