Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
1c3673a3
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,发现更多精彩内容 >>
提交
1c3673a3
编写于
3月 04, 2014
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'biz' of github.com:dianping/cat into biz
上级
aa051d82
3c245d8e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
100 addition
and
19 deletion
+100
-19
cat-client/src/main/java/com/dianping/cat/configuration/ClientConfigManager.java
...a/com/dianping/cat/configuration/ClientConfigManager.java
+4
-0
cat-client/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
.../dianping/cat/message/internal/DefaultMessageManager.java
+42
-1
cat-client/src/main/java/com/dianping/cat/message/internal/DefaultTaggedTransaction.java
...anping/cat/message/internal/DefaultTaggedTransaction.java
+4
-2
cat-client/src/main/java/com/dianping/cat/message/spi/MessageManager.java
...ain/java/com/dianping/cat/message/spi/MessageManager.java
+10
-0
cat-client/src/test/java/com/dianping/cat/message/internal/MultiThreadingTest.java
...com/dianping/cat/message/internal/MultiThreadingTest.java
+7
-15
cat-client/src/test/resources/META-INF/cat/client.xml
cat-client/src/test/resources/META-INF/cat/client.xml
+1
-1
cat-client/src/test/resources/com/dianping/cat/message/message-truncated-for-size.txt
...s/com/dianping/cat/message/message-truncated-for-size.txt
+32
-0
未找到文件。
cat-client/src/main/java/com/dianping/cat/configuration/ClientConfigManager.java
浏览文件 @
1c3673a3
...
...
@@ -97,6 +97,10 @@ public class ClientConfigManager implements LogEnabled {
}
}
public
int
getTaggedTransactionCacheSize
()
{
return
1024
;
}
public
void
initialize
(
File
configFile
)
throws
Exception
{
ClientConfig
globalConfig
=
null
;
ClientConfig
clientConfig
=
null
;
...
...
cat-client/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
浏览文件 @
1c3673a3
...
...
@@ -2,7 +2,10 @@ package com.dianping.cat.message.internal;
import
java.io.IOException
;
import
java.util.HashSet
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.Stack
;
...
...
@@ -18,6 +21,7 @@ import com.dianping.cat.configuration.ClientConfigManager;
import
com.dianping.cat.configuration.NetworkInterfaceManager
;
import
com.dianping.cat.configuration.client.entity.Domain
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.TaggedTransaction
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.io.MessageSender
;
import
com.dianping.cat.message.io.TransportManager
;
...
...
@@ -53,6 +57,8 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
private
TransactionHelper
m_validator
=
new
TransactionHelper
();
private
Map
<
String
,
TaggedTransaction
>
m_taggedTransactions
;
private
Logger
m_logger
;
@Override
...
...
@@ -64,6 +70,20 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
}
}
@Override
public
void
bind
(
String
tag
,
String
title
)
{
TaggedTransaction
t
=
m_taggedTransactions
.
get
(
tag
);
if
(
t
!=
null
)
{
MessageTree
tree
=
getThreadLocalMessageTree
();
if
(
tree
!=
null
)
{
t
.
start
();
t
.
bind
(
tag
,
tree
.
getMessageId
(),
title
);
}
}
}
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
...
...
@@ -161,6 +181,18 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
}
catch
(
IOException
e
)
{
throw
new
InitializationException
(
"Error while initializing MessageIdFactory!"
,
e
);
}
// initialize the tagged transaction cache
final
int
size
=
m_configManager
.
getTaggedTransactionCacheSize
();
m_taggedTransactions
=
new
LinkedHashMap
<
String
,
TaggedTransaction
>(
size
*
4
/
3
+
1
,
0.75f
,
true
)
{
private
static
final
long
serialVersionUID
=
1L
;
@Override
protected
boolean
removeEldestEntry
(
Entry
<
String
,
TaggedTransaction
>
eldest
)
{
return
size
()
>=
size
;
}
};
}
@Override
...
...
@@ -240,6 +272,12 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
if
(
ctx
!=
null
)
{
ctx
.
start
(
transaction
,
forked
);
if
(
transaction
instanceof
TaggedTransaction
)
{
TaggedTransaction
tt
=
(
TaggedTransaction
)
transaction
;
m_taggedTransactions
.
put
(
tt
.
getTag
(),
tt
);
}
}
else
if
(
m_firstMessage
)
{
m_firstMessage
=
false
;
m_logger
.
warn
(
"CAT client is not enabled because it's not initialized yet"
);
...
...
@@ -434,7 +472,10 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
}
private
void
markAsRunAway
(
Transaction
parent
,
DefaultTaggedTransaction
transaction
)
{
transaction
.
addData
(
"RunAway"
);
if
(!
transaction
.
hasChildren
())
{
transaction
.
addData
(
"RunAway"
);
}
transaction
.
setStatus
(
Message
.
SUCCESS
);
transaction
.
setStandalone
(
true
);
transaction
.
complete
();
...
...
cat-client/src/main/java/com/dianping/cat/message/internal/DefaultTaggedTransaction.java
浏览文件 @
1c3673a3
...
...
@@ -62,7 +62,9 @@ public class DefaultTaggedTransaction extends DefaultTransaction implements Tagg
public
void
start
()
{
MessageTree
tree
=
getManager
().
getThreadLocalMessageTree
();
tree
.
setParentMessageId
(
m_parentMessageId
);
tree
.
setRootMessageId
(
m_rootMessageId
);
if
(
tree
!=
null
&&
tree
.
getRootMessageId
()
==
null
)
{
tree
.
setParentMessageId
(
m_parentMessageId
);
tree
.
setRootMessageId
(
m_rootMessageId
);
}
}
}
cat-client/src/main/java/com/dianping/cat/message/spi/MessageManager.java
浏览文件 @
1c3673a3
...
...
@@ -88,4 +88,14 @@ public interface MessageManager {
*/
public
void
start
(
Transaction
transaction
,
boolean
forked
);
/**
* Binds the current message tree to the transaction tagged with <code>tag</code>.
*
* @param tag
* tag name of the tagged transaction
* @param title
* title shown in the logview
*/
public
void
bind
(
String
tag
,
String
title
);
}
\ No newline at end of file
cat-client/src/test/java/com/dianping/cat/message/internal/MultiThreadingTest.java
浏览文件 @
1c3673a3
...
...
@@ -11,9 +11,7 @@ import org.unidal.helper.Threads;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.ForkedTransaction
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.TaggedTransaction
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.spi.MessageTree
;
public
class
MultiThreadingTest
{
@After
...
...
@@ -44,12 +42,12 @@ public class MultiThreadingTest {
@Test
public
void
testTaggedTransaction
()
throws
Exception
{
Transaction
t
=
Cat
.
newTransaction
(
"TaggedRoot
3
"
,
"Root"
);
TaggedTransaction
t1
=
Cat
.
newTaggedTransaction
(
"TaggedChild"
,
"Child1"
,
"Tag1"
);
TaggedTransaction
t2
=
Cat
.
newTaggedTransaction
(
"TaggedChild"
,
"Child2"
,
"Tag2"
);
Transaction
t
=
Cat
.
newTransaction
(
"TaggedRoot"
,
"Root"
);
Cat
.
newTaggedTransaction
(
"TaggedChild"
,
"Child1"
,
"Tag1"
);
Cat
.
newTaggedTransaction
(
"TaggedChild"
,
"Child2"
,
"Tag2"
);
Threads
.
forGroup
().
start
(
new
TaggedThread
(
t1
,
500
,
"Tag1"
));
Threads
.
forGroup
().
start
(
new
TaggedThread
(
t2
,
100
,
"Tag2"
));
Threads
.
forGroup
().
start
(
new
TaggedThread
(
500
,
"Tag1"
));
Threads
.
forGroup
().
start
(
new
TaggedThread
(
100
,
"Tag2"
));
TimeUnit
.
MILLISECONDS
.
sleep
(
200
);
...
...
@@ -58,14 +56,11 @@ public class MultiThreadingTest {
}
static
class
TaggedThread
extends
Thread
{
private
TaggedTransaction
m_transaction
;
private
int
m_timeout
;
private
String
m_tag
;
public
TaggedThread
(
TaggedTransaction
t
,
int
timeout
,
String
tag
)
{
m_transaction
=
t
;
public
TaggedThread
(
int
timeout
,
String
tag
)
{
m_timeout
=
timeout
;
m_tag
=
tag
;
}
...
...
@@ -73,15 +68,12 @@ public class MultiThreadingTest {
@Override
public
void
run
()
{
Transaction
t
=
Cat
.
newTransaction
(
"TaggedThread"
,
m_tag
);
MessageTree
tree
=
Cat
.
getManager
().
getThreadLocalMessageTree
();
m_transaction
.
start
();
try
{
TimeUnit
.
MILLISECONDS
.
sleep
(
m_timeout
);
t
.
setStatus
(
Message
.
SUCCESS
);
m_transaction
.
bind
(
m_tag
,
tree
.
getMessageId
(),
"chil
d"
);
Cat
.
getManager
().
bind
(
m_tag
,
"Child Tagged Threa
d"
);
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
t
.
setStatus
(
e
);
...
...
cat-client/src/test/resources/META-INF/cat/client.xml
浏览文件 @
1c3673a3
<config
mode=
"client"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation=
"config.xsd"
>
<domain
id=
"Cat
2
"
/>
<domain
id=
"Cat"
/>
</config>
cat-client/src/test/resources/com/dianping/cat/message/message-truncated-for-size.txt
浏览文件 @
1c3673a3
...
...
@@ -6,6 +6,9 @@ A URL0 MyPage 0
A URL0 MyPage 0
A URL0 MyPage 0
A URL0 MyPage 0
E RemoteCall Next 0
T URL MyPage 0 k1=v1
t URL MyPage
A URL0 MyPage 0
A URL0 MyPage 0
A URL0 MyPage 0
...
...
@@ -13,12 +16,19 @@ A URL0 MyPage 0
A URL0 MyPage 0
A URL0 MyPage 0
A URL0 MyPage 0
E RemoteCall Next 0
T URL MyPage 0 k1=v1
t URL MyPage
A URL0 MyPage 0
A URL0 MyPage 0
A URL0 MyPage 0
A URL0 MyPage 0
A URL0 MyPage 0
A URL0 MyPage 0
A URL1 MyPage 0
E RemoteCall Next 0
T URL MyPage 0 k1=v1
t URL MyPage
t URL1 MyPage
t URL2 MyPage
E Event Name0 0
...
...
@@ -26,16 +36,37 @@ E Event Name1 0
E Event Name2 0
E Event Name3 0
E Event Name4 0
T URL2 MyPage 0
T URL1 MyPage 0
E RemoteCall Next 0
T URL MyPage 0 k1=v1
t URL MyPage
t URL1 MyPage
t URL2 MyPage
E Event Name5 0
E Event Name6 0
E Event Name7 0
E Event Name8 0
E Event Name9 0
T URL2 MyPage 0
T URL1 MyPage 0
E RemoteCall Next 0
T URL MyPage 0 k1=v1
t URL MyPage
t URL1 MyPage
t URL2 MyPage
E Event Name10 0
E Event Name11 0
E Event Name12 0
E Event Name13 0
E Event Name14 0
T URL2 MyPage 0
T URL1 MyPage 0
E RemoteCall Next 0
T URL MyPage 0 k1=v1
t URL MyPage
t URL1 MyPage
t URL2 MyPage
E Event Name15 0
E Event Name16 0
E Event Name17 0
...
...
@@ -43,4 +74,5 @@ E Event Name18 0
E Event Name19 0
T URL2 MyPage unset
T URL1 MyPage unset
E TruncatedTransaction TotalDuration 0
T URL MyPage 0 k1=v1
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录