Merge "Take advantage of MultipartTransactionAware"
authorTony Tkacik <ttkacik@cisco.com>
Tue, 18 Mar 2014 10:42:51 +0000 (10:42 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 18 Mar 2014 10:42:51 +0000 (10:42 +0000)
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/MultipartMessageManager.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsHandler.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsListener.java

index 56b2052..425a449 100644 (file)
@@ -11,6 +11,7 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.MultipartTransactionAware;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
 
@@ -91,7 +92,12 @@ class MultipartMessageManager {
         txIdTotableIdMap.put(new TxIdEntry(id), Preconditions.checkNotNull(tableId));
     }
 
-    public Short isExpectedTableTransaction(TransactionAware transaction, Boolean more) {
+    public Short isExpectedTableTransaction(TransactionAware transaction) {
+        Boolean more = null;
+        if (transaction instanceof MultipartTransactionAware) {
+            more = ((MultipartTransactionAware)transaction).isMoreReplies();
+        }
+
         if (!isExpectedTransaction(transaction, more)) {
             return null;
         }
@@ -109,8 +115,8 @@ class MultipartMessageManager {
         txIdToRequestTypeMap.put(entry, getExpiryTime());
     }
 
-    public boolean isExpectedTransaction(TransactionAware transaction, Boolean more) {
-        TxIdEntry entry = new TxIdEntry(transaction.getTransactionId());
+    private boolean isExpectedTransaction(TransactionAware transaction, Boolean more) {
+        final TxIdEntry entry = new TxIdEntry(transaction.getTransactionId());
         if (more != null && more.booleanValue()) {
             return txIdToRequestTypeMap.containsKey(entry);
         } else {
@@ -118,6 +124,15 @@ class MultipartMessageManager {
         }
     }
 
+    public boolean isExpectedTransaction(TransactionAware transaction) {
+        Boolean more = null;
+        if (transaction instanceof MultipartTransactionAware) {
+            more = ((MultipartTransactionAware)transaction).isMoreReplies();
+        }
+
+        return isExpectedTransaction(transaction, more);
+    }
+
     private Long getExpiryTime() {
         return System.nanoTime() + lifetimeNanos;
     }
index 6796b4e..c4334ab 100644 (file)
@@ -137,50 +137,50 @@ public final class NodeStatisticsHandler implements AutoCloseable, FlowCapableCo
         return dps.beginTransaction();
     }
 
-    public synchronized void updateGroupDescStats(TransactionAware transaction, Boolean more, List<GroupDescStats> list) {
-        if (msgManager.isExpectedTransaction(transaction, more)) {
+    public synchronized void updateGroupDescStats(TransactionAware transaction, List<GroupDescStats> list) {
+        if (msgManager.isExpectedTransaction(transaction)) {
             groupDescStats.updateStats(list);
         }
     }
 
-    public synchronized void updateGroupStats(TransactionAware transaction, Boolean more, List<GroupStats> list) {
-        if (msgManager.isExpectedTransaction(transaction, more)) {
+    public synchronized void updateGroupStats(TransactionAware transaction, List<GroupStats> list) {
+        if (msgManager.isExpectedTransaction(transaction)) {
             groupStats.updateStats(list);
         }
     }
 
-    public synchronized void updateMeterConfigStats(TransactionAware transaction, Boolean more, List<MeterConfigStats> list) {
-        if (msgManager.isExpectedTransaction(transaction, more)) {
+    public synchronized void updateMeterConfigStats(TransactionAware transaction, List<MeterConfigStats> list) {
+        if (msgManager.isExpectedTransaction(transaction)) {
             meterConfigStats.updateStats(list);
         }
     }
 
-    public synchronized void updateMeterStats(TransactionAware transaction, Boolean more, List<MeterStats> list) {
-        if (msgManager.isExpectedTransaction(transaction, more)) {
+    public synchronized void updateMeterStats(TransactionAware transaction, List<MeterStats> list) {
+        if (msgManager.isExpectedTransaction(transaction)) {
             meterStats.updateStats(list);
         }
     }
 
-    public synchronized void updateQueueStats(TransactionAware transaction, Boolean more, List<QueueIdAndStatisticsMap> list) {
-        if (msgManager.isExpectedTransaction(transaction, more)) {
+    public synchronized void updateQueueStats(TransactionAware transaction, List<QueueIdAndStatisticsMap> list) {
+        if (msgManager.isExpectedTransaction(transaction)) {
             queueStats.updateStats(list);
         }
     }
 
-    public synchronized void updateFlowTableStats(TransactionAware transaction, Boolean more, List<FlowTableAndStatisticsMap> list) {
-        if (msgManager.isExpectedTransaction(transaction, more)) {
+    public synchronized void updateFlowTableStats(TransactionAware transaction, List<FlowTableAndStatisticsMap> list) {
+        if (msgManager.isExpectedTransaction(transaction)) {
             flowTableStats.updateStats(list);
         }
     }
 
-    public synchronized void updateNodeConnectorStats(TransactionAware transaction, Boolean more, List<NodeConnectorStatisticsAndPortNumberMap> list) {
-        if (msgManager.isExpectedTransaction(transaction, more)) {
+    public synchronized void updateNodeConnectorStats(TransactionAware transaction, List<NodeConnectorStatisticsAndPortNumberMap> list) {
+        if (msgManager.isExpectedTransaction(transaction)) {
             nodeConnectorStats.updateStats(list);
         }
     }
 
-    public synchronized void updateAggregateFlowStats(TransactionAware transaction, Boolean more, AggregateFlowStatistics flowStats) {
-        final Short tableId = msgManager.isExpectedTableTransaction(transaction, more);
+    public synchronized void updateAggregateFlowStats(TransactionAware transaction, AggregateFlowStatistics flowStats) {
+        final Short tableId = msgManager.isExpectedTableTransaction(transaction);
         if (tableId != null) {
             final DataModificationTransaction trans = dps.beginTransaction();
             InstanceIdentifier<Table> tableRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, targetNodeKey)
@@ -203,8 +203,8 @@ public final class NodeStatisticsHandler implements AutoCloseable, FlowCapableCo
         }
     }
 
-    public synchronized void updateFlowStats(TransactionAware transaction, Boolean more, List<FlowAndStatisticsMapList> list) {
-        if (msgManager.isExpectedTransaction(transaction, more)) {
+    public synchronized void updateFlowStats(TransactionAware transaction, List<FlowAndStatisticsMapList> list) {
+        if (msgManager.isExpectedTransaction(transaction)) {
             flowStats.updateStats(list);
         }
     }
index bd9f96c..a06f7ef 100644 (file)
@@ -57,7 +57,7 @@ public class StatisticsListener implements OpendaylightGroupStatisticsListener,
     public void onMeterConfigStatsUpdated(final MeterConfigStatsUpdated notification) {
         final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
         if (handler != null) {
-            handler.updateMeterConfigStats(notification, notification.isMoreReplies(), notification.getMeterConfigStats());
+            handler.updateMeterConfigStats(notification, notification.getMeterConfigStats());
         }
     }
 
@@ -65,7 +65,7 @@ public class StatisticsListener implements OpendaylightGroupStatisticsListener,
     public void onMeterStatisticsUpdated(MeterStatisticsUpdated notification) {
         final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
         if (handler != null) {
-            handler.updateMeterStats(notification, notification.isMoreReplies(), notification.getMeterStats());
+            handler.updateMeterStats(notification, notification.getMeterStats());
         }
     }
 
@@ -73,7 +73,7 @@ public class StatisticsListener implements OpendaylightGroupStatisticsListener,
     public void onGroupDescStatsUpdated(GroupDescStatsUpdated notification) {
         final NodeStatisticsHandler handler = statisticsManager.getStatisticsHandler(notification.getId());
         if (handler != null) {
-            handler.updateGroupDescStats(notification, notification.isMoreReplies(), notification.getGroupDescStats());
+            handler.updateGroupDescStats(notification, notification.getGroupDescStats());
         }
     }
 
@@ -81,7 +81,7 @@ public class StatisticsListener implements OpendaylightGroupStatisticsListener,
     public void onGroupStatisticsUpdated(GroupStatisticsUpdated notification) {
         final NodeStatisticsHandler handler = statisticsManager.getStatisticsHandler(notification.getId());
         if (handler != null) {
-            handler.updateGroupStats(notification, notification.isMoreReplies(), notification.getGroupStats());
+            handler.updateGroupStats(notification, notification.getGroupStats());
         }
     }
 
@@ -106,7 +106,7 @@ public class StatisticsListener implements OpendaylightGroupStatisticsListener,
         sucLogger.debug("Received flow stats update : {}",notification.toString());
         final NodeStatisticsHandler sna = this.statisticsManager.getStatisticsHandler(notification.getId());
         if (sna != null) {
-            sna.updateFlowStats(notification, notification.isMoreReplies(), notification.getFlowAndStatisticsMapList());
+            sna.updateFlowStats(notification, notification.getFlowAndStatisticsMapList());
         }
     }
 
@@ -114,7 +114,7 @@ public class StatisticsListener implements OpendaylightGroupStatisticsListener,
     public void onAggregateFlowStatisticsUpdate(AggregateFlowStatisticsUpdate notification) {
         final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
         if (handler != null) {
-            handler.updateAggregateFlowStats(notification, notification.isMoreReplies(), notification);
+            handler.updateAggregateFlowStats(notification, notification);
         }
     }
 
@@ -122,7 +122,7 @@ public class StatisticsListener implements OpendaylightGroupStatisticsListener,
     public void onNodeConnectorStatisticsUpdate(NodeConnectorStatisticsUpdate notification) {
         final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
         if (handler != null) {
-            handler.updateNodeConnectorStats(notification, notification.isMoreReplies(), notification.getNodeConnectorStatisticsAndPortNumberMap());
+            handler.updateNodeConnectorStats(notification, notification.getNodeConnectorStatisticsAndPortNumberMap());
         }
     }
 
@@ -130,7 +130,7 @@ public class StatisticsListener implements OpendaylightGroupStatisticsListener,
     public void onFlowTableStatisticsUpdate(FlowTableStatisticsUpdate notification) {
         final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
         if (handler != null) {
-            handler.updateFlowTableStats(notification, notification.isMoreReplies(), notification.getFlowTableAndStatisticsMap());
+            handler.updateFlowTableStats(notification, notification.getFlowTableAndStatisticsMap());
         }
     }
 
@@ -138,7 +138,7 @@ public class StatisticsListener implements OpendaylightGroupStatisticsListener,
     public void onQueueStatisticsUpdate(QueueStatisticsUpdate notification) {
         final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
         if (handler != null) {
-            handler.updateQueueStats(notification, notification.isMoreReplies(), notification.getQueueIdAndStatisticsMap());
+            handler.updateQueueStats(notification, notification.getQueueIdAndStatisticsMap());
         }
     }
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.