use of com.alibaba.druid.pool.DruidDataSource 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 com.alibaba.druid.pool.DruidDataSource 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 com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class JdbcStatManager method reset.
@Override
public void reset() {
resetCount.incrementAndGet();
connectionStat.reset();
statementStat.reset();
resultSetStat.reset();
final ConcurrentMap<String, DataSourceProxyImpl> dataSources = DruidDriver.getProxyDataSources();
for (DataSourceProxyImpl dataSource : dataSources.values()) {
dataSource.getDataSourceStat().reset();
}
for (DruidDataSource instance : DruidDataSourceStatManager.getDruidDataSourceInstances()) {
instance.getDataSourceStat().reset();
}
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class Case2 method test_0.
public void test_0() throws Exception {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setInitialSize(initialSize);
dataSource.setMaxActive(maxActive);
dataSource.setMinIdle(minPoolSize);
dataSource.setMaxIdle(maxPoolSize);
dataSource.setPoolPreparedStatements(true);
dataSource.setDriverClassName(driverClass);
dataSource.setUrl(jdbcUrl);
dataSource.setPoolPreparedStatements(true);
dataSource.setUsername(user);
dataSource.setPassword(password);
dataSource.setValidationQuery(validationQuery);
dataSource.setTestOnBorrow(testOnBorrow);
for (int i = 0; i < executeCount; ++i) {
p0(dataSource, "druid", threadCount);
}
System.out.println();
}
use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.
the class CaseKylin_mysql_idle_1 method druid.
public void druid() throws Exception {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setInitialSize(initialSize);
dataSource.setMaxActive(maxActive);
dataSource.setMaxIdle(maxIdle);
dataSource.setMinIdle(minIdle);
dataSource.setMaxWait(maxWait);
dataSource.setPoolPreparedStatements(true);
dataSource.setDriverClassName(driverClass);
dataSource.setUrl(jdbcUrl);
dataSource.setPoolPreparedStatements(true);
dataSource.setUsername(user);
dataSource.setPassword(password);
dataSource.setValidationQuery(validationQuery);
dataSource.setTestOnBorrow(testOnBorrow);
dataSource.setTestOnBorrow(testWhileIdle);
dataSource.setTestOnBorrow(testOnReturn);
dataSource.setRemoveAbandoned(removeAbandoned);
dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout);
dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
dataSource.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
p0(dataSource, "druid", threadCount);
long startMillis = System.currentTimeMillis();
for (int i = 0; i < 1000; ++i) {
p0(dataSource, "druid", threadCount);
long seconds = (System.currentTimeMillis() - startMillis) / 1000L;
System.out.println("seconds : " + seconds);
}
System.out.println();
}
Aggregations