@Override protected void shutDown() throws Exception { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) { OperationalStats operationalStats = entry.getValue(); ObjectName objectName = getObjectName(operationalStats); if (objectName == null) { LOG.warn("Found an operational extension with null service name and stat type while unregistering - {}. " + "Ignoring this extension.", operationalStats.getClass().getName()); continue; } try { mbs.unregisterMBean(objectName); } catch (InstanceNotFoundException e) { LOG.warn("MBean {} not found while un-registering. Ignoring.", objectName); } catch (MBeanRegistrationException e) { LOG.warn("Error while un-registering MBean {}.", e); } operationalStats.destroy(); } LOG.info("Successfully shutdown operational stats service."); }
@Override protected void shutDown() throws Exception { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) { OperationalStats operationalStats = entry.getValue(); ObjectName objectName = getObjectName(operationalStats); if (objectName == null) { LOG.warn("Found an operational extension with null service name and stat type while unregistering - {}. " + "Ignoring this extension.", operationalStats.getClass().getName()); continue; } try { mbs.unregisterMBean(objectName); } catch (InstanceNotFoundException e) { LOG.warn("MBean {} not found while un-registering. Ignoring.", objectName); } catch (MBeanRegistrationException e) { LOG.warn("Error while un-registering MBean {}.", e); } operationalStats.destroy(); } LOG.info("Successfully shutdown operational stats service."); }