Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
5cac9e00
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5cac9e00
编写于
9月 04, 2014
作者:
L
leon.li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add config modification record feature
上级
0ffbce74
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
161 addition
and
2 deletion
+161
-2
cat-home/src/main/java/com/dianping/cat/system/page/config/ConfigModificationService.java
...ing/cat/system/page/config/ConfigModificationService.java
+32
-0
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
...ain/java/com/dianping/cat/system/page/config/Handler.java
+32
-0
cat-home/src/main/resources/META-INF/dal/jdbc/report-codegen.xml
...e/src/main/resources/META-INF/dal/jdbc/report-codegen.xml
+40
-0
cat-home/src/main/resources/META-INF/dal/jdbc/report-dal.xml
cat-home/src/main/resources/META-INF/dal/jdbc/report-dal.xml
+3
-0
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+40
-0
cat-home/src/main/resources/META-INF/wizard/jdbc/wizard.xml
cat-home/src/main/resources/META-INF/wizard/jdbc/wizard.xml
+2
-1
cat-home/src/main/webapp/WEB-INF/tags/body.tag
cat-home/src/main/webapp/WEB-INF/tags/body.tag
+1
-1
script/Cat.sql
script/Cat.sql
+11
-0
未找到文件。
cat-home/src/main/java/com/dianping/cat/system/page/config/ConfigModificationService.java
0 → 100644
浏览文件 @
5cac9e00
package
com.dianping.cat.system.page.config
;
import
java.util.Date
;
import
org.unidal.lookup.annotation.Inject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.home.dal.report.ConfigModification
;
import
com.dianping.cat.home.dal.report.ConfigModificationDao
;
import
com.dianping.cat.report.page.JsonBuilder
;
public
class
ConfigModificationService
{
@Inject
ConfigModificationDao
m_configModificationDao
;
public
void
store
(
String
userName
,
String
accountName
,
Payload
payload
)
{
ConfigModification
modification
=
m_configModificationDao
.
createLocal
();
modification
.
setUserName
(
userName
);
modification
.
setAccountName
(
accountName
);
modification
.
setActionName
(
payload
.
getAction
().
getName
());
modification
.
setDate
(
new
Date
());
modification
.
setArgument
(
new
JsonBuilder
().
toJson
(
payload
));
try
{
m_configModificationDao
.
insert
(
modification
);
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
ex
);
}
}
}
cat-home/src/main/java/com/dianping/cat/system/page/config/Handler.java
浏览文件 @
5cac9e00
package
com.dianping.cat.system.page.config
;
import
java.io.IOException
;
import
java.net.URLDecoder
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
...
...
@@ -13,6 +14,7 @@ import java.util.Map.Entry;
import
java.util.Set
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.Cookie
;
import
org.codehaus.plexus.util.StringUtils
;
import
org.hsqldb.lib.StringUtil
;
...
...
@@ -129,6 +131,9 @@ public class Handler implements PageHandler<Context> {
@Inject
private
RouterConfigManager
m_routerConfigManager
;
@Inject
private
ConfigModificationService
m_modificationService
;
private
void
deleteAggregationRule
(
Payload
payload
)
{
m_aggreationConfigManager
.
deleteAggregationRule
(
payload
.
getPattern
());
}
...
...
@@ -230,6 +235,8 @@ public class Handler implements PageHandler<Context> {
Model
model
=
new
Model
(
ctx
);
Payload
payload
=
ctx
.
getPayload
();
storeModifyInfo
(
ctx
,
payload
);
model
.
setPage
(
SystemPage
.
CONFIG
);
Action
action
=
payload
.
getAction
();
...
...
@@ -630,6 +637,31 @@ public class Handler implements PageHandler<Context> {
return
project
;
}
private
void
storeModifyInfo
(
Context
ctx
,
Payload
payload
)
{
Cookie
cookie
=
ctx
.
getCookie
(
"ct"
);
if
(
cookie
!=
null
)
{
String
cookieValue
=
cookie
.
getValue
();
try
{
String
[]
values
=
cookieValue
.
split
(
"\\|"
);
String
userName
=
values
[
0
];
String
account
=
values
[
1
];
if
(
userName
.
startsWith
(
"\""
))
{
userName
=
userName
.
substring
(
1
,
userName
.
length
()
-
1
);
}
userName
=
URLDecoder
.
decode
(
userName
,
"UTF-8"
);
m_modificationService
.
store
(
userName
,
account
,
payload
);
}
catch
(
Exception
ex
)
{
Cat
.
logError
(
"store cookie fail:"
+
cookieValue
,
new
RuntimeException
());
}
}
else
{
Cat
.
logError
(
"cannot get cookie info"
,
new
RuntimeException
());
}
}
private
void
updateAggregationRule
(
Payload
payload
)
{
AggregationRule
proto
=
payload
.
getRule
();
m_aggreationConfigManager
.
insertAggregationRule
(
proto
);
...
...
cat-home/src/main/resources/META-INF/dal/jdbc/report-codegen.xml
浏览文件 @
5cac9e00
...
...
@@ -166,6 +166,46 @@
</query>
</query-defs>
</entity>
<entity
name=
"config-modification"
table=
"config_modification"
alias=
"cm"
>
<member
name=
"id"
field=
"id"
value-type=
"int"
length=
"10"
nullable=
"false"
key=
"true"
auto-increment=
"true"
/>
<member
name=
"user-name"
field=
"user_name"
value-type=
"String"
length=
"64"
nullable=
"false"
/>
<member
name=
"account-name"
field=
"account_name"
value-type=
"String"
length=
"64"
nullable=
"false"
/>
<member
name=
"action-name"
field=
"action_name"
value-type=
"String"
length=
"64"
nullable=
"false"
/>
<member
name=
"argument"
field=
"argument"
value-type=
"String"
length=
"2147483647"
/>
<member
name=
"date"
field=
"date"
value-type=
"Date"
nullable=
"false"
/>
<member
name=
"creation-date"
field=
"creation_date"
value-type=
"Date"
nullable=
"false"
/>
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<primary-key
name=
"PRIMARY"
members=
"id"
/>
<readsets>
<readset
name=
"FULL"
all=
"true"
/>
</readsets>
<updatesets>
<updateset
name=
"FULL"
all=
"true"
/>
</updatesets>
<query-defs>
<query
name=
"find-by-PK"
type=
"SELECT"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[SELECT <FIELDS/>
FROM
<TABLE/>
WHERE
<FIELD
name=
'id'
/>
= ${key-id}]]>
</statement>
</query>
<query
name=
"insert"
type=
"INSERT"
>
<statement>
<![CDATA[INSERT INTO <TABLE/>
(
<FIELDS/>
)
VALUES(
<VALUES/>
)]]>
</statement>
</query>
<query
name=
"update-by-PK"
type=
"UPDATE"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[UPDATE <TABLE/>
SET
<FIELDS/>
WHERE
<FIELD
name=
'id'
/>
= ${key-id}]]>
</statement>
</query>
<query
name=
"delete-by-PK"
type=
"DELETE"
>
<param
name=
"key-id"
/>
<statement>
<![CDATA[DELETE FROM <TABLE/>
WHERE
<FIELD
name=
'id'
/>
= ${key-id}]]>
</statement>
</query>
</query-defs>
</entity>
<entity
name=
"daily-report-content"
table=
"daily_report_content"
alias=
"drc"
>
<member
name=
"report-id"
field=
"report_id"
value-type=
"int"
length=
"10"
nullable=
"false"
key=
"true"
/>
<member
name=
"content"
field=
"content"
value-type=
"byte[]"
length=
"2147483647"
nullable=
"false"
/>
...
...
cat-home/src/main/resources/META-INF/dal/jdbc/report-dal.xml
浏览文件 @
5cac9e00
...
...
@@ -267,4 +267,7 @@
</query>
</query-defs>
</entity>
<entity
name=
"config-modification"
table=
"config_modification"
alias=
"cm"
>
<member
name=
"creation-date"
insert-expr=
"NOW()"
/>
</entity>
</entities>
\ No newline at end of file
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
5cac9e00
...
...
@@ -2016,6 +2016,16 @@
<data-source-name>
cat
</data-source-name>
</configuration>
</component>
<component>
<role>
org.unidal.dal.jdbc.mapping.TableProvider
</role>
<role-hint>
config-modification
</role-hint>
<implementation>
org.unidal.dal.jdbc.mapping.SimpleTableProvider
</implementation>
<configuration>
<logical-table-name>
config-modification
</logical-table-name>
<physical-table-name>
config_modification
</physical-table-name>
<data-source-name>
cat
</data-source-name>
</configuration>
</component>
<component>
<role>
org.unidal.dal.jdbc.mapping.TableProvider
</role>
<role-hint>
daily-report-content
</role-hint>
...
...
@@ -2112,6 +2122,15 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.home.dal.report.ConfigModificationDao
</role>
<implementation>
com.dianping.cat.home.dal.report.ConfigModificationDao
</implementation>
<requirements>
<requirement>
<role>
org.unidal.dal.jdbc.QueryEngine
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.home.dal.report.DailyReportContentDao
</role>
<implementation>
com.dianping.cat.home.dal.report.DailyReportContentDao
</implementation>
...
...
@@ -4668,6 +4687,9 @@
<requirement>
<role>
com.dianping.cat.system.config.RouterConfigManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.page.config.ConfigModificationService
</role>
</requirement>
</requirements>
</component>
<component>
...
...
@@ -4775,6 +4797,24 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.config.ConfigModificationService
</role>
<implementation>
com.dianping.cat.system.page.config.ConfigModificationService
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.home.dal.report.ConfigModificationDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.home.dal.report.ConfigModificationDao
</role>
<implementation>
com.dianping.cat.home.dal.report.ConfigModificationDao
</implementation>
<requirements>
<requirement>
<role>
org.unidal.dal.jdbc.QueryEngine
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.plugin.Handler
</role>
<implementation>
com.dianping.cat.system.page.plugin.Handler
</implementation>
...
...
cat-home/src/main/resources/META-INF/wizard/jdbc/wizard.xml
浏览文件 @
5cac9e00
...
...
@@ -18,7 +18,8 @@
<table
name=
"weekly_report_content"
/>
<table
name=
"alert"
/>
<table
name=
"alert_summary"
/>
<table
name=
"overload_table"
/>
<table
name=
"overload"
/>
<table
name=
"config_modification"
/>
</group>
<group
name=
"alarm"
package=
"com.dianping.cat.home.dal.alarm"
>
<table
name=
"mailRecord"
/>
...
...
cat-home/src/main/webapp/WEB-INF/tags/body.tag
浏览文件 @
5cac9e00
...
...
@@ -179,7 +179,7 @@
loginInfo
.
innerHTML
=
'
<a href="/cat/s/login?op=logout">
'
+
name
+
'
登出</a>
'
;
}
else
{
var
loginInfo
=
document
.
getElementById
(
'
loginInfo
'
);
loginInfo
.
innerHTML
=
'
<a href="#loginModal" data-toggle="modal">登
陆
</a>
'
;
loginInfo
.
innerHTML
=
'
<a href="#loginModal" data-toggle="modal">登
录
</a>
'
;
}
});
</script>
...
...
script/Cat.sql
浏览文件 @
5cac9e00
...
...
@@ -385,3 +385,14 @@ CREATE TABLE `overload` (
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`reported`
(
`report_id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1242
DEFAULT
CHARSET
=
utf8
COMMENT
=
'过大容量表'
;
CREATE
TABLE
`config_modification`
(
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'自增长ID'
,
`user_name`
varchar
(
64
)
NOT
NULL
COMMENT
'用户名'
,
`account_name`
varchar
(
64
)
NOT
NULL
COMMENT
'账户名'
,
`action_name`
varchar
(
64
)
NOT
NULL
COMMENT
'action名'
,
`argument`
longtext
COMMENT
'参数内容'
,
`date`
datetime
NOT
NULL
COMMENT
'修改时间'
,
`creation_date`
datetime
NOT
NULL
COMMENT
'创建时间'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1242
DEFAULT
CHARSET
=
utf8
COMMENT
=
'配置修改记录表'
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录