* so we have to try get statistics for it and wait for response
* Error or response package with results.
*/
- METER_STATS
+ METER_STATS,
+
+ //Custom flags for meter feature stats
+ METER_FEATURE_STATS,
+
+ //Custom flags for group feature stats
+ GROUP_FEATURE_STATS
}
/**
*/
boolean registerAdditionalNodeFeature(InstanceIdentifier<Node> nodeIdent, StatCapabTypes statCapab);
+ /**
+ * Method remove stats {@link StatCapabTypes} from Node identified by
+ * nodeIdent -> InstanceIdentifier<Node>
+ *
+ * @param nodeIdent
+ * @return true/false if the {@link StatCapabTypes} remove successful
+ */
+ boolean unregisterNodeStats(InstanceIdentifier<Node> nodeIdent, StatCapabTypes statCapab);
+
/**
* Method return true only and only if {@link StatPermCollector} contain
* valid node registration in its internal {@link Node} map.
*/
void registerAdditionalNodeFeature(InstanceIdentifier<Node> nodeIdent, StatCapabTypes statCapab);
+ /**
+ * Method wraps {@link StatPermCollector}.unregisterNodeStats to provide
+ * possibility to unregister Node stats type {@link StatCapabTypes} from
+ * statistics collecting.
+ *
+ * @param nodeIdent
+ * @param statCapab
+ */
+ void unregisterNodeStats(InstanceIdentifier<Node> nodeIdent, StatCapabTypes statCapab);
+
/**
* Method provides access to Device RPC methods by wrapped
* internal method. In next {@link StatRpcMsgManager} is registered all
return;
}
- if(!nodeRegistrationManager.isFlowCapableNodeOwner(nodeId)) { return; }
-
final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier
.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
+ manager.registerAdditionalNodeFeature(nodeIdent, StatCapabTypes.GROUP_STATS);
+
+ if(!nodeRegistrationManager.isFlowCapableNodeOwner(nodeId)) { return; }
+
final List<? extends TransactionAware> cacheNotifs = txContainer.get().getNotifications();
for (final TransactionAware notif : cacheNotifs) {
if ( ! (notif instanceof GroupFeaturesUpdated)) {
if (node.isPresent()) {
tx.merge(LogicalDatastoreType.OPERATIONAL, nodeGroupFeatureIdent, new NodeGroupFeaturesBuilder().build(), true);
tx.put(LogicalDatastoreType.OPERATIONAL, groupFeatureIdent, stats);
- manager.registerAdditionalNodeFeature(nodeIdent, StatCapabTypes.GROUP_STATS);
+ manager.unregisterNodeStats(nodeIdent, StatCapabTypes.GROUP_FEATURE_STATS);
+ } else {
+ LOG.debug("Node {} is NOT present in the operational data store",nodeId);
}
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionAware;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+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.inventory.rev130819.nodes.NodeKey;
}
if(!nodeRegistrationManager.isFlowCapableNodeOwner(nodeId)) { return; }
-
/* Prepare List actual Meters and not updated Meters will be removed */
final List<Meter> existMeters = fNode.get().getMeter() != null
? fNode.get().getMeter() : Collections.<Meter> emptyList();
return;
}
- if(!nodeRegistrationManager.isFlowCapableNodeOwner(nodeId)) { return; }
-
final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier
.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
+ //Register meter feature irrespective of whether this instance is
+ //master instance of the device or not. In cluster mode, all instances
+ // should have knowledge if meter is supported by the device.
+ manager.registerAdditionalNodeFeature(nodeIdent, StatCapabTypes.METER_STATS);
+
+ if(!nodeRegistrationManager.isFlowCapableNodeOwner(nodeId)) { return; }
+
final List<? extends TransactionAware> cacheNotifs = txContainer.get().getNotifications();
for (final TransactionAware notif : cacheNotifs) {
if ( ! (notif instanceof MeterFeaturesUpdated)) {
if (node.isPresent()) {
tx.merge(LogicalDatastoreType.OPERATIONAL, nodeMeterFeatureIdent, new NodeMeterFeaturesBuilder().build(), true);
tx.put(LogicalDatastoreType.OPERATIONAL, meterFeatureIdent, stats);
- manager.registerAdditionalNodeFeature(nodeIdent, StatCapabTypes.METER_STATS);
+ manager.unregisterNodeStats(nodeIdent, StatCapabTypes.METER_FEATURE_STATS);
+ } else {
+ LOG.debug("Node {} is NOT present in the operational data store",nodeId);
}
}
}
statCapabTypes.add(StatCapabTypes.QUEUE_STATS);
}
}
+
+ statCapabTypes.add(StatCapabTypes.GROUP_FEATURE_STATS);
+ statCapabTypes.add(StatCapabTypes.METER_FEATURE_STATS);
+
maxCapTables = data.getMaxTables();
final Optional<Short> maxTables = Optional.<Short> of(maxCapTables);
NodeId nodeId = InstanceIdentifier.keyOf(nodeIdent).getId();
boolean ownershipState = preConfigurationCheck(nodeId);
setNodeOwnership(nodeId, ownershipState);
- if(ownershipState) {
- LOG.info("onNodeUpdated: Send group/meter feature request to the device {}",nodeIdent);
- manager.getRpcMsgManager().getGroupFeaturesStat(nodeRef);
- manager.getRpcMsgManager().getMeterFeaturesStat(nodeRef);
- }
+ LOG.info("onNodeUpdated: Send group/meter feature request to the device {}",nodeIdent);
+ manager.getRpcMsgManager().getGroupFeaturesStat(nodeRef);
+ manager.getRpcMsgManager().getMeterFeaturesStat(nodeRef);
}
}
@Override
public boolean isFlowCapableNodeOwner(NodeId node) {
if(this.nodeOwnershipState.containsKey(node)){
- return this.nodeOwnershipState.get(node).booleanValue();
+ boolean state = this.nodeOwnershipState.get(node).booleanValue();
+ LOG.debug("Is Node {} owned by this instance : {}",node, state);
+ return state;
}
return false;
}
-
@Override
public void ownershipChanged(EntityOwnershipChange ownershipChange) {
}
private void setNodeOwnership(NodeId node, boolean ownership) {
+ LOG.debug("Set {} ownership for Node {}",ownership?"Master":"Slave",node);
this.nodeOwnershipState.put(node,ownership);
}
return true;
}
+ @Override
+ public boolean unregisterNodeStats(final InstanceIdentifier<Node> ident,
+ final StatCapabTypes statCapab) {
+ if (isNodeIdentValidForUse(ident)) {
+ if ( ! statNodeHolder.containsKey(ident)) {
+ return false;
+ }
+ final StatNodeInfoHolder statNode = statNodeHolder.get(ident);
+ if ( statNode.getStatMarkers().contains(statCapab)) {
+ synchronized (statNodeHolderLock) {
+ if ( statNode.getStatMarkers().contains(statCapab)) {
+ final List<StatCapabTypes> statCapabForEdit = new ArrayList<>(statNode.getStatMarkers());
+ statCapabForEdit.remove(statCapab);
+ final StatNodeInfoHolder nodeInfoHolder = new StatNodeInfoHolder(statNode.getNodeRef(),
+ Collections.unmodifiableList(statCapabForEdit), statNode.getMaxTables());
+
+ final Map<InstanceIdentifier<Node>, StatNodeInfoHolder> statNodes =
+ new HashMap<>(statNodeHolder);
+ statNodes.put(ident, nodeInfoHolder);
+ statNodeHolder = Collections.unmodifiableMap(statNodes);
+ }
+ }
+ }
+ }
+ return true;
+ }
+
@Override
public void collectNextStatistics(final TransactionId xid) {
if (checkTransactionId(xid) && wakeMe) {
manager.getRpcMsgManager().getAggregateFlowStat(actualNodeRef, tableId);
}*/
break;
+ case METER_FEATURE_STATS:
+ LOG.trace("STAT-MANAGER-collecting METER-FEATURE-STATS for NodeRef {}", actualNodeRef);
+ manager.getRpcMsgManager().getMeterFeaturesStat(actualNodeRef);
+ break;
+ case GROUP_FEATURE_STATS:
+ LOG.trace("STAT-MANAGER-collecting GROUP-FEATURE-STATS for NodeRef {}", actualNodeRef);
+ manager.getRpcMsgManager().getGroupFeaturesStat(actualNodeRef);
+ break;
default:
/* Exception for programmers in implementation cycle */
throw new IllegalStateException("Not implemented ASK for " + statMarker);
LOG.debug("Node {} has not been extended for feature {}!", nodeIdent, statCapab);
}
+ @Override
+ public void unregisterNodeStats(final InstanceIdentifier<Node> nodeIdent,
+ final StatCapabTypes statCapab) {
+ for (final StatPermCollector collector : statCollectors) {
+ if (collector.unregisterNodeStats(nodeIdent, statCapab)) {
+ return;
+ }
+ }
+ LOG.debug("Stats type {} is not removed from the node {}!", statCapab,nodeIdent );
+ }
+
/* Getter internal Statistic Manager Job Classes */
@Override
public StatRpcMsgManager getRpcMsgManager() {