use of javax.management.MalformedObjectNameException in project common by zenlunatics.
the class Admin method writeTomcatState.
// --------------------------------------------------------------------------
private void writeTomcatState(Request request) throws IOException {
DecimalFormat df = new DecimalFormat();
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
try {
request.writer.h4("Memory");
Table table = new Table(request.writer).addClass("table table-condensed table-striped").addStyle("width", "auto");
Runtime runtime = Runtime.getRuntime();
table.tr().td("max").td(df.format(runtime.maxMemory()));
table.tr().td("total").td(df.format(runtime.totalMemory()));
table.tr().td("free").td(df.format(runtime.freeMemory()));
table.tr().td("used").td(df.format(runtime.totalMemory() - runtime.freeMemory()));
table.close();
request.writer.h4("Sessions");
String context = request.getContext();
if (context == null || context.length() == 0)
context = "/";
ObjectName objectName = new ObjectName("Catalina:type=Manager,context=" + context + ",host=localhost");
table = new Table(request.writer).addClass("table table-condensed table-striped").addStyle("width", "auto");
table.tr().td("count").td(mBeanServer.getAttribute(objectName, "sessionCounter").toString());
table.tr().td("active").td(mBeanServer.getAttribute(objectName, "activeSessions").toString());
table.tr().td("expired").td(mBeanServer.getAttribute(objectName, "expiredSessions").toString());
table.close();
} catch (MalformedObjectNameException | AttributeNotFoundException | InstanceNotFoundException | MBeanException | ReflectionException e) {
System.out.println(e);
}
}
use of javax.management.MalformedObjectNameException in project component-runtime by Talend.
the class JmxManager method onCreate.
@Override
public void onCreate(final Container container) {
try {
final ObjectName name = new ObjectName(String.format(namePattern, container.getId()));
server.registerMBean(new ContainerMBean(manager, container), name);
container.set(JmxData.class, new JmxData(name));
} catch (final InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | MalformedObjectNameException e) {
log.warn(e.getMessage(), e);
}
}
use of javax.management.MalformedObjectNameException in project redisson by redisson.
the class JCacheManager method enableManagement.
@Override
public void enableManagement(String cacheName, boolean enabled) {
checkNotClosed();
if (cacheName == null) {
throw new NullPointerException();
}
JCache<?, ?> cache = caches.get(cacheName);
if (cache == null) {
throw new NullPointerException();
}
if (enabled) {
JCacheManagementMXBean statBean = managementBeans.get(cache);
if (statBean == null) {
statBean = new JCacheManagementMXBean(cache);
JCacheManagementMXBean oldBean = managementBeans.putIfAbsent(cache, statBean);
if (oldBean != null) {
statBean = oldBean;
}
}
try {
ObjectName objectName = queryNames("Configuration", cache);
if (mBeanServer.queryNames(objectName, null).isEmpty()) {
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 {
unregisterManagementBean(cache);
}
cache.getConfiguration(JCacheConfiguration.class).setManagementEnabled(enabled);
}
use of javax.management.MalformedObjectNameException in project cassandra by apache.
the class ColumnFamilyStoreMBeanIterator method connect.
/**
* Create a connection to the JMX agent and setup the M[X]Bean proxies.
*
* @throws IOException on connection failures
*/
protected void connect() throws IOException {
JMXServiceURL jmxUrl = new JMXServiceURL(String.format(fmtUrl, host, port));
Map<String, Object> env = new HashMap<String, Object>();
if (username != null) {
String[] creds = { username, password };
env.put(JMXConnector.CREDENTIALS, creds);
}
env.put("com.sun.jndi.rmi.factory.socket", getRMIClientSocketFactory());
jmxc = JMXConnectorFactory.connect(jmxUrl, env);
mbeanServerConn = jmxc.getMBeanServerConnection();
try {
ObjectName name = new ObjectName(ssObjName);
ssProxy = JMX.newMBeanProxy(mbeanServerConn, name, StorageServiceMBean.class);
name = new ObjectName(MessagingService.MBEAN_NAME);
msProxy = JMX.newMBeanProxy(mbeanServerConn, name, MessagingServiceMBean.class);
name = new ObjectName(StreamManagerMBean.OBJECT_NAME);
streamProxy = JMX.newMBeanProxy(mbeanServerConn, name, StreamManagerMBean.class);
name = new ObjectName(CompactionManager.MBEAN_OBJECT_NAME);
compactionProxy = JMX.newMBeanProxy(mbeanServerConn, name, CompactionManagerMBean.class);
name = new ObjectName(FailureDetector.MBEAN_NAME);
fdProxy = JMX.newMBeanProxy(mbeanServerConn, name, FailureDetectorMBean.class);
name = new ObjectName(CacheService.MBEAN_NAME);
cacheService = JMX.newMBeanProxy(mbeanServerConn, name, CacheServiceMBean.class);
name = new ObjectName(StorageProxy.MBEAN_NAME);
spProxy = JMX.newMBeanProxy(mbeanServerConn, name, StorageProxyMBean.class);
name = new ObjectName(HintsService.MBEAN_NAME);
hsProxy = JMX.newMBeanProxy(mbeanServerConn, name, HintsServiceMBean.class);
name = new ObjectName(GCInspector.MBEAN_NAME);
gcProxy = JMX.newMBeanProxy(mbeanServerConn, name, GCInspectorMXBean.class);
name = new ObjectName(Gossiper.MBEAN_NAME);
gossProxy = JMX.newMBeanProxy(mbeanServerConn, name, GossiperMBean.class);
name = new ObjectName(BatchlogManager.MBEAN_NAME);
bmProxy = JMX.newMBeanProxy(mbeanServerConn, name, BatchlogManagerMBean.class);
name = new ObjectName(ActiveRepairServiceMBean.MBEAN_NAME);
arsProxy = JMX.newMBeanProxy(mbeanServerConn, name, ActiveRepairServiceMBean.class);
name = new ObjectName(AuditLogManager.MBEAN_NAME);
almProxy = JMX.newMBeanProxy(mbeanServerConn, name, AuditLogManagerMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + PasswordAuthenticator.CredentialsCacheMBean.CACHE_NAME);
ccProxy = JMX.newMBeanProxy(mbeanServerConn, name, PasswordAuthenticator.CredentialsCacheMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + AuthorizationProxy.JmxPermissionsCacheMBean.CACHE_NAME);
jpcProxy = JMX.newMBeanProxy(mbeanServerConn, name, AuthorizationProxy.JmxPermissionsCacheMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + NetworkPermissionsCache.CACHE_NAME);
npcProxy = JMX.newMBeanProxy(mbeanServerConn, name, NetworkPermissionsCacheMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + PermissionsCache.CACHE_NAME);
pcProxy = JMX.newMBeanProxy(mbeanServerConn, name, PermissionsCacheMBean.class);
name = new ObjectName(AuthCache.MBEAN_NAME_BASE + RolesCache.CACHE_NAME);
rcProxy = JMX.newMBeanProxy(mbeanServerConn, name, RolesCacheMBean.class);
} catch (MalformedObjectNameException e) {
throw new RuntimeException("Invalid ObjectName? Please report this as a bug.", e);
}
memProxy = ManagementFactory.newPlatformMXBeanProxy(mbeanServerConn, ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class);
runtimeProxy = ManagementFactory.newPlatformMXBeanProxy(mbeanServerConn, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
}
use of javax.management.MalformedObjectNameException in project cassandra by apache.
the class ColumnFamilyStoreMBeanIterator method getColumnFamilyMetric.
/**
* Retrieve ColumnFamily metrics
* @param ks Keyspace for which stats are to be displayed or null for the global value
* @param cf ColumnFamily for which stats are to be displayed or null for the keyspace value (if ks supplied)
* @param metricName View {@link TableMetrics}.
*/
public Object getColumnFamilyMetric(String ks, String cf, String metricName) {
try {
ObjectName oName = null;
if (!Strings.isNullOrEmpty(ks) && !Strings.isNullOrEmpty(cf)) {
String type = cf.contains(".") ? "IndexTable" : "Table";
oName = new ObjectName(String.format("org.apache.cassandra.metrics:type=%s,keyspace=%s,scope=%s,name=%s", type, ks, cf, metricName));
} else if (!Strings.isNullOrEmpty(ks)) {
oName = new ObjectName(String.format("org.apache.cassandra.metrics:type=Keyspace,keyspace=%s,name=%s", ks, metricName));
} else {
oName = new ObjectName(String.format("org.apache.cassandra.metrics:type=Table,name=%s", metricName));
}
switch(metricName) {
case "BloomFilterDiskSpaceUsed":
case "BloomFilterFalsePositives":
case "BloomFilterFalseRatio":
case "BloomFilterOffHeapMemoryUsed":
case "IndexSummaryOffHeapMemoryUsed":
case "CompressionMetadataOffHeapMemoryUsed":
case "CompressionRatio":
case "EstimatedColumnCountHistogram":
case "EstimatedPartitionSizeHistogram":
case "EstimatedPartitionCount":
case "KeyCacheHitRate":
case "LiveSSTableCount":
case "OldVersionSSTableCount":
case "MaxPartitionSize":
case "MeanPartitionSize":
case "MemtableColumnsCount":
case "MemtableLiveDataSize":
case "MemtableOffHeapSize":
case "MinPartitionSize":
case "PercentRepaired":
case "BytesRepaired":
case "BytesUnrepaired":
case "BytesPendingRepair":
case "RecentBloomFilterFalsePositives":
case "RecentBloomFilterFalseRatio":
case "SnapshotsSize":
return JMX.newMBeanProxy(mbeanServerConn, oName, CassandraMetricsRegistry.JmxGaugeMBean.class).getValue();
case "LiveDiskSpaceUsed":
case "MemtableSwitchCount":
case "SpeculativeRetries":
case "TotalDiskSpaceUsed":
case "WriteTotalLatency":
case "ReadTotalLatency":
case "PendingFlushes":
case "DroppedMutations":
return JMX.newMBeanProxy(mbeanServerConn, oName, CassandraMetricsRegistry.JmxCounterMBean.class).getCount();
case "CoordinatorReadLatency":
case "CoordinatorScanLatency":
case "ReadLatency":
case "WriteLatency":
return JMX.newMBeanProxy(mbeanServerConn, oName, CassandraMetricsRegistry.JmxTimerMBean.class);
case "LiveScannedHistogram":
case "SSTablesPerReadHistogram":
case "TombstoneScannedHistogram":
return JMX.newMBeanProxy(mbeanServerConn, oName, CassandraMetricsRegistry.JmxHistogramMBean.class);
default:
throw new RuntimeException("Unknown table metric " + metricName);
}
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
}
}
Aggregations