Search in sources :

Example 21 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project cassandra by apache.

the class ThreadPoolMetrics method getJmxThreadPools.

public static Multimap<String, String> getJmxThreadPools(MBeanServerConnection mbeanServerConn) {
    try {
        Multimap<String, String> threadPools = HashMultimap.create();
        Set<ObjectName> threadPoolObjectNames = mbeanServerConn.queryNames(new ObjectName("org.apache.cassandra.metrics:type=ThreadPools,*"), null);
        for (ObjectName oName : threadPoolObjectNames) {
            threadPools.put(oName.getKeyProperty("path"), oName.getKeyProperty("scope"));
        }
        return threadPools;
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException("Bad query to JMX server: ", e);
    } catch (IOException e) {
        throw new RuntimeException("Error getting threadpool names from JMX", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) IOException(java.io.IOException) ObjectName(javax.management.ObjectName)

Example 22 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project cassandra by apache.

the class ColumnFamilyStoreMBeanIterator method setCacheCapacities.

public void setCacheCapacities(int keyCacheCapacity, int rowCacheCapacity, int counterCacheCapacity) {
    try {
        String keyCachePath = "org.apache.cassandra.db:type=Caches";
        CacheServiceMBean cacheMBean = JMX.newMBeanProxy(mbeanServerConn, new ObjectName(keyCachePath), CacheServiceMBean.class);
        cacheMBean.setKeyCacheCapacityInMB(keyCacheCapacity);
        cacheMBean.setRowCacheCapacityInMB(rowCacheCapacity);
        cacheMBean.setCounterCacheCapacityInMB(counterCacheCapacity);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CacheServiceMBean(org.apache.cassandra.service.CacheServiceMBean) ObjectName(javax.management.ObjectName)

Example 23 with MalformedObjectNameException

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
     */
private 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(HintedHandOffManager.MBEAN_NAME);
        hhProxy = JMX.newMBeanProxy(mbeanServerConn, name, HintedHandOffManagerMBean.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);
    } 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);
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) HintedHandOffManagerMBean(org.apache.cassandra.db.HintedHandOffManagerMBean) MalformedObjectNameException(javax.management.MalformedObjectNameException) CompactionManagerMBean(org.apache.cassandra.db.compaction.CompactionManagerMBean) HashMap(java.util.HashMap) CacheServiceMBean(org.apache.cassandra.service.CacheServiceMBean) GossiperMBean(org.apache.cassandra.gms.GossiperMBean) MessagingServiceMBean(org.apache.cassandra.net.MessagingServiceMBean) FailureDetectorMBean(org.apache.cassandra.gms.FailureDetectorMBean) RuntimeMXBean(java.lang.management.RuntimeMXBean) ObjectName(javax.management.ObjectName) ActiveRepairServiceMBean(org.apache.cassandra.service.ActiveRepairServiceMBean) StorageServiceMBean(org.apache.cassandra.service.StorageServiceMBean) GCInspectorMXBean(org.apache.cassandra.service.GCInspectorMXBean) MemoryMXBean(java.lang.management.MemoryMXBean) StreamManagerMBean(org.apache.cassandra.streaming.StreamManagerMBean) BatchlogManagerMBean(org.apache.cassandra.batchlog.BatchlogManagerMBean) StorageProxyMBean(org.apache.cassandra.service.StorageProxyMBean)

Example 24 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project cassandra by apache.

the class ColumnFamilyStoreMBeanIterator method setCacheKeysToSave.

public void setCacheKeysToSave(int keyCacheKeysToSave, int rowCacheKeysToSave, int counterCacheKeysToSave) {
    try {
        String keyCachePath = "org.apache.cassandra.db:type=Caches";
        CacheServiceMBean cacheMBean = JMX.newMBeanProxy(mbeanServerConn, new ObjectName(keyCachePath), CacheServiceMBean.class);
        cacheMBean.setKeyCacheKeysToSave(keyCacheKeysToSave);
        cacheMBean.setRowCacheKeysToSave(rowCacheKeysToSave);
        cacheMBean.setCounterCacheKeysToSave(counterCacheKeysToSave);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CacheServiceMBean(org.apache.cassandra.service.CacheServiceMBean) ObjectName(javax.management.ObjectName)

Example 25 with MalformedObjectNameException

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 "MaxPartitionSize":
            case "MeanPartitionSize":
            case "MemtableColumnsCount":
            case "MemtableLiveDataSize":
            case "MemtableOffHeapSize":
            case "MinPartitionSize":
            case "PercentRepaired":
            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);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CassandraMetricsRegistry(org.apache.cassandra.metrics.CassandraMetricsRegistry) ObjectName(javax.management.ObjectName)

Aggregations

MalformedObjectNameException (javax.management.MalformedObjectNameException)123 ObjectName (javax.management.ObjectName)115 MBeanServer (javax.management.MBeanServer)34 MBeanRegistrationException (javax.management.MBeanRegistrationException)32 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)27 InstanceNotFoundException (javax.management.InstanceNotFoundException)26 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)25 IOException (java.io.IOException)22 ArrayList (java.util.ArrayList)14 MBeanException (javax.management.MBeanException)7 ReflectionException (javax.management.ReflectionException)7 HashMap (java.util.HashMap)6 StandardMBean (javax.management.StandardMBean)5 CacheServiceMBean (org.apache.cassandra.service.CacheServiceMBean)5 Map (java.util.Map)4 HashSet (java.util.HashSet)3 CacheException (javax.cache.CacheException)3 Group (org.apache.catalina.Group)3 User (org.apache.catalina.User)3 NamingResourcesImpl (org.apache.catalina.deploy.NamingResourcesImpl)3