+ private void updatePacketInRateLimiters() {
+ synchronized (deviceContexts) {
+ final int deviceContextsSize = deviceContexts.size();
+ if (deviceContextsSize > 0) {
+ long freshNotificationLimit = globalNotificationQuota / deviceContextsSize;
+ if (freshNotificationLimit < 100) {
+ freshNotificationLimit = 100;
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("fresh notification limit = {}", freshNotificationLimit);
+ }
+ for (final DeviceContext deviceContext : deviceContexts.values()) {
+ deviceContext.updatePacketInRateLimit(freshNotificationLimit);
+ }
+ }
+ }
+ }
+
+ public void onDeviceRemoved(DeviceInfo deviceInfo) {
+ DeviceContext deviceContext = deviceContexts.remove(deviceInfo);
+ removeddeviceContexts.putIfAbsent(deviceInfo, deviceContext);
+ LOG.debug("Device context removed for node {}", deviceInfo.getLOGValue());
+
+ lifecycleServices.remove(deviceInfo);
+ LOG.debug("Lifecycle service removed for node {}", deviceInfo.getLOGValue());
+ }
+
+ @Override
+ public void ownershipChanged(EntityOwnershipChange entityOwnershipChange) {
+ if (!entityOwnershipChange.hasOwner()) {
+ final YangInstanceIdentifier yii = entityOwnershipChange.getEntity().getId();
+ final YangInstanceIdentifier.NodeIdentifierWithPredicates niiwp =
+ (YangInstanceIdentifier.NodeIdentifierWithPredicates) yii.getLastPathArgument();
+ String entityName = niiwp.getKeyValues().values().iterator().next().toString();
+ LOG.info("Entity ownership changed for device : {} : {}", entityName, entityOwnershipChange);
+
+ if (entityName != null ){
+ if (!removeddeviceContexts.isEmpty()) {
+ for (DeviceInfo device : removeddeviceContexts.keySet()) {
+ if (device.getNodeId().getValue().equals(entityName)) {
+ LOG.info("Cleaning up operational data of the node : {}", entityName);
+ // No owner present for the entity, clean up the data and remove it from
+ // removed context.
+ removeddeviceContexts.remove(device).cleanupDeviceData();
+ return;
+ }
+ }
+ }
+ removeDeviceFromOperationalDS(DeviceStateUtil.createNodeInstanceIdentifier(new NodeId(entityName)),
+ entityName);
+ }
+ }
+ }