use of javax.management.NotCompliantMBeanException in project jdk8u_jdk by JetBrains.
the class ManagementFactoryHelper method addMBean.
/**
* Registers a given MBean if not registered in the MBeanServer;
* otherwise, just return.
*/
private static void addMBean(MBeanServer mbs, Object mbean, String mbeanName) {
try {
final ObjectName objName = Util.newObjectName(mbeanName);
// inner class requires these fields to be final
final MBeanServer mbs0 = mbs;
final Object mbean0 = mbean;
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
public Void run() throws MBeanRegistrationException, NotCompliantMBeanException {
try {
mbs0.registerMBean(mbean0, objName);
return null;
} catch (InstanceAlreadyExistsException e) {
// if an instance with the object name exists in
// the MBeanServer ignore the exception
}
return null;
}
});
} catch (PrivilegedActionException e) {
throw Util.newException(e.getException());
}
}
use of javax.management.NotCompliantMBeanException in project ddf by codice.
the class QueryMonitor method registerMbean.
private void registerMbean() {
try {
objectName = new ObjectName(QueryMonitor.class.getName() + ":service=querymonitor");
mBeanServer = ManagementFactory.getPlatformMBeanServer();
} catch (MalformedObjectNameException e) {
LOGGER.info("Unable to create Query Monitor Configuration MBean.", e);
}
if (mBeanServer == null) {
return;
}
try {
try {
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Registered Query Monitor Configuration MBean under object name: {}", objectName.toString());
} catch (InstanceAlreadyExistsException e) {
// Try to remove and re-register
mBeanServer.unregisterMBean(objectName);
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Re-registered Query Monitor Configuration MBean");
}
} catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
LOGGER.info("Could not register MBean [{}].", objectName.toString(), e);
}
}
use of javax.management.NotCompliantMBeanException in project ddf by codice.
the class DataUsage method registerMbean.
private void registerMbean() {
try {
objectName = new ObjectName(DataUsage.class.getName() + ":service=datausage");
mBeanServer = ManagementFactory.getPlatformMBeanServer();
} catch (MalformedObjectNameException e) {
LOGGER.error("Unable to create Data Usage Configuration MBean.", e);
}
if (mBeanServer == null) {
return;
}
try {
try {
mBeanServer.registerMBean(this, objectName);
LOGGER.info("Registered Data Usage Configuration MBean under object name: {}", objectName.toString());
} catch (InstanceAlreadyExistsException e) {
// Try to remove and re-register
mBeanServer.unregisterMBean(objectName);
mBeanServer.registerMBean(this, objectName);
LOGGER.info("Re-registered Data Usage Configuration MBean");
}
} catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
LOGGER.error("Could not register MBean [{}].", objectName.toString(), e);
}
}
use of javax.management.NotCompliantMBeanException in project flink by apache.
the class JMXReporter method notifyOfAddedMetric.
// ------------------------------------------------------------------------
// adding / removing metrics
// ------------------------------------------------------------------------
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
final String domain = generateJmxDomain(metricName, group);
final Hashtable<String, String> table = generateJmxTable(group.getAllVariables());
AbstractBean jmxMetric;
ObjectName jmxName;
try {
jmxName = new ObjectName(domain, table);
} catch (MalformedObjectNameException e) {
/**
* There is an implementation error on our side if this occurs. Either the domain was modified and no longer
* conforms to the JMX domain rules or the table wasn't properly generated.
*/
LOG.debug("Implementation error. The domain or table does not conform to JMX rules.", e);
return;
}
if (metric instanceof Gauge) {
jmxMetric = new JmxGauge((Gauge<?>) metric);
} else if (metric instanceof Counter) {
jmxMetric = new JmxCounter((Counter) metric);
} else if (metric instanceof Histogram) {
jmxMetric = new JmxHistogram((Histogram) metric);
} else if (metric instanceof Meter) {
jmxMetric = new JmxMeter((Meter) metric);
} else {
LOG.error("Cannot add unknown metric type: {}. This indicates that the metric type " + "is not supported by this reporter.", metric.getClass().getName());
return;
}
try {
synchronized (this) {
mBeanServer.registerMBean(jmxMetric, jmxName);
registeredMetrics.put(metric, jmxName);
}
} catch (NotCompliantMBeanException e) {
// implementation error on our side
LOG.debug("Metric did not comply with JMX MBean rules.", e);
} catch (InstanceAlreadyExistsException e) {
LOG.warn("A metric with the name " + jmxName + " was already registered.", e);
} catch (Throwable t) {
LOG.warn("Failed to register metric", t);
}
}
use of javax.management.NotCompliantMBeanException 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);
}
Aggregations