Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
1f3f3579
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,发现更多精彩内容 >>
提交
1f3f3579
编写于
7月 21, 2014
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
review code
上级
6993a972
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
70 addition
and
73 deletion
+70
-73
cat-broker/src/main/java/com/dianping/cat/broker/api/app/BucketHandler.java
...n/java/com/dianping/cat/broker/api/app/BucketHandler.java
+9
-0
cat-broker/src/main/java/com/dianping/cat/broker/api/page/batch/Handler.java
.../java/com/dianping/cat/broker/api/page/batch/Handler.java
+51
-55
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
...main/java/com/dianping/cat/config/app/AppDataService.java
+5
-8
cat-home/src/main/java/com/dianping/cat/report/page/app/graph/AppGraphCreator.java
...m/dianping/cat/report/page/app/graph/AppGraphCreator.java
+4
-6
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
...main/java/com/dianping/cat/report/view/NavigationBar.java
+0
-2
cat-home/src/main/resources/chrome/cat.crx
cat-home/src/main/resources/chrome/cat.crx
+0
-0
cat-home/src/main/resources/chrome/cat/cat.js
cat-home/src/main/resources/chrome/cat/cat.js
+1
-2
未找到文件。
cat-broker/src/main/java/com/dianping/cat/broker/api/app/BucketHandler.java
浏览文件 @
1f3f3579
...
...
@@ -40,6 +40,7 @@ public class BucketHandler implements Task {
int
minute
=
(
int
)
(
m_startTime
%
ONE_DAY
/
ONE_MINUTE
);
Date
period
=
new
Date
(
m_startTime
-
minute
*
ONE_MINUTE
);
List
<
AppDataCommand
>
appDataCommands
=
new
ArrayList
<
AppDataCommand
>();
int
batchSize
=
100
;
for
(
Entry
<
Integer
,
HashMap
<
String
,
AppData
>>
outerEntry
:
m_mergedData
.
entrySet
())
{
for
(
Entry
<
String
,
AppData
>
entry
:
outerEntry
.
getValue
().
entrySet
())
{
...
...
@@ -62,9 +63,17 @@ public class BucketHandler implements Task {
proto
.
setResponsePackage
(
appData
.
getResponseByte
());
proto
.
setCreationDate
(
new
Date
());
appDataCommands
.
add
(
proto
);
if
(
appDataCommands
.
size
()
>=
batchSize
)
{
batchInsert
(
appDataCommands
);
appDataCommands
=
new
ArrayList
<
AppDataCommand
>();
}
}
}
batchInsert
(
appDataCommands
);
}
private
void
batchInsert
(
List
<
AppDataCommand
>
appDataCommands
)
{
try
{
m_appDataService
.
insert
((
AppDataCommand
[])
appDataCommands
.
toArray
());
}
catch
(
Exception
e
)
{
...
...
cat-broker/src/main/java/com/dianping/cat/broker/api/page/batch/Handler.java
浏览文件 @
1f3f3579
...
...
@@ -65,76 +65,72 @@ public class Handler implements PageHandler<Context>, LogEnabled {
String
userIp
=
m_util
.
getRemoteIp
(
request
);
String
version
=
payload
.
getVersion
();
if
(
version
.
equals
(
"1"
))
{
processVersion1
(
payload
,
request
,
userIp
);
}
else
if
(
version
.
equals
(
"2"
))
{
processVersion2
(
payload
,
request
,
userIp
);
if
(
userIp
!=
null
)
{
if
(
version
.
equals
(
"1"
))
{
processVersion1
(
payload
,
request
,
userIp
);
}
else
if
(
version
.
equals
(
"2"
))
{
processVersion2
(
payload
,
request
,
userIp
);
}
}
else
{
m_logger
.
info
(
"unknown http request, x-forwarded-for:"
+
request
.
getHeader
(
"x-forwarded-for"
));
}
response
.
getWriter
().
write
(
"OK"
);
}
private
void
processVersion1
(
Payload
payload
,
HttpServletRequest
request
,
String
userIp
)
{
if
(
userIp
!=
null
)
{
try
{
String
content
=
payload
.
getContent
();
String
[]
lines
=
content
.
split
(
"\n"
);
for
(
String
line
:
lines
)
{
String
[]
tabs
=
line
.
split
(
"\t"
);
// timstampTABtargetUrlTABdurationTABhttpCodeTABerrorCodeENTER
if
(
tabs
.
length
==
5
&&
validate
(
tabs
[
3
],
tabs
[
4
]))
{
MonitorEntity
entity
=
new
MonitorEntity
();
String
httpStatus
=
tabs
[
3
];
String
errorCode
=
tabs
[
4
];
if
(
StringUtils
.
isEmpty
(
errorCode
))
{
errorCode
=
Constrants
.
NOT_SET
;
}
if
(
StringUtils
.
isEmpty
(
httpStatus
))
{
httpStatus
=
Constrants
.
NOT_SET
;
}
entity
.
setTimestamp
(
Long
.
parseLong
(
tabs
[
0
]));
entity
.
setTargetUrl
(
tabs
[
1
]);
entity
.
setDuration
(
Double
.
parseDouble
(
tabs
[
2
]));
entity
.
setHttpStatus
(
httpStatus
);
entity
.
setErrorCode
(
errorCode
);
entity
.
setIp
(
userIp
);
if
(
payload
.
getVersion
().
equals
(
"1"
))
{
entity
.
setCount
(
10
);
}
m_manager
.
offer
(
entity
);
try
{
String
content
=
payload
.
getContent
();
String
[]
lines
=
content
.
split
(
"\n"
);
for
(
String
line
:
lines
)
{
String
[]
tabs
=
line
.
split
(
"\t"
);
// timstampTABtargetUrlTABdurationTABhttpCodeTABerrorCodeENTER
if
(
tabs
.
length
==
5
&&
validate
(
tabs
[
3
],
tabs
[
4
]))
{
MonitorEntity
entity
=
new
MonitorEntity
();
String
httpStatus
=
tabs
[
3
];
String
errorCode
=
tabs
[
4
];
if
(
StringUtils
.
isEmpty
(
errorCode
))
{
errorCode
=
Constrants
.
NOT_SET
;
}
if
(
StringUtils
.
isEmpty
(
httpStatus
))
{
httpStatus
=
Constrants
.
NOT_SET
;
}
entity
.
setTimestamp
(
Long
.
parseLong
(
tabs
[
0
]));
entity
.
setTargetUrl
(
tabs
[
1
]);
entity
.
setDuration
(
Double
.
parseDouble
(
tabs
[
2
]));
entity
.
setHttpStatus
(
httpStatus
);
entity
.
setErrorCode
(
errorCode
);
entity
.
setIp
(
userIp
);
if
(
payload
.
getVersion
().
equals
(
"1"
))
{
entity
.
setCount
(
10
);
}
m_manager
.
offer
(
entity
);
}
}
catch
(
Exception
e
)
{
m_logger
.
error
(
e
.
getMessage
(),
e
);
}
}
else
{
m_logger
.
info
(
"unknown http request, x-forwarded-for:"
+
request
.
getHeader
(
"x-forwarded-for"
)
);
}
catch
(
Exception
e
)
{
m_logger
.
error
(
e
.
getMessage
(),
e
);
}
}
private
void
processVersion2
(
Payload
payload
,
HttpServletRequest
request
,
String
userIp
)
{
if
(
userIp
!=
null
)
{
String
content
=
payload
.
getContent
();
String
records
[]
=
content
.
split
(
"\n"
);
IpInfo
ipInfo
=
m_ipService
.
findIpInfoByString
(
userIp
);
if
(
ipInfo
!=
null
)
{
String
province
=
ipInfo
.
getProvince
();
String
operatorStr
=
ipInfo
.
getChannel
();
Integer
cityId
=
m_appConfigManager
.
getCities
().
get
(
province
);
Integer
operatorId
=
m_appConfigManager
.
getOperators
().
get
(
operatorStr
);
if
(
cityId
!=
null
&&
operatorId
!=
null
)
{
for
(
String
record
:
records
)
{
processOneRecord
(
cityId
,
operatorId
,
record
);
}
String
content
=
payload
.
getContent
();
String
records
[]
=
content
.
split
(
"\n"
);
IpInfo
ipInfo
=
m_ipService
.
findIpInfoByString
(
userIp
);
if
(
ipInfo
!=
null
)
{
String
province
=
ipInfo
.
getProvince
();
String
operatorStr
=
ipInfo
.
getChannel
();
Integer
cityId
=
m_appConfigManager
.
getCities
().
get
(
province
);
Integer
operatorId
=
m_appConfigManager
.
getOperators
().
get
(
operatorStr
);
if
(
cityId
!=
null
&&
operatorId
!=
null
)
{
for
(
String
record
:
records
)
{
processOneRecord
(
cityId
,
operatorId
,
record
);
}
}
}
else
{
m_logger
.
info
(
"unknown http request, x-forwarded-for:"
+
request
.
getHeader
(
"x-forwarded-for"
));
}
}
...
...
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
浏览文件 @
1f3f3579
...
...
@@ -26,20 +26,16 @@ public class AppDataService {
@Inject
private
AppConfigManager
m_appConfigManager
;
public
static
final
String
SUCCESS
=
"success"
;
public
static
final
String
SUCCESS
=
"success"
;
public
static
final
String
REQUEST
=
"request"
;
public
static
final
String
DELAY
=
"delay"
;
public
void
insert
(
AppDataCommand
proto
)
throws
DalException
{
m_dao
.
insert
(
proto
);
}
public
void
insert
(
AppDataCommand
[]
proto
)
throws
DalException
{
m_dao
.
insert
(
proto
);
}
public
double
[]
queryValue
(
QueryEntity
entity
,
String
type
)
{
int
commandId
=
entity
.
getCommand
();
Date
period
=
entity
.
getDate
();
...
...
@@ -71,11 +67,11 @@ public class AppDataService {
Pair
<
Integer
,
Map
<
Integer
,
List
<
AppDataCommand
>>>
dataPair
=
convert2AppDataCommandMap
(
datas
);
return
queryDelayAvg
(
dataPair
);
}
else
{
throw
new
RuntimeException
(
"unexpected query type, type:"
+
type
);
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
e
.
printStackTrace
();
}
return
null
;
}
...
...
@@ -170,4 +166,5 @@ public class AppDataService {
}
return
value
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/app/graph/AppGraphCreator.java
浏览文件 @
1f3f3579
...
...
@@ -30,7 +30,6 @@ public class AppGraphCreator extends AbstractGraphCreator {
double
[]
values2
=
prepareQueryData
(
queryEntity2
,
type
);
dataList
.
add
(
values2
);
}
return
buildChartData
(
dataList
,
type
);
}
...
...
@@ -48,18 +47,18 @@ public class AppGraphCreator extends AbstractGraphCreator {
}
else
if
(
AppDataService
.
DELAY
.
equals
(
type
))
{
return
"成功延时(ms)"
;
}
else
{
return
""
;
throw
new
RuntimeException
(
"unexpected query type, type:"
+
type
)
;
}
}
public
LineChart
buildChartData
(
final
LinkedList
<
double
[]>
dataList
,
String
type
)
{
LineChart
lineChart
=
new
LineChart
();
lineChart
.
setId
(
"app"
);
lineChart
.
setHtmlTitle
(
queryType
(
type
));
int
i
=
1
;
int
length
=
dataList
.
size
()
;
for
(
double
[]
data
:
dataList
)
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
double
[]
data
=
dataList
.
get
(
i
);
lineChart
.
add
(
"查询"
+
i
++,
data
);
}
return
lineChart
;
...
...
@@ -76,7 +75,6 @@ public class AppGraphCreator extends AbstractGraphCreator {
time
+=
step
*
TimeUtil
.
ONE_MINUTE
;
map
.
put
(
time
,
data
[
i
]);
}
return
map
;
}
}
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
浏览文件 @
1f3f3579
...
...
@@ -21,8 +21,6 @@ public class NavigationBar {
public
Page
[]
getVisiblePages
()
{
return
new
Page
[]
{
ReportPage
.
HOME
,
ReportPage
.
METRIC
,
ReportPage
.
USERMONITOR
,
...
...
cat-home/src/main/resources/chrome/cat.crx
浏览文件 @
1f3f3579
无法预览此类型文件
cat-home/src/main/resources/chrome/cat/cat.js
浏览文件 @
1f3f3579
...
...
@@ -77,7 +77,7 @@ function TabManager() {
};
this
.
headersWillBeSent
=
function
(
tabId
,
headers
)
{
headers
.
push
({
name
:
"
X-CAT-TRACE-MODE
"
,
value
:
"
1
"
});
headers
.
push
({
name
:
"
X-CAT-TRACE-MODE
"
,
value
:
"
true
"
});
return
{
requestHeaders
:
headers
};
};
...
...
@@ -110,7 +110,6 @@ function TabManager() {
console
.
debug
(
"
show pageAction for
"
+
tabId
);
chrome
.
pageAction
.
show
(
tabId
);
};
}
var
tabMgr
=
new
TabManager
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录