improve monitor support

This commit is contained in:
wenshao
2013-08-17 00:43:37 +08:00
parent 73f72e0f94
commit 8ab0219c4e
9 changed files with 300 additions and 14 deletions
@@ -727,6 +727,10 @@ public class MySqlExprParser extends SQLExprParser {
if (lexer.token() == Token.KEY) {
lexer.nextToken();
}
if (lexer.token() == Token.INDEX) {
lexer.nextToken();
}
MySqlUnique unique = new MySqlUnique();
@@ -23,9 +23,9 @@ public class MonitorContext {
private final Map<String, Object> atrributes = new HashMap<String, Object>();
private String domainName = "defaultDomain";
private String appName = "defaultApp";
private String clusterName = "defaultCluster";
private String domainName = "default";
private String appName = "default";
private String clusterName = "default";
private String host;
private int pid;
@@ -56,6 +56,7 @@ public class MonitorDaoJdbcImpl implements MonitorDao {
private DataSource dataSource;
private BeanInfo dataSourceStatBeanInfo = new BeanInfo(DruidDataSourceStatValue.class);
private BeanInfo sqlStatBeanInfo = new BeanInfo(JdbcSqlStatValue.class);
private BeanInfo springMethodStatBeanInfo = new BeanInfo(SpringMethodStatValue.class);
private BeanInfo webURIStatBeanInfo = new BeanInfo(WebURIStatValue.class);
@@ -65,7 +66,8 @@ public class MonitorDaoJdbcImpl implements MonitorDao {
}
public void createTables(String dbType) {
String[] resources = new String[] { "const.sql", //
String[] resources = new String[] { "basic.sql", //
"const.sql", //
"datasource.sql", //
"springmethod.sql", //
"sql.sql", //
@@ -96,6 +98,8 @@ public class MonitorDaoJdbcImpl implements MonitorDao {
@Override
public void saveSql(MonitorContext ctx, List<DruidDataSourceStatValue> dataSourceList) {
save(dataSourceStatBeanInfo, ctx, dataSourceList);
for (DruidDataSourceStatValue dataSourceStatValue : dataSourceList) {
List<JdbcSqlStatValue> sqlList = dataSourceStatValue.getSqlList();
save(sqlStatBeanInfo, ctx, sqlList);
@@ -232,16 +236,16 @@ public class MonitorDaoJdbcImpl implements MonitorDao {
String domain = (String) filters.get("domain");
if (StringUtils.isEmpty(domain)) {
domain = "defaultDomain";
domain = "default";
}
String app = (String) filters.get("app");
if (StringUtils.isEmpty(app)) {
app = "defaultApp";
app = "default";
}
String cluster = (String) filters.get("cluster");
if (StringUtils.isEmpty(cluster)) {
cluster = "defaultCluster";
cluster = "default";
}
String host = (String) filters.get("host");
@@ -364,11 +368,11 @@ public class MonitorDaoJdbcImpl implements MonitorDao {
private void loadHashValue(FieldInfo hashField, List<?> list, Map<String, Object> filters) {
String domain = (String) filters.get("domain");
if (StringUtils.isEmpty(domain)) {
domain = "defaultDomain";
domain = "default";
}
String app = (String) filters.get("app");
if (StringUtils.isEmpty(app)) {
app = "defaultApp";
app = "default";
}
for (Object statValue : list) {
@@ -0,0 +1,47 @@
/*
* 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.entity;
public class MonitorApp {
private long id;
private String domain;
private String app;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
}
@@ -0,0 +1,57 @@
/*
* 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.entity;
public class MonitorCluster {
private long id;
private String domain;
private String app;
private String cluster;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getCluster() {
return cluster;
}
public void setCluster(String cluster) {
this.cluster = cluster;
}
}
@@ -0,0 +1,39 @@
/*
* 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.entity;
public class MonitorDomain {
private long id;
private String domain;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
}
@@ -0,0 +1,95 @@
/*
* 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.entity;
import java.util.Date;
public class MonitorInstance {
private long id;
private String domain;
private String app;
private String cluster;
private String host;
private String ip;
private Date lastActiveTime;
private Long lastPID;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getCluster() {
return cluster;
}
public void setCluster(String cluster) {
this.cluster = cluster;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public Date getLastActiveTime() {
return lastActiveTime;
}
public void setLastActiveTime(Date lastActiveTime) {
this.lastActiveTime = lastActiveTime;
}
public Long getLastPID() {
return lastPID;
}
public void setLastPID(Long lastPID) {
this.lastPID = lastPID;
}
}