Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
f75ab1bb
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,发现更多精彩内容 >>
提交
f75ab1bb
编写于
5月 20, 2014
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the log on broker-service
上级
bab765bd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
11 deletion
+36
-11
cat-broker/src/main/java/com/dianping/cat/broker/api/page/MonitorManager.java
...java/com/dianping/cat/broker/api/page/MonitorManager.java
+4
-1
cat-broker/src/main/java/com/dianping/cat/broker/api/page/single/Handler.java
...java/com/dianping/cat/broker/api/page/single/Handler.java
+10
-4
cat-broker/src/main/webapp/WEB-INF/web.xml
cat-broker/src/main/webapp/WEB-INF/web.xml
+15
-0
cat-broker/src/test/java/com/dianping/cat/broker/PostTest.java
...roker/src/test/java/com/dianping/cat/broker/PostTest.java
+7
-6
未找到文件。
cat-broker/src/main/java/com/dianping/cat/broker/api/page/MonitorManager.java
浏览文件 @
f75ab1bb
...
...
@@ -19,6 +19,7 @@ import com.dianping.cat.CatConstants;
import
com.dianping.cat.Monitor
;
import
com.dianping.cat.broker.api.page.IpService.IpInfo
;
import
com.dianping.cat.config.UrlPatternConfigManager
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.Metric
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.internal.DefaultMetric
;
...
...
@@ -107,7 +108,7 @@ public class MonitorManager implements Initializable, LogEnabled {
try
{
String
ip
=
entity
.
getIp
();
IpInfo
ipInfo
=
m_ipService
.
findIpInfoByString
(
ip
);
if
(
ipInfo
!=
null
)
{
String
city
=
ipInfo
.
getProvince
()
+
"-"
+
ipInfo
.
getCity
();
String
channel
=
ipInfo
.
getChannel
();
...
...
@@ -142,6 +143,8 @@ public class MonitorManager implements Initializable, LogEnabled {
defaultMetric
.
addData
(
String
.
valueOf
(
1
));
}
}
else
{
Cat
.
logEvent
(
"IpService"
,
"NotFound"
,
Event
.
SUCCESS
,
ip
);
m_logger
.
error
(
String
.
format
(
"ip service can't resolve ip: "
,
ip
));
}
t
.
setStatus
(
Transaction
.
SUCCESS
);
...
...
cat-broker/src/main/java/com/dianping/cat/broker/api/page/single/Handler.java
浏览文件 @
f75ab1bb
...
...
@@ -5,10 +5,12 @@ import java.io.IOException;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.broker.api.ApiPage
;
import
com.dianping.cat.broker.api.page.MonitorEntity
;
import
com.dianping.cat.broker.api.page.MonitorManager
;
import
com.dianping.cat.broker.api.page.RequestUtils
;
import
com.dianping.cat.message.Event
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
...
...
@@ -18,7 +20,7 @@ import org.unidal.web.mvc.annotation.InboundActionMeta;
import
org.unidal.web.mvc.annotation.OutboundActionMeta
;
import
org.unidal.web.mvc.annotation.PayloadMeta
;
public
class
Handler
implements
PageHandler
<
Context
>,
LogEnabled
{
public
class
Handler
implements
PageHandler
<
Context
>,
LogEnabled
{
@Inject
private
JspViewer
m_jspViewer
;
...
...
@@ -28,12 +30,12 @@ public class Handler implements PageHandler<Context>,LogEnabled{
@Inject
private
RequestUtils
m_util
;
private
Logger
m_logger
;
private
Logger
m_logger
;
@Override
public
void
enableLogging
(
Logger
logger
)
{
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
}
@Override
@PayloadMeta
(
Payload
.
class
)
...
...
@@ -56,6 +58,8 @@ public class Handler implements PageHandler<Context>,LogEnabled{
String
userIp
=
m_util
.
getRemoteIp
(
request
);
if
(
userIp
!=
null
)
{
Cat
.
logEvent
(
"Ip"
,
"hit"
,
Event
.
SUCCESS
,
userIp
);
entity
.
setDuration
(
payload
.
getDuration
());
entity
.
setErrorCode
(
payload
.
getErrorCode
());
entity
.
setHttpStatus
(
payload
.
getHttpStatus
());
...
...
@@ -65,6 +69,8 @@ public class Handler implements PageHandler<Context>,LogEnabled{
m_manager
.
offer
(
entity
);
}
else
{
Cat
.
logEvent
(
"Ip"
,
"miss"
,
Event
.
SUCCESS
,
request
.
getHeader
(
"x-forwarded-for"
));
m_logger
.
info
(
"unknown http request, x-forwarded-for:"
+
request
.
getHeader
(
"x-forwarded-for"
));
}
...
...
cat-broker/src/main/webapp/WEB-INF/web.xml
浏览文件 @
f75ab1bb
...
...
@@ -2,6 +2,10 @@
<web-app
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version=
"2.5"
>
<filter>
<filter-name>
cat-filter
</filter-name>
<filter-class>
com.dianping.cat.servlet.CatFilter
</filter-class>
</filter>
<servlet>
<servlet-name>
mvc-servlet
</servlet-name>
<servlet-class>
org.unidal.web.MVC
</servlet-class>
...
...
@@ -15,6 +19,17 @@
</init-param>
<load-on-startup>
2
</load-on-startup>
</servlet>
<filter-mapping>
<filter-name>
cat-filter
</filter-name>
<url-pattern>
/api/*
</url-pattern>
<dispatcher>
REQUEST
</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>
cat-filter
</filter-name>
<url-pattern>
/jsp/*
</url-pattern>
<dispatcher>
FORWARD
</dispatcher>
</filter-mapping>
<servlet-mapping>
<servlet-name>
mvc-servlet
</servlet-name>
<url-pattern>
/api/*
</url-pattern>
...
...
cat-broker/src/test/java/com/dianping/cat/broker/PostTest.java
浏览文件 @
f75ab1bb
...
...
@@ -25,29 +25,30 @@ public class PostTest {
String
url
=
null
;
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api?v=1.0&tu=http://www.dianping.com/test&d=100&hs=200&ts="
url
=
"http://"
+
host
+
"/broker-service/api
/singel
?v=1.0&tu=http://www.dianping.com/test&d=100&hs=200&ts="
+
time
;
System
.
out
.
println
(
url
);
read
(
url
);
}
for
(
int
i
=
0
;
i
<
150
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api?v=1.0&tu=http://www.dianping.com/test&d=100&hs=300&ts="
url
=
"http://"
+
host
+
"/broker-service/api
/singel
?v=1.0&tu=http://www.dianping.com/test&d=100&hs=300&ts="
+
time
;
read
(
url
);
}
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api?v=1.0&tu=http://www.dianping.com/test&d=100&hs=400&ts="
url
=
"http://"
+
host
+
"/broker-service/api
/singel
?v=1.0&tu=http://www.dianping.com/test&d=100&hs=400&ts="
+
time
;
read
(
url
);
}
for
(
int
i
=
0
;
i
<
250
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api?v=1.0&tu=http://www.dianping.com/test&d=100&ec=300&ts="
url
=
"http://"
+
host
+
"/broker-service/api
/singel
?v=1.0&tu=http://www.dianping.com/test&d=100&ec=300&ts="
+
time
;
read
(
url
);
}
for
(
int
i
=
0
;
i
<
300
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api?v=1.0&tu=http://www.dianping.com/test&d=100&ec=400&ts="
url
=
"http://"
+
host
+
"/broker-service/api
/singel
?v=1.0&tu=http://www.dianping.com/test&d=100&ec=400&ts="
+
time
;
read
(
url
);
}
...
...
@@ -63,7 +64,7 @@ public class PostTest {
@Test
public
void
test
()
throws
Exception
{
String
url
=
"http://localhost:2765/broker-service/api/
batch
?v=1.0"
;
String
url
=
"http://localhost:2765/broker-service/api/
singel
?v=1.0"
;
URLConnection
conn
=
new
URL
(
url
).
openConnection
();
conn
.
setDoOutput
(
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录