Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
c014f35b
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,发现更多精彩内容 >>
提交
c014f35b
编写于
9月 03, 2013
作者:
Y
yong.you
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tps calculate to tps
上级
f95c6f04
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
85 addition
and
122 deletion
+85
-122
cat-home/src/main/java/com/dianping/cat/report/page/cache/Handler.java
...main/java/com/dianping/cat/report/page/cache/Handler.java
+20
-60
cat-home/src/main/java/com/dianping/cat/report/page/event/Handler.java
...main/java/com/dianping/cat/report/page/event/Handler.java
+9
-32
cat-home/src/main/java/com/dianping/cat/report/page/event/TpsStatistics.java
...ava/com/dianping/cat/report/page/event/TpsStatistics.java
+25
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
...ava/com/dianping/cat/report/page/transaction/Handler.java
+6
-30
cat-home/src/main/java/com/dianping/cat/report/page/transaction/TpsStatistics.java
...m/dianping/cat/report/page/transaction/TpsStatistics.java
+25
-0
未找到文件。
cat-home/src/main/java/com/dianping/cat/report/page/cache/Handler.java
浏览文件 @
c014f35b
...
...
@@ -15,22 +15,19 @@ import org.unidal.web.mvc.annotation.InboundActionMeta;
import
org.unidal.web.mvc.annotation.OutboundActionMeta
;
import
org.unidal.web.mvc.annotation.PayloadMeta
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.consumer.event.EventAnalyzer
;
import
com.dianping.cat.consumer.event.EventReportMerger
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.transaction.TransactionAnalyzer
;
import
com.dianping.cat.consumer.transaction.TransactionReportMerger
;
import
com.dianping.cat.consumer.transaction.model.entity.Machine
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.report.ReportPage
;
import
com.dianping.cat.report.page.PayloadNormalizer
;
import
com.dianping.cat.report.page.event.EventMergeManager
;
import
com.dianping.cat.report.page.event.TpsStatistics
;
import
com.dianping.cat.report.page.model.spi.ModelService
;
import
com.dianping.cat.report.page.transaction.MergeAllMachine
;
import
com.dianping.cat.report.page.transaction.MergeAllName
;
...
...
@@ -76,75 +73,38 @@ public class Handler implements PageHandler<Context> {
private
void
calculateEventTps
(
Payload
payload
,
EventReport
report
)
{
if
(
payload
!=
null
&&
report
!=
null
)
{
boolean
isCurrent
=
payload
.
getPeriod
().
isCurrent
();
String
ip
=
payload
.
getIpAddress
();
com
.
dianping
.
cat
.
consumer
.
event
.
model
.
entity
.
Machine
machine
=
report
.
getMachines
().
get
(
ip
);
if
(
machine
==
null
)
{
return
;
}
for
(
EventType
eventType
:
machine
.
getTypes
().
values
())
{
long
totalCount
=
eventType
.
getTotalCount
();
double
tps
=
0
;
if
(
isCurrent
)
{
double
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
tps
=
totalCount
/
seconds
;
}
else
{
double
time
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
tps
=
totalCount
/
(
double
)
time
;
}
eventType
.
setTps
(
tps
);
for
(
EventName
transName
:
eventType
.
getNames
().
values
())
{
long
totalNameCount
=
transName
.
getTotalCount
();
double
nameTps
=
0
;
try
{
if
(
payload
!=
null
&&
report
!=
null
)
{
boolean
isCurrent
=
payload
.
getPeriod
().
isCurrent
();
double
seconds
;
if
(
isCurrent
)
{
double
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
nameTps
=
totalNameCount
/
seconds
;
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
}
else
{
double
time
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
nameTps
=
totalNameCount
/
(
double
)
time
;
seconds
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
}
transName
.
setTps
(
nameTps
);
new
TpsStatistics
(
seconds
).
visitEventReport
(
report
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
}
private
void
calculateTransactionTps
(
Payload
payload
,
TransactionReport
report
)
{
if
(
payload
!=
null
&&
report
!=
null
)
{
boolean
isCurrent
=
payload
.
getPeriod
().
isCurrent
();
String
ip
=
payload
.
getIpAddress
();
Machine
machine
=
report
.
getMachines
().
get
(
ip
);
if
(
machine
==
null
)
{
return
;
}
for
(
TransactionType
transType
:
machine
.
getTypes
().
values
())
{
long
totalCount
=
transType
.
getTotalCount
();
double
tps
=
0
;
if
(
isCurrent
)
{
double
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
tps
=
totalCount
/
seconds
;
}
else
{
double
time
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
tps
=
totalCount
/
(
double
)
time
;
}
transType
.
setTps
(
tps
);
for
(
TransactionName
transName
:
transType
.
getNames
().
values
())
{
long
totalNameCount
=
transName
.
getTotalCount
();
double
nameTps
=
0
;
try
{
if
(
payload
!=
null
&&
report
!=
null
)
{
boolean
isCurrent
=
payload
.
getPeriod
().
isCurrent
();
double
seconds
;
if
(
isCurrent
)
{
double
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
nameTps
=
totalNameCount
/
seconds
;
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
}
else
{
double
time
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
nameTps
=
totalNameCount
/
(
double
)
time
;
seconds
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
}
transName
.
setTps
(
nameTps
);
new
com
.
dianping
.
cat
.
report
.
page
.
transaction
.
TpsStatistics
(
seconds
).
visitTransactionReport
(
report
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/event/Handler.java
浏览文件 @
c014f35b
...
...
@@ -22,7 +22,6 @@ import com.dianping.cat.consumer.event.EventAnalyzer;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventReport
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.event.model.entity.Machine
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.report.ReportPage
;
import
com.dianping.cat.report.graph.GraphBuilder
;
...
...
@@ -74,41 +73,19 @@ public class Handler implements PageHandler<Context> {
}
private
void
calculateTps
(
Payload
payload
,
EventReport
report
)
{
if
(
payload
!=
null
&&
report
!=
null
)
{
boolean
isCurrent
=
payload
.
getPeriod
().
isCurrent
();
String
ip
=
payload
.
getIpAddress
();
Machine
machine
=
report
.
getMachines
().
get
(
ip
);
if
(
machine
==
null
)
{
return
;
}
for
(
EventType
eventType
:
machine
.
getTypes
().
values
())
{
long
totalCount
=
eventType
.
getTotalCount
();
double
tps
=
0
;
try
{
if
(
payload
!=
null
&&
report
!=
null
)
{
boolean
isCurrent
=
payload
.
getPeriod
().
isCurrent
();
double
seconds
;
if
(
isCurrent
)
{
double
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
tps
=
totalCount
/
seconds
;
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
}
else
{
double
time
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
tps
=
totalCount
/
(
double
)
time
;
}
eventType
.
setTps
(
tps
);
for
(
EventName
transName
:
eventType
.
getNames
().
values
())
{
long
totalNameCount
=
transName
.
getTotalCount
();
double
nameTps
=
0
;
if
(
isCurrent
)
{
double
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
nameTps
=
totalNameCount
/
seconds
;
}
else
{
double
time
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
nameTps
=
totalNameCount
/
(
double
)
time
;
}
transName
.
setTps
(
nameTps
);
transName
.
setTotalPercent
(
totalNameCount
/
(
double
)
totalCount
);
seconds
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
}
new
TpsStatistics
(
seconds
).
visitEventReport
(
report
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
...
...
cat-home/src/main/java/com/dianping/cat/report/page/event/TpsStatistics.java
0 → 100644
浏览文件 @
c014f35b
package
com.dianping.cat.report.page.event
;
import
com.dianping.cat.consumer.event.model.entity.EventName
;
import
com.dianping.cat.consumer.event.model.entity.EventType
;
import
com.dianping.cat.consumer.event.model.transform.BaseVisitor
;
public
class
TpsStatistics
extends
BaseVisitor
{
public
double
m_duration
;
public
TpsStatistics
(
double
duration
)
{
m_duration
=
duration
;
}
@Override
public
void
visitName
(
EventName
name
)
{
name
.
setTps
(
name
.
getTotalCount
()
*
1.0
/
m_duration
);
}
@Override
public
void
visitType
(
EventType
type
)
{
type
.
setTps
(
type
.
getTotalCount
()
*
1.0
/
m_duration
);
super
.
visitType
(
type
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
浏览文件 @
c014f35b
...
...
@@ -18,7 +18,6 @@ import org.unidal.web.mvc.annotation.PayloadMeta;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.consumer.transaction.TransactionAnalyzer
;
import
com.dianping.cat.consumer.transaction.model.entity.Machine
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
...
...
@@ -85,36 +84,13 @@ public class Handler implements PageHandler<Context> {
try
{
if
(
payload
!=
null
&&
report
!=
null
)
{
boolean
isCurrent
=
payload
.
getPeriod
().
isCurrent
();
String
ip
=
payload
.
getIpAddress
();
Machine
machine
=
report
.
getMachines
().
get
(
ip
);
if
(
machine
==
null
)
{
return
;
}
for
(
TransactionType
transType
:
machine
.
getTypes
().
values
())
{
long
totalCount
=
transType
.
getTotalCount
();
double
tps
=
0
;
if
(
isCurrent
)
{
double
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
tps
=
totalCount
/
seconds
;
}
else
{
double
time
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
tps
=
totalCount
/
(
double
)
time
;
}
transType
.
setTps
(
tps
);
for
(
TransactionName
transName
:
transType
.
getNames
().
values
())
{
long
totalNameCount
=
transName
.
getTotalCount
();
double
nameTps
=
0
;
if
(
isCurrent
)
{
double
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
nameTps
=
totalNameCount
/
seconds
;
}
else
{
double
time
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
nameTps
=
totalNameCount
/
(
double
)
time
;
}
transName
.
setTps
(
nameTps
);
transName
.
setTotalPercent
((
double
)
totalNameCount
/
totalCount
);
}
double
seconds
;
if
(
isCurrent
)
{
seconds
=
(
System
.
currentTimeMillis
()
-
payload
.
getCurrentDate
())
/
(
double
)
1000
;
}
else
{
seconds
=
(
report
.
getEndTime
().
getTime
()
-
report
.
getStartTime
().
getTime
())
/
(
double
)
1000
;
}
new
TpsStatistics
(
seconds
).
visitTransactionReport
(
report
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/transaction/TpsStatistics.java
0 → 100644
浏览文件 @
c014f35b
package
com.dianping.cat.report.page.transaction
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionName
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionType
;
import
com.dianping.cat.consumer.transaction.model.transform.BaseVisitor
;
public
class
TpsStatistics
extends
BaseVisitor
{
public
double
m_duration
;
public
TpsStatistics
(
double
duration
)
{
m_duration
=
duration
;
}
@Override
public
void
visitName
(
TransactionName
name
)
{
name
.
setTps
(
name
.
getTotalCount
()
*
1.0
/
m_duration
);
}
@Override
public
void
visitType
(
TransactionType
type
)
{
type
.
setTps
(
type
.
getTotalCount
()
*
1.0
/
m_duration
);
super
.
visitType
(
type
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录