Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
9fa9196b
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,发现更多精彩内容 >>
提交
9fa9196b
编写于
3月 21, 2012
作者:
Y
You Yong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the cat problem jsp
上级
9424fc62
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
197 addition
and
18 deletion
+197
-18
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/CompositeProblemService.java
...at/report/page/model/problem/CompositeProblemService.java
+48
-0
cat-home/src/main/java/com/dianping/cat/report/page/problem/Action.java
...ain/java/com/dianping/cat/report/page/problem/Action.java
+3
-2
cat-home/src/main/java/com/dianping/cat/report/page/problem/Handler.java
...in/java/com/dianping/cat/report/page/problem/Handler.java
+38
-1
cat-home/src/main/java/com/dianping/cat/report/page/problem/JspFile.java
...in/java/com/dianping/cat/report/page/problem/JspFile.java
+1
-0
cat-home/src/main/java/com/dianping/cat/report/page/problem/JspViewer.java
.../java/com/dianping/cat/report/page/problem/JspViewer.java
+2
-0
cat-home/src/main/java/com/dianping/cat/report/page/problem/Model.java
...main/java/com/dianping/cat/report/page/problem/Model.java
+22
-0
cat-home/src/main/java/com/dianping/cat/report/page/problem/Payload.java
...in/java/com/dianping/cat/report/page/problem/Payload.java
+19
-7
cat-home/src/main/java/com/dianping/cat/report/page/problem/ProblemStatistics.java
...m/dianping/cat/report/page/problem/ProblemStatistics.java
+25
-0
cat-home/src/main/java/com/dianping/cat/report/view/ProblemReportHelper.java
...ava/com/dianping/cat/report/view/ProblemReportHelper.java
+10
-4
cat-home/src/main/webapp/WEB-INF/app.tld
cat-home/src/main/webapp/WEB-INF/app.tld
+2
-2
cat-home/src/main/webapp/jsp/report/problem.jsp
cat-home/src/main/webapp/jsp/report/problem.jsp
+1
-1
cat-home/src/main/webapp/jsp/report/problemDetail.jsp
cat-home/src/main/webapp/jsp/report/problemDetail.jsp
+25
-0
cat-home/src/test/java/com/dianping/cat/TestServer.java
cat-home/src/test/java/com/dianping/cat/TestServer.java
+1
-1
未找到文件。
cat-home/src/main/java/com/dianping/cat/report/page/model/problem/CompositeProblemService.java
浏览文件 @
9fa9196b
package
com.dianping.cat.report.page.model.problem
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -16,6 +18,7 @@ import com.dianping.cat.consumer.problem.model.transform.DefaultMerger;
import
com.dianping.cat.report.page.model.spi.ModelRequest
;
import
com.dianping.cat.report.page.model.spi.ModelResponse
;
import
com.dianping.cat.report.page.model.spi.ModelService
;
import
com.site.helper.Splitters
;
import
com.site.lookup.annotation.Inject
;
public
class
CompositeProblemService
implements
ModelService
<
ProblemReport
>,
Initializable
{
...
...
@@ -91,4 +94,49 @@ public class CompositeProblemService implements ModelService<ProblemReport>, Ini
public
void
setSerivces
(
ModelService
<
ProblemReport
>...
services
)
{
m_services
=
Arrays
.
asList
(
services
);
}
/**
* Inject remote servers to load transaction model.
* <p>
*
* For example, servers: 192.168.1.1:2281,192.168.1.2,192.168.1.3
*
* @param servers
* server list separated by comma(',')
*/
public
void
setRemoteServers
(
String
servers
)
{
List
<
String
>
endpoints
=
Splitters
.
by
(
','
).
split
(
servers
);
String
localAddress
=
null
;
String
localHost
=
null
;
try
{
localAddress
=
InetAddress
.
getLocalHost
().
getHostAddress
();
localHost
=
InetAddress
.
getLocalHost
().
getHostName
();
}
catch
(
UnknownHostException
e
)
{
// ignore it
}
for
(
String
endpoint
:
endpoints
)
{
int
pos
=
endpoint
.
indexOf
(
':'
);
String
host
=
(
pos
>
0
?
endpoint
.
substring
(
0
,
pos
)
:
endpoint
);
int
port
=
(
pos
>
0
?
Integer
.
parseInt
(
endpoint
.
substring
(
pos
)
+
1
)
:
2281
);
if
(
port
==
2281
)
{
if
(
"localhost"
.
equals
(
host
)
||
host
.
startsWith
(
"127.0."
))
{
// exclude localhost
continue
;
}
else
if
(
host
.
equals
(
localAddress
)
||
host
.
equals
(
localHost
))
{
// exclude itself
continue
;
}
}
RemoteProblemService
remote
=
new
RemoteProblemService
();
remote
.
setHost
(
host
);
remote
.
setPort
(
port
);
m_services
.
add
(
remote
);
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/problem/Action.java
浏览文件 @
9fa9196b
package
com.dianping.cat.report.page.problem
;
public
enum
Action
implements
com
.
site
.
web
.
mvc
.
Action
{
VIEW
(
"view"
);
VIEW
(
"view"
),
DETAIL
(
"detail"
);
private
String
m_name
;
private
Action
(
String
name
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/problem/Handler.java
浏览文件 @
9fa9196b
package
com.dianping.cat.report.page.problem
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.ServletException
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.JavaThread
;
import
com.dianping.cat.consumer.problem.model.entity.Machine
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
...
...
@@ -92,18 +96,51 @@ public class Handler implements PageHandler<Context> {
Model
model
=
new
Model
(
ctx
);
Payload
payload
=
ctx
.
getPayload
();
model
.
setAction
(
Action
.
VIEW
);
model
.
setAction
(
payload
.
getAction
()
);
model
.
setPage
(
ReportPage
.
PROBLEM
);
switch
(
payload
.
getAction
())
{
case
VIEW:
showSummary
(
model
,
payload
);
break
;
case
DETAIL:
showDetail
(
model
,
payload
);
}
m_jspViewer
.
view
(
ctx
,
model
);
}
private
void
showDetail
(
Model
model
,
Payload
payload
)
{
ProblemReport
report
=
getReport
(
payload
);
Machine
machine
=
report
.
getMachines
().
get
(
payload
.
getIpAddress
());
JavaThread
thread
=
machine
.
getThreads
().
get
(
payload
.
getThreadId
());
Segment
segment
=
thread
.
getSegments
().
get
(
payload
.
getMinute
());
if
(
segment
==
null
)
{
model
.
setEntries
(
new
ArrayList
<
Entry
>());
model
.
setStatistics
(
new
ArrayList
<
ProblemStatistics
>());
return
;
}
List
<
Entry
>
entries
=
segment
.
getEntries
();
Map
<
String
,
ProblemStatistics
>
typeCounts
=
new
HashMap
<
String
,
ProblemStatistics
>();
for
(
Entry
entry
:
entries
)
{
String
type
=
entry
.
getType
();
ProblemStatistics
staticstics
=
typeCounts
.
get
(
type
);
if
(
staticstics
!=
null
)
{
staticstics
.
setCount
(
staticstics
.
getCount
()
+
1
);
}
else
{
ProblemStatistics
temp
=
new
ProblemStatistics
();
temp
.
setCount
(
1
).
setType
(
type
);
typeCounts
.
put
(
type
,
temp
);
}
}
model
.
setEntries
(
entries
);
model
.
setStatistics
(
new
ArrayList
<
ProblemStatistics
>(
typeCounts
.
values
()));
}
private
void
showSummary
(
Model
model
,
Payload
payload
)
{
try
{
ModelPeriod
period
=
payload
.
getPeriod
();
...
...
cat-home/src/main/java/com/dianping/cat/report/page/problem/JspFile.java
浏览文件 @
9fa9196b
...
...
@@ -3,6 +3,7 @@ package com.dianping.cat.report.page.problem;
public
enum
JspFile
{
VIEW
(
"/jsp/report/problem.jsp"
),
DETAIL
(
"jsp/report/problemDetail.jsp"
)
;
private
String
m_path
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/problem/JspViewer.java
浏览文件 @
9fa9196b
...
...
@@ -11,6 +11,8 @@ public class JspViewer extends BaseJspViewer<ReportPage, Action, Context, Model>
switch
(
action
)
{
case
VIEW:
return
JspFile
.
VIEW
.
getPath
();
case
DETAIL:
return
JspFile
.
DETAIL
.
getPath
();
}
throw
new
RuntimeException
(
"Unknown action: "
+
action
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/problem/Model.java
浏览文件 @
9fa9196b
...
...
@@ -2,7 +2,9 @@ package com.dianping.cat.report.page.problem;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
com.dianping.cat.consumer.problem.model.entity.Entry
;
import
com.dianping.cat.consumer.problem.model.entity.ProblemReport
;
import
com.dianping.cat.report.page.AbstractReportModel
;
...
...
@@ -14,6 +16,10 @@ public class Model extends AbstractReportModel<Action, Context> {
private
String
m_ipAddress
;
private
int
m_hour
;
private
List
<
Entry
>
m_entries
;
private
List
<
ProblemStatistics
>
m_statistics
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
...
...
@@ -73,4 +79,20 @@ public class Model extends AbstractReportModel<Action, Context> {
public
void
setIpAddress
(
String
ipAddress
)
{
m_ipAddress
=
ipAddress
;
}
public
List
<
Entry
>
getEntries
()
{
return
m_entries
;
}
public
void
setEntries
(
List
<
Entry
>
entries
)
{
m_entries
=
entries
;
}
public
List
<
ProblemStatistics
>
getStatistics
()
{
return
m_statistics
;
}
public
void
setStatistics
(
List
<
ProblemStatistics
>
statistics
)
{
m_statistics
=
statistics
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/problem/Payload.java
浏览文件 @
9fa9196b
...
...
@@ -11,10 +11,13 @@ public class Payload extends AbstractReportPayload<Action> {
@FieldMeta
(
"ip"
)
private
String
m_ipAddress
;
@FieldMeta
(
"thread"
)
private
String
m_threadId
;
@FieldMeta
(
"minute"
)
private
int
m_minute
;
public
Payload
()
{
super
(
ReportPage
.
PROBLEM
);
}
...
...
@@ -28,21 +31,30 @@ public class Payload extends AbstractReportPayload<Action> {
return
m_ipAddress
;
}
public
int
getMinute
()
{
return
m_minute
;
}
public
String
getThreadId
()
{
return
m_threadId
;
}
return
m_threadId
;
}
public
void
setAction
(
Action
action
)
{
m_action
=
action
;
public
void
setAction
(
String
action
)
{
m_action
=
Action
.
getByName
(
action
,
Action
.
VIEW
)
;
}
public
void
setIpAddress
(
String
ipAddress
)
{
m_ipAddress
=
ipAddress
;
}
public
void
setMinute
(
int
minute
)
{
m_minute
=
minute
;
}
public
void
setThreadId
(
String
threadId
)
{
m_threadId
=
threadId
;
}
m_threadId
=
threadId
;
}
@Override
public
void
validate
(
ActionContext
<?>
ctx
)
{
if
(
m_action
==
null
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/problem/ProblemStatistics.java
0 → 100644
浏览文件 @
9fa9196b
package
com.dianping.cat.report.page.problem
;
public
class
ProblemStatistics
{
private
String
m_type
;
private
int
m_count
;
public
String
getType
()
{
return
m_type
;
}
public
ProblemStatistics
setType
(
String
type
)
{
m_type
=
type
;
return
this
;
}
public
int
getCount
()
{
return
m_count
;
}
public
ProblemStatistics
setCount
(
int
count
)
{
m_count
=
count
;
return
this
;
}
}
cat-home/src/main/java/com/dianping/cat/report/view/ProblemReportHelper.java
浏览文件 @
9fa9196b
...
...
@@ -10,7 +10,7 @@ import com.dianping.cat.consumer.problem.model.entity.Segment;
/* used by problem.jsp */
public
class
ProblemReportHelper
{
public
static
String
showLegends
(
JavaThread
thread
,
int
minute
)
{
public
static
String
showLegends
(
JavaThread
thread
,
int
minute
,
String
domain
,
String
ipAddress
,
long
date
)
{
Segment
segment
=
thread
.
findSegment
(
minute
);
if
(
segment
==
null
)
{
...
...
@@ -35,9 +35,15 @@ public class ProblemReportHelper {
if
(
messageId
==
null
)
{
sb
.
append
(
" "
);
}
else
{
sb
.
append
(
"<a href=\"/cat/r/m/"
).
append
(
messageId
).
append
(
"/logview.html\" class=\""
);
sb
.
append
(
name
);
sb
.
append
(
"\"> </a>"
);
sb
.
append
(
"<a href=\"/cat/r/p?op=detail"
).
append
(
"&thread="
).
append
(
thread
.
getId
());
sb
.
append
(
"&domain="
).
append
(
domain
);
sb
.
append
(
"&ip="
).
append
(
ipAddress
);
sb
.
append
(
"&date="
).
append
(
date
);
sb
.
append
(
"&minute="
).
append
(
minute
);
sb
.
append
(
"\" class=\""
).
append
(
name
).
append
(
"\"> </a>"
);
//sb.append("<a href=\"/cat/r/m/").append(messageId).append("/logview.html\" class=\"");
//sb.append(name);
//sb.append("\"> </a>");
}
}
...
...
cat-home/src/main/webapp/WEB-INF/app.tld
浏览文件 @
9fa9196b
...
...
@@ -44,7 +44,7 @@
<description>
show legends for problem summary report
</description>
<name>
showLegends
</name>
<function-class>
com.dianping.cat.report.view.ProblemReportHelper
</function-class>
<function-signature>
String showLegends(com.dianping.cat.consumer.problem.model.entity.JavaThread, int)
</function-signature>
<example>
${a:showLegends(thread,
minu
te)}
</example>
<function-signature>
String showLegends(com.dianping.cat.consumer.problem.model.entity.JavaThread, int
, java.lang.String, java.lang.String, long
)
</function-signature>
<example>
${a:showLegends(thread,
minute, domain, ip, da
te)}
</example>
</function>
</taglib>
\ No newline at end of file
cat-home/src/main/webapp/jsp/report/problem.jsp
浏览文件 @
9fa9196b
...
...
@@ -39,7 +39,7 @@
<tr
class=
"${minute%2==0 ? 'even' : 'odd'}"
>
<td>
${w:format(model.hour,'00')}:${w:format(minute,'00')}
</td>
<c:forEach
var=
"thread"
items=
"
${
threads
}
"
>
<td>
${a:showLegends(thread.value, minute)}
</td>
<td>
${a:showLegends(thread.value, minute
, model.domain, model.ipAddress, model.date
)}
</td>
</c:forEach>
</tr>
</c:forEach>
...
...
cat-home/src/main/webapp/jsp/report/problemDetail.jsp
0 → 100644
浏览文件 @
9fa9196b
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<%@ taglib
prefix=
"a"
uri=
"/WEB-INF/app.tld"
%>
<%@ taglib
prefix=
"w"
uri=
"/web/core"
%>
<%@ taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%>
<%@ taglib
prefix=
"res"
uri=
"http://www.unidal.org/webres"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.report.page.problem.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.problem.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.problem.Model"
scope=
"request"
/>
<table>
<tr>
<th>
Statistics
</th>
<c:forEach
var=
"item"
items=
"
${
model
.
statistics
}
"
>
<td>
${item.type} ${item.count}
</td>
</c:forEach>
</tr>
</table>
<table
>
<tr>
<th>
Error
</th>
<c:forEach
var=
"entry"
items=
"
${
model
.
entries
}
"
>
<td>
${entry.messageId}
</td>
</c:forEach>
</tr>
</table>
\ No newline at end of file
cat-home/src/test/java/com/dianping/cat/TestServer.java
浏览文件 @
9fa9196b
...
...
@@ -102,7 +102,7 @@ public class TestServer extends SimpleServerSupport {
@Test
public
void
startServer
()
throws
Exception
{
// open the page in the default browser
s_adaptor
.
display
(
"/cat/r"
);
//
s_adaptor.display("/cat/r");
System
.
out
.
println
(
String
.
format
(
"[%s] Press any key to stop server ... "
,
getTimestamp
()));
System
.
in
.
read
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录