Search in sources :

Example 16 with CompositeType

use of javax.management.openmbean.CompositeType in project druid by alibaba.

the class JdbcStatManager method getConnectionList.

public TabularData getConnectionList() throws JMException {
    CompositeType rowType = JdbcConnectionStat.Entry.getCompositeType();
    String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]);
    TabularType tabularType = new TabularType("ConnectionList", "ConnectionList", rowType, indexNames);
    TabularData data = new TabularDataSupport(tabularType);
    final ConcurrentMap<String, DataSourceProxyImpl> dataSources = DruidDriver.getProxyDataSources();
    for (DataSourceProxyImpl dataSource : dataSources.values()) {
        JdbcDataSourceStat dataSourceStat = dataSource.getDataSourceStat();
        ConcurrentMap<Long, JdbcConnectionStat.Entry> connections = dataSourceStat.getConnections();
        for (Map.Entry<Long, JdbcConnectionStat.Entry> entry : connections.entrySet()) {
            data.put(entry.getValue().getCompositeData());
        }
    }
    for (DruidDataSource instance : DruidDataSourceStatManager.getDruidDataSourceInstances()) {
        JdbcDataSourceStat dataSourceStat = instance.getDataSourceStat();
        ConcurrentMap<Long, JdbcConnectionStat.Entry> connections = dataSourceStat.getConnections();
        for (Map.Entry<Long, JdbcConnectionStat.Entry> entry : connections.entrySet()) {
            data.put(entry.getValue().getCompositeData());
        }
    }
    return data;
}
Also used : DataSourceProxyImpl(com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl) TabularType(javax.management.openmbean.TabularType) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) AtomicLong(java.util.concurrent.atomic.AtomicLong) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) CompositeType(javax.management.openmbean.CompositeType)

Example 17 with CompositeType

use of javax.management.openmbean.CompositeType in project druid by alibaba.

the class JdbcStatManager method getSqlList.

@Override
public TabularData getSqlList() throws JMException {
    CompositeType rowType = JdbcSqlStat.getCompositeType();
    String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]);
    TabularType tabularType = new TabularType("SqlListStatistic", "SqlListStatistic", rowType, indexNames);
    TabularData data = new TabularDataSupport(tabularType);
    JdbcDataSourceStat globalStat = JdbcDataSourceStat.getGlobal();
    if (globalStat != null) {
        Map<String, JdbcSqlStat> statMap = globalStat.getSqlStatMap();
        for (Map.Entry<String, JdbcSqlStat> entry : statMap.entrySet()) {
            if (entry.getValue().getExecuteCount() == 0 && entry.getValue().getRunningCount() == 0) {
                continue;
            }
            Map<String, Object> map = entry.getValue().getData();
            map.put("URL", globalStat.getUrl());
            data.put(new CompositeDataSupport(JdbcSqlStat.getCompositeType(), map));
        }
    }
    for (DataSourceProxyImpl dataSource : DruidDriver.getProxyDataSources().values()) {
        JdbcDataSourceStat druidDataSourceStat = dataSource.getDataSourceStat();
        if (druidDataSourceStat == globalStat) {
            continue;
        }
        Map<String, JdbcSqlStat> statMap = druidDataSourceStat.getSqlStatMap();
        for (Map.Entry<String, JdbcSqlStat> entry : statMap.entrySet()) {
            if (entry.getValue().getExecuteCount() == 0 && entry.getValue().getRunningCount() == 0) {
                continue;
            }
            Map<String, Object> map = entry.getValue().getData();
            map.put("URL", dataSource.getUrl());
            data.put(new CompositeDataSupport(JdbcSqlStat.getCompositeType(), map));
        }
    }
    for (DruidDataSource dataSource : DruidDataSourceStatManager.getDruidDataSourceInstances()) {
        JdbcDataSourceStat druidDataSourceStat = dataSource.getDataSourceStat();
        if (druidDataSourceStat == globalStat) {
            continue;
        }
        Map<String, JdbcSqlStat> statMap = druidDataSourceStat.getSqlStatMap();
        for (Map.Entry<String, JdbcSqlStat> entry : statMap.entrySet()) {
            if (entry.getValue().getExecuteCount() == 0 && entry.getValue().getRunningCount() == 0) {
                continue;
            }
            Map<String, Object> map = entry.getValue().getData();
            map.put("URL", dataSource.getUrl());
            data.put(new CompositeDataSupport(JdbcSqlStat.getCompositeType(), map));
        }
    }
    return data;
}
Also used : DataSourceProxyImpl(com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) CompositeType(javax.management.openmbean.CompositeType)

Example 18 with CompositeType

use of javax.management.openmbean.CompositeType in project druid by alibaba.

the class DruidDataSourceStatManager method getDataSourceList.

public TabularData getDataSourceList() throws JMException {
    CompositeType rowType = getDruidDataSourceCompositeType();
    String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]);
    TabularType tabularType = new TabularType("DruidDataSourceStat", "DruidDataSourceStat", rowType, indexNames);
    TabularData data = new TabularDataSupport(tabularType);
    final Set<Object> dataSources = getInstances().keySet();
    for (Object dataSource : dataSources) {
        data.put(getCompositeData(dataSource));
    }
    return data;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

