mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
support monitor
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
CREATE TABLE druid_sql (
|
||||
id bigint(20) NOT NULL,
|
||||
domain varchar(45),
|
||||
app varchar(45),
|
||||
cluster varchar(45),
|
||||
host varchar(128),
|
||||
pid int(10),
|
||||
collectTime datetime NOT NULL,
|
||||
sqlHash bigint(20),
|
||||
dataSource varchar(256),
|
||||
lastStartTime bigint(20),
|
||||
batchTotal bigint(20),
|
||||
batchToMax int(10),
|
||||
execSuccessCount bigint(20),
|
||||
execNanoTotal bigint(20),
|
||||
execNanoMax bigint(20),
|
||||
running int(10),
|
||||
concurrentMax int(10),
|
||||
running bigint(20),
|
||||
executeAndResultSetHoldTime bigint(20),
|
||||
name varchar(256),
|
||||
file varchar(256),
|
||||
dbType varchar(256),
|
||||
execNanoMaxOccurTime bigint(20),
|
||||
errorCount bigint(20),
|
||||
errorLastMsg varchar(256),
|
||||
errorLastClass varchar(256),
|
||||
errorLastStackTrace varchar(256),
|
||||
errorLastTime bigint(20),
|
||||
updateCount bigint(20),
|
||||
updateCountMax bigint(20),
|
||||
fetchRowCount bigint(20),
|
||||
fetchRowCountMax bigint(20),
|
||||
inTxnCount bigint(20),
|
||||
lastSlowParameters varchar(256),
|
||||
clobOpenCount bigint(20),
|
||||
blobOpenCount bigint(20),
|
||||
readStringLength bigint(20),
|
||||
readBytesLength bigint(20),
|
||||
inputStreamOpenCount bigint(20),
|
||||
readerOpenCount bigint(20),
|
||||
h1 bigint(20),
|
||||
h10 bigint(20),
|
||||
h100 int(10),
|
||||
h1000 int(10),
|
||||
h10000 int(10),
|
||||
h100000 int(10),
|
||||
h1000000 int(10),
|
||||
hmore int(10),
|
||||
eh1 bigint(20),
|
||||
eh10 bigint(20),
|
||||
eh100 int(10),
|
||||
eh1000 int(10),
|
||||
eh10000 int(10),
|
||||
eh100000 int(10),
|
||||
eh1000000 int(10),
|
||||
ehmore int(10),
|
||||
f1 bigint(20),
|
||||
f10 bigint(20),
|
||||
f100 bigint(20),
|
||||
f1000 int(10),
|
||||
f10000 int(10),
|
||||
fmore int(10),
|
||||
u1 bigint(20),
|
||||
u10 bigint(20),
|
||||
u100 bigint(20),
|
||||
u1000 int(10),
|
||||
u10000 int(10),
|
||||
umore int(10),
|
||||
PRIAMRY KEY (id)
|
||||
)
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 1999-2011 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.druid.support.monitor.dao;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.druid.bvt.support.monitor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -16,31 +17,48 @@ public class MonitorDaoJdbcImplTest extends TestCase {
|
||||
public void testBuildSql() throws Exception {
|
||||
MonitorDaoJdbcImpl dao = new MonitorDaoJdbcImpl();
|
||||
|
||||
String sql = dao.buildInsertSql(new BeanInfo(JdbcSqlStatValue.class));
|
||||
{
|
||||
String sql = dao.buildInsertSql(new BeanInfo(JdbcSqlStatValue.class));
|
||||
|
||||
System.out.println(SQLUtils.format(sql, JdbcConstants.MYSQL));
|
||||
System.out.println(SQLUtils.format(sql, JdbcConstants.MYSQL));
|
||||
}
|
||||
{
|
||||
String sql = buildCreateSql(dao, new BeanInfo(JdbcSqlStatValue.class));
|
||||
System.out.println(SQLUtils.format(sql, JdbcConstants.MYSQL));
|
||||
}
|
||||
}
|
||||
|
||||
public String buildInsertSql(MonitorDaoJdbcImpl dao, BeanInfo beanInfo) {
|
||||
|
||||
public String buildCreateSql(MonitorDaoJdbcImpl dao, BeanInfo beanInfo) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("CREATE TABLE ") //
|
||||
.append(dao.getTableName(beanInfo));
|
||||
|
||||
buf.append(" (domain, app, cluster, host, pid, collectTime");
|
||||
buf.append("( id bigint(20) NOT NULL");
|
||||
buf.append(", domain varchar(45)");
|
||||
buf.append(", app varchar(45)");
|
||||
buf.append(", cluster varchar(45)");
|
||||
buf.append(", host varchar(128)");
|
||||
buf.append(", pid int(10)");
|
||||
buf.append(", collectTime datetime NOT NULL");
|
||||
List<FieldInfo> fields = beanInfo.getFields();
|
||||
for (int i = 0; i < fields.size(); ++i) {
|
||||
FieldInfo field = fields.get(i);
|
||||
buf.append(", ");
|
||||
buf.append(field.getColumnName());
|
||||
if (field.getFieldType().equals(int.class) || field.getFieldType().equals(Integer.class)) {
|
||||
buf.append(" int(10)");
|
||||
} else if (field.getFieldType().equals(long.class) || field.getFieldType().equals(Long.class)) {
|
||||
buf.append(" bigint(20)");
|
||||
} else if (field.getFieldType().equals(String.class)) {
|
||||
buf.append(" varchar(256)");
|
||||
} else if (field.getFieldType().equals(Date.class)) {
|
||||
buf.append(" datetime");
|
||||
}
|
||||
}
|
||||
buf.append(")\nVALUES (?, ?, ?, ?, ?, ?");
|
||||
for (int i = 0; i < fields.size(); ++i) {
|
||||
buf.append(", ?");
|
||||
}
|
||||
|
||||
buf.append(", PRIMARY KEY(id)");
|
||||
buf.append(")");
|
||||
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user