private void doHandleNotification(Notification notif, Object o) { LOGGER.trace("handleNotification[{}]", notif); if (notif instanceof MBeanServerNotification) { MBeanServerNotification notification = (MBeanServerNotification) notif; String domain = notification.getMBeanName().getDomain(); String path = CONTAINER_DOMAIN.getPath((String) o, domain); try { if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notification.getType())) { if (domains.add(domain) && exists(curator.get(), path) == null) { setData(curator.get(), path, ""); } } else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals( notification.getType())) { domains.clear(); domains.addAll(Arrays.asList(mbeanServer.get().getDomains())); if (!domains.contains(domain)) { // domain is no present any more deleteSafe(curator.get(), path); } } } catch (Exception e) { LOGGER.warn( "Exception while jmx domain synchronization from event: " + notif + ". This exception will be ignored.", e); } } }
private void registerDomains() throws Exception { String runtimeIdentity = runtimeProperties.get().getRuntimeIdentity(); synchronized (this) { domains.addAll(Arrays.asList(mbeanServer.get().getDomains())); } for (String domain : mbeanServer.get().getDomains()) { setData( curator.get(), CONTAINER_DOMAIN.getPath(runtimeIdentity, domain), "", CreateMode.EPHEMERAL); } }