Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Statistics Mgr to avoid unnucessary cache updates
[controller.git]
/
opendaylight
/
statisticsmanager
/
implementation
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
statisticsmanager
/
internal
/
StatisticsManager.java
diff --git
a/opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java
b/opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java
index f5c13b61053ee5eaaa7eab5594608cd3da4ce5d7..eec183d59573aea1bc7deda423416fd4a27b575b 100644
(file)
--- a/
opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java
+++ b/
opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java
@@
-167,7
+167,7
@@
public class StatisticsManager implements IStatisticsManager, IReadServiceListen
* Function called after registering the service in OSGi service registry.
*/
void started(){
* Function called after registering the service in OSGi service registry.
*/
void started(){
- //
r
etrieve current statistics so we don't have to wait for next refresh
+ //
R
etrieve current statistics so we don't have to wait for next refresh
ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(
ISwitchManager.class, container.getName(), this);
if (reader != null && switchManager != null) {
ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(
ISwitchManager.class, container.getName(), this);
if (reader != null && switchManager != null) {
@@
-180,7
+180,7
@@
public class StatisticsManager implements IStatisticsManager, IReadServiceListen
}
} else {
}
} else {
- log.
warn("Failed to retrieve current statistics. Statistics will not be immi
diately available!");
+ log.
trace("Failed to retrieve current statistics. Statistics will not be imme
diately available!");
}
}
}
}
@@
-247,7
+247,7
@@
public class StatisticsManager implements IStatisticsManager, IReadServiceListen
}
Node node;
}
Node node;
- //
i
ndex FlowEntries' flows by node so we don't traverse entire flow list for each flowEntry
+ //
I
ndex FlowEntries' flows by node so we don't traverse entire flow list for each flowEntry
Map<Node, Set<Flow>> index = new HashMap<Node, Set<Flow>>();
for (FlowEntry flowEntry : flowList) {
node = flowEntry.getNode();
Map<Node, Set<Flow>> index = new HashMap<Node, Set<Flow>>();
for (FlowEntry flowEntry : flowList) {
node = flowEntry.getNode();
@@
-256,7
+256,7
@@
public class StatisticsManager implements IStatisticsManager, IReadServiceListen
index.put(node, set);
}
index.put(node, set);
}
- //
i
terate over flows per indexed node and add to output
+ //
I
terate over flows per indexed node and add to output
for (Entry<Node, Set<Flow>> indexEntry : index.entrySet()) {
node = indexEntry.getKey();
List<FlowOnNode> flowsPerNode = flowStatistics.get(node);
for (Entry<Node, Set<Flow>> indexEntry : index.entrySet()) {
node = indexEntry.getKey();
List<FlowOnNode> flowsPerNode = flowStatistics.get(node);
@@
-356,27
+356,40
@@
public class StatisticsManager implements IStatisticsManager, IReadServiceListen
@Override
public void nodeFlowStatisticsUpdated(Node node, List<FlowOnNode> flowStatsList) {
@Override
public void nodeFlowStatisticsUpdated(Node node, List<FlowOnNode> flowStatsList) {
- this.flowStatistics.put(node, 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) {
}
@Override
public void nodeConnectorStatisticsUpdated(Node node, List<NodeConnectorStatistics> ncStatsList) {
- this.nodeConnectorStatistics.put(node, 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) {
}
@Override
public void nodeTableStatisticsUpdated(Node node, List<NodeTableStatistics> tableStatsList) {
- this.tableStatistics.put(node, 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) {
}
@Override
public void descriptionStatisticsUpdated(Node node, NodeDescription nodeDescription) {
- this.descriptionStatistics.put(node, 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) {
}
@Override
public void updateNode(Node node, UpdateType type, Set<Property> props) {
- //
if node is removed, remove
stats mappings
+ //
If node is removed, clean up
stats mappings
if (type == UpdateType.REMOVED) {
flowStatistics.remove(node);
nodeConnectorStatistics.remove(node);
if (type == UpdateType.REMOVED) {
flowStatistics.remove(node);
nodeConnectorStatistics.remove(node);
@@
-387,6
+400,6
@@
public class StatisticsManager implements IStatisticsManager, IReadServiceListen
@Override
public void updateNodeConnector(NodeConnector nodeConnector, UpdateType type, Set<Property> props) {
@Override
public void updateNodeConnector(NodeConnector nodeConnector, UpdateType type, Set<Property> props) {
- //
n
ot interested in this update
+ //
N
ot interested in this update
}
}
}
}