use of javax.management.JMException in project fabric8 by fabric8io.
the class ManagedApiFeature method initialize.
@Override
public void initialize(Server server, Bus bus) {
ManagedApi mApi = new ManagedApi(bus, server.getEndpoint(), server);
InstrumentationManager iMgr = bus.getExtension(InstrumentationManager.class);
if (iMgr != null) {
try {
iMgr.register(mApi);
ServerLifeCycleManager slcMgr = bus.getExtension(ServerLifeCycleManager.class);
if (slcMgr != null) {
slcMgr.registerListener(mApi);
slcMgr.startServer(server);
}
} catch (JMException jmex) {
jmex.printStackTrace();
LOG.log(Level.WARNING, "Registering ManagedApi failed.", jmex);
}
}
}
use of javax.management.JMException in project presto by prestodb.
the class JmxMetadata method getJmxTableHandle.
private JmxTableHandle getJmxTableHandle(SchemaTableName tableName) {
try {
String objectNamePattern = toPattern(tableName.getTableName().toLowerCase(ENGLISH));
List<ObjectName> objectNames = mbeanServer.queryNames(WILDCARD, null).stream().filter(name -> name.getCanonicalName().toLowerCase(ENGLISH).matches(objectNamePattern)).collect(toImmutableList());
if (objectNames.isEmpty()) {
return null;
}
List<JmxColumnHandle> columns = new ArrayList<>();
columns.add(new JmxColumnHandle(NODE_COLUMN_NAME, createUnboundedVarcharType()));
columns.add(new JmxColumnHandle(OBJECT_NAME_NAME, createUnboundedVarcharType()));
for (ObjectName objectName : objectNames) {
MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
getColumnHandles(mbeanInfo).forEach(columns::add);
}
// Since this method is being called on all nodes in the cluster, we must ensure (by sorting)
// that attributes are in the same order on all of them.
columns = columns.stream().distinct().sorted(comparing(JmxColumnHandle::getColumnName)).collect(toImmutableList());
return new JmxTableHandle(tableName, objectNames.stream().map(ObjectName::toString).collect(toImmutableList()), columns, true);
} catch (JMException e) {
return null;
}
}
use of javax.management.JMException in project kafka by apache.
the class AppInfoParser method unregisterAppInfo.
public static synchronized void unregisterAppInfo(String prefix, String id, Metrics metrics) {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
try {
ObjectName name = new ObjectName(prefix + ":type=app-info,id=" + Sanitizer.jmxSanitize(id));
if (server.isRegistered(name))
server.unregisterMBean(name);
unregisterMetrics(metrics);
} catch (JMException e) {
log.warn("Error unregistering AppInfo mbean", e);
} finally {
log.info("App info {} for {} unregistered", prefix, id);
}
}
use of javax.management.JMException in project kafka by apache.
the class AppInfoParser method registerAppInfo.
public static synchronized void registerAppInfo(String prefix, String id, Metrics metrics, long nowMs) {
try {
ObjectName name = new ObjectName(prefix + ":type=app-info,id=" + Sanitizer.jmxSanitize(id));
AppInfo mBean = new AppInfo(nowMs);
ManagementFactory.getPlatformMBeanServer().registerMBean(mBean, name);
// prefix will be added later by JmxReporter
registerMetrics(metrics, mBean);
} catch (JMException e) {
log.warn("Error registering AppInfo mbean", e);
}
}
use of javax.management.JMException in project wildfly by wildfly.
the class EndpointService method registerEndpoint.
private void registerEndpoint(final Endpoint endpoint) {
MBeanServer mbeanServer = serverConfigService.get().getMbeanServer();
if (mbeanServer != null) {
try {
ManagedEndpoint jmxEndpoint = new ManagedEndpoint(endpoint, mbeanServer);
mbeanServer.registerMBean(jmxEndpoint, endpoint.getName());
} catch (final JMException ex) {
WSLogger.ROOT_LOGGER.trace("Cannot register endpoint in JMX server", ex);
WSLogger.ROOT_LOGGER.cannotRegisterEndpoint(endpoint.getShortName());
}
} else {
WSLogger.ROOT_LOGGER.mBeanServerNotAvailable(endpoint.getShortName());
}
}
Aggregations