- // Now notify other containers
- Set<String> containers = (nodeContainerMap.get(node) == null) ? new HashSet<String>() : new HashSet<String>(
- nodeContainerMap.get(node));
- containers.add(GlobalConstants.DEFAULT.toString());
- for (String container : containers) {
- notifyInventoryShimInternalListener(container, node, type, props);
+
+ //establish locality before notifying
+ boolean isNodeLocal;
+ if (type == UpdateType.REMOVED){
+ //if removing get the locality first
+ isNodeLocal = connectionOutService.isLocal(node);
+ notifyGlobalInventoryShimInternalListener(node, type, props);
+ } else {
+ notifyGlobalInventoryShimInternalListener(node, type, props);
+ isNodeLocal = connectionOutService.isLocal(node);
+ }
+
+ if (isNodeLocal) {
+ // Now notify other containers
+ Set<String> containers = (nodeContainerMap.get(node) == null) ? new HashSet<String>() : new HashSet<String>(
+ nodeContainerMap.get(node));
+ containers.add(GlobalConstants.DEFAULT.toString());
+ for (String container : containers) {
+ notifyInventoryShimInternalListener(container, node, type, props);
+ }
+
+ // Notify external listener
+ notifyInventoryShimExternalListener(node, type, props);
+
+ logger.debug("Connection service accepted the inventory notification for {} {}", node, type);
+ } else {
+ logger.debug("Connection service dropped the inventory notification for {} {}", node, type);
+ }
+ }
+
+ private void notifyGlobalInventoryShimInternalListener(Node node, UpdateType type, Set<Property> props) {
+ for (IInventoryShimInternalListener globalListener : globalInventoryShimInternalListeners) {
+ globalListener.updateNode(node, type, props);
+ logger.trace(
+ "notifyGlobalInventoryShimInternalListener {} type {}",
+ new Object[] { node, type });