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 genius by opendaylight.
the class PortNameMapping method registerPortMappingBean.
public static void registerPortMappingBean() {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName mbeanName = null;
try {
mbeanName = new ObjectName(beanName);
} catch (MalformedObjectNameException e) {
LOG.error("ObjectName instance creation failed for BEANAME {}", beanName, e);
}
try {
if (!mbs.isRegistered(mbeanName)) {
mbs.registerMBean(new PortNameMapping(), mbeanName);
LOG.debug("Registered Mbean {} successfully", mbeanName);
}
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
LOG.error("Registeration failed for Mbean {}", mbeanName, e);
}
}
use of javax.management.NotCompliantMBeanException in project infrautils by opendaylight.
the class MBeanUtils method registerServerMBean.
public static MBeanServer registerServerMBean(Object mxBeanImplementor, String objNameStr) throws JMException {
LOG.debug("register MBean for {}", objNameStr);
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
ObjectName objName = new ObjectName(objNameStr);
mbs.registerMBean(mxBeanImplementor, objName);
LOG.info("MBean registration for {} SUCCESSFUL.", objNameStr);
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | MalformedObjectNameException ex) {
LOG.error("MBean registration for {} FAILED.", objNameStr, ex);
throw ex;
}
return mbs;
}
use of javax.management.NotCompliantMBeanException in project infrautils by opendaylight.
the class AbstractMXBean method registerMBean.
/**
* Registers this bean with the platform MBean server with the domain defined by
* {@link #BASE_JMX_PREFIX}.
*
* @return true is successfully registered, false otherwise.
*/
protected final boolean registerMBean() {
@Var boolean registered = false;
try {
// Object to identify MBean
ObjectName mbeanObjectName = this.getMBeanObjectName();
LOG.debug("Register MBean {}", mbeanObjectName);
// unregistered if already registered
if (server.isRegistered(mbeanObjectName)) {
LOG.debug("MBean {} found to be already registered", mbeanObjectName);
try {
unregisterMBean(mbeanObjectName);
} catch (MBeanRegistrationException | InstanceNotFoundException e) {
LOG.warn("unregister mbean {} caused exception", mbeanObjectName, e);
}
}
server.registerMBean(this, mbeanObjectName);
registered = true;
LOG.debug("MBean {} registered successfully", mbeanObjectName.getCanonicalName());
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | MalformedObjectNameException e) {
LOG.error("MBean {} registration failed", mbeanName, e);
}
return registered;
}
use of javax.management.NotCompliantMBeanException in project jvm-tools by aragozin.
the class HotspotInternalMBeanEnabler method start.
@Override
public void start(Properties agentProps, String agentArgs, Instrumentation inst) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
try {
String mname = "sun.management:type=HotspotThreading";
MBeanInfo info = ManagementFactory.getPlatformMBeanServer().getMBeanInfo(new ObjectName(mname));
if (info != null) {
// bean is present
agentProps.put(this.getClass().getName() + ".enabled", "true");
return;
}
} catch (Exception e) {
// ignore
}
HotspotInternal hi = new HotspotInternal();
ManagementFactory.getPlatformMBeanServer().registerMBean(hi, null);
agentProps.put(this.getClass().getName() + ".enabled", "true");
}
Aggregations