Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
18086908
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,发现更多精彩内容 >>
提交
18086908
编写于
8月 15, 2012
作者:
Y
youyong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the cat reload thread
上级
32a0923f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
37 deletion
+35
-37
cat-core/src/main/java/com/dianping/cat/configuration/ClientConfigReloader.java
.../com/dianping/cat/configuration/ClientConfigReloader.java
+35
-30
cat-core/src/main/java/com/dianping/cat/status/StatusUpdateTask.java
...c/main/java/com/dianping/cat/status/StatusUpdateTask.java
+0
-2
cat-core/src/main/resources/META-INF/plexus/components.xml
cat-core/src/main/resources/META-INF/plexus/components.xml
+0
-5
未找到文件。
cat-core/src/main/java/com/dianping/cat/configuration/ClientConfigReloader.java
浏览文件 @
18086908
...
@@ -6,6 +6,7 @@ import java.io.InputStream;
...
@@ -6,6 +6,7 @@ import java.io.InputStream;
import
java.util.Map
;
import
java.util.Map
;
import
org.xml.sax.SAXException
;
import
org.xml.sax.SAXException
;
import
org.xml.sax.SAXParseException
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.client.entity.ClientConfig
;
import
com.dianping.cat.configuration.client.entity.ClientConfig
;
...
@@ -46,6 +47,30 @@ public class ClientConfigReloader implements Task {
...
@@ -46,6 +47,30 @@ public class ClientConfigReloader implements Task {
}
}
}
}
public
ClientConfig
getClientConfig
()
throws
IOException
,
SAXException
{
ClientConfig
clientConfig
=
null
;
InputStream
in
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
CAT_CLIENT_XML
);
if
(
in
==
null
)
{
in
=
Cat
.
class
.
getResourceAsStream
(
CAT_CLIENT_XML
);
}
if
(
in
!=
null
)
{
String
xml
=
Files
.
forIO
().
readFrom
(
in
,
"utf-8"
);
clientConfig
=
new
DefaultDomParser
().
parse
(
xml
);
}
String
content
=
Files
.
forIO
().
readFrom
(
m_file
,
"utf-8"
);
ClientConfig
globalConfig
=
m_parser
.
parse
(
content
);
if
(
globalConfig
!=
null
&&
clientConfig
!=
null
)
{
globalConfig
.
accept
(
new
ClientConfigMerger
(
clientConfig
));
}
return
clientConfig
;
}
@Override
@Override
public
void
run
()
{
public
void
run
()
{
while
(
isActive
())
{
while
(
isActive
())
{
...
@@ -54,7 +79,7 @@ public class ClientConfigReloader implements Task {
...
@@ -54,7 +79,7 @@ public class ClientConfigReloader implements Task {
long
now
=
m_file
.
lastModified
();
long
now
=
m_file
.
lastModified
();
if
(
now
>
m_lastModifyTime
)
{
if
(
now
>
m_lastModifyTime
)
{
ClientConfig
newConfig
=
merger
ClientConfig
();
ClientConfig
newConfig
=
get
ClientConfig
();
Map
<
String
,
Domain
>
domains
=
newConfig
.
getDomains
();
Map
<
String
,
Domain
>
domains
=
newConfig
.
getDomains
();
Domain
firstDomain
=
domains
.
isEmpty
()
?
null
:
domains
.
values
().
iterator
().
next
();
Domain
firstDomain
=
domains
.
isEmpty
()
?
null
:
domains
.
values
().
iterator
().
next
();
...
@@ -63,21 +88,25 @@ public class ClientConfigReloader implements Task {
...
@@ -63,21 +88,25 @@ public class ClientConfigReloader implements Task {
boolean
oldEnabled
=
m_config
.
isEnabled
();
boolean
oldEnabled
=
m_config
.
isEnabled
();
if
(
oldEnabled
!=
catEnable
)
{
if
(
oldEnabled
!=
catEnable
)
{
if
(
oldEnabled
){
if
(
oldEnabled
)
{
Cat
.
getProducer
().
logEvent
(
"System"
,
"Reload"
,
Message
.
SUCCESS
,
String
.
format
(
"Change from %s to %s"
,
oldEnabled
,
catEnable
));
Cat
.
getProducer
().
logEvent
(
"System"
,
"Reload:"
+
catEnable
,
Message
.
SUCCESS
,
String
.
format
(
"Change from %s to %s"
,
oldEnabled
,
catEnable
));
}
}
synchronized
(
m_config
)
{
synchronized
(
m_config
)
{
m_config
.
setEnabled
(
catEnable
);
m_config
.
setEnabled
(
catEnable
);
}
}
if
(
catEnable
){
if
(
catEnable
)
{
Cat
.
getProducer
().
logEvent
(
"System"
,
"Reload"
,
Message
.
SUCCESS
,
String
.
format
(
"Change from %s to %s"
,
oldEnabled
,
catEnable
));
Cat
.
getProducer
().
logEvent
(
"System"
,
"Reload:"
+
catEnable
,
Message
.
SUCCESS
,
String
.
format
(
"Change from %s to %s"
,
oldEnabled
,
catEnable
));
}
}
}
}
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
Cat
.
getProducer
().
logEvent
(
"System"
,
"ReloadIOException"
,
"IOException"
,
null
);
Cat
.
getProducer
().
logEvent
(
"System"
,
"ReloadIOException"
,
"IOException"
,
null
);
}
catch
(
SAXException
e
)
{
}
catch
(
SAX
Parse
Exception
e
)
{
Cat
.
getProducer
().
logEvent
(
"System"
,
"ReloadSAXException"
,
"SAXException"
,
null
);
Cat
.
getProducer
().
logEvent
(
"System"
,
"ReloadSAXException"
,
"SAXException"
,
null
);
}
catch
(
RuntimeException
e
)
{
Cat
.
getProducer
().
logEvent
(
"System"
,
"ReloadException"
,
"RuntimeException"
,
null
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
Cat
.
logError
(
e
);
}
}
...
@@ -92,28 +121,4 @@ public class ClientConfigReloader implements Task {
...
@@ -92,28 +121,4 @@ public class ClientConfigReloader implements Task {
public
void
shutdown
()
{
public
void
shutdown
()
{
m_active
=
false
;
m_active
=
false
;
}
}
public
ClientConfig
mergerClientConfig
()
throws
IOException
,
SAXException
{
ClientConfig
clientConfig
=
null
;
InputStream
in
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
CAT_CLIENT_XML
);
if
(
in
==
null
)
{
in
=
Cat
.
class
.
getResourceAsStream
(
CAT_CLIENT_XML
);
}
if
(
in
!=
null
)
{
String
xml
=
Files
.
forIO
().
readFrom
(
in
,
"utf-8"
);
clientConfig
=
new
DefaultDomParser
().
parse
(
xml
);
}
String
content
=
Files
.
forIO
().
readFrom
(
m_file
,
"utf-8"
);
ClientConfig
globalConfig
=
m_parser
.
parse
(
content
);
if
(
globalConfig
!=
null
&&
clientConfig
!=
null
)
{
globalConfig
.
accept
(
new
ClientConfigMerger
(
clientConfig
));
}
return
clientConfig
;
}
}
}
\ No newline at end of file
cat-core/src/main/java/com/dianping/cat/status/StatusUpdateTask.java
浏览文件 @
18086908
...
@@ -85,8 +85,6 @@ public class StatusUpdateTask implements Task, Initializable {
...
@@ -85,8 +85,6 @@ public class StatusUpdateTask implements Task, Initializable {
}
}
t
.
setStatus
(
Message
.
SUCCESS
);
t
.
setStatus
(
Message
.
SUCCESS
);
t
.
complete
();
t
.
complete
();
}
else
{
System
.
out
.
println
(
"Cat is disable!"
);
}
}
long
elapsed
=
MilliSecondTimer
.
currentTimeMillis
()
-
start
;
long
elapsed
=
MilliSecondTimer
.
currentTimeMillis
()
-
start
;
...
...
cat-core/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
18086908
...
@@ -220,11 +220,6 @@
...
@@ -220,11 +220,6 @@
<role-hint>
cat-core
</role-hint>
<role-hint>
cat-core
</role-hint>
<implementation>
com.dianping.cat.CatCoreModule
</implementation>
<implementation>
com.dianping.cat.CatCoreModule
</implementation>
</component>
</component>
<component>
<role>
com.site.initialization.Module
</role>
<role-hint>
cat-client
</role-hint>
<implementation>
com.dianping.cat.CatClientModule
</implementation>
</component>
<component>
<component>
<role>
com.dianping.cat.message.spi.codec.BufferWriter
</role>
<role>
com.dianping.cat.message.spi.codec.BufferWriter
</role>
<role-hint>
escape
</role-hint>
<role-hint>
escape
</role-hint>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录