import com.google.common.base.Preconditions;
/**
- * Main responsibility of this class to clean up all the stale statistics data
- * associated to Flow,Meter,Group,Queue.
- * @author avishnoi@in.ibm.com
+ * This class handles the lifecycle of per-node statistics. It receives data
+ * from StatisticsListener, stores it in the data store and keeps track of
+ * when the data should be removed.
*
+ * @author avishnoi@in.ibm.com
*/
-public class NodeStatisticsAger {
- private static final Logger logger = LoggerFactory.getLogger(NodeStatisticsAger.class);
+public class NodeStatisticsHandler {
+ private static final Logger logger = LoggerFactory.getLogger(NodeStatisticsHandler.class);
private static final int NUMBER_OF_WAIT_CYCLES = 2;
private final Map<GroupDescStats,Long> groupDescStatsUpdate = new HashMap<>();
private final NodeKey targetNodeKey;
private int unaccountedFlowsCounter = 1;
- public NodeStatisticsAger(StatisticsProvider statisticsProvider, NodeKey nodeKey){
+ public NodeStatisticsHandler(StatisticsProvider statisticsProvider, NodeKey nodeKey){
this.statisticsProvider = Preconditions.checkNotNull(statisticsProvider);
this.targetNodeKey = Preconditions.checkNotNull(nodeKey);
this.targetNodeIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class, targetNodeKey).build();
return true;
}
- private NodeStatisticsAger getOuterType() {
- return NodeStatisticsAger.this;
+ private NodeStatisticsHandler getOuterType() {
+ return NodeStatisticsHandler.this;
}
}
import org.slf4j.LoggerFactory;
/**
- * Class implement statistics manager related listener interface and augment all the
- * received statistics data to data stores.
+ * This class is responsible for listening for statistics update notifications and
+ * routing them to the appropriate NodeStatisticsHandler.
+
* TODO: Need to add error message listener and clean-up the associated tx id
* if it exists in the tx-id cache.
* @author vishnoianil
- *
*/
-public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsListener,
+public class StatisticsListener implements OpendaylightGroupStatisticsListener,
OpendaylightMeterStatisticsListener,
OpendaylightFlowStatisticsListener,
OpendaylightPortStatisticsListener,
OpendaylightFlowTableStatisticsListener,
OpendaylightQueueStatisticsListener{
- private final static Logger sucLogger = LoggerFactory.getLogger(StatisticsUpdateCommiter.class);
+ private final static Logger sucLogger = LoggerFactory.getLogger(StatisticsListener.class);
private final StatisticsProvider statisticsManager;
private final MultipartMessageManager messageManager;
* default ctor
* @param manager
*/
- public StatisticsUpdateCommiter(final StatisticsProvider manager){
+ public StatisticsListener(final StatisticsProvider manager){
this.statisticsManager = manager;
this.messageManager = this.statisticsManager.getMultipartMessageManager();
}
return;
//Add statistics to local cache
- final NodeStatisticsAger sna = this.statisticsManager.getStatisticsHandler(notification.getId());
- if (sna != null) {
- sna.updateMeterConfigStats(notification.getMeterConfigStats());
+ final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
+ if (handler != null) {
+ handler.updateMeterConfigStats(notification.getMeterConfigStats());
}
}
return;
//Add statistics to local cache
- final NodeStatisticsAger nsa = this.statisticsManager.getStatisticsHandler(notification.getId());
- if (nsa != null) {
- nsa.updateMeterStats(notification.getMeterStats());
+ final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
+ if (handler != null) {
+ handler.updateMeterStats(notification.getMeterStats());
}
}
if(!messageManager.isRequestTxIdExist(notification.getId(),notification.getTransactionId(),notification.isMoreReplies()))
return;
- final NodeStatisticsAger nsa = statisticsManager.getStatisticsHandler(notification.getId());
- if (nsa != null) {
- nsa.updateGroupDescStats(notification.getGroupDescStats());
+ final NodeStatisticsHandler handler = statisticsManager.getStatisticsHandler(notification.getId());
+ if (handler != null) {
+ handler.updateGroupDescStats(notification.getGroupDescStats());
}
}
if(!messageManager.isRequestTxIdExist(notification.getId(),notification.getTransactionId(),notification.isMoreReplies()))
return;
- final NodeStatisticsAger nsa = statisticsManager.getStatisticsHandler(notification.getId());
- if (nsa != null) {
- nsa.updateGroupStats(notification.getGroupStats());
+ final NodeStatisticsHandler handler = statisticsManager.getStatisticsHandler(notification.getId());
+ if (handler != null) {
+ handler.updateGroupStats(notification.getGroupStats());
}
}
@Override
public void onMeterFeaturesUpdated(MeterFeaturesUpdated notification) {
- final NodeStatisticsAger sna = this.statisticsManager.getStatisticsHandler(notification.getId());
+ final NodeStatisticsHandler sna = this.statisticsManager.getStatisticsHandler(notification.getId());
if (sna != null) {
sna.updateMeterFeatures(notification);
}
@Override
public void onGroupFeaturesUpdated(GroupFeaturesUpdated notification) {
- final NodeStatisticsAger sna = this.statisticsManager.getStatisticsHandler(notification.getId());
+ final NodeStatisticsHandler sna = this.statisticsManager.getStatisticsHandler(notification.getId());
if (sna != null) {
sna.updateGroupFeatures(notification);
}
return;
sucLogger.debug("Received flow stats update : {}",notification.toString());
- final NodeStatisticsAger sna = this.statisticsManager.getStatisticsHandler(notification.getId());
+ final NodeStatisticsHandler sna = this.statisticsManager.getStatisticsHandler(notification.getId());
if (sna != null) {
sna.updateFlowStats(notification.getFlowAndStatisticsMapList());
}
if(!messageManager.isRequestTxIdExist(notification.getId(),notification.getTransactionId(),notification.isMoreReplies()))
return;
- final NodeStatisticsAger nsa = this.statisticsManager.getStatisticsHandler(notification.getId());
- if (nsa != null) {
+ final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
+ if (handler != null) {
final Short tableId = messageManager.getTableIdForTxId(notification.getId(),notification.getTransactionId());
- nsa.updateAggregateFlowStats(tableId, notification);
+ handler.updateAggregateFlowStats(tableId, notification);
}
}
if(!messageManager.isRequestTxIdExist(notification.getId(),notification.getTransactionId(),notification.isMoreReplies()))
return;
- final NodeStatisticsAger nsa = this.statisticsManager.getStatisticsHandler(notification.getId());
- if (nsa != null) {
- nsa.updateNodeConnectorStats(notification.getNodeConnectorStatisticsAndPortNumberMap());
+ final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
+ if (handler != null) {
+ handler.updateNodeConnectorStats(notification.getNodeConnectorStatisticsAndPortNumberMap());
}
}
if(!messageManager.isRequestTxIdExist(notification.getId(),notification.getTransactionId(),notification.isMoreReplies()))
return;
- final NodeStatisticsAger nsa = this.statisticsManager.getStatisticsHandler(notification.getId());
- if (nsa != null) {
- nsa.updateFlowTableStats(notification.getFlowTableAndStatisticsMap());
+ final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
+ if (handler != null) {
+ handler.updateFlowTableStats(notification.getFlowTableAndStatisticsMap());
}
}
return;
//Add statistics to local cache
- final NodeStatisticsAger nsa = this.statisticsManager.getStatisticsHandler(notification.getId());
- if (nsa != null) {
- nsa.updateQueueStats(notification.getQueueIdAndStatisticsMap());
+ final NodeStatisticsHandler handler = this.statisticsManager.getStatisticsHandler(notification.getId());
+ if (handler != null) {
+ handler.updateQueueStats(notification.getQueueIdAndStatisticsMap());
}
}
}
private final DataProviderService dps;
//Local caching of stats
- private final ConcurrentMap<NodeId,NodeStatisticsAger> statisticsCache = new ConcurrentHashMap<>();
+ private final ConcurrentMap<NodeId,NodeStatisticsHandler> statisticsCache = new ConcurrentHashMap<>();
private OpendaylightGroupStatisticsService groupStatsService;
return multipartMessageManager;
}
- private final StatisticsUpdateCommiter updateCommiter = new StatisticsUpdateCommiter(StatisticsProvider.this);
+ private final StatisticsListener updateCommiter = new StatisticsListener(StatisticsProvider.this);
private Registration<NotificationListener> listenerRegistration;
public void run() {
while(true){
try {
- for(NodeStatisticsAger nodeStatisticsAger : statisticsCache.values()){
+ for(NodeStatisticsHandler nodeStatisticsAger : statisticsCache.values()){
nodeStatisticsAger.cleanStaleStatistics();
}
multipartMessageManager.cleanStaleTransactionIds();
* @return Node statistics handler for that node. Null if the statistics should
* not handled.
*/
- public final NodeStatisticsAger getStatisticsHandler(final NodeId nodeId) {
+ public final NodeStatisticsHandler getStatisticsHandler(final NodeId nodeId) {
Preconditions.checkNotNull(nodeId);
- NodeStatisticsAger ager = statisticsCache.get(nodeId);
+ NodeStatisticsHandler ager = statisticsCache.get(nodeId);
if (ager == null) {
- ager = new NodeStatisticsAger(this, new NodeKey(nodeId));
+ ager = new NodeStatisticsHandler(this, new NodeKey(nodeId));
statisticsCache.put(nodeId, ager);
}