X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Finternal%2FReadServiceFilter.java;h=e1b244f2c1ede4330d9bda67df4ae693c97af162;hb=315a10ec8b79abec3f4d718359ebb4202bffcb11;hp=2c8708f20ee46295972a6b18b280df436f009dfc;hpb=2d36fc2f0b7691efe2f641beacd146c260676fea;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadServiceFilter.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadServiceFilter.java index 2c8708f20e..e1b244f2c1 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadServiceFilter.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadServiceFilter.java @@ -27,6 +27,7 @@ import org.opendaylight.controller.sal.action.Action; 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; @@ -55,7 +56,7 @@ import org.slf4j.LoggerFactory; * 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; @@ -64,7 +65,8 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener private ConcurrentMap> containerToNode; private ConcurrentMap> containerToNt; private ConcurrentMap> containerFlows; - private ConcurrentMap readFilterInternalListeners; + private ConcurrentMap readFilterInternalListeners = + new ConcurrentHashMap(); public void setController(IController core) { this.controller = core; @@ -119,7 +121,6 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener containerToNt = new ConcurrentHashMap>(); containerToNode = new ConcurrentHashMap>(); containerFlows = new ConcurrentHashMap>(); - readFilterInternalListeners = new ConcurrentHashMap(); } /** @@ -129,6 +130,7 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener * */ void destroy() { + readFilterInternalListeners.clear(); } /** @@ -187,7 +189,7 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener List flowOnNodeList = new FlowStatisticsConverter(ofList).getFlowOnNodeList(node); List filteredList = filterFlowListPerContainer(container, node, flowOnNodeList); - return (filteredList == null || filteredList.isEmpty()) ? null : filteredList.get(0); + return (filteredList.isEmpty()) ? null : filteredList.get(0); } @Override @@ -201,10 +203,8 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener // Convert and filter the statistics per container List flowOnNodeList = new FlowStatisticsConverter(ofList).getFlowOnNodeList(node); - List filteredList = filterFlowListPerContainer(container, node, flowOnNodeList); - - return (filteredList == null) ? null : filteredList; + return filterFlowListPerContainer(container, node, flowOnNodeList); } @Override @@ -231,10 +231,10 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener * @param list * @return */ - public List filterFlowListPerContainer(String container, + private List filterFlowListPerContainer(String container, Node nodeId, List list) { if (list == null) { - return null; + return Collections.emptyList(); } // Create new filtered list of flows @@ -258,9 +258,9 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener * @param list * @return */ - public List filterPortListPerContainer(String container, long switchId, List list) { + private List filterPortListPerContainer(String container, long switchId, List list) { if (list == null) { - return null; + return Collections.emptyList(); } // Create new filtered list of flows @@ -279,10 +279,10 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener } - public List filterTableListPerContainer( + private List filterTableListPerContainer( String container, long switchId, List list) { if (list == null) { - return null; + return Collections.emptyList(); } // Create new filtered list of node tables @@ -515,7 +515,7 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener long sid = (Long) node.getID(); List ofList = (cached == true) ? statsMgr .getOFPortStatistics(sid) : statsMgr.queryStatistics(sid, - OFStatisticsType.FLOW, null); + OFStatisticsType.PORT, null); List filteredList = filterPortListPerContainer(containerName, sid, ofList); @@ -555,7 +555,7 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener public List readAllNodeTable(String containerName, Node node, boolean cached) { long sid = (Long) node.getID(); List ofList = (cached == true) ? - statsMgr.getOFTableStatistics(sid) : statsMgr.queryStatistics(sid, OFStatisticsType.FLOW, null); + statsMgr.getOFTableStatistics(sid) : statsMgr.queryStatistics(sid, OFStatisticsType.TABLE, null); List filteredList = filterTableListPerContainer(containerName, sid, ofList); @@ -631,4 +631,17 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener 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); + } }