Search in sources :

Example 16 with InstanceNotFoundException

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");
    }
}
Also used : CacheServiceMBean(org.apache.cassandra.service.CacheServiceMBean) InstanceNotFoundException(javax.management.InstanceNotFoundException) MemoryUsage(java.lang.management.MemoryUsage)

Example 17 with InstanceNotFoundException

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);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) InstanceNotFoundException(javax.management.InstanceNotFoundException) ConfigurationAdminMBeanHandler(org.apache.aries.jmx.cm.ConfigurationAdminMBeanHandler) ProvisioningServiceMBeanHandler(org.apache.aries.jmx.provisioning.ProvisioningServiceMBeanHandler) MBeanHandler(org.apache.aries.jmx.MBeanHandler) PackageStateMBeanHandler(org.apache.aries.jmx.framework.PackageStateMBeanHandler) PermissionAdminMBeanHandler(org.apache.aries.jmx.permissionadmin.PermissionAdminMBeanHandler) BundleStateMBeanHandler(org.apache.aries.jmx.framework.BundleStateMBeanHandler) UserAdminMBeanHandler(org.apache.aries.jmx.useradmin.UserAdminMBeanHandler) FrameworkMBeanHandler(org.apache.aries.jmx.framework.FrameworkMBeanHandler) BundleWiringStateMBeanHandler(org.apache.aries.jmx.framework.wiring.BundleWiringStateMBeanHandler) ServiceStateMBeanHandler(org.apache.aries.jmx.framework.ServiceStateMBeanHandler) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MalformedObjectNameException(javax.management.MalformedObjectNameException) ObjectName(javax.management.ObjectName)

Example 18 with InstanceNotFoundException

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);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 19 with InstanceNotFoundException

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;
    }
}
Also used : MBeanPersister(mx4j.persist.MBeanPersister) MalformedObjectNameException(javax.management.MalformedObjectNameException) PersisterMBean(mx4j.persist.PersisterMBean) FilePersister(mx4j.persist.FilePersister) InstanceNotFoundException(javax.management.InstanceNotFoundException) Logger(mx4j.log.Logger) FileLogger(mx4j.log.FileLogger) MBeanLogger(mx4j.log.MBeanLogger) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) ObjectName(javax.management.ObjectName) Descriptor(javax.management.Descriptor) MBeanException(javax.management.MBeanException) MBeanServer(javax.management.MBeanServer)

Example 20 with InstanceNotFoundException

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);
    }
}
Also used : ReflectionException(javax.management.ReflectionException) MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanException(javax.management.MBeanException) OperationsException(javax.management.OperationsException) ReflectionException(javax.management.ReflectionException) AdminException(org.apache.geode.admin.AdminException) MalformedObjectNameException(javax.management.MalformedObjectNameException) GemFireException(org.apache.geode.GemFireException) GemFireIOException(org.apache.geode.GemFireIOException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) IOException(java.io.IOException) MBeanException(javax.management.MBeanException) ObjectName(javax.management.ObjectName)

Aggregations

InstanceNotFoundException (javax.management.InstanceNotFoundException)102 ObjectName (javax.management.ObjectName)59 ReflectionException (javax.management.ReflectionException)44 MBeanException (javax.management.MBeanException)32 MalformedObjectNameException (javax.management.MalformedObjectNameException)28 MBeanRegistrationException (javax.management.MBeanRegistrationException)25 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)19 MBeanServer (javax.management.MBeanServer)17 IOException (java.io.IOException)16 AttributeNotFoundException (javax.management.AttributeNotFoundException)16 Attribute (javax.management.Attribute)15 IntrospectionException (javax.management.IntrospectionException)14 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)14 AttributeList (javax.management.AttributeList)12 ObjectInstance (javax.management.ObjectInstance)12 MBeanInfo (javax.management.MBeanInfo)11 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)10 RuntimeOperationsException (javax.management.RuntimeOperationsException)9 ArrayList (java.util.ArrayList)7 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)7