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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations