use of javax.management.MBeanRegistrationException in project dropwizard by dropwizard.
the class DefaultLoggingFactory method configure.
@Override
public void configure(MetricRegistry metricRegistry, String name) {
LoggingUtil.hijackJDKLogging();
CHANGE_LOGGER_CONTEXT_LOCK.lock();
final Logger root;
try {
root = configureLoggers(name);
} finally {
CHANGE_LOGGER_CONTEXT_LOCK.unlock();
}
final LevelFilterFactory<ILoggingEvent> levelFilterFactory = new ThresholdLevelFilterFactory();
final AsyncAppenderFactory<ILoggingEvent> asyncAppenderFactory = new AsyncLoggingEventAppenderFactory();
final LayoutFactory<ILoggingEvent> layoutFactory = new DropwizardLayoutFactory();
for (AppenderFactory<ILoggingEvent> output : appenders) {
root.addAppender(output.build(loggerContext, name, layoutFactory, levelFilterFactory, asyncAppenderFactory));
}
StatusPrinter.setPrintStream(configurationErrorsStream);
try {
StatusPrinter.printIfErrorsOccured(loggerContext);
} finally {
StatusPrinter.setPrintStream(System.out);
}
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
MBEAN_REGISTRATION_LOCK.lock();
try {
final ObjectName objectName = new ObjectName("io.dropwizard:type=Logging");
if (!server.isRegistered(objectName)) {
server.registerMBean(new JMXConfigurator(loggerContext, server, objectName), objectName);
}
} catch (MalformedObjectNameException | InstanceAlreadyExistsException | NotCompliantMBeanException | MBeanRegistrationException e) {
throw new RuntimeException(e);
} finally {
MBEAN_REGISTRATION_LOCK.unlock();
}
configureInstrumentation(root, metricRegistry);
}
use of javax.management.MBeanRegistrationException in project databus by linkedin.
the class GoldenGateEventProducer method shutdown.
// TBD : Reconcile this behavior in parent class
@Override
public synchronized void shutdown() {
_log.info("Golden gate evert producer shutdown requested.");
_shutdownRequested = true;
for (ObjectName name : _registeredMbeans) {
try {
_mbeanServer.unregisterMBean(name);
_log.info("Unregistered gg-source mbean: " + name);
} catch (MBeanRegistrationException e) {
_log.warn("Exception when unregistering gg-source statistics mbean: " + name + e);
} catch (InstanceNotFoundException e) {
_log.warn("Exception when unregistering gg-source statistics mbean: " + name + e);
}
}
if (_worker != null) {
if (_worker._parser == null) {
_log.error("The parser is null, unable to shutdown the event producer");
return;
}
_worker._parser.setShutDownRequested(true);
_worker.interrupt();
}
_log.warn("Shut down request sent to thread");
}
use of javax.management.MBeanRegistrationException in project archaius by Netflix.
the class ConfigJMXManager method registerConfigMbean.
public static ConfigMBean registerConfigMbean(AbstractConfiguration config) {
StandardMBean mbean = null;
ConfigMBean bean = null;
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
bean = new BaseConfigMBean(config);
mbean = new StandardMBean(bean, ConfigMBean.class);
mbs.registerMBean(mbean, getJMXObjectName(config, bean));
} catch (NotCompliantMBeanException e) {
throw new RuntimeException("NotCompliantMBeanException", e);
} catch (InstanceAlreadyExistsException e) {
throw new RuntimeException("InstanceAlreadyExistsException", e);
} catch (MBeanRegistrationException e) {
throw new RuntimeException("MBeanRegistrationException", e);
} catch (Exception e) {
throw new RuntimeException("registerConfigMbeanException", e);
}
return bean;
}
use of javax.management.MBeanRegistrationException in project redisson by redisson.
the class JCacheManager method enableStatistics.
@Override
public void enableStatistics(String cacheName, boolean enabled) {
checkNotClosed();
if (cacheName == null) {
throw new NullPointerException();
}
JCache<?, ?> cache = caches.get(cacheName);
if (cache == null) {
throw new NullPointerException();
}
if (enabled) {
JCacheStatisticsMXBean statBean = statBeans.get(cache);
if (statBean == null) {
statBean = new JCacheStatisticsMXBean();
JCacheStatisticsMXBean oldBean = statBeans.putIfAbsent(cache, statBean);
if (oldBean != null) {
statBean = oldBean;
}
}
try {
ObjectName objectName = queryNames("Statistics", cache);
if (!mBeanServer.isRegistered(objectName)) {
mBeanServer.registerMBean(statBean, objectName);
}
} catch (MalformedObjectNameException e) {
throw new CacheException(e);
} catch (InstanceAlreadyExistsException e) {
throw new CacheException(e);
} catch (MBeanRegistrationException e) {
throw new CacheException(e);
} catch (NotCompliantMBeanException e) {
throw new CacheException(e);
}
} else {
unregisterStatisticsBean(cache);
}
cache.getConfiguration(JCacheConfiguration.class).setStatisticsEnabled(enabled);
}
use of javax.management.MBeanRegistrationException in project quasar by puniverse.
the class JMXFibersMonitor method registerMBean.
@SuppressWarnings({ "CallToPrintStackTrace", "CallToThreadDumpStack" })
protected void registerMBean() {
try {
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
final ObjectName mxbeanName = new ObjectName(mbeanName);
mbs.registerMBean(this, mxbeanName);
this.registered = true;
} catch (InstanceAlreadyExistsException ex) {
throw new RuntimeException(ex);
} catch (MBeanRegistrationException ex) {
ex.printStackTrace();
} catch (NotCompliantMBeanException ex) {
throw new AssertionError(ex);
} catch (MalformedObjectNameException ex) {
throw new AssertionError(ex);
}
MonitoringServices.getInstance().addPerfNotificationListener(this, mbeanName);
}
Aggregations