Example 19 with CompositeType

use of javax.management.openmbean.CompositeType in project druid by alibaba.

the class DruidDataSourceStatManager method getDruidDataSourceCompositeType.

public static CompositeType getDruidDataSourceCompositeType() throws JMException {
    if (COMPOSITE_TYPE != null) {
        return COMPOSITE_TYPE;
    }
    OpenType<?>[] indexTypes = new OpenType<?>[] { //
    SimpleType.STRING, //
    SimpleType.STRING, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.INTEGER, //
    SimpleType.INTEGER, //
    SimpleType.INTEGER, //
    SimpleType.INTEGER, //
    SimpleType.INTEGER, //
    SimpleType.INTEGER, //
    SimpleType.INTEGER, //
    SimpleType.BOOLEAN, //
    SimpleType.BOOLEAN, //
    SimpleType.BOOLEAN, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.STRING, //
    SimpleType.STRING, //
    SimpleType.INTEGER, //
    SimpleType.STRING, //
    SimpleType.STRING, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    JMXUtils.getThrowableCompositeType(), //
    JMXUtils.getThrowableCompositeType(), //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.LONG, //
    SimpleType.STRING, //
    SimpleType.DATE, //
    SimpleType.DATE, //
    SimpleType.LONG, //
    SimpleType.LONG };
    String[] indexNames = { //
    "Name", //
    "URL", //
    "CreateCount", //
    "DestroyCount", //
    "ConnectCount", //
    "CloseCount", //
    "ActiveCount", //
    "PoolingCount", //
    "LockQueueLength", //
    "WaitThreadCount", //
    "InitialSize", //
    "MaxActive", //
    "MinIdle", //
    "PoolPreparedStatements", //
    "TestOnBorrow", //
    "TestOnReturn", //
    "MinEvictableIdleTimeMillis", //
    "ConnectErrorCount", //
    "CreateTimespanMillis", //
    "DbType", //
    "ValidationQuery", //
    "ValidationQueryTimeout", //
    "DriverClassName", //
    "Username", //
    "RemoveAbandonedCount", //
    "NotEmptyWaitCount", //
    "NotEmptyWaitNanos", //
    "ErrorCount", //
    "ReusePreparedStatementCount", //
    "StartTransactionCount", //
    "CommitCount", //
    "RollbackCount", //
    "LastError", //
    "LastCreateError", //
    "PreparedStatementCacheDeleteCount", //
    "PreparedStatementCacheAccessCount", //
    "PreparedStatementCacheMissCount", //
    "PreparedStatementCacheHitCount", //
    "PreparedStatementCacheCurrentCount", //
    "Version", //
    "LastErrorTime", //
    "LastCreateErrorTime", //
    "CreateErrorCount", //
    "DiscardCount" };
    String[] indexDescriptions = indexNames;
    COMPOSITE_TYPE = new CompositeType("DataSourceStatistic", "DataSource Statistic", indexNames, indexDescriptions, indexTypes);
    return COMPOSITE_TYPE;
}
Also used : OpenType(javax.management.openmbean.OpenType) CompositeType(javax.management.openmbean.CompositeType)

Example 20 with CompositeType

use of javax.management.openmbean.CompositeType in project jmxtrans by jmxtrans.

the class JmxResultProcessor method getResult.

/**
	 * Populates the Result objects. This is a recursive function. Query
	 * contains the keys that we want to get the values of.
	 */
private void getResult(Builder<Result> accumulator, String attributeName, CompositeData cds) {
    CompositeType t = cds.getCompositeType();
    Map<String, Object> values = newHashMap();
    Set<String> keys = t.keySet();
    for (String key : keys) {
        Object value = cds.get(key);
        if (value instanceof TabularDataSupport) {
            TabularDataSupport tds = (TabularDataSupport) value;
            processTabularDataSupport(accumulator, attributeName + "." + key, tds);
        // continue because we added tabular contents within above, but need primitives at this level
        } else if (value instanceof CompositeDataSupport) {
            // now recursively go through everything.
            CompositeDataSupport cds2 = (CompositeDataSupport) value;
            getResult(accumulator, attributeName, cds2);
            // because we don't want to add to the list yet.
            return;
        } else {
            values.put(key, value);
        }
    }
    Result r = getNewResultObject(attributeName, values);
    accumulator.add(r);
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Aggregations

CompositeType (javax.management.openmbean.CompositeType)82 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)55 CompositeData (javax.management.openmbean.CompositeData)50 TabularDataSupport (javax.management.openmbean.TabularDataSupport)50 TabularData (javax.management.openmbean.TabularData)47 TabularType (javax.management.openmbean.TabularType)27 OpenType (javax.management.openmbean.OpenType)23 OpenDataException (javax.management.openmbean.OpenDataException)22 Map (java.util.Map)20 ObjectName (javax.management.ObjectName)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 MBeanServer (javax.management.MBeanServer)6 ArrayType (javax.management.openmbean.ArrayType)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3