From: Anil Vishnoi Date: Thu, 14 Nov 2013 22:50:09 +0000 (+0530) Subject: MD-SAL Statistics Manager - Added sending request and caching response X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~396 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=72e582a38f8700e0cef8780053f468ef8e64a3be MD-SAL Statistics Manager - Added sending request and caching response Change-Id: I283a543a3a9e7ec3ea74c1018a82e51990ce03f9 Signed-off-by: Anil Vishnoi --- diff --git a/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/group-statistics.yang b/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/group-statistics.yang index 043b0077f7..c1740d8abd 100644 --- a/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/group-statistics.yang +++ b/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/group-statistics.yang @@ -18,10 +18,9 @@ module opendaylight-group-statistics { grouping group-stats-response { uses "inv:node-context-ref"; - leaf group-stats-id { - type group-stats-ref; + list group-statistics{ + uses group-types:group-statistics; } - uses group-types:group-statistics; } typedef group-features-ref { @@ -31,9 +30,6 @@ module opendaylight-group-statistics { grouping group-features-response { uses "inv:node-context-ref"; - leaf group-features-id { - type group-features-ref; - } uses group-types:group-features; } @@ -44,10 +40,23 @@ module opendaylight-group-statistics { grouping group-desc-response { uses "inv:node-context-ref"; - leaf group-desc-id { - type group-desc-ref; + list group-desc-stats { + uses group-types:group-desc-stats; } - uses group-types:group-desc-stats; + } + + container group-all-statistics { + container group-stats { + uses group-stats-response; + } + + container group-features { + uses group-features-response; + } + + container group-desc { + uses group-desc-response; + } } // RPC calls @@ -56,9 +65,7 @@ module opendaylight-group-statistics { uses inv:node-context-ref; } output { - list group-statistics { - uses group-stats-response; - } + uses group-stats-response; uses tr:transaction-aware; } @@ -81,9 +88,6 @@ module opendaylight-group-statistics { rpc get-group-description { input { uses inv:node-context-ref; - leaf group-id{ - type group-types:group-id; - } } output { uses group-desc-response; @@ -94,9 +98,6 @@ module opendaylight-group-statistics { rpc get-group-features { input { uses inv:node-context-ref; - leaf group-id{ - type group-types:group-id; - } } output { uses group-features-response; @@ -108,16 +109,28 @@ module opendaylight-group-statistics { //Notification calls notification group-statistics-updated { + leaf group-stats-id { + type group-stats-ref; + } + uses group-stats-response; uses tr:transaction-aware; } notification group-desc-stats-updated { + leaf group-desc-id { + type group-desc-ref; + } + uses group-desc-response; uses tr:transaction-aware; } notification group-features-updated { + leaf group-features-id { + type group-features-ref; + } + uses group-features-response; uses tr:transaction-aware; } diff --git a/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/meter-statistics.yang b/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/meter-statistics.yang index 18dd60d08d..3561e4f339 100644 --- a/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/meter-statistics.yang +++ b/opendaylight/md-sal/model/model-flow-statistics/src/main/yang/meter-statistics.yang @@ -19,10 +19,9 @@ module opendaylight-meter-statistics { grouping meter-stats-response { uses "inv:node-context-ref"; - leaf meter-stats-id { - type meter-stats-ref; + list meter-statistics { + uses meter-types:meter-statistics; } - uses meter-types:meter-statistics; } typedef meter-config-ref { @@ -32,10 +31,9 @@ module opendaylight-meter-statistics { grouping meter-config-response { uses "inv:node-context-ref"; - leaf meter-config-id { - type meter-config-ref; + list meter-config-stats { + uses meter-types:meter-config-stats; } - uses meter-types:meter-config-stats; } typedef meter-features-ref { @@ -45,28 +43,35 @@ module opendaylight-meter-statistics { grouping meter-features-response { uses "inv:node-context-ref"; - leaf meter-features-id { - type meter-features-ref; - } uses meter-types:meter-features; } + container meter-all-stats { + container meter-stats { + uses meter-stats-response; + } + + container meter-config { + uses meter-config-response; + } + + container meter-features { + uses meter-features-response; + } + } // RPC calls rpc get-all-meter-statistics { input { uses inv:node-context-ref; } output { - list meter-statistics { - uses meter-stats-response; - uses tr:transaction-aware; - } + uses meter-stats-response; + uses tr:transaction-aware; } } rpc get-meter-statistics { - description "RPC Method to send meter statistics request to the give switch for specific meter"; input { uses inv:node-context-ref; leaf meter-id{ @@ -80,12 +85,9 @@ module opendaylight-meter-statistics { } - rpc get-meter-config-statistics { + rpc get-all-meter-config-statistics { input { uses inv:node-context-ref; - leaf meter-id{ - type meter-types:meter-id; - } } output { uses meter-config-response; @@ -96,9 +98,6 @@ module opendaylight-meter-statistics { rpc get-meter-features { input { uses inv:node-context-ref; - leaf meter-id{ - type meter-types:meter-id; - } } output { uses meter-features-response; @@ -110,16 +109,27 @@ module opendaylight-meter-statistics { //Notification calls notification meter-statistics-updated { - uses meter-stats-response; + leaf meter-stats-id { + type meter-stats-ref; + } + uses meter-stats-response; uses tr:transaction-aware; } notification meter-config-stats-updated { + leaf meter-config-id { + type meter-config-ref; + } + uses meter-config-response; uses tr:transaction-aware; } notification meter-features-updated { + leaf meter-features-id { + type meter-features-ref; + } + uses meter-features-response; uses tr:transaction-aware; } diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatistics.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatistics.java new file mode 100644 index 0000000000..8507324b57 --- /dev/null +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatistics.java @@ -0,0 +1,89 @@ +package org.opendaylight.controller.md.statistics.manager; + +import java.util.List; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.desc.response.GroupDescStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.stats.response.GroupStatistics; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.config.response.MeterConfigStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.stats.response.MeterStatistics; + +public class NodeStatistics { + + private NodeRef targetNode; + + private List groupStatistics; + + private List meterStatistics; + + private List groupDescStats; + + private List meterConfigStats; + + private List groupFeatures; + + private List meterFeatures; + + public NodeStatistics(){ + + } + + public NodeRef getTargetNode() { + return targetNode; + } + + public void setTargetNode(NodeRef targetNode) { + this.targetNode = targetNode; + } + + public List getGroupStatistics() { + return groupStatistics; + } + + public void setGroupStatistics(List groupStatistics) { + this.groupStatistics = groupStatistics; + } + + public List getMeterStatistics() { + return meterStatistics; + } + + public void setMeterStatistics(List meterStatistics) { + this.meterStatistics = meterStatistics; + } + + public List getGroupDescStats() { + return groupDescStats; + } + + public void setGroupDescStats(List groupDescStats) { + this.groupDescStats = groupDescStats; + } + + public List getMeterConfigStats() { + return meterConfigStats; + } + + public void setMeterConfigStats(List meterConfigStats) { + this.meterConfigStats = meterConfigStats; + } + + public List getGroupFeatures() { + return groupFeatures; + } + + public void setGroupFeatures( + List groupFeatures) { + this.groupFeatures = groupFeatures; + } + + public List getMeterFeatures() { + return meterFeatures; + } + + public void setMeterFeatures( + List meterFeatures) { + this.meterFeatures = meterFeatures; + } + +} diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java index 073d43ef60..5c02b6cea0 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java @@ -1,13 +1,36 @@ package org.opendaylight.controller.md.statistics.manager; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.Future; + import org.eclipse.xtext.xbase.lib.Exceptions; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService; import org.opendaylight.yangtools.concepts.Registration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,6 +46,15 @@ public class StatisticsProvider implements AutoCloseable { private OpendaylightMeterStatisticsService meterStatsService; + private Thread statisticsRequesterThread; + + private final InstanceIdentifier nodesIdentifier = InstanceIdentifier.builder().node(Nodes.class).toInstance(); + + //Local caching of stats + + private final ConcurrentMap statisticsCache = + new ConcurrentHashMap(); + public DataProviderService getDataService() { return this.dps; } @@ -50,10 +82,28 @@ public class StatisticsProvider implements AutoCloseable { this.listenerRegistration = registerNotificationListener; // Get Group/Meter statistics service instance - groupStatsService = StatisticsManagerActivator.getProviderContext().getRpcService(OpendaylightGroupStatisticsService.class); + groupStatsService = StatisticsManagerActivator.getProviderContext(). + getRpcService(OpendaylightGroupStatisticsService.class); - meterStatsService = StatisticsManagerActivator.getProviderContext().getRpcService(OpendaylightMeterStatisticsService.class); + meterStatsService = StatisticsManagerActivator.getProviderContext(). + getRpcService(OpendaylightMeterStatisticsService.class); + + statisticsRequesterThread = new Thread( new Runnable(){ + @Override + public void run() { + while(true){ + try { + statsRequestSender(); + + Thread.sleep(5000); + }catch (Exception e){ + spLogger.error("Exception occurred while sending stats request : {}",e.getMessage()); + e.printStackTrace(); + } + } + } + }); spLogger.info("Statistics Provider started."); } @@ -63,6 +113,100 @@ public class StatisticsProvider implements AutoCloseable { return dps.beginTransaction(); } + private void statsRequestSender(){ + + //Need to call API to receive all the nodes connected to controller. + + List targetNodes = new ArrayList(); + + for (NodeRef targetNode : targetNodes){ + + sendAllGroupStatisticsRequest(targetNode); + + sendAllMeterStatisticsRequest(targetNode); + + //We need to add check, so see if groups/meters are supported + //by the target node. + sendGroupDescriptionRequest(targetNode); + + sendGroupFeaturesRequest(targetNode); + + sendMeterConfigStatisticsRequest(targetNode); + + sendMeterFeaturesRequest(targetNode); + } + } + + private void sendAllGroupStatisticsRequest(NodeRef targetNode){ + + GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder(); + + input.setNode(targetNode); + + Future> response = + groupStatsService.getAllGroupStatistics(input.build()); + } + + private void sendGroupDescriptionRequest(NodeRef targetNode){ + GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder(); + + input.setNode(targetNode); + + Future> response = + groupStatsService.getGroupDescription(input.build()); + } + + private void sendGroupFeaturesRequest(NodeRef targetNode){ + + GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder(); + + input.setNode(targetNode); + + Future> response = + groupStatsService.getGroupFeatures(input.build()); + } + + private void sendAllMeterStatisticsRequest(NodeRef targenetNode){ + + GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder(); + + input.setNode(targenetNode); + + Future> response = + meterStatsService.getAllMeterStatistics(input.build()); + } + + private void sendMeterConfigStatisticsRequest(NodeRef targetNode){ + + GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder(); + + input.setNode(targetNode); + + Future> response = + meterStatsService.getAllMeterConfigStatistics(input.build()); + + } + private void sendMeterFeaturesRequest(NodeRef targetNode){ + + GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder(); + + input.setNode(targetNode); + + Future> response = + meterStatsService.getMeterFeatures(input.build()); + } + + public ConcurrentMap getStatisticsCache() { + return statisticsCache; + } + + private List getAllConnectedNodes(){ + + Nodes nodes = (Nodes) dps.readOperationalData(nodesIdentifier); + return nodes.getNode(); + } + + @SuppressWarnings("deprecation") @Override public void close(){ @@ -71,6 +215,8 @@ public class StatisticsProvider implements AutoCloseable { if (this.listenerRegistration != null) { this.listenerRegistration.close(); + + this.statisticsRequesterThread.destroy(); } } catch (Throwable e) { diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateCommiter.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateCommiter.java index f952124c91..cba039f815 100644 --- a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateCommiter.java +++ b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateCommiter.java @@ -1,13 +1,30 @@ package org.opendaylight.controller.md.statistics.manager; +import java.util.concurrent.ConcurrentMap; + +import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatsRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.all.statistics.GroupDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.all.statistics.GroupFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.all.statistics.GroupStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdated; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatsRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.all.stats.MeterConfigBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.all.stats.MeterFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.meter.all.stats.MeterStatsBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsListener, OpendaylightMeterStatisticsListener { @@ -23,35 +40,135 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList } @Override public void onMeterConfigStatsUpdated(MeterConfigStatsUpdated notification) { - // TODO Auto-generated method stub + //Add statistics to local cache + ConcurrentMap cache = this.statisticsManager.getStatisticsCache(); + if(!cache.containsKey(notification.getNode())){ + cache.put(notification.getNode(), new NodeStatistics()); + } + cache.get(notification.getNode()).setMeterConfigStats(notification.getMeterConfigStats()); + + //Publish data to configuration data store + DataModificationTransaction it = this.statisticsManager.startChange(); + MeterConfigRef ref = notification.getMeterConfigId(); + + MeterConfigBuilder meterConfig = new MeterConfigBuilder(); + meterConfig.setNode(notification.getNode()); + meterConfig.setMeterConfigStats(notification.getMeterConfigStats()); + + InstanceIdentifier refValue = ref.getValue(); + it.putRuntimeData(refValue, meterConfig.build()); + it.commit(); } @Override public void onMeterStatisticsUpdated(MeterStatisticsUpdated notification) { - // TODO Auto-generated method stub + //Add statistics to local cache + ConcurrentMap cache = this.statisticsManager.getStatisticsCache(); + if(!cache.containsKey(notification.getNode())){ + cache.put(notification.getNode(), new NodeStatistics()); + } + cache.get(notification.getNode()).setMeterStatistics(notification.getMeterStatistics()); + + //Publish data to configuration data store + DataModificationTransaction it = this.statisticsManager.startChange(); + MeterStatsRef ref = notification.getMeterStatsId(); + MeterStatsBuilder meterStats = new MeterStatsBuilder(); + meterStats.setNode(notification.getNode()); + meterStats.setMeterStatistics(notification.getMeterStatistics()); + + InstanceIdentifier refValue = ref.getValue(); + it.putRuntimeData(refValue, meterStats.build()); + it.commit(); } @Override public void onGroupDescStatsUpdated(GroupDescStatsUpdated notification) { - // TODO Auto-generated method stub + //Add statistics to local cache + ConcurrentMap cache = this.statisticsManager.getStatisticsCache(); + if(!cache.containsKey(notification.getNode())){ + cache.put(notification.getNode(), new NodeStatistics()); + } + cache.get(notification.getNode()).setGroupDescStats(notification.getGroupDescStats()); + + //Publish data to configuration data store + DataModificationTransaction it = this.statisticsManager.startChange(); + GroupDescRef ref = notification.getGroupDescId(); + GroupDescBuilder descStats = new GroupDescBuilder(); + descStats.setNode(notification.getNode()); + descStats.setGroupDescStats(notification.getGroupDescStats()); + + InstanceIdentifier refValue = ref.getValue(); + it.putRuntimeData(refValue, descStats.build()); + it.commit(); } @Override public void onGroupStatisticsUpdated(GroupStatisticsUpdated notification) { - // TODO Auto-generated method stub + + //Add statistics to local cache + ConcurrentMap cache = this.statisticsManager.getStatisticsCache(); + if(!cache.containsKey(notification.getNode())){ + cache.put(notification.getNode(), new NodeStatistics()); + } + cache.get(notification.getNode()).setGroupStatistics(notification.getGroupStatistics()); + + //Publish data to configuration data store + DataModificationTransaction it = this.statisticsManager.startChange(); + GroupStatsRef ref = notification.getGroupStatsId(); + GroupStatsBuilder groupStats = new GroupStatsBuilder(); + groupStats.setNode(notification.getNode()); + groupStats.setGroupStatistics(notification.getGroupStatistics()); + + InstanceIdentifier refValue = ref.getValue(); + it.putRuntimeData(refValue, groupStats.build()); + it.commit(); } @Override public void onMeterFeaturesUpdated(MeterFeaturesUpdated notification) { - // TODO Auto-generated method stub + + //Add statistics to local cache + ConcurrentMap cache = this.statisticsManager.getStatisticsCache(); + if(!cache.containsKey(notification.getNode())){ + cache.put(notification.getNode(), new NodeStatistics()); + } + cache.get(notification.getNode()).setMeterFeatures(notification.getMeterFeatures()); + //Publish data to configuration data store + DataModificationTransaction it = this.statisticsManager.startChange(); + MeterFeaturesRef ref = notification.getMeterFeaturesId(); + + MeterFeaturesBuilder meterFeatures = new MeterFeaturesBuilder(); + meterFeatures.setNode(notification.getNode()); + meterFeatures.setMeterFeatures(notification.getMeterFeatures()); + + InstanceIdentifier refValue = ref.getValue(); + it.putRuntimeData(refValue, meterFeatures.build()); + it.commit(); } + @Override public void onGroupFeaturesUpdated(GroupFeaturesUpdated notification) { - // TODO Auto-generated method stub - } + //Add statistics to local cache + ConcurrentMap cache = this.statisticsManager.getStatisticsCache(); + if(!cache.containsKey(notification.getNode())){ + cache.put(notification.getNode(), new NodeStatistics()); + } + cache.get(notification.getNode()).setGroupFeatures(notification.getGroupFeatures()); + + //Publish data to configuration data store + DataModificationTransaction it = this.statisticsManager.startChange(); + GroupFeaturesRef ref = notification.getGroupFeaturesId(); + GroupFeaturesBuilder featuresStats = new GroupFeaturesBuilder(); + featuresStats.setNode(notification.getNode()); + featuresStats.setGroupFeatures(notification.getGroupFeatures()); + + InstanceIdentifier refValue = ref.getValue(); + it.putRuntimeData(refValue, featuresStats.build()); + it.commit(); + } }