container/services/src/main/java/org/mobicents/slee/runtime/sbbentity/SbbEntityLockFacility.java
@CacheEntryRemoved
	public void onNodeRemovedEvent(CacheEntryRemovedEvent event) {
		if(!event.isOriginLocal() && !event.isPre()) {
			// remote node removal
			Fqn fqn = ((NodeKey)event.getKey()).getFqn();
			if (fqn != null) {
				if(doInfoLogs) {
					logger.info("onNodeRemovedEvent( fqn = "+fqn+", size = "+fqn.size()+" )");
				}
				if (fqn.get(0).equals(SbbEntityFactoryCacheData.SBB_ENTITY_FACTORY_FQN_NAME)) {
					// is child of sbb entity factory cache data, i.e., /sbbe
					int fqnSize = fqn.size();
					if (fqnSize < 3) {
						return;
					}
					SbbEntityID sbbEntityID = null;
					if (fqnSize == 3) {
						// /sbbe/serviceid/convergenceName root sbb entity
						ServiceID serviceID = (ServiceID) fqn.get(1);
						String convergenceName = (String) fqn.get(2);
						sbbEntityID = new RootSbbEntityID(serviceID, convergenceName);
						if (doInfoLogs) {
							logger.info("Root sbb entity " + sbbEntityID + " was remotely removed, ensuring there is no local lock");
						}
					} else {
						// must end as /chd/chdRelationName/childId
						if (!fqn.get(fqnSize - 3).equals(SbbEntityCacheData.CHILD_RELATIONs_CHILD_NODE_NAME)) {
							return;
						}
						// let get the party started and rebuild the sbb entity id!
						ServiceID serviceID = (ServiceID) fqn.get(1);
						String convergenceName = (String) fqn.get(2);
						sbbEntityID = new RootSbbEntityID(serviceID, convergenceName);
						int i = 3;
						while (fqnSize >= i + 3) {
							// fqn get(i) is chd, skip
							String childRelationName = (String) fqn.get(i + 1);
							String childId = (String) fqn.get(i + 2);
							sbbEntityID = new NonRootSbbEntityID(sbbEntityID, childRelationName, childId);
							i += 3;
						}
						if (doInfoLogs) {
							logger.info("Non root sbb entity " + sbbEntityID + " was remotely removed, ensuring there is no local lock");
						}
					}
					if (locks.remove(sbbEntityID) != null) {
						if (doInfoLogs) {
							logger.info("Remotely removed lock for " + sbbEntityID);
						}
					}
				}
			}
		}
	}
@CacheEntryRemoved
	public void onNodeRemovedEvent(CacheEntryRemovedEvent event) {
		if(!event.isOriginLocal() && !event.isPre()) {
			// remote node removal
			Fqn fqn = ((NodeKey)event.getKey()).getFqn();
			if (fqn != null) {
				if(doInfoLogs) {
					logger.info("onNodeRemovedEvent( fqn = "+fqn+", size = "+fqn.size()+" )");
				}
				if (fqn.get(0).equals(SbbEntityFactoryCacheData.SBB_ENTITY_FACTORY_FQN_NAME)) {
					// is child of sbb entity factory cache data, i.e., /sbbe
					int fqnSize = fqn.size();
					if (fqnSize < 3) {
						return;
					}
					SbbEntityID sbbEntityID = null;
					if (fqnSize == 3) {
						// /sbbe/serviceid/convergenceName root sbb entity
						ServiceID serviceID = (ServiceID) fqn.get(1);
						String convergenceName = (String) fqn.get(2);
						sbbEntityID = new RootSbbEntityID(serviceID, convergenceName);
						if (doInfoLogs) {
							logger.info("Root sbb entity " + sbbEntityID + " was remotely removed, ensuring there is no local lock");
						}
					} else {
						// must end as /chd/chdRelationName/childId
						if (!fqn.get(fqnSize - 3).equals(SbbEntityCacheData.CHILD_RELATIONs_CHILD_NODE_NAME)) {
							return;
						}
						// let get the party started and rebuild the sbb entity id!
						ServiceID serviceID = (ServiceID) fqn.get(1);
						String convergenceName = (String) fqn.get(2);
						sbbEntityID = new RootSbbEntityID(serviceID, convergenceName);
						int i = 3;
						while (fqnSize >= i + 3) {
							// fqn get(i) is chd, skip
							String childRelationName = (String) fqn.get(i + 1);
							String childId = (String) fqn.get(i + 2);
							sbbEntityID = new NonRootSbbEntityID(sbbEntityID, childRelationName, childId);
							i += 3;
						}
						if (doInfoLogs) {
							logger.info("Non root sbb entity " + sbbEntityID + " was remotely removed, ensuring there is no local lock");
						}
					}
					if (locks.remove(sbbEntityID) != null) {
						if (doInfoLogs) {
							logger.info("Remotely removed lock for " + sbbEntityID);
						}
					}
				}
			}
		}
	}
/*
private class DataRemovaClusterListener implements DataRemovalListener {

private final Fqn<?> baseFqn = null;

@SuppressWarnings("unchecked")
public void dataRemoved(Fqn arg0) {
final SbbEntityID sbbEntityId = (SbbEntityID) arg0.getLastElement();
if(locks.remove(sbbEntityId) != null) {
if(doTraceLogs) {
logger.trace("Remotely removed lock for "+sbbEntityId);
}
}
}

@SuppressWarnings("unchecked")
public Fqn getBaseFqn() {
return baseFqn;
}

}