Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
a297000b
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,发现更多精彩内容 >>
提交
a297000b
编写于
11月 05, 2012
作者:
Y
youyong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the cat project info
上级
7b0f3f9a
变更
38
显示空白变更内容
内联
并排
Showing
38 changed file
with
1327 addition
and
451 deletion
+1327
-451
cat-consumer/src/main/java/com/dianping/cat/consumer/common/CommonAnalyzer.java
...java/com/dianping/cat/consumer/common/CommonAnalyzer.java
+1
-1
cat-core/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+2
-1
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucket.java
...ava/com/dianping/cat/storage/dump/LocalMessageBucket.java
+24
-17
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucketManager.java
.../dianping/cat/storage/dump/LocalMessageBucketManager.java
+13
-1
cat-core/src/main/resources/META-INF/plexus/components.xml
cat-core/src/main/resources/META-INF/plexus/components.xml
+6
-0
cat-home/pom.xml
cat-home/pom.xml
+233
-232
cat-home/src/main/java/com/dianping/cat/report/page/AbstractReportModel.java
...ava/com/dianping/cat/report/page/AbstractReportModel.java
+25
-0
cat-home/src/main/java/com/dianping/cat/report/view/DomainNavManager.java
...n/java/com/dianping/cat/report/view/DomainNavManager.java
+4
-0
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
...main/java/com/dianping/cat/report/view/NavigationBar.java
+2
-0
cat-home/src/main/java/com/dianping/cat/system/SystemModule.java
...e/src/main/java/com/dianping/cat/system/SystemModule.java
+3
-1
cat-home/src/main/java/com/dianping/cat/system/SystemPage.java
...ome/src/main/java/com/dianping/cat/system/SystemPage.java
+20
-18
cat-home/src/main/java/com/dianping/cat/system/page/alarm/Action.java
.../main/java/com/dianping/cat/system/page/alarm/Action.java
+10
-10
cat-home/src/main/java/com/dianping/cat/system/page/alarm/Handler.java
...main/java/com/dianping/cat/system/page/alarm/Handler.java
+2
-2
cat-home/src/main/java/com/dianping/cat/system/page/alarm/JspFile.java
...main/java/com/dianping/cat/system/page/alarm/JspFile.java
+8
-8
cat-home/src/main/java/com/dianping/cat/system/page/alarm/Model.java
...c/main/java/com/dianping/cat/system/page/alarm/Model.java
+20
-20
cat-home/src/main/java/com/dianping/cat/system/page/alarm/Payload.java
...main/java/com/dianping/cat/system/page/alarm/Payload.java
+14
-14
cat-home/src/main/java/com/dianping/cat/system/page/alarm/RecordManager.java
...ava/com/dianping/cat/system/page/alarm/RecordManager.java
+22
-22
cat-home/src/main/java/com/dianping/cat/system/page/alarm/ScheduledManager.java
.../com/dianping/cat/system/page/alarm/ScheduledManager.java
+9
-9
cat-home/src/main/java/com/dianping/cat/system/page/alarm/UserReportSubState.java
...om/dianping/cat/system/page/alarm/UserReportSubState.java
+4
-4
cat-home/src/main/java/com/dianping/cat/system/page/project/Action.java
...ain/java/com/dianping/cat/system/page/project/Action.java
+30
-0
cat-home/src/main/java/com/dianping/cat/system/page/project/Context.java
...in/java/com/dianping/cat/system/page/project/Context.java
+7
-0
cat-home/src/main/java/com/dianping/cat/system/page/project/Handler.java
...in/java/com/dianping/cat/system/page/project/Handler.java
+129
-0
cat-home/src/main/java/com/dianping/cat/system/page/project/JspFile.java
...in/java/com/dianping/cat/system/page/project/JspFile.java
+17
-0
cat-home/src/main/java/com/dianping/cat/system/page/project/JspViewer.java
.../java/com/dianping/cat/system/page/project/JspViewer.java
+23
-0
cat-home/src/main/java/com/dianping/cat/system/page/project/Model.java
...main/java/com/dianping/cat/system/page/project/Model.java
+52
-0
cat-home/src/main/java/com/dianping/cat/system/page/project/Payload.java
...in/java/com/dianping/cat/system/page/project/Payload.java
+109
-0
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+45
-20
cat-home/src/main/resources/META-INF/wizard/webapp/wizard.xml
...home/src/main/resources/META-INF/wizard/webapp/wizard.xml
+4
-1
cat-home/src/main/webapp/WEB-INF/tags/historyReport.tag
cat-home/src/main/webapp/WEB-INF/tags/historyReport.tag
+18
-19
cat-home/src/main/webapp/WEB-INF/tags/hourlyReport.tag
cat-home/src/main/webapp/WEB-INF/tags/hourlyReport.tag
+18
-20
cat-home/src/main/webapp/css/report.css
cat-home/src/main/webapp/css/report.css
+8
-0
cat-home/src/main/webapp/jsp/report/home.jsp
cat-home/src/main/webapp/jsp/report/home.jsp
+1
-0
cat-home/src/main/webapp/jsp/system/project.jsp
cat-home/src/main/webapp/jsp/system/project.jsp
+41
-0
cat-home/src/main/webapp/jsp/system/projectUpdate.jsp
cat-home/src/main/webapp/jsp/system/projectUpdate.jsp
+48
-0
cat-home/src/test/java/com/dianping/cat/demo/TestMaxMessage.java
...e/src/test/java/com/dianping/cat/demo/TestMaxMessage.java
+90
-0
cat-home/src/test/java/com/dianping/cat/demo/TestSendMessage.java
.../src/test/java/com/dianping/cat/demo/TestSendMessage.java
+11
-2
cat-home/src/test/java/com/dianping/cat/report/analyzer/ArchMonthAnalyzer.java
...a/com/dianping/cat/report/analyzer/ArchMonthAnalyzer.java
+39
-29
cat-home/src/test/java/com/dianping/cat/report/analyzer/MachineMonthAnalyzer.java
...om/dianping/cat/report/analyzer/MachineMonthAnalyzer.java
+215
-0
未找到文件。
cat-consumer/src/main/java/com/dianping/cat/consumer/common/CommonAnalyzer.java
浏览文件 @
a297000b
...
...
@@ -256,7 +256,7 @@ public class CommonAnalyzer extends AbstractMessageAnalyzer<CommonReport> implem
public
static
final
String
TUANGOUZHIFU
=
"支付中心"
;
public
static
final
String
MIDDLDWARE
=
"基础组
建
"
;
public
static
final
String
MIDDLDWARE
=
"基础组
件
"
;
public
static
final
String
MOBILEWEB
=
"手机后台"
;
...
...
cat-core/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
a297000b
...
...
@@ -103,7 +103,8 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
.
req
(
MessageCodec
.
class
,
PlainTextMessageCodec
.
ID
)
//
.
req
(
ChannelBufferManager
.
class
));
all
.
add
(
C
(
MessageBucketManager
.
class
,
LocalMessageBucketManager
.
ID
,
LocalMessageBucketManager
.
class
)
//
.
req
(
ServerConfigManager
.
class
,
MessagePathBuilder
.
class
));
.
req
(
ServerConfigManager
.
class
,
MessagePathBuilder
.
class
)
//
.
req
(
MessageCodec
.
class
,
ChannelBufferManager
.
class
));
all
.
add
(
C
(
ChannelBufferManager
.
class
));
all
.
add
(
C
(
Module
.
class
,
CatCoreModule
.
ID
,
CatCoreModule
.
class
));
...
...
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucket.java
浏览文件 @
a297000b
...
...
@@ -109,10 +109,11 @@ public class LocalMessageBucket implements MessageBucket {
}
}
protected
synchronized
MessageBlock
flushBlock
()
throws
IOException
{
protected
MessageBlock
flushBlock
()
throws
IOException
{
boolean
b
=
m_dirty
.
get
();
if
(
b
)
{
synchronized
(
m_out
)
{
m_out
.
close
();
byte
[]
data
=
m_buf
.
toByteArray
();
...
...
@@ -128,6 +129,8 @@ public class LocalMessageBucket implements MessageBucket {
m_block
=
new
MessageBlock
(
m_dataFile
);
}
}
}
return
null
;
}
...
...
@@ -166,15 +169,19 @@ public class LocalMessageBucket implements MessageBucket {
}
@Override
public
synchronized
MessageBlock
store
(
final
MessageTree
tree
,
final
MessageId
id
)
throws
IOException
{
public
MessageBlock
store
(
final
MessageTree
tree
,
final
MessageId
id
)
throws
IOException
{
final
ChannelBuffer
buf
=
m_bufferManager
.
allocate
();
m_lastAccessTime
=
System
.
currentTimeMillis
();
m_codec
.
encode
(
tree
,
buf
);
return
storeMessage
(
buf
,
id
);
}
synchronized
MessageBlock
storeMessage
(
final
ChannelBuffer
buf
,
final
MessageId
id
)
throws
IOException
{
int
size
=
buf
.
readableBytes
();
m_dirty
.
set
(
true
);
m_lastAccessTime
=
System
.
currentTimeMillis
();
m_blockSize
+=
size
;
m_block
.
addIndex
(
id
.
getIndex
(),
size
);
buf
.
getBytes
(
0
,
m_out
,
size
);
// write buffer and compress it
...
...
cat-core/src/main/java/com/dianping/cat/storage/dump/LocalMessageBucketManager.java
浏览文件 @
a297000b
...
...
@@ -18,6 +18,7 @@ import org.codehaus.plexus.logging.LogEnabled;
import
org.codehaus.plexus.logging.Logger
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
import
org.jboss.netty.buffer.ChannelBuffer
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
...
...
@@ -26,6 +27,7 @@ import com.dianping.cat.message.Message;
import
com.dianping.cat.message.MessageProducer
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.internal.MessageId
;
import
com.dianping.cat.message.spi.MessageCodec
;
import
com.dianping.cat.message.spi.MessagePathBuilder
;
import
com.dianping.cat.message.spi.MessageTree
;
import
com.site.helper.Files
;
...
...
@@ -49,6 +51,12 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
@Inject
private
ServerConfigManager
m_configManager
;
@Inject
private
MessageCodec
m_codec
;
@Inject
private
ChannelBufferManager
m_bufferManager
;
private
BlockingQueue
<
EncodeItem
>
m_encodeItems
=
new
LinkedBlockingQueue
<
EncodeItem
>(
10000
);
private
int
m_error
;
...
...
@@ -148,6 +156,7 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
Threads
.
forGroup
(
"Cat"
).
start
(
new
MessageEncode
(
1
));
Threads
.
forGroup
(
"Cat"
).
start
(
new
MessageEncode
(
2
));
Threads
.
forGroup
(
"Cat"
).
start
(
new
MessageEncode
(
3
));
Threads
.
forGroup
(
"Cat"
).
start
(
new
MessageEncode
(
4
));
}
private
boolean
isFit
(
String
path
)
{
...
...
@@ -457,7 +466,10 @@ public class LocalMessageBucketManager extends ContainerHolder implements Messag
MessageId
id
=
item
.
getId
();
try
{
MessageBlock
bolck
=
bucket
.
store
(
tree
,
id
);
final
ChannelBuffer
buf
=
m_bufferManager
.
allocate
();
m_codec
.
encode
(
tree
,
buf
);
MessageBlock
bolck
=
bucket
.
storeMessage
(
buf
,
id
);
if
(
bolck
!=
null
)
{
boolean
result
=
m_messageBlocks
.
offer
(
bolck
);
...
...
cat-core/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
a297000b
...
...
@@ -216,6 +216,12 @@
<requirement>
<role>
com.dianping.cat.message.spi.MessagePathBuilder
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.message.spi.MessageCodec
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.storage.dump.ChannelBufferManager
</role>
</requirement>
</requirements>
</component>
<component>
...
...
cat-home/pom.xml
浏览文件 @
a297000b
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<parent>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
parent
</artifactId>
...
...
@@ -174,11 +173,9 @@
<goal>
dal-jdbc
</goal>
</goals>
<configuration>
<manifest>
<![CDATA[
${basedir}/src/main/resources/META-INF/dal/jdbc/report-manifest.xml,
<manifest>
<![CDATA[${basedir}/src/main/resources/META-INF/dal/jdbc/report-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/jdbc/alarm-manifest.xml,
${basedir}/src/main/resources/META-INF/dal/jdbc/user-manifest.xml,
]]>
</manifest>
${basedir}/src/main/resources/META-INF/dal/jdbc/user-manifest.xml,]]>
</manifest>
</configuration>
</execution>
</executions>
...
...
@@ -221,6 +218,9 @@
<content>
<![CDATA[org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.compliance=1.6]]><![CDATA[org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.compliance=1.6]]>
</content>
</file>
</additionalConfig>
...
...
@@ -233,6 +233,7 @@ org.eclipse.jdt.core.compiler.compliance=1.6]]></content>
<packaging>
war
</packaging>
<env>
alpha
</env>
<test-framework.scope>
test
</test-framework.scope>
<project.build.sourceEncoding>
utf-8
</project.build.sourceEncoding>
</properties>
</project>
cat-home/src/main/java/com/dianping/cat/report/page/AbstractReportModel.java
浏览文件 @
a297000b
...
...
@@ -6,6 +6,7 @@ import java.util.Collection;
import
java.util.Date
;
import
java.util.Map
;
import
com.dainping.cat.consumer.dal.report.Project
;
import
com.dianping.cat.report.ReportPage
;
import
com.dianping.cat.report.view.DomainNavManager
;
import
com.dianping.cat.report.view.HistoryNav
;
...
...
@@ -89,6 +90,30 @@ public abstract class AbstractReportModel<A extends Action, M extends ActionCont
// required by report tag
public
abstract
Collection
<
String
>
getDomains
();
public
String
getDepartment
()
{
String
domain
=
getDomain
();
if
(
domain
!=
null
)
{
Project
project
=
DomainNavManager
.
getProjectByName
(
domain
);
if
(
project
!=
null
)
{
return
project
.
getDepartment
();
}
}
return
"Default"
;
}
public
String
getProjectLine
()
{
String
domain
=
getDomain
();
if
(
domain
!=
null
)
{
Project
project
=
DomainNavManager
.
getProjectByName
(
domain
);
if
(
project
!=
null
)
{
return
project
.
getProjectLine
();
}
}
return
"Default"
;
}
public
Map
<
String
,
Department
>
getDomainGroups
()
{
return
DomainNavManager
.
getDepartment
(
getDomains
());
}
...
...
cat-home/src/main/java/com/dianping/cat/report/view/DomainNavManager.java
浏览文件 @
a297000b
...
...
@@ -27,6 +27,10 @@ public class DomainNavManager implements Initializable {
private
static
Map
<
String
,
Project
>
m_projects
=
new
HashMap
<
String
,
Project
>();
public
static
Project
getProjectByName
(
String
domain
)
{
return
m_projects
.
get
(
domain
);
}
public
static
Map
<
String
,
Department
>
getDepartment
(
Collection
<
String
>
domains
)
{
Map
<
String
,
Department
>
result
=
new
TreeMap
<
String
,
Department
>();
...
...
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
浏览文件 @
a297000b
...
...
@@ -48,6 +48,8 @@ public class NavigationBar {
SystemPage
.
ALARM
,
SystemPage
.
PROJECT
,
SystemPage
.
LOGIN
};
...
...
cat-home/src/main/java/com/dianping/cat/system/SystemModule.java
浏览文件 @
a297000b
...
...
@@ -9,7 +9,9 @@ import com.site.web.mvc.annotation.ModulePagesMeta;
com
.
dianping
.
cat
.
system
.
page
.
alarm
.
Handler
.
class
,
com
.
dianping
.
cat
.
system
.
page
.
login
.
Handler
.
class
com
.
dianping
.
cat
.
system
.
page
.
login
.
Handler
.
class
,
com
.
dianping
.
cat
.
system
.
page
.
project
.
Handler
.
class
})
public
class
SystemModule
extends
AbstractModule
{
...
...
cat-home/src/main/java/com/dianping/cat/system/SystemPage.java
浏览文件 @
a297000b
...
...
@@ -7,28 +7,20 @@ public enum SystemPage implements Page {
ALARM
(
"alarm"
,
"alarm"
,
"Alarm"
,
"Alarm"
,
true
),
LOGIN
(
"login"
,
"login"
,
"Login"
,
"Login"
,
false
)
;
LOGIN
(
"login"
,
"login"
,
"Login"
,
"Login"
,
false
)
,
public
static
SystemPage
getByName
(
String
name
,
SystemPage
defaultPage
)
{
for
(
SystemPage
action
:
SystemPage
.
values
())
{
if
(
action
.
getName
().
equals
(
name
))
{
return
action
;
}
}
return
defaultPage
;
}
private
String
m_description
;
PROJECT
(
"project"
,
"project"
,
"Project"
,
"Project"
,
true
);
private
String
m_name
;
private
String
m_path
;
private
boolean
m_standalone
;
private
String
m_title
;
private
String
m_description
;
private
boolean
m_standalone
;
private
SystemPage
(
String
name
,
String
path
,
String
title
,
String
description
,
boolean
standalone
)
{
m_name
=
name
;
m_path
=
path
;
...
...
@@ -37,6 +29,16 @@ public enum SystemPage implements Page {
m_standalone
=
standalone
;
}
public
static
SystemPage
getByName
(
String
name
,
SystemPage
defaultPage
)
{
for
(
SystemPage
action
:
SystemPage
.
values
())
{
if
(
action
.
getName
().
equals
(
name
))
{
return
action
;
}
}
return
defaultPage
;
}
public
String
getDescription
()
{
return
m_description
;
}
...
...
@@ -65,11 +67,11 @@ public enum SystemPage implements Page {
return
m_title
;
}
public
SystemPage
[]
getValues
()
{
return
SystemPage
.
values
();
}
public
boolean
isStandalone
()
{
return
m_standalone
;
}
public
SystemPage
[]
getValues
()
{
return
SystemPage
.
values
();
}
}
cat-home/src/main/java/com/dianping/cat/system/page/alarm/Action.java
浏览文件 @
a297000b
...
...
@@ -3,8 +3,6 @@ package com.dianping.cat.system.page.alarm;
public
enum
Action
implements
com
.
site
.
web
.
mvc
.
Action
{
ALARM_RECORD_DETAIL
(
"alarmRecordDetail"
),
REPORT_RECORD_LIST
(
"reportRecordList"
),
ALARM_RECORD_LIST
(
"alarmRecordList"
),
ALARM_RULE_ADD
(
"alarmRuleAdd"
),
...
...
@@ -33,25 +31,27 @@ public enum Action implements com.site.web.mvc.Action {
EXCEPTION_ALARM_RULE_SUB
(
"exceptionAlarmRuleSub"
),
SERVICE_ALARM_RULE_DELETE
(
"serviceAlarmRuleDelete
"
),
REPORT_RECORD_LIST
(
"reportRecordList
"
),
S
ERVICE_ALARM_RULE_LIST
(
"serviceAlarmRules
"
),
S
CHEDULED_REPORT_ADD
(
"scheduledReportAdd
"
),
S
ERVICE_ALARM_RULE_SUB
(
"serviceAlarmRuleSub
"
),
S
CHEDULED_REPORT_ADD_SUBMIT
(
"scheduledReportAddSubmit
"
),
SCHEDULED_REPORT_
LIST
(
"scheduledReports
"
),
SCHEDULED_REPORT_
DELETE
(
"scheduledReportDelete
"
),
SCHEDULED_REPORT_
ADD
(
"scheduledReportAdd
"
),
SCHEDULED_REPORT_
LIST
(
"scheduledReports
"
),
SCHEDULED_REPORT_
ADD_SUBMIT
(
"scheduledReportAddSubmit
"
),
SCHEDULED_REPORT_
SUB
(
"scheduledReportSub
"
),
SCHEDULED_REPORT_UPDATE
(
"scheduledReportUpdate"
),
SCHEDULED_REPORT_UPDATE_SUBMIT
(
"scheduledReportUpdateSubmit"
),
SCHEDULED_REPORT_DELETE
(
"scheduledReportDelete"
),
SERVICE_ALARM_RULE_DELETE
(
"serviceAlarmRuleDelete"
),
SERVICE_ALARM_RULE_LIST
(
"serviceAlarmRules"
),
S
CHEDULED_REPORT_SUB
(
"scheduledReport
Sub"
)
S
ERVICE_ALARM_RULE_SUB
(
"serviceAlarmRule
Sub"
)
;
...
...
cat-home/src/main/java/com/dianping/cat/system/page/alarm/Handler.java
浏览文件 @
a297000b
...
...
@@ -28,10 +28,10 @@ public class Handler implements PageHandler<Context> {
private
RuleManager
m_ruleManager
;
@Inject
private
TemplateManager
m_template
Manager
;
private
ScheduledManager
m_scheduled
Manager
;
@Inject
private
ScheduledManager
m_scheduled
Manager
;
private
TemplateManager
m_template
Manager
;
private
int
getLoginUserId
(
Context
ctx
)
{
DpAdminLogin
member
=
ctx
.
getSigninMember
();
...
...
cat-home/src/main/java/com/dianping/cat/system/page/alarm/JspFile.java
浏览文件 @
a297000b
...
...
@@ -31,25 +31,25 @@ public enum JspFile {
EXCEPTION_ALARM_RULE_SUB
(
"/jsp/system/alarmExceptionRules.jsp"
),
S
ERVICE_ALARM_RULE_DELETE
(
"/jsp/system/alarmServiceRules
.jsp"
),
S
CHEDULED_REPORT_ADD
(
"/jsp/system/scheduledReportAdd
.jsp"
),
S
ERVICE_ALARM_RULE_LIST
(
"/jsp/system/alarmServiceRules
.jsp"
),
S
CHEDULED_REPORT_ADD_SUBMIT
(
"/jsp/system/alarmOpState
.jsp"
),
S
ERVICE_ALARM_RULE_SUB
(
"/jsp/system/alarmServiceRule
s.jsp"
),
S
CHEDULED_REPORT_DELETE
(
"/jsp/system/scheduledReport
s.jsp"
),
SCHEDULED_REPORT_LIST
(
"/jsp/system/scheduledReports.jsp"
),
SCHEDULED_REPORT_ADD
(
"/jsp/system/scheduledReportAdd.jsp"
),
SCHEDULED_REPORT_ADD_SUBMIT
(
"/jsp/system/alarmOpState.jsp"
),
SCHEDULED_REPORT_SUB
(
"/jsp/system/scheduledReports.jsp"
),
SCHEDULED_REPORT_UPDATE
(
"/jsp/system/scheduledReportUpdate.jsp"
),
SCHEDULED_REPORT_UPDATE_SUBMIT
(
"/jsp/system/alarmOpState.jsp"
),
SCHEDULED_REPORT_DELETE
(
"/jsp/system/scheduledReports.jsp"
),
SERVICE_ALARM_RULE_DELETE
(
"/jsp/system/alarmServiceRules.jsp"
),
SERVICE_ALARM_RULE_LIST
(
"/jsp/system/alarmServiceRules.jsp"
),
S
CHEDULED_REPORT_SUB
(
"/jsp/system/scheduledReport
s.jsp"
)
S
ERVICE_ALARM_RULE_SUB
(
"/jsp/system/alarmServiceRule
s.jsp"
)
;
...
...
cat-home/src/main/java/com/dianping/cat/system/page/alarm/Model.java
浏览文件 @
a297000b
...
...
@@ -20,18 +20,18 @@ public class Model extends ViewModel<SystemPage, Action, Context> {
private
List
<
MailRecord
>
m_mailRecords
;
private
S
cheduledReport
m_scheduledReport
;
private
S
tring
m_opState
;
private
List
<
ScheduledReport
>
m_schduledReports
;
private
S
tring
m_opState
;
private
S
cheduledReport
m_scheduledReport
;
private
int
m_templateIndex
;
private
List
<
UserAlarmSubState
>
m_userSubStates
;
private
List
<
UserReportSubState
>
m_userReportSubStates
;
private
List
<
UserAlarmSubState
>
m_userSubStates
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
...
...
@@ -73,10 +73,22 @@ public class Model extends ViewModel<SystemPage, Action, Context> {
return
m_opState
;
}
public
List
<
ScheduledReport
>
getSchduledReports
()
{
return
m_schduledReports
;
}
public
ScheduledReport
getScheduledReport
()
{
return
m_scheduledReport
;
}
public
int
getTemplateIndex
()
{
return
m_templateIndex
;
}
public
List
<
UserReportSubState
>
getUserReportSubStates
()
{
return
m_userReportSubStates
;
}
public
List
<
UserAlarmSubState
>
getUserSubStates
()
{
return
m_userSubStates
;
}
...
...
@@ -105,28 +117,16 @@ public class Model extends ViewModel<SystemPage, Action, Context> {
m_opState
=
opState
;
}
public
void
setTemplateIndex
(
int
templateIndex
)
{
m_templateIndex
=
templateIndex
;
}
public
ScheduledReport
getScheduledReport
()
{
return
m_scheduledReport
;
public
void
setSchduledReports
(
List
<
ScheduledReport
>
schduledReports
)
{
m_schduledReports
=
schduledReports
;
}
public
void
setScheduledReport
(
ScheduledReport
scheduledReport
)
{
m_scheduledReport
=
scheduledReport
;
}
public
List
<
ScheduledReport
>
getSchduledReports
()
{
return
m_schduledReports
;
}
public
void
setSchduledReports
(
List
<
ScheduledReport
>
schduledReports
)
{
m_schduledReports
=
schduledReports
;
}
public
List
<
UserReportSubState
>
getUserReportSubStates
()
{
return
m_userReportSubStates
;
public
void
setTemplateIndex
(
int
templateIndex
)
{
m_templateIndex
=
templateIndex
;
}
public
void
setUserReportSubStates
(
List
<
UserReportSubState
>
userReportSubStates
)
{
...
...
cat-home/src/main/java/com/dianping/cat/system/page/alarm/Payload.java
浏览文件 @
a297000b
...
...
@@ -15,9 +15,6 @@ public class Payload implements ActionPayload<SystemPage, Action> {
@FieldMeta
(
"alarmRuleId"
)
private
int
m_alarmRuleId
;
@FieldMeta
(
"scheduledReportId"
)
private
int
m_scheduledReportId
;
@FieldMeta
(
"alarmTemplateId"
)
private
int
m_alarmTemplateId
;
...
...
@@ -29,6 +26,9 @@ public class Payload implements ActionPayload<SystemPage, Action> {
private
SystemPage
m_page
;
@FieldMeta
(
"scheduledReportId"
)
private
int
m_scheduledReportId
;
@FieldMeta
(
"templateName"
)
private
String
m_templateName
;
...
...
@@ -72,6 +72,10 @@ public class Payload implements ActionPayload<SystemPage, Action> {
return
""
;
}
public
int
getScheduledReportId
()
{
return
m_scheduledReportId
;
}
public
String
getTemplateName
()
{
return
m_templateName
;
}
...
...
@@ -113,6 +117,10 @@ public class Payload implements ActionPayload<SystemPage, Action> {
m_page
=
SystemPage
.
getByName
(
page
,
SystemPage
.
ALARM
);
}
public
void
setScheduledReportId
(
int
scheduledReportId
)
{
m_scheduledReportId
=
scheduledReportId
;
}
public
void
setTemplateName
(
String
templateName
)
{
m_templateName
=
templateName
;
}
...
...
@@ -125,14 +133,6 @@ public class Payload implements ActionPayload<SystemPage, Action> {
m_userSubState
=
userSubState
;
}
public
int
getScheduledReportId
()
{
return
m_scheduledReportId
;
}
public
void
setScheduledReportId
(
int
scheduledReportId
)
{
m_scheduledReportId
=
scheduledReportId
;
}
@Override
public
void
validate
(
ActionContext
<?>
ctx
)
{
if
(
m_action
==
null
)
{
...
...
cat-home/src/main/java/com/dianping/cat/system/page/alarm/RecordManager.java
浏览文件 @
a297000b
...
...
@@ -22,10 +22,10 @@ public class RecordManager {
private
AlarmRuleSubscriptionDao
m_alarmRuleSubscriptionDao
;
@Inject
private
ScheduledReportSubscriptionDao
m_scheduledReportSubscription
Dao
;
private
MailRecordDao
m_mailRecord
Dao
;
@Inject
private
MailRecordDao
m_mailRecord
Dao
;
private
ScheduledReportSubscriptionDao
m_scheduledReportSubscription
Dao
;
public
void
queryAlarmRecordDetail
(
Payload
payload
,
Model
model
)
{
int
id
=
payload
.
getAlarmRecordId
();
...
...
@@ -38,26 +38,6 @@ public class RecordManager {
}
}
public
void
queryUserReportRecords
(
Model
model
,
int
userId
)
{
try
{
List
<
ScheduledReportSubscription
>
scheduledReportSubscriptions
=
m_scheduledReportSubscriptionDao
.
findByUserId
(
userId
,
ScheduledReportSubscriptionEntity
.
READSET_FULL
);
int
size
=
scheduledReportSubscriptions
.
size
();
int
ruleIds
[]
=
new
int
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
ScheduledReportSubscription
scheduledReportSubscription
=
scheduledReportSubscriptions
.
get
(
i
);
ruleIds
[
i
]
=
scheduledReportSubscription
.
getScheduledReportId
();
}
List
<
MailRecord
>
mails
=
m_mailRecordDao
.
findReportRecordByRuleId
(
ruleIds
,
MailRecordEntity
.
READSET_FULL
);
model
.
setMailRecords
(
mails
);
}
catch
(
DalNotFoundException
e
)
{
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
model
.
setTemplateIndex
(
3
);
}
public
void
queryUserAlarmRecords
(
Model
model
,
int
userId
)
{
try
{
List
<
AlarmRuleSubscription
>
alarmRuleSubscriptions
=
m_alarmRuleSubscriptionDao
.
findByUserId
(
userId
,
...
...
@@ -79,4 +59,24 @@ public class RecordManager {
}
model
.
setTemplateIndex
(
2
);
}
public
void
queryUserReportRecords
(
Model
model
,
int
userId
)
{
try
{
List
<
ScheduledReportSubscription
>
scheduledReportSubscriptions
=
m_scheduledReportSubscriptionDao
.
findByUserId
(
userId
,
ScheduledReportSubscriptionEntity
.
READSET_FULL
);
int
size
=
scheduledReportSubscriptions
.
size
();
int
ruleIds
[]
=
new
int
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
ScheduledReportSubscription
scheduledReportSubscription
=
scheduledReportSubscriptions
.
get
(
i
);
ruleIds
[
i
]
=
scheduledReportSubscription
.
getScheduledReportId
();
}
List
<
MailRecord
>
mails
=
m_mailRecordDao
.
findReportRecordByRuleId
(
ruleIds
,
MailRecordEntity
.
READSET_FULL
);
model
.
setMailRecords
(
mails
);
}
catch
(
DalNotFoundException
e
)
{
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
model
.
setTemplateIndex
(
3
);
}
}
cat-home/src/main/java/com/dianping/cat/system/page/alarm/ScheduledManager.java
浏览文件 @
a297000b
...
...
@@ -22,19 +22,13 @@ import com.site.lookup.annotation.Inject;
public
class
ScheduledManager
{
@Inject
private
ScheduledReportDao
m_scheduledReport
Dao
;
private
DpAdminLoginDao
m_login
Dao
;
@Inject
private
ScheduledReport
SubscriptionDao
m_scheduledReportSubscription
Dao
;
private
ScheduledReport
Dao
m_scheduledReport
Dao
;
@Inject
private
DpAdminLoginDao
m_loginDao
;
public
List
<
ScheduledReport
>
queryScheduledReports
()
throws
DalException
{
List
<
ScheduledReport
>
reports
=
m_scheduledReportDao
.
findAll
(
ScheduledReportEntity
.
READSET_FULL
);
return
reports
;
}
private
ScheduledReportSubscriptionDao
m_scheduledReportSubscriptionDao
;
public
List
<
String
>
queryEmailsBySchReportId
(
int
scheduledReportId
)
throws
DalException
{
List
<
String
>
emails
=
new
ArrayList
<
String
>();
...
...
@@ -51,6 +45,12 @@ public class ScheduledManager {
return
emails
;
}
public
List
<
ScheduledReport
>
queryScheduledReports
()
throws
DalException
{
List
<
ScheduledReport
>
reports
=
m_scheduledReportDao
.
findAll
(
ScheduledReportEntity
.
READSET_FULL
);
return
reports
;
}
public
void
queryScheduledReports
(
Model
model
,
int
userId
)
{
List
<
UserReportSubState
>
userRules
=
new
ArrayList
<
UserReportSubState
>();
try
{
...
...
cat-home/src/main/java/com/dianping/cat/system/page/alarm/UserReportSubState.java
浏览文件 @
a297000b
...
...
@@ -18,14 +18,14 @@ public class UserReportSubState {
return
m_scheduledReport
;
}
public
void
setScheduledReport
(
ScheduledReport
scheduledReport
)
{
m_scheduledReport
=
scheduledReport
;
}
public
int
getSubscriberState
()
{
return
m_subscriberState
;
}
public
void
setScheduledReport
(
ScheduledReport
scheduledReport
)
{
m_scheduledReport
=
scheduledReport
;
}
public
void
setSubscriberState
(
int
subscriberState
)
{
m_subscriberState
=
subscriberState
;
}
...
...
cat-home/src/main/java/com/dianping/cat/system/page/project/Action.java
0 → 100644
浏览文件 @
a297000b
package
com.dianping.cat.system.page.project
;
public
enum
Action
implements
com
.
site
.
web
.
mvc
.
Action
{
ALL
(
"view"
),
PROJECT_UPDATE
(
"update"
),
PROJECT_UPDATE_SUBMIT
(
"updateSubmit"
);
public
static
Action
getByName
(
String
name
,
Action
defaultAction
)
{
for
(
Action
action
:
Action
.
values
())
{
if
(
action
.
getName
().
equals
(
name
))
{
return
action
;
}
}
return
defaultAction
;
}
private
String
m_name
;
private
Action
(
String
name
)
{
m_name
=
name
;
}
@Override
public
String
getName
()
{
return
m_name
;
}
}
cat-home/src/main/java/com/dianping/cat/system/page/project/Context.java
0 → 100644
浏览文件 @
a297000b
package
com.dianping.cat.system.page.project
;
import
com.dianping.cat.system.SystemContext
;
public
class
Context
extends
SystemContext
<
Payload
>
{
}
cat-home/src/main/java/com/dianping/cat/system/page/project/Handler.java
0 → 100644
浏览文件 @
a297000b
package
com.dianping.cat.system.page.project
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
javax.servlet.ServletException
;
import
com.dainping.cat.consumer.dal.report.Project
;
import
com.dainping.cat.consumer.dal.report.ProjectDao
;
import
com.dainping.cat.consumer.dal.report.ProjectEntity
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.system.SystemPage
;
import
com.site.dal.jdbc.DalException
;
import
com.site.lookup.annotation.Inject
;
import
com.site.web.mvc.PageHandler
;
import
com.site.web.mvc.annotation.InboundActionMeta
;
import
com.site.web.mvc.annotation.OutboundActionMeta
;
import
com.site.web.mvc.annotation.PayloadMeta
;
public
class
Handler
implements
PageHandler
<
Context
>
{
@Inject
private
JspViewer
m_jspViewer
;
@Inject
private
ProjectDao
m_projectDao
;
@Override
@PayloadMeta
(
Payload
.
class
)
@InboundActionMeta
(
name
=
"project"
)
public
void
handleInbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
// display only, no action here
}
@Override
@OutboundActionMeta
(
name
=
"project"
)
public
void
handleOutbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
Model
model
=
new
Model
(
ctx
);
Payload
payload
=
ctx
.
getPayload
();
model
.
setPage
(
SystemPage
.
PROJECT
);
Action
action
=
payload
.
getAction
();
model
.
setAction
(
action
);
switch
(
action
)
{
case
ALL:
model
.
setProjects
(
queryAllProjects
());
break
;
case
PROJECT_UPDATE:
model
.
setProject
(
queryProjectById
(
payload
.
getProjectId
()));
break
;
case
PROJECT_UPDATE_SUBMIT:
updateProject
(
payload
);
model
.
setProjects
(
queryAllProjects
());
break
;
}
m_jspViewer
.
view
(
ctx
,
model
);
}
private
void
updateProject
(
Payload
payload
)
{
int
projectId
=
payload
.
getProjectId
();
String
department
=
payload
.
getDepartment
();
String
email
=
payload
.
getEmail
();
String
owner
=
payload
.
getOwner
();
String
projectLine
=
payload
.
getProjectLine
();
String
domain
=
payload
.
getDomain
();
Project
project
=
m_projectDao
.
createLocal
();
project
.
setId
(
projectId
);
project
.
setKeyId
(
projectId
);
project
.
setDepartment
(
department
);
project
.
setEmail
(
email
);
project
.
setDomain
(
domain
);
project
.
setOwner
(
owner
);
project
.
setProjectLine
(
projectLine
);
try
{
m_projectDao
.
updateByPK
(
project
,
ProjectEntity
.
UPDATESET_FULL
);
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
}
private
List
<
Project
>
queryAllProjects
()
{
List
<
Project
>
projects
=
new
ArrayList
<
Project
>();
try
{
projects
=
m_projectDao
.
findAll
(
ProjectEntity
.
READSET_FULL
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
Collections
.
sort
(
projects
,
new
ProjectCompartor
());
return
projects
;
}
private
Project
queryProjectById
(
int
projectId
)
{
Project
project
=
null
;
try
{
project
=
m_projectDao
.
findByPK
(
projectId
,
ProjectEntity
.
READSET_FULL
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
return
project
;
}
class
ProjectCompartor
implements
Comparator
<
Project
>
{
@Override
public
int
compare
(
Project
o1
,
Project
o2
)
{
String
department1
=
o1
.
getDepartment
();
String
department2
=
o2
.
getDepartment
();
String
productLine1
=
o1
.
getProjectLine
();
String
productLine2
=
o2
.
getProjectLine
();
if
(
department1
.
equalsIgnoreCase
(
department2
))
{
if
(
productLine1
.
equalsIgnoreCase
(
productLine2
))
{
return
o1
.
getDomain
().
compareTo
(
o2
.
getDomain
());
}
else
{
return
productLine1
.
compareTo
(
productLine2
);
}
}
else
{
return
department1
.
compareTo
(
productLine2
);
}
}
}
}
cat-home/src/main/java/com/dianping/cat/system/page/project/JspFile.java
0 → 100644
浏览文件 @
a297000b
package
com.dianping.cat.system.page.project
;
public
enum
JspFile
{
ALL
(
"/jsp/system/project.jsp"
),
UPATE
(
"/jsp/system/projectUpdate.jsp"
),
;
private
String
m_path
;
private
JspFile
(
String
path
)
{
m_path
=
path
;
}
public
String
getPath
()
{
return
m_path
;
}
}
cat-home/src/main/java/com/dianping/cat/system/page/project/JspViewer.java
0 → 100644
浏览文件 @
a297000b
package
com.dianping.cat.system.page.project
;
import
com.dianping.cat.system.SystemPage
;
import
com.site.web.mvc.view.BaseJspViewer
;
public
class
JspViewer
extends
BaseJspViewer
<
SystemPage
,
Action
,
Context
,
Model
>
{
@Override
protected
String
getJspFilePath
(
Context
ctx
,
Model
model
)
{
Action
action
=
model
.
getAction
();
switch
(
action
)
{
case
ALL:
return
JspFile
.
ALL
.
getPath
();
case
PROJECT_UPDATE:
return
JspFile
.
UPATE
.
getPath
();
case
PROJECT_UPDATE_SUBMIT:
return
JspFile
.
ALL
.
getPath
();
default
:
}
throw
new
RuntimeException
(
"Unknown action: "
+
action
);
}
}
cat-home/src/main/java/com/dianping/cat/system/page/project/Model.java
0 → 100644
浏览文件 @
a297000b
package
com.dianping.cat.system.page.project
;
import
java.util.Collections
;
import
java.util.List
;
import
com.dainping.cat.consumer.dal.report.Project
;
import
com.dianping.cat.system.SystemPage
;
import
com.site.web.mvc.ViewModel
;
public
class
Model
extends
ViewModel
<
SystemPage
,
Action
,
Context
>
{
private
Project
m_project
;
private
List
<
Project
>
m_projects
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
public
String
getDate
()
{
return
""
;
}
@Override
public
Action
getDefaultAction
()
{
return
Action
.
ALL
;
}
public
String
getDomain
()
{
return
""
;
}
public
List
<
String
>
getDomains
()
{
return
Collections
.
emptyList
();
}
public
Project
getProject
()
{
return
m_project
;
}
public
List
<
Project
>
getProjects
()
{
return
m_projects
;
}
public
void
setProject
(
Project
project
)
{
m_project
=
project
;
}
public
void
setProjects
(
List
<
Project
>
projects
)
{
m_projects
=
projects
;
}
}
cat-home/src/main/java/com/dianping/cat/system/page/project/Payload.java
0 → 100644
浏览文件 @
a297000b
package
com.dianping.cat.system.page.project
;
import
com.dianping.cat.system.SystemPage
;
import
com.site.web.mvc.ActionContext
;
import
com.site.web.mvc.ActionPayload
;
import
com.site.web.mvc.payload.annotation.FieldMeta
;
public
class
Payload
implements
ActionPayload
<
SystemPage
,
Action
>
{
@FieldMeta
(
"op"
)
private
Action
m_action
;
@FieldMeta
(
"department"
)
private
String
m_department
;
@FieldMeta
(
"email"
)
private
String
m_email
;
@FieldMeta
(
"owner"
)
private
String
m_owner
;
private
SystemPage
m_page
;
@FieldMeta
(
"projectId"
)
private
int
m_projectId
;
@FieldMeta
(
"projectLine"
)
private
String
m_projectLine
;
@FieldMeta
(
"domain"
)
private
String
m_domain
;
@Override
public
Action
getAction
()
{
if
(
m_action
==
null
)
{
m_action
=
Action
.
ALL
;
}
return
m_action
;
}
public
String
getDepartment
()
{
return
m_department
;
}
public
String
getEmail
()
{
return
m_email
;
}
public
String
getOwner
()
{
return
m_owner
;
}
@Override
public
SystemPage
getPage
()
{
return
m_page
;
}
public
int
getProjectId
()
{
return
m_projectId
;
}
public
String
getProjectLine
()
{
return
m_projectLine
;
}
public
String
getReportType
()
{
return
""
;
}
public
void
setAction
(
String
action
)
{
m_action
=
Action
.
getByName
(
action
,
Action
.
ALL
);
}
public
void
setDepartment
(
String
department
)
{
m_department
=
department
;
}
public
void
setEmail
(
String
email
)
{
m_email
=
email
;
}
public
void
setOwner
(
String
owner
)
{
m_owner
=
owner
;
}
@Override
public
void
setPage
(
String
page
)
{
m_page
=
SystemPage
.
getByName
(
page
,
SystemPage
.
PROJECT
);
}
public
void
setProjectId
(
int
projectId
)
{
m_projectId
=
projectId
;
}
public
String
getDomain
()
{
return
m_domain
;
}
public
void
setDomain
(
String
domain
)
{
m_domain
=
domain
;
}
public
void
setProjectLine
(
String
projectLine
)
{
m_projectLine
=
projectLine
;
}
@Override
public
void
validate
(
ActionContext
<?>
ctx
)
{
}
}
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
a297000b
...
...
@@ -2306,10 +2306,10 @@
<role>
com.dianping.cat.system.page.alarm.RuleManager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.page.alarm.
Template
Manager
</role>
<role>
com.dianping.cat.system.page.alarm.
Scheduled
Manager
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.system.page.alarm.
Scheduled
Manager
</role>
<role>
com.dianping.cat.system.page.alarm.
Template
Manager
</role>
</requirement>
</requirements>
</component>
...
...
@@ -2325,10 +2325,10 @@
<role>
com.dianping.cat.home.dal.alarm.AlarmRuleSubscriptionDao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.home.dal.alarm.
ScheduledReportSubscription
Dao
</role>
<role>
com.dianping.cat.home.dal.alarm.
MailRecord
Dao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.home.dal.alarm.
MailRecord
Dao
</role>
<role>
com.dianping.cat.home.dal.alarm.
ScheduledReportSubscription
Dao
</role>
</requirement>
</requirements>
</component>
...
...
@@ -2342,8 +2342,8 @@
</requirements>
</component>
<component>
<role>
com.dianping.cat.home.dal.alarm.
ScheduledReportSubscription
Dao
</role>
<implementation>
com.dianping.cat.home.dal.alarm.
ScheduledReportSubscription
Dao
</implementation>
<role>
com.dianping.cat.home.dal.alarm.
MailRecord
Dao
</role>
<implementation>
com.dianping.cat.home.dal.alarm.
MailRecord
Dao
</implementation>
<requirements>
<requirement>
<role>
com.site.dal.jdbc.QueryEngine
</role>
...
...
@@ -2351,8 +2351,8 @@
</requirements>
</component>
<component>
<role>
com.dianping.cat.home.dal.alarm.
MailRecord
Dao
</role>
<implementation>
com.dianping.cat.home.dal.alarm.
MailRecord
Dao
</implementation>
<role>
com.dianping.cat.home.dal.alarm.
ScheduledReportSubscription
Dao
</role>
<implementation>
com.dianping.cat.home.dal.alarm.
ScheduledReportSubscription
Dao
</implementation>
<requirements>
<requirement>
<role>
com.site.dal.jdbc.QueryEngine
</role>
...
...
@@ -2404,27 +2404,18 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.alarm.TemplateManager
</role>
<implementation>
com.dianping.cat.system.page.alarm.TemplateManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.home.dal.alarm.AlarmTemplateDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.alarm.ScheduledManager
</role>
<implementation>
com.dianping.cat.system.page.alarm.ScheduledManager
</implementation>
<requirements>
<requirement>
<role>
com.d
ianping.cat.home.dal.alarm.ScheduledReport
Dao
</role>
<role>
com.d
ainping.cat.home.dal.user.DpAdminLogin
Dao
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.home.dal.alarm.ScheduledReport
Subscription
Dao
</role>
<role>
com.dianping.cat.home.dal.alarm.ScheduledReportDao
</role>
</requirement>
<requirement>
<role>
com.d
ainping.cat.home.dal.user.DpAdminLogi
nDao
</role>
<role>
com.d
ianping.cat.home.dal.alarm.ScheduledReportSubscriptio
nDao
</role>
</requirement>
</requirements>
</component>
...
...
@@ -2437,6 +2428,15 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.alarm.TemplateManager
</role>
<implementation>
com.dianping.cat.system.page.alarm.TemplateManager
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.home.dal.alarm.AlarmTemplateDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.login.Handler
</role>
<implementation>
com.dianping.cat.system.page.login.Handler
</implementation>
...
...
@@ -2494,6 +2494,31 @@
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.project.Handler
</role>
<implementation>
com.dianping.cat.system.page.project.Handler
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.system.page.project.JspViewer
</role>
</requirement>
<requirement>
<role>
com.dainping.cat.consumer.dal.report.ProjectDao
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.page.project.JspViewer
</role>
<implementation>
com.dianping.cat.system.page.project.JspViewer
</implementation>
</component>
<component>
<role>
com.dainping.cat.consumer.dal.report.ProjectDao
</role>
<implementation>
com.dainping.cat.consumer.dal.report.ProjectDao
</implementation>
<requirements>
<requirement>
<role>
com.site.dal.jdbc.QueryEngine
</role>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.system.alarm.AlarmRuleCreator
</role>
<implementation>
com.dianping.cat.system.alarm.AlarmRuleCreator
</implementation>
...
...
cat-home/src/main/resources/META-INF/wizard/webapp/wizard.xml
浏览文件 @
a297000b
<wizard
package=
"com.dianping.cat"
>
<webapp
package=
"com.dianping.cat"
webres=
"true"
>
<webapp
package=
"com.dianping.cat"
webres=
"true"
plugin-management=
"true"
>
<module
name=
"report"
path=
"r"
>
<page
name=
"home"
title=
"Home"
default=
"true"
>
<description>
Home Page
</description>
...
...
@@ -63,6 +63,9 @@
<page
name=
"login"
title=
"Login"
default=
"true"
path=
"login"
standalone=
"false"
>
<description>
Login
</description>
</page>
<page
name=
"project"
title=
"Project"
path=
"project"
>
<description>
Project
</description>
</page>
</module>
</webapp>
</wizard>
cat-home/src/main/webapp/WEB-INF/tags/historyReport.tag
浏览文件 @
a297000b
...
...
@@ -11,6 +11,7 @@
<a:body>
<res:useCss value='${res.css.local.report_css}' target="head-css" />
<res:useJs value="${res.js.local['jquery-1.7.1.js']}" target="head-js"/>
<div class="report">
<table class="header">
...
...
@@ -36,25 +37,23 @@
</td>
</tr>
</table>
<%-- <table class="navbar">
<tr>
<td class="domain" rowspan="2" style="vertical-align:top;">
<div class="domain">
<c:forEach var="domain" items="${model.domains}">
<c:choose>
<c:when test="${model.domain eq domain}">
<a href="?op=history&domain=${domain}&date=${model.date}&reportType=${model.reportType}" class="current">[ ${domain} ]</a>
</c:when>
<c:otherwise>
<a href="?op=history&domain=${domain}&date=${model.date}&reportType=${model.reportType}">[ ${domain} ]</a>
</c:otherwise>
</c:choose>
</c:forEach>
<div class="position">Current Domain: ${model.department} > ${model.projectLine}
> ${model.domain}
[ <a href="javascript:showDomain()" id="switch">ShowDomain</a> ]
<script>
function showDomain() {
var b = $('#switch').html();
if (b == 'ShowDomain') {
$('.navbar').slideDown();
$('#switch').html("HiddenDomain");
} else {
$('.navbar').slideUp();
$('#switch').html("ShowDomain");
}
}
</script>
</div>
</td>
</tr>
</table> --%>
<div class="navbar">
<div class="navbar" style="display:none">
<table border="1" rules="all">
<c:forEach var="item" items="${model.domainGroups}">
<tr>
...
...
cat-home/src/main/webapp/WEB-INF/tags/hourlyReport.tag
浏览文件 @
a297000b
...
...
@@ -11,6 +11,7 @@
<a:body>
<res:useCss value='${res.css.local.report_css}' target="head-css" />
<res:useJs value="${res.js.local['jquery-1.7.1.js']}" target="head-js"/>
<div class="report">
<table class="header">
...
...
@@ -26,26 +27,23 @@
</td>
</tr>
</table>
<%-- <table class="navbar">
<tr>
<
td class="domain"
>
<div class="domain">
<c:forEach var="domain" items="${model.domains}">
<c:choose>
<c:when test="${model.domain eq domain}">
<a href="${model.baseUri}?domain=${domain}&date=${model.date}" class="current">[ ${domain} ]</a>
</c:when>
<c:otherwise>
<a href="${model.baseUri}?domain=${domain}&date=${model.date}">[ ${domain} ]</a>
</c:otherwise>
</c:choose>
</c:forEach
>
<div class="position"> Current Domain: ${model.department} > ${model.projectLine}
> ${model.domain}
[ <a href="javascript:showDomain()" id="switch">ShowDomain</a> ]
<
script
>
function showDomain() {
var b = $('#switch').html();
if (b == 'ShowDomain') {
$('.navbar').slideDown();
$('#switch').html("HiddenDomain");
} else {
$('.navbar').slideUp();
$('#switch').html("ShowDomain");
}
}
</script
>
</div>
</td>
</tr>
</table> --%>
<div class="navbar">
<div class="navbar" style="display:none">
<table border="1" rules="all">
<c:forEach var="item" items="${model.domainGroups}">
<tr>
...
...
cat-home/src/main/webapp/css/report.css
浏览文件 @
a297000b
...
...
@@ -78,3 +78,11 @@
width
:
100%
;
text-align
:
center
;
}
.report
.position
{
padding
:
4px
;
padding-left
:
8px
;
font-weight
:
bold
;
font-size
:
14px
;
background
:
lightBlue
;
}
\ No newline at end of file
cat-home/src/main/webapp/jsp/report/home.jsp
浏览文件 @
a297000b
...
...
@@ -43,6 +43,7 @@ Welcome to <b>Central Application Tracking (CAT)</b>.
<tr
class=
"even"
><td>
2
</td><td>
集成了CAT,但是在测试环境看不到信息
</td><td>
请check相关步骤
<a
href=
"http://wiki.dianpingoa.com/bin/view/SOA%E6%9E%B6%E6%9E%84/CAT%E9%9B%86%E6%88%90%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3"
target=
"_blank"
>
CAT集成帮助文档
</a></td></tr>
<tr
class=
"odd"
><td>
3
</td><td>
Transaction、Event报表区间
</
<
td><td>
Transaction、Event历史报表,图表X轴以5分钟为刻度,Y轴表示每5分钟的值
</td></tr>
<tr
class=
"even"
><td>
4
</td><td>
Problem、Hearbeat报表区间
</
<
td><td>
Problem、Heartbeat历史报表,图表X轴以1分钟为刻度,Y轴表示每1分钟的值
</td></tr>
<tr
class=
"odd"
><td>
5
</td><td>
项目信息修改
</
<
td><td
style=
"color:red;"
>
请到Project标签下,修改项目所在分组的基本信息
</td></tr>
</table>
<br>
<br>
...
...
cat-home/src/main/webapp/jsp/system/project.jsp
0 → 100644
浏览文件 @
a297000b
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"res"
uri=
"http://www.unidal.org/webres"
%>
<%@ taglib
prefix=
"w"
uri=
"http://www.unidal.org/web/core"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.system.page.project.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.system.page.project.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.system.page.project.Model"
scope=
"request"
/>
<a:body>
<res:useCss
value=
'
${
res
.
css
.
local
.
alarm_css
}
'
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'alarm_js'
]
}
"
target=
"head-js"
/>
<div>
</br>
<table
class=
"project"
width=
"60%"
>
<tr
class=
"odd"
>
<td
width=
"15%"
>
项目名称
</td>
<td
width=
"10%"
>
所属部门
</td>
<td
width=
"10%"
>
产品线
</td>
<td
width=
"15%"
>
组邮件
</td>
<td
width=
"8%"
>
负责人
</td>
<td
width=
"5%"
>
操作
</td>
</tr>
<c:forEach
var=
"item"
items=
"
${
model
.
projects
}
"
varStatus=
"status"
>
<tr
class=
"${status.index mod 2 != 0 ? 'odd' : 'even'}"
>
<td>
${item.domain}
</td>
<td>
${item.department}
</td>
<td>
${item.projectLine}
</td>
<td>
${item.email}
</td>
<td>
${item.owner}
</td>
<td><a
href=
"?op=update&projectId=${item.id}"
>
编辑
</a></td>
</tr>
</c:forEach>
</table>
</div>
</a:body>
\ No newline at end of file
cat-home/src/main/webapp/jsp/system/projectUpdate.jsp
0 → 100644
浏览文件 @
a297000b
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"res"
uri=
"http://www.unidal.org/webres"
%>
<%@ taglib
prefix=
"w"
uri=
"http://www.unidal.org/web/core"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.system.page.project.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.system.page.project.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.system.page.project.Model"
scope=
"request"
/>
<a:body>
<res:useCss
value=
'
${
res
.
css
.
local
.
alarm_css
}
'
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'alarm_js'
]
}
"
target=
"head-js"
/>
<form
name=
"projectUpdate"
method=
"post"
action=
"${model.pageUri}?op=updateSubmit"
>
<table
border=
"0"
>
<input
type=
"hidden"
name=
"projectId"
value=
"${model.project.id}"
/>
<input
type=
"hidden"
name=
"domain"
value=
"${model.project.domain}"
/>
<tr>
<td>
项目名称
</td>
<td>
${model.project.domain}
</td>
</tr>
<tr>
<td>
所属部门
</td>
<td><input
type=
"name"
name=
"department"
value=
"${model.project.department}"
/></td>
</tr>
<tr>
<td>
产品线
</td>
<td><input
type=
"name"
name=
"projectLine"
value=
"${model.project.projectLine}"
/></td>
</tr>
<tr>
<td>
项目组邮件(多个,逗号分割)
</td>
<td><input
type=
"name"
name=
"email"
value=
"${model.project.email}"
/></td>
</tr>
<tr>
<td>
负责人
</td>
<td><input
type=
"name"
name=
"owner"
value=
"${model.project.owner}"
/></td>
</tr>
<tr>
<td>
</td>
<td><input
type=
"submit"
name=
"submit"
value=
"submit"
/></td>
</tr>
</table>
</form>
</a:body>
\ No newline at end of file
cat-home/src/test/java/com/dianping/cat/demo/TestMaxMessage.java
0 → 100644
浏览文件 @
a297000b
package
com.dianping.cat.demo
;
import
org.junit.Test
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
public
class
TestMaxMessage
{
@Test
public
void
testSend
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"CatTest"
,
"CatTest"
+
i
%
10
);
t
.
setStatus
(
Message
.
SUCCESS
);
Cat
.
getProducer
().
newEvent
(
"Cache.kvdb"
,
"Method"
+
i
%
10
+
":missed"
);
t
.
addData
(
"key and value"
);
t
.
complete
();
}
Thread
.
sleep
(
10
*
100
);
}
@Test
public
void
sendMaxMessage
()
throws
Exception
{
long
time
=
System
.
currentTimeMillis
();
int
i
=
10
;
while
(
i
>
0
)
{
i
++;
Transaction
total
=
Cat
.
newTransaction
(
"Test"
,
"Test"
);
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Cache.kvdb"
,
"Method"
+
i
%
10
);
t
.
setStatus
(
Message
.
SUCCESS
);
Cat
.
getProducer
().
newEvent
(
"Cache.kvdb"
,
"Method"
+
i
%
10
+
":missed"
);
t
.
addData
(
"key and value"
);
Transaction
t2
=
Cat
.
getProducer
().
newTransaction
(
"Cache.web"
,
"Method"
+
i
%
10
);
Cat
.
getProducer
().
newEvent
(
"Cache.web"
,
"Method"
+
i
%
10
+
":missed"
);
t2
.
addData
(
"key and value"
);
t2
.
setStatus
(
Message
.
SUCCESS
);
t2
.
complete
();
Transaction
t3
=
Cat
.
getProducer
().
newTransaction
(
"Cache.memcached"
,
"Method"
+
i
%
10
);
t3
.
addData
(
"key and value"
);
t3
.
setStatus
(
Message
.
SUCCESS
);
t3
.
complete
();
Transaction
t4
=
Cat
.
getProducer
().
newTransaction
(
"Cache.memcached"
,
"Method"
+
i
%
10
);
t4
.
addData
(
"key and value"
);
t4
.
setStatus
(
Message
.
SUCCESS
);
t4
.
complete
();
Transaction
t5
=
Cat
.
getProducer
().
newTransaction
(
"Cache.memcached"
,
"Method"
+
i
%
10
);
Transaction
t6
=
Cat
.
getProducer
().
newTransaction
(
"Cache.memcached"
,
"Method"
+
i
%
10
);
t6
.
addData
(
"key and value"
);
t6
.
setStatus
(
Message
.
SUCCESS
);
t6
.
complete
();
Transaction
t9
=
Cat
.
getProducer
().
newTransaction
(
"Cache.memcached"
,
"Method"
+
i
%
10
);
Transaction
t7
=
Cat
.
getProducer
().
newTransaction
(
"Cache.memcached"
,
"Method"
+
i
%
10
);
t7
.
addData
(
"key and value"
);
t7
.
setStatus
(
Message
.
SUCCESS
);
t7
.
complete
();
Transaction
t8
=
Cat
.
getProducer
().
newTransaction
(
"Cache.memcached"
,
"Method"
+
i
%
10
);
t8
.
addData
(
"key and value"
);
t8
.
setStatus
(
Message
.
SUCCESS
);
t8
.
complete
();
t9
.
addData
(
"key and value"
);
t9
.
setStatus
(
Message
.
SUCCESS
);
t9
.
complete
();
t5
.
addData
(
"key and value"
);
t5
.
setStatus
(
Message
.
SUCCESS
);
t5
.
complete
();
t
.
complete
();
total
.
setStatus
(
Transaction
.
SUCCESS
);
total
.
complete
();
if
(
i
%
10000
==
0
)
{
long
duration
=
System
.
currentTimeMillis
()
-
time
;
System
.
out
.
println
(
"["
+
duration
+
"ms]"
+
"[total]"
+
i
+
"[每秒"
+
i
/
duration
*
1000
+
"]"
);
}
}
Thread
.
sleep
(
10
*
1000
);
}
}
\ No newline at end of file
cat-home/src/test/java/com/dianping/cat/demo/TestSendMessage.java
浏览文件 @
a297000b
...
...
@@ -251,9 +251,10 @@ public class TestSendMessage {
public
void
sendMaxMessage
()
throws
Exception
{
long
time
=
System
.
currentTimeMillis
();
int
i
=
10
;
while
(
i
>
0
)
{
i
=
10
*
1000000
-
(
int
)
(
System
.
currentTimeMillis
()
-
time
);
while
(
i
>
0
)
{
i
++;
Transaction
total
=
Cat
.
newTransaction
(
"Cat"
,
"Test"
);
Transaction
t
=
Cat
.
getProducer
().
newTransaction
(
"Cache.kvdb"
,
"Method"
+
i
%
10
);
t
.
setStatus
(
Message
.
SUCCESS
);
Cat
.
getProducer
().
newEvent
(
"Cache.kvdb"
,
"Method"
+
i
%
10
+
":missed"
);
...
...
@@ -300,6 +301,14 @@ public class TestSendMessage {
t9
.
setStatus
(
Message
.
SUCCESS
);
t9
.
complete
();
t
.
complete
();
total
.
setStatus
(
Transaction
.
SUCCESS
);
t
.
complete
();
if
(
i
%
10000
==
0
)
{
long
duration
=
System
.
currentTimeMillis
()
-
time
;
System
.
out
.
println
(
"["
+
duration
+
"ms]"
+
"[total]"
+
i
+
"[每秒"
+
i
/
duration
*
1000
+
"]"
);
}
}
Thread
.
sleep
(
10
*
1000
);
}
...
...
cat-home/src/test/java/com/dianping/cat/report/analyzer/ArchMonthAnalyzer.java
浏览文件 @
a297000b
...
...
@@ -69,9 +69,21 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
Set
<
String
>
domains
=
queryAllDomain
(
start
,
end
);
for
(
int
i
=
0
;
i
<
31
;
i
++)
{
long
t
=
start
.
getTime
()
+
i
*
TimeUtil
.
ONE_DAY
;
Date
date
=
new
Date
(
t
);
System
.
out
.
println
(
"Process "
+
date
);
Date
date
=
new
Date
(
start
.
getTime
()
+
i
*
TimeUtil
.
ONE_DAY
);
System
.
out
.
println
(
"process day "
+
date
);
processOneDay
(
date
,
domains
);
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
for
(
Entry
<
Long
,
Indicator
>
entry
:
indicators
.
entrySet
())
{
Date
time
=
new
Date
(
entry
.
getKey
());
Indicator
indicator
=
entry
.
getValue
();
System
.
out
.
println
(
sdf
.
format
(
time
)
+
"\t"
+
indicator
);
}
}
private
void
processOneDay
(
Date
date
,
Set
<
String
>
domains
)
{
for
(
String
domain
:
domains
)
{
try
{
Dailyreport
report
=
m_dailyreportDao
.
findByNameDomainPeriod
(
date
,
domain
,
"transaction"
,
...
...
@@ -83,9 +95,9 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
Indicator
indicator
=
indicators
.
get
(
date
.
getTime
());
if
(
indicator
==
null
)
{
indicator
=
new
Indicator
();
indicators
.
put
(
t
,
indicator
);
indicators
.
put
(
date
.
getTime
()
,
indicator
);
}
indicator
.
accept
(
machine
);
indicator
.
accept
(
machine
,
transactionReport
);
}
catch
(
DalNotFoundException
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -93,20 +105,6 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
}
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
for
(
Entry
<
Long
,
Indicator
>
entry
:
indicators
.
entrySet
())
{
Date
time
=
new
Date
(
entry
.
getKey
());
Indicator
indicator
=
entry
.
getValue
();
System
.
out
.
println
(
sdf
.
format
(
time
)
+
"\t"
+
indicator
);
}
String
timestamp
=
new
SimpleDateFormat
(
"MM-dd HH:mm:ss.SSS"
).
format
(
new
Date
());
System
.
out
.
println
(
String
.
format
(
"[%s] [INFO] Press any key to stop ... "
,
timestamp
));
System
.
in
.
read
();
}
public
static
class
Indicator
{
private
Item
m_call
=
new
Item
();
...
...
@@ -122,7 +120,7 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
private
Item
m_webCache
=
new
Item
();
public
void
accept
(
Machine
machine
)
{
public
void
accept
(
Machine
machine
,
TransactionReport
report
)
{
Collection
<
TransactionType
>
types
=
machine
.
getTypes
().
values
();
for
(
TransactionType
type
:
types
)
{
String
name
=
type
.
getId
();
...
...
@@ -130,8 +128,17 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
long
error
=
type
.
getFailCount
();
double
sum
=
type
.
getSum
();
if
(
name
.
equalsIgnoreCase
(
"url"
))
{
m_url
.
add
(
count
,
error
,
sum
);
m_url
.
add
(
count
,
error
,
sum
);
double
avg
=
type
.
getAvg
();
if
(
avg
>
90
)
{
System
.
out
.
println
(
report
.
getDomain
());
System
.
out
.
println
(
count
+
" "
+
avg
);
}
}
else
if
(
name
.
equalsIgnoreCase
(
"service"
)
||
name
.
equalsIgnoreCase
(
"pigeonService"
))
{
double
avg
=
type
.
getAvg
();
if
(
avg
>
10
)
{
System
.
out
.
println
(
report
.
getDomain
());
System
.
out
.
println
(
count
+
" "
+
avg
);
}
m_service
.
add
(
count
,
error
,
sum
);
}
else
if
(
name
.
equalsIgnoreCase
(
"call"
)
||
name
.
equalsIgnoreCase
(
"pigeonCall"
))
{
m_call
.
add
(
count
,
error
,
sum
);
...
...
@@ -141,9 +148,12 @@ public class ArchMonthAnalyzer extends ComponentTestCase {
m_kvdbCache
.
add
(
count
,
error
,
sum
);
}
else
if
(
name
.
startsWith
(
"Cache.memcached"
))
{
m_memCache
.
add
(
count
,
error
,
sum
);
if
(
error
>
1000
)
{
System
.
out
.
println
(
report
.
getDomain
());
System
.
out
.
println
(
machine
.
getIp
());
}
}
else
if
(
name
.
equalsIgnoreCase
(
"Cache.web"
))
{
m_webCache
.
add
(
count
,
error
,
sum
);
}
else
{
}
}
}
...
...
cat-home/src/test/java/com/dianping/cat/report/analyzer/MachineMonthAnalyzer.java
0 → 100644
浏览文件 @
a297000b
package
com.dianping.cat.report.analyzer
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.consumer.health.model.entity.HealthReport
;
import
com.dianping.cat.consumer.health.model.entity.MachineInfo
;
import
com.dianping.cat.consumer.health.model.transform.DefaultSaxParser
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.dal.report.Dailyreport
;
import
com.dianping.cat.home.dal.report.DailyreportDao
;
import
com.dianping.cat.home.dal.report.DailyreportEntity
;
import
com.dianping.cat.report.view.StringSortHelper
;
import
com.site.dal.jdbc.DalException
;
import
com.site.dal.jdbc.DalNotFoundException
;
import
com.site.lookup.ComponentTestCase
;
import
com.site.lookup.annotation.Inject
;
@RunWith
(
JUnit4
.
class
)
public
class
MachineMonthAnalyzer
extends
ComponentTestCase
{
private
Map
<
String
,
MonthDomain
>
m_indicators
=
new
LinkedHashMap
<
String
,
MonthDomain
>();
@Inject
private
DailyreportDao
m_dailyreportDao
;
@Before
public
void
setUp
()
throws
Exception
{
super
.
setUp
();
m_dailyreportDao
=
lookup
(
DailyreportDao
.
class
);
}
private
List
<
String
>
queryAllDomain
(
Date
start
,
Date
end
)
{
Set
<
String
>
domains
=
new
LinkedHashSet
<
String
>();
try
{
List
<
Dailyreport
>
reports
=
m_dailyreportDao
.
findAllDomainsByNameDuration
(
start
,
end
,
"health"
,
DailyreportEntity
.
READSET_DOMAIN_NAME
);
for
(
Dailyreport
report
:
reports
)
{
domains
.
add
(
report
.
getDomain
());
}
}
catch
(
DalException
e
)
{
Cat
.
logError
(
e
);
}
return
StringSortHelper
.
sort
(
domains
);
}
@Test
public
void
builderData
()
throws
IOException
{
Date
start
=
TimeUtil
.
getLastMonth
();
Date
end
=
TimeUtil
.
getCurrentMonth
();
List
<
String
>
domains
=
queryAllDomain
(
start
,
end
);
int
day
=
31
;
for
(
int
i
=
0
;
i
<
day
;
i
++)
{
Date
date
=
new
Date
(
start
.
getTime
()
+
i
*
TimeUtil
.
ONE_DAY
);
System
.
out
.
println
(
"process day "
+
date
);
processOneDay
(
date
,
domains
);
}
System
.
out
.
print
(
"项目名称"
+
"\t"
);
System
.
out
.
print
(
"部署机器"
+
"\t"
);
System
.
out
.
print
(
"平均负载"
+
"\t"
);
System
.
out
.
println
(
"最大负载"
+
"\t"
);
for
(
Entry
<
String
,
MonthDomain
>
entry
:
m_indicators
.
entrySet
())
{
MonthDomain
monthInfo
=
entry
.
getValue
();
System
.
out
.
println
(
entry
.
getKey
()
+
"\t"
+
monthInfo
);
}
}
private
void
processOneDay
(
Date
date
,
List
<
String
>
domains
)
{
for
(
String
domain
:
domains
)
{
try
{
Dailyreport
report
=
m_dailyreportDao
.
findByNameDomainPeriod
(
date
,
domain
,
"health"
,
DailyreportEntity
.
READSET_FULL
);
HealthReport
healthReport
=
DefaultSaxParser
.
parse
(
report
.
getContent
());
MachineInfo
machine
=
healthReport
.
getMachineInfo
();
MonthDomain
indicator
=
m_indicators
.
get
(
domain
);
if
(
indicator
==
null
)
{
indicator
=
new
MonthDomain
();
m_indicators
.
put
(
domain
,
indicator
);
}
DomainInfo
t
=
indicator
.
findOrCreatDomain
(
date
);
t
.
add
(
machine
.
getNumbers
(),
machine
.
getAvgMaxLoad
(),
machine
.
getAvgLoad
());
}
catch
(
DalNotFoundException
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
public
class
MonthDomain
{
private
Map
<
Long
,
DomainInfo
>
m_infos
=
new
LinkedHashMap
<
Long
,
DomainInfo
>();
public
DomainInfo
find
(
Date
date
)
{
return
m_infos
.
get
(
date
.
getTime
());
}
public
DomainInfo
findOrCreatDomain
(
Date
date
)
{
DomainInfo
info
=
m_infos
.
get
(
date
);
if
(
info
==
null
)
{
info
=
new
DomainInfo
();
m_infos
.
put
(
date
.
getTime
(),
info
);
}
return
info
;
}
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
DomainInfo
info
=
new
DomainInfo
();
for
(
DomainInfo
temp
:
m_infos
.
values
())
{
info
.
merger
(
temp
);
}
sb
.
append
(
info
);
return
sb
.
toString
();
}
}
public
class
DomainInfo
{
private
int
m_machine
;
private
double
m_loadSum
;
private
double
m_loadAvg
;
private
double
m_maxLoad
;
private
double
m_maxLoadSum
;
private
int
m_days
;
public
DomainInfo
merger
(
DomainInfo
info
)
{
m_machine
=
info
.
getMachine
();
m_loadSum
+=
info
.
getLoadSum
();
m_days
++;
if
(
info
.
getMaxLoad
()
>
m_maxLoad
)
{
m_maxLoad
=
info
.
getMaxLoad
();
}
m_maxLoadSum
+=
info
.
getMaxLoadSum
();
return
this
;
}
public
double
getMaxLoadSum
()
{
return
m_maxLoadSum
;
}
public
void
add
(
int
machine
,
double
maxLoad
,
double
loadAvg
)
{
m_machine
=
machine
;
m_loadSum
+=
loadAvg
;
m_loadAvg
=
loadAvg
;
m_maxLoad
=
maxLoad
;
m_maxLoadSum
=
maxLoad
;
m_days
=
1
;
}
public
int
getMachine
()
{
return
m_machine
;
}
public
void
setMachine
(
int
machine
)
{
m_machine
=
machine
;
}
public
double
getLoadSum
()
{
return
m_loadSum
;
}
public
void
setLoadSum
(
double
loadSum
)
{
m_loadSum
=
loadSum
;
}
public
double
getMaxLoad
()
{
return
m_maxLoad
;
}
public
void
setMaxLoad
(
double
maxLoad
)
{
m_maxLoad
=
maxLoad
;
}
public
double
getLoadAvg
()
{
return
m_loadAvg
;
}
public
void
setLoadAvg
(
double
loadAvg
)
{
m_loadAvg
=
loadAvg
;
}
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
m_machine
).
append
(
"\t"
).
append
(
m_loadSum
/
m_days
).
append
(
"\t"
).
append
(
m_maxLoadSum
/
m_days
)
.
append
(
"\t"
);
return
sb
.
toString
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录