use of javax.management.InstanceNotFoundException in project cassandra by apache.
the class Info method execute.
@Override
public void execute(NodeProbe probe) {
boolean gossipInitialized = probe.isGossipRunning();
System.out.printf("%-23s: %s%n", "ID", probe.getLocalHostId());
System.out.printf("%-23s: %s%n", "Gossip active", gossipInitialized);
System.out.printf("%-23s: %s%n", "Native Transport active", probe.isNativeTransportRunning());
System.out.printf("%-23s: %s%n", "Load", probe.getLoadString());
if (gossipInitialized)
System.out.printf("%-23s: %s%n", "Generation No", probe.getCurrentGenerationNumber());
else
System.out.printf("%-23s: %s%n", "Generation No", 0);
// Uptime
long secondsUp = probe.getUptime() / 1000;
System.out.printf("%-23s: %d%n", "Uptime (seconds)", secondsUp);
// Memory usage
MemoryUsage heapUsage = probe.getHeapMemoryUsage();
double memUsed = (double) heapUsage.getUsed() / (1024 * 1024);
double memMax = (double) heapUsage.getMax() / (1024 * 1024);
System.out.printf("%-23s: %.2f / %.2f%n", "Heap Memory (MB)", memUsed, memMax);
try {
System.out.printf("%-23s: %.2f%n", "Off Heap Memory (MB)", getOffHeapMemoryUsed(probe));
} catch (RuntimeException e) {
// offheap-metrics introduced in 2.1.3 - older versions do not have the appropriate mbeans
if (!(e.getCause() instanceof InstanceNotFoundException))
throw e;
}
// Data Center/Rack
System.out.printf("%-23s: %s%n", "Data Center", probe.getDataCenter());
System.out.printf("%-23s: %s%n", "Rack", probe.getRack());
// Exceptions
System.out.printf("%-23s: %s%n", "Exceptions", probe.getStorageMetric("Exceptions"));
CacheServiceMBean cacheService = probe.getCacheServiceMBean();
// Key Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds
System.out.printf("%-23s: entries %d, size %s, capacity %s, %d hits, %d requests, %.3f recent hit rate, %d save period in seconds%n", "Key Cache", probe.getCacheMetric("KeyCache", "Entries"), FileUtils.stringifyFileSize((long) probe.getCacheMetric("KeyCache", "Size")), FileUtils.stringifyFileSize((long) probe.getCacheMetric("KeyCache", "Capacity")), probe.getCacheMetric("KeyCache", "Hits"), probe.getCacheMetric("KeyCache", "Requests"), probe.getCacheMetric("KeyCache", "HitRate"), cacheService.getKeyCacheSavePeriodInSeconds());
// Row Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds
System.out.printf("%-23s: entries %d, size %s, capacity %s, %d hits, %d requests, %.3f recent hit rate, %d save period in seconds%n", "Row Cache", probe.getCacheMetric("RowCache", "Entries"), FileUtils.stringifyFileSize((long) probe.getCacheMetric("RowCache", "Size")), FileUtils.stringifyFileSize((long) probe.getCacheMetric("RowCache", "Capacity")), probe.getCacheMetric("RowCache", "Hits"), probe.getCacheMetric("RowCache", "Requests"), probe.getCacheMetric("RowCache", "HitRate"), cacheService.getRowCacheSavePeriodInSeconds());
// Counter Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds
System.out.printf("%-23s: entries %d, size %s, capacity %s, %d hits, %d requests, %.3f recent hit rate, %d save period in seconds%n", "Counter Cache", probe.getCacheMetric("CounterCache", "Entries"), FileUtils.stringifyFileSize((long) probe.getCacheMetric("CounterCache", "Size")), FileUtils.stringifyFileSize((long) probe.getCacheMetric("CounterCache", "Capacity")), probe.getCacheMetric("CounterCache", "Hits"), probe.getCacheMetric("CounterCache", "Requests"), probe.getCacheMetric("CounterCache", "HitRate"), cacheService.getCounterCacheSavePeriodInSeconds());
// Chunk Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds
try {
System.out.printf("%-23s: entries %d, size %s, capacity %s, %d misses, %d requests, %.3f recent hit rate, %.3f %s miss latency%n", "Chunk Cache", probe.getCacheMetric("ChunkCache", "Entries"), FileUtils.stringifyFileSize((long) probe.getCacheMetric("ChunkCache", "Size")), FileUtils.stringifyFileSize((long) probe.getCacheMetric("ChunkCache", "Capacity")), probe.getCacheMetric("ChunkCache", "Misses"), probe.getCacheMetric("ChunkCache", "Requests"), probe.getCacheMetric("ChunkCache", "HitRate"), probe.getCacheMetric("ChunkCache", "MissLatency"), probe.getCacheMetric("ChunkCache", "MissLatencyUnit"));
} catch (RuntimeException e) {
if (!(e.getCause() instanceof InstanceNotFoundException))
throw e;
// Chunk cache is not on.
}
// Global table stats
System.out.printf("%-23s: %s%%%n", "Percent Repaired", probe.getColumnFamilyMetric(null, null, "PercentRepaired"));
// check if node is already joined, before getting tokens, since it throws exception if not.
if (probe.isJoined()) {
// Tokens
List<String> tokens = probe.getTokens();
if (tokens.size() == 1 || this.tokens)
for (String token : tokens) System.out.printf("%-23s: %s%n", "Token", token);
else
System.out.printf("%-23s: (invoke with -T/--tokens to see all %d tokens)%n", "Token", tokens.size());
} else {
System.out.printf("%-23s: (node is not joined to the cluster)%n", "Token");
}
}
use of javax.management.InstanceNotFoundException in project aries by apache.
the class JMXAgentImpl method unregisterMBeans.
/**
* @see org.apache.aries.jmx.agent.JMXAgent#unregisterMBeans(javax.management.MBeanServer)
*/
public synchronized void unregisterMBeans(final MBeanServer server) {
for (MBeanHandler mBeanHandler : mbeansHandlers.keySet()) {
if (mbeansHandlers.get(mBeanHandler) == Boolean.TRUE) {
try {
String name = mBeanHandler.getName();
StandardMBean mbean = mBeanHandler.getMbean();
if (mbean != null) {
logger.log(LogService.LOG_INFO, "Unregistering " + mbean.getMBeanInterface().getName() + " to MBeanServer " + server + " with name " + name);
server.unregisterMBean(new ObjectName(name));
}
} catch (MBeanRegistrationException e) {
logger.log(LogService.LOG_ERROR, "Can't unregister MBean", e);
} catch (InstanceNotFoundException e) {
logger.log(LogService.LOG_ERROR, "MBean doesn't exist in the repository", e);
} catch (MalformedObjectNameException e) {
logger.log(LogService.LOG_ERROR, "Try to unregister with no valid objectname", e);
} catch (NullPointerException e) {
logger.log(LogService.LOG_ERROR, "Name of objectname can't be null ", e);
} catch (Exception e) {
logger.log(LogService.LOG_ERROR, "Cannot unregister MBean: " + mBeanHandler, e);
}
}
}
mbeanServers.remove(server);
}
use of javax.management.InstanceNotFoundException in project aries by apache.
the class JMXAgentImpl method unregisterMBean.
/**
* @see org.apache.aries.jmx.agent.JMXAgent#unregisterMBean(org.apache.aries.jmx.MBeanHandler)
*/
public synchronized void unregisterMBean(final MBeanHandler mBeanHandler) {
for (MBeanServer server : mbeanServers.keySet()) {
String name = mBeanHandler.getName();
try {
logger.log(LogService.LOG_INFO, "Unregistering mbean " + " to MBeanServer " + server + " with name " + name);
server.unregisterMBean(new ObjectName(name));
} catch (MBeanRegistrationException e) {
logger.log(LogService.LOG_ERROR, "Can't register MBean", e);
} catch (InstanceNotFoundException e) {
logger.log(LogService.LOG_ERROR, "MBean doesn't exist in the repository", e);
} catch (MalformedObjectNameException e) {
logger.log(LogService.LOG_ERROR, "Try to register with no valid objectname, Stopping registration", e);
return;
} catch (NullPointerException e) {
logger.log(LogService.LOG_ERROR, "Name of objectname can't be null, Stopping registration", e);
return;
}
}
mbeansHandlers.put(mBeanHandler, Boolean.FALSE);
}
use of javax.management.InstanceNotFoundException in project geode by apache.
the class MX4JModelMBean method findPersister.
private PersisterMBean findPersister() throws MBeanException, InstanceNotFoundException {
Logger logger = getLogger();
ModelMBeanInfo info = getModelMBeanInfo();
if (info == null) {
// Not yet initialized
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("Can't find persister, ModelMBeanInfo is null");
return null;
}
Descriptor mbeanDescriptor = info.getMBeanDescriptor();
if (mbeanDescriptor == null) {
// This is normally should not happen if ModelMBeanInfoSupport is used
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("Can't find persister, MBean descriptor is null");
return null;
}
String location = (String) mbeanDescriptor.getFieldValue("persistLocation");
String name = (String) mbeanDescriptor.getFieldValue("persistName");
String mbeanName = (String) mbeanDescriptor.getFieldValue("name");
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Persistence fields: location=" + location + ", name=" + name);
if (mbeanName == null && name == null) {
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Persistence is not supported by this ModelMBean");
return null;
}
// Try to see if this mbean should delegate to another mbean
if (name != null) {
try {
ObjectName objectName = new ObjectName(name.trim());
// OK, a valid object name
MBeanServer server = getMBeanServer();
if (server == null)
throw new MBeanException(new IllegalStateException(LocalizedStrings.MX4JModelMBean_MX4JMODELMBEAN_IS_NOT_REGISTERED.toLocalizedString()));
if (server.isRegistered(objectName) && server.isInstanceOf(objectName, PersisterMBean.class.getName())) {
// OK, the given mbean is registered with this mbean server
PersisterMBean persister = new MBeanPersister(server, objectName);
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Persistence is delegated to this MBean: " + objectName);
return persister;
} else {
throw new InstanceNotFoundException(objectName.toString());
}
} catch (MalformedObjectNameException ignored) {
// It does not delegates to another mbean, use default
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("Persistence is not delegated to another MBean");
}
// Default is serialization to file
FilePersister persister = new FilePersister(location, name);
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Persistence is realized through file system in " + persister.getFileName());
return persister;
} else {
// Only location given, use MBean name
FilePersister persister = new FilePersister(location, mbeanName);
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Persistence is realized through file system in " + persister.getFileName());
return persister;
}
}
use of javax.management.InstanceNotFoundException in project geode by apache.
the class ConnectionNotificationFilterImpl method stopRMIConnectorServer.
/** Stops the RMIConnectorServer and unregisters its MBean. */
private void stopRMIConnectorServer() {
if (!this.agentConfig.isRmiEnabled())
return;
// stop the RMI Connector server...
try {
this.rmiConnector.stop();
} catch (Exception e) {
logger.warn(e.getMessage(), e);
}
try {
ObjectName rmiRegistryNamingName = getRMIRegistryNamingName();
if (this.agentConfig.isRmiRegistryEnabled() && mBeanServer.isRegistered(rmiRegistryNamingName)) {
String[] empty = new String[0];
mBeanServer.invoke(rmiRegistryNamingName, "stop", empty, empty);
MBeanUtil.unregisterMBean(rmiRegistryNamingName);
}
} catch (MalformedObjectNameException e) {
logger.warn(e.getMessage(), e);
} catch (InstanceNotFoundException e) {
logger.warn(e.getMessage(), e);
} catch (ReflectionException e) {
logger.warn(e.getMessage(), e);
} catch (MBeanException e) {
logger.warn(e.getMessage(), e);
}
try {
ObjectName rmiConnectorServerName = getRMIConnectorServerName();
if (mBeanServer.isRegistered(rmiConnectorServerName)) {
MBeanUtil.unregisterMBean(rmiConnectorServerName);
}
} catch (MalformedObjectNameException e) {
logger.warn(e.getMessage(), e);
}
}
Aggregations