Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
d8b1514b
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,发现更多精彩内容 >>
提交
d8b1514b
编写于
5月 16, 2012
作者:
S
sean.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bugfix
上级
223b917f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
35 addition
and
10 deletion
+35
-10
cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageProducer.java
...dianping/cat/message/internal/DefaultMessageProducer.java
+6
-1
cat-home/src/main/java/com/dianping/cat/report/page/model/spi/internal/BaseCompositeModelService.java
...rt/page/model/spi/internal/BaseCompositeModelService.java
+1
-0
cat-home/src/main/java/com/dianping/cat/report/page/model/spi/internal/BaseHistoricalModelService.java
...t/page/model/spi/internal/BaseHistoricalModelService.java
+1
-0
cat-home/src/test/java/com/dianping/cat/demo/Demo.java
cat-home/src/test/java/com/dianping/cat/demo/Demo.java
+25
-7
cat-home/src/test/resources/com/dianping/cat/demo/client.xml
cat-home/src/test/resources/com/dianping/cat/demo/client.xml
+2
-2
未找到文件。
cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageProducer.java
浏览文件 @
d8b1514b
...
@@ -119,7 +119,7 @@ public class DefaultMessageProducer implements MessageProducer {
...
@@ -119,7 +119,7 @@ public class DefaultMessageProducer implements MessageProducer {
if
(!
m_manager
.
hasContext
())
{
if
(!
m_manager
.
hasContext
())
{
m_manager
.
setup
();
m_manager
.
setup
();
}
}
if
(
m_manager
.
isCatEnabled
())
{
if
(
m_manager
.
isCatEnabled
())
{
DefaultTransaction
transaction
=
new
DefaultTransaction
(
type
,
name
,
m_manager
);
DefaultTransaction
transaction
=
new
DefaultTransaction
(
type
,
name
,
m_manager
);
...
@@ -131,6 +131,11 @@ public class DefaultMessageProducer implements MessageProducer {
...
@@ -131,6 +131,11 @@ public class DefaultMessageProducer implements MessageProducer {
}
}
public
Transaction
newTransaction
(
Transaction
parent
,
String
type
,
String
name
)
{
public
Transaction
newTransaction
(
Transaction
parent
,
String
type
,
String
name
)
{
// this enable CAT client logging cat message without explicit setup
if
(!
m_manager
.
hasContext
())
{
m_manager
.
setup
();
}
if
(
m_manager
.
isCatEnabled
()
&&
parent
!=
null
)
{
if
(
m_manager
.
isCatEnabled
()
&&
parent
!=
null
)
{
DefaultTransaction
transaction
=
new
DefaultTransaction
(
type
,
name
,
m_manager
);
DefaultTransaction
transaction
=
new
DefaultTransaction
(
type
,
name
,
m_manager
);
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/spi/internal/BaseCompositeModelService.java
浏览文件 @
d8b1514b
...
@@ -77,6 +77,7 @@ public abstract class BaseCompositeModelService<T> extends ModelServiceWithCalSu
...
@@ -77,6 +77,7 @@ public abstract class BaseCompositeModelService<T> extends ModelServiceWithCalSu
t
.
setStatus
(
Message
.
SUCCESS
);
t
.
setStatus
(
Message
.
SUCCESS
);
t
.
addData
(
"request"
,
request
);
t
.
addData
(
"request"
,
request
);
t
.
addData
(
"thread"
,
Thread
.
currentThread
());
for
(
final
ModelService
<
T
>
service
:
m_allServices
)
{
for
(
final
ModelService
<
T
>
service
:
m_allServices
)
{
if
(!
service
.
isEligable
(
request
))
{
if
(!
service
.
isEligable
(
request
))
{
...
...
cat-home/src/main/java/com/dianping/cat/report/page/model/spi/internal/BaseHistoricalModelService.java
浏览文件 @
d8b1514b
...
@@ -37,6 +37,7 @@ public abstract class BaseHistoricalModelService<T> extends ModelServiceWithCalS
...
@@ -37,6 +37,7 @@ public abstract class BaseHistoricalModelService<T> extends ModelServiceWithCalS
public
ModelResponse
<
T
>
invoke
(
ModelRequest
request
)
{
public
ModelResponse
<
T
>
invoke
(
ModelRequest
request
)
{
ModelResponse
<
T
>
response
=
new
ModelResponse
<
T
>();
ModelResponse
<
T
>
response
=
new
ModelResponse
<
T
>();
Transaction
t
=
newTransaction
(
"ModelService"
,
getClass
().
getSimpleName
());
Transaction
t
=
newTransaction
(
"ModelService"
,
getClass
().
getSimpleName
());
t
.
addData
(
"thread"
,
Thread
.
currentThread
());
try
{
try
{
T
model
=
buildModel
(
request
);
T
model
=
buildModel
(
request
);
...
...
cat-home/src/test/java/com/dianping/cat/demo/Demo.java
浏览文件 @
d8b1514b
...
@@ -10,8 +10,10 @@ import org.junit.runner.RunWith;
...
@@ -10,8 +10,10 @@ import org.junit.runner.RunWith;
import
org.junit.runners.JUnit4
;
import
org.junit.runners.JUnit4
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Event
;
import
com.dianping.cat.message.MessageProducer
;
import
com.dianping.cat.message.MessageProducer
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.internal.DefaultMessageProducer
;
import
com.site.lookup.ComponentTestCase
;
import
com.site.lookup.ComponentTestCase
;
@RunWith
(
JUnit4
.
class
)
@RunWith
(
JUnit4
.
class
)
...
@@ -36,7 +38,7 @@ public class Demo extends ComponentTestCase {
...
@@ -36,7 +38,7 @@ public class Demo extends ComponentTestCase {
}
}
@Test
@Test
public
void
demo
()
throws
Exception
{
public
void
testSingleTransaction
()
throws
Exception
{
MessageProducer
cat
=
lookup
(
MessageProducer
.
class
);
MessageProducer
cat
=
lookup
(
MessageProducer
.
class
);
Transaction
t
=
cat
.
newTransaction
(
"URL"
,
"FailureReportPage"
);
Transaction
t
=
cat
.
newTransaction
(
"URL"
,
"FailureReportPage"
);
...
@@ -51,11 +53,27 @@ public class Demo extends ComponentTestCase {
...
@@ -51,11 +53,27 @@ public class Demo extends ComponentTestCase {
}
}
@Test
@Test
public
void
demo2
()
throws
Exception
{
public
void
testNestTransaction
()
throws
Exception
{
MessageProducer
cat
=
lookup
(
MessageProducer
.
class
);
DefaultMessageProducer
cat
=
(
DefaultMessageProducer
)
Cat
.
getProducer
();
Transaction
t
=
cat
.
newTransaction
(
"SQL3"
,
"update-user"
);
final
Transaction
f
=
cat
.
newTransaction
(
"demo"
,
"father"
);
Thread
.
sleep
(
10
);
Thread
child
=
new
Thread
(
new
Runnable
()
{
t
.
setStatus
(
"error"
);
@Override
t
.
complete
();
public
void
run
()
{
DefaultMessageProducer
cat
=
(
DefaultMessageProducer
)
Cat
.
getProducer
();
Transaction
t
=
cat
.
newTransaction
(
f
,
"demo"
,
"child"
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
t
.
setStatus
(
"child"
);
t
.
complete
();
}
});
child
.
start
();
child
.
join
();
f
.
setStatus
(
"father"
);
f
.
complete
();
}
}
}
}
cat-home/src/test/resources/com/dianping/cat/demo/client.xml
浏览文件 @
d8b1514b
<config
mode=
"client"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation=
"config.xsd"
>
<config
mode=
"client"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation=
"config.xsd"
>
<
app
domain=
"Review"
/>
<
domain
id=
"Cat-demo"
enabled=
"true"
/>
<servers>
<servers>
<server
ip=
"1
27.0.0.1
"
port=
"2280"
/>
<server
ip=
"1
92.168.7.43
"
port=
"2280"
/>
</servers>
</servers>
</config>
</config>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录