+ if (node == null){
+ return null;
+ }
+
+ List<NodeConnectorStatistics> statList = new ArrayList<NodeConnectorStatistics>();
+ List<NodeConnectorStatistics> cachedList = nodeConnectorStatistics.get(node);
+ if (cachedList != null) {
+ statList.addAll(cachedList);
+ }
+ return statList;
+ }
+
+ @Override
+ public NodeTableStatistics getNodeTableStatistics(NodeTable nodeTable) {
+ if (nodeTable == null){
+ return null;
+ }
+ List<NodeTableStatistics> statList = tableStatistics.get(nodeTable.getNode());
+ if (statList != null){
+ for (NodeTableStatistics stat : statList) {
+ if (stat.getNodeTable().getID().equals(nodeTable.getID())){
+ return stat;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public List<NodeTableStatistics> getNodeTableStatistics(Node node){
+ if (node == null){
+ return null;
+ }
+ List<NodeTableStatistics> statList = new ArrayList<NodeTableStatistics>();
+ List<NodeTableStatistics> cachedList = tableStatistics.get(node);
+ if (cachedList != null) {
+ statList.addAll(cachedList);
+ }
+ return statList;
+ }
+
+ @Override
+ public void nodeFlowStatisticsUpdated(Node node, List<FlowOnNode> flowStatsList) {
+ List<FlowOnNode> currentStat = this.flowStatistics.get(node);
+ // Update cache only if changed to avoid unnecessary cache sync operations
+ if (! flowStatsList.equals(currentStat)){
+ this.flowStatistics.put(node, flowStatsList);
+ }
+ }
+
+ @Override
+ public void nodeConnectorStatisticsUpdated(Node node, List<NodeConnectorStatistics> ncStatsList) {
+ List<NodeConnectorStatistics> currentStat = this.nodeConnectorStatistics.get(node);
+ if (! ncStatsList.equals(currentStat)){
+ this.nodeConnectorStatistics.put(node, ncStatsList);
+ }
+ }
+
+ @Override
+ public void nodeTableStatisticsUpdated(Node node, List<NodeTableStatistics> tableStatsList) {
+ List<NodeTableStatistics> currentStat = this.tableStatistics.get(node);
+ if (! tableStatsList.equals(currentStat)) {
+ this.tableStatistics.put(node, tableStatsList);
+ }
+ }
+
+ @Override
+ public void descriptionStatisticsUpdated(Node node, NodeDescription nodeDescription) {
+ NodeDescription currentDesc = this.descriptionStatistics.get(node);
+ if (! nodeDescription.equals(currentDesc)){
+ this.descriptionStatistics.put(node, nodeDescription);
+ }
+ }
+
+ @Override
+ public void updateNode(Node node, UpdateType type, Set<Property> props) {
+ // If node is removed, clean up stats mappings
+ if (type == UpdateType.REMOVED) {
+ flowStatistics.remove(node);
+ nodeConnectorStatistics.remove(node);
+ tableStatistics.remove(node);
+ descriptionStatistics.remove(node);
+ }
+ }
+
+ @Override
+ public void updateNodeConnector(NodeConnector nodeConnector, UpdateType type, Set<Property> props) {
+ // Not interested in this update