Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
51f3a125
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,发现更多精彩内容 >>
提交
51f3a125
编写于
3月 19, 2012
作者:
F
Frankie Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
configure model refactory
上级
8d61e6c4
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
445 addition
and
234 deletion
+445
-234
cat-consumer/src/main/java/META-INF/MANIFEST.MF
cat-consumer/src/main/java/META-INF/MANIFEST.MF
+0
-3
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
...ianping/cat/consumer/transaction/TransactionAnalyzer.java
+0
-4
cat-core/pom.xml
cat-core/pom.xml
+2
-2
cat-core/src/main/java/com/dianping/cat/Cat.java
cat-core/src/main/java/com/dianping/cat/Cat.java
+40
-21
cat-core/src/main/java/com/dianping/cat/configuration/ClientConfigMerger.java
...va/com/dianping/cat/configuration/ClientConfigMerger.java
+48
-0
cat-core/src/main/java/com/dianping/cat/configuration/ClientConfigValidator.java
...com/dianping/cat/configuration/ClientConfigValidator.java
+47
-4
cat-core/src/main/java/com/dianping/cat/log4j/CatAppender.java
...ore/src/main/java/com/dianping/cat/log4j/CatAppender.java
+4
-4
cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
.../dianping/cat/message/internal/DefaultMessageManager.java
+7
-5
cat-core/src/main/java/com/dianping/cat/message/internal/MessageIdFactory.java
...a/com/dianping/cat/message/internal/MessageIdFactory.java
+2
-8
cat-core/src/main/java/com/dianping/cat/message/io/TcpSocketReceiver.java
...n/java/com/dianping/cat/message/io/TcpSocketReceiver.java
+37
-9
cat-core/src/main/java/com/dianping/cat/message/spi/MessagePathBuilder.java
...java/com/dianping/cat/message/spi/MessagePathBuilder.java
+1
-4
cat-core/src/main/java/com/dianping/cat/message/spi/internal/DefaultMessageHandler.java
...nping/cat/message/spi/internal/DefaultMessageHandler.java
+12
-2
cat-core/src/main/java/com/dianping/cat/message/spi/internal/DefaultMessagePathBuilder.java
...g/cat/message/spi/internal/DefaultMessagePathBuilder.java
+0
-24
cat-core/src/main/resources/META-INF/dal/model/codegen.xml
cat-core/src/main/resources/META-INF/dal/model/codegen.xml
+0
-33
cat-core/src/main/resources/META-INF/dal/model/config-codegen.xml
.../src/main/resources/META-INF/dal/model/config-codegen.xml
+29
-0
cat-core/src/main/resources/META-INF/dal/model/config-manifest.xml
...src/main/resources/META-INF/dal/model/config-manifest.xml
+6
-0
cat-core/src/main/resources/META-INF/dal/model/config-model.xml
...re/src/main/resources/META-INF/dal/model/config-model.xml
+23
-0
cat-core/src/main/resources/com/dianping/cat/configuration/model/config.xsd
...resources/com/dianping/cat/configuration/model/config.xsd
+7
-13
cat-core/src/test/java/META-INF/MANIFEST.MF
cat-core/src/test/java/META-INF/MANIFEST.MF
+0
-3
cat-core/src/test/java/com/dianping/cat/message/CatTestCase.java
...e/src/test/java/com/dianping/cat/message/CatTestCase.java
+3
-3
cat-core/src/test/java/com/dianping/cat/message/configuration/ConfigTest.java
...va/com/dianping/cat/message/configuration/ConfigTest.java
+61
-11
cat-core/src/test/java/com/dianping/cat/message/internal/MessageIdFactoryTest.java
...m/dianping/cat/message/internal/MessageIdFactoryTest.java
+1
-3
cat-core/src/test/resources/com/dianping/cat/configuration/model/config.xml
...resources/com/dianping/cat/configuration/model/config.xml
+0
-17
cat-core/src/test/resources/com/dianping/cat/message/configuration/client-config.xml
.../com/dianping/cat/message/configuration/client-config.xml
+3
-0
cat-core/src/test/resources/com/dianping/cat/message/configuration/config.xml
...sources/com/dianping/cat/message/configuration/config.xml
+15
-0
cat-core/src/test/resources/com/dianping/cat/message/configuration/config.xsd
...sources/com/dianping/cat/message/configuration/config.xsd
+35
-13
cat-core/src/test/resources/com/dianping/cat/message/configuration/global-config.xml
.../com/dianping/cat/message/configuration/global-config.xml
+3
-2
cat-core/src/test/resources/com/dianping/cat/message/configuration/server.xml
...sources/com/dianping/cat/message/configuration/server.xml
+1
-9
cat-home/src/main/resources/META-INF/cat/client.xml
cat-home/src/main/resources/META-INF/cat/client.xml
+2
-2
cat-home/src/main/resources/META-INF/cat/config.xsd
cat-home/src/main/resources/META-INF/cat/config.xsd
+56
-34
cat-job/src/test/java/com/dianping/cat/storage/hdfs/BucketTest.java
...c/test/java/com/dianping/cat/storage/hdfs/BucketTest.java
+0
-1
未找到文件。
cat-consumer/src/main/java/META-INF/MANIFEST.MF
已删除
100644 → 0
浏览文件 @
8d61e6c4
Manifest-Version: 1.0
Class-Path:
cat-consumer/src/main/java/com/dianping/cat/consumer/transaction/TransactionAnalyzer.java
浏览文件 @
51f3a125
...
...
@@ -32,10 +32,6 @@ import com.dianping.cat.storage.BucketManager;
import
com.dianping.cat.storage.internal.AbstractFileBucket
;
import
com.site.lookup.annotation.Inject
;
/**
* @author sean.wang
* @since Jan 5, 2012
*/
public
class
TransactionAnalyzer
extends
AbstractMessageAnalyzer
<
TransactionReport
>
implements
LogEnabled
{
private
static
final
long
MINUTE
=
60
*
1000
;
...
...
cat-core/pom.xml
浏览文件 @
51f3a125
...
...
@@ -39,7 +39,7 @@
<plugin>
<groupId>
com.site.maven.plugins
</groupId>
<artifactId>
maven-codegen-plugin
</artifactId>
<version>
1.0.1
0
</version>
<version>
1.0.1
1
</version>
<executions>
<execution>
<id>
default-cli
</id>
...
...
@@ -48,7 +48,7 @@
<goal>
dal-model
</goal>
</goals>
<configuration>
<manifest>
${basedir}/src/main/resources/META-INF/dal/model/manifest.xml
<manifest>
${basedir}/src/main/resources/META-INF/dal/model/
config-
manifest.xml
</manifest>
</configuration>
</execution>
...
...
cat-core/src/main/java/com/dianping/cat/Cat.java
浏览文件 @
51f3a125
...
...
@@ -8,6 +8,7 @@ import org.codehaus.plexus.PlexusContainer;
import
org.codehaus.plexus.PlexusContainerException
;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException
;
import
com.dianping.cat.configuration.ClientConfigMerger
;
import
com.dianping.cat.configuration.ClientConfigValidator
;
import
com.dianping.cat.configuration.model.entity.Config
;
import
com.dianping.cat.configuration.model.transform.DefaultXmlParser
;
...
...
@@ -68,17 +69,42 @@ public class Cat {
}
public
static
void
initialize
(
PlexusContainer
container
,
File
configFile
)
{
Config
config
=
null
;
if
(
container
!=
null
)
{
if
(!
s_instance
.
m_initialized
)
{
s_instance
.
setContainer
(
container
);
s_instance
.
m_initialized
=
true
;
}
else
{
throw
new
RuntimeException
(
"Cat has already been initialized before!"
);
}
}
Config
config
=
loadClientConfig
(
configFile
);
if
(
config
!=
null
)
{
getInstance
().
m_manager
.
initializeClient
(
config
);
}
else
{
getInstance
().
m_manager
.
initializeClient
(
null
);
System
.
out
.
println
(
"[WARN] Cat client is disabled due to no config file found!"
);
}
}
static
Config
loadClientConfig
(
File
configFile
)
{
Config
globalConfig
=
null
;
Config
clientConfig
=
null
;
// read config from local file system
try
{
// read the global configure from local file system
// so that OPS can:
// - configure the cat servers to connect
// - enable/disable Cat for specific domain(s)
if
(
configFile
!=
null
)
{
String
xml
=
Files
.
forIO
().
readFrom
(
configFile
.
getCanonicalFile
(),
"utf-8"
);
c
onfig
=
new
DefaultXmlParser
().
parse
(
xml
);
globalC
onfig
=
new
DefaultXmlParser
().
parse
(
xml
);
}
if
(
config
==
null
)
{
// load the client configure from Java class-path
if
(
clientConfig
==
null
)
{
InputStream
in
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
CAT_CLIENT_XML
);
if
(
in
==
null
)
{
...
...
@@ -88,31 +114,24 @@ public class Cat {
if
(
in
!=
null
)
{
String
xml
=
Files
.
forIO
().
readFrom
(
in
,
"utf-8"
);
config
=
new
DefaultXmlParser
().
parse
(
xml
);
c
lientC
onfig
=
new
DefaultXmlParser
().
parse
(
xml
);
}
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
String
.
format
(
"Error when loading configuration file
: %s
!"
,
configFile
),
e
);
throw
new
RuntimeException
(
String
.
format
(
"Error when loading configuration file
(%s)
!"
,
configFile
),
e
);
}
if
(
container
!=
null
)
{
if
(!
s_instance
.
m_initialized
)
{
s_instance
.
setContainer
(
container
);
s_instance
.
m_initialized
=
true
;
}
else
{
throw
new
RuntimeException
(
"Cat has already been initialized before!"
);
}
// merge the two configures together to make it effected
if
(
globalConfig
!=
null
&&
clientConfig
!=
null
)
{
globalConfig
.
accept
(
new
ClientConfigMerger
(
clientConfig
));
}
if
(
config
!=
null
)
{
ClientConfigValidator
validator
=
new
ClientConfigValidator
();
config
.
accept
(
validator
);
getInstance
().
m_manager
.
initializeClient
(
config
);
}
else
{
getInstance
().
m_manager
.
initializeClient
(
null
);
System
.
out
.
println
(
"[WARN] Cat client is disabled due to no config file found!"
);
// do validation
if
(
clientConfig
!=
null
)
{
clientConfig
.
accept
(
new
ClientConfigValidator
());
}
return
clientConfig
;
}
public
static
boolean
isInitialized
()
{
...
...
cat-core/src/main/java/com/dianping/cat/configuration/ClientConfigMerger.java
0 → 100644
浏览文件 @
51f3a125
package
com.dianping.cat.configuration
;
import
com.dianping.cat.configuration.model.entity.Config
;
import
com.dianping.cat.configuration.model.entity.Domain
;
import
com.dianping.cat.configuration.model.entity.Property
;
import
com.dianping.cat.configuration.model.transform.DefaultMerger
;
public
class
ClientConfigMerger
extends
DefaultMerger
{
public
ClientConfigMerger
(
Config
config
)
{
super
(
config
);
}
@Override
protected
void
visitConfigChildren
(
Config
old
,
Config
config
)
{
if
(
old
!=
null
)
{
getStack
().
push
(
old
);
// if servers is configured, then never merge it
if
(
old
.
getServers
().
isEmpty
())
{
old
.
getServers
().
addAll
(
config
.
getServers
());
}
// only configured domain in client configure will be merged
for
(
Domain
domain
:
config
.
getDomains
().
values
())
{
if
(
old
.
getDomains
().
containsKey
(
domain
.
getId
()))
{
visitDomain
(
domain
);
}
}
for
(
Property
property
:
config
.
getProperties
().
values
())
{
visitProperty
(
property
);
}
getStack
().
pop
();
}
}
@Override
protected
void
mergeDomain
(
Domain
old
,
Domain
domain
)
{
if
(
domain
.
getIp
()
!=
null
)
{
old
.
setIp
(
domain
.
getIp
());
}
if
(
domain
.
getEnabled
()
!=
null
)
{
old
.
setEnabled
(
domain
.
getEnabled
());
}
}
}
cat-core/src/main/java/com/dianping/cat/configuration/ClientConfigValidator.java
浏览文件 @
51f3a125
package
com.dianping.cat.configuration
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
com.dianping.cat.configuration.model.entity.Config
;
import
com.dianping.cat.configuration.model.entity.Domain
;
import
com.dianping.cat.configuration.model.entity.Server
;
import
com.dianping.cat.configuration.model.transform.DefaultValidator
;
public
class
ClientConfigValidator
extends
DefaultValidator
{
private
String
getLocalAddress
()
{
try
{
return
InetAddress
.
getLocalHost
().
getHostAddress
();
}
catch
(
UnknownHostException
e
)
{
// ignore it
}
return
null
;
}
@Override
public
void
visitConfig
(
Config
config
)
{
if
(!
"client"
.
equals
(
config
.
getMode
()))
{
throw
new
RuntimeException
(
String
.
format
(
"Attribute(%s) at path(%s) is required!"
,
"mode"
,
"/config"
));
}
else
if
(
config
.
getApp
()
==
null
)
{
throw
new
RuntimeException
(
String
.
format
(
"Element(%s) at path(%s) is required!"
,
"app"
,
"/config"
));
throw
new
RuntimeException
(
String
.
format
(
"Attribute(%s) of /config is required in config: %s"
,
"mode"
,
config
));
}
else
if
(
config
.
getServers
().
size
()
==
0
)
{
throw
new
RuntimeException
(
String
.
format
(
"Element(%s) at path(%s) is required!"
,
"servers"
,
"/config"
));
throw
new
RuntimeException
(
String
.
format
(
"Element(%s) of /config is required in config: %s"
,
"servers"
,
config
));
}
super
.
visitConfig
(
config
);
}
@Override
public
void
visitDomain
(
Domain
domain
)
{
super
.
visitDomain
(
domain
);
// set default values
if
(
domain
.
getEnabled
()
==
null
)
{
domain
.
setEnabled
(
true
);
}
if
(
domain
.
getIp
()
==
null
)
{
domain
.
setIp
(
getLocalAddress
());
}
}
@Override
public
void
visitServer
(
Server
server
)
{
super
.
visitServer
(
server
);
// set default values
if
(
server
.
getPort
()
==
null
)
{
server
.
setPort
(
2280
);
}
if
(
server
.
getEnabled
()
==
null
)
{
server
.
setEnabled
(
true
);
}
}
}
cat-core/src/main/java/com/dianping/cat/log4j/CatAppender.java
浏览文件 @
51f3a125
...
...
@@ -16,10 +16,10 @@ public class CatAppender extends AppenderSkeleton {
if
(
throwableInformation
!=
null
)
{
if
(
Cat
.
getManager
().
getThreadLocalMessageTree
()
!=
null
)
{
Cat
.
getProducer
().
logError
(
throwableInformation
.
getThrowable
());
}
else
{
Cat
.
setup
(
null
);
Cat
.
getProducer
().
logError
(
throwableInformation
.
getThrowable
());
Cat
.
reset
();
//
} else {
//
Cat.setup(null);
//
Cat.getProducer().logError(throwableInformation.getThrowable());
//
Cat.reset();
}
}
}
...
...
cat-core/src/main/java/com/dianping/cat/message/internal/DefaultMessageManager.java
浏览文件 @
51f3a125
...
...
@@ -3,6 +3,7 @@ package com.dianping.cat.message.internal;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Stack
;
import
org.codehaus.plexus.logging.LogEnabled
;
...
...
@@ -10,6 +11,7 @@ import org.codehaus.plexus.logging.Logger;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.model.entity.Config
;
import
com.dianping.cat.configuration.model.entity.Domain
;
import
com.dianping.cat.message.Message
;
import
com.dianping.cat.message.Transaction
;
import
com.dianping.cat.message.io.MessageSender
;
...
...
@@ -121,9 +123,9 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
m_clientConfig
.
setMode
(
"client"
);
}
if
(
m_clientConfig
.
getApp
()
!=
null
)
{
m_domain
=
m_clientConfig
.
getApp
().
getDomain
();
}
Map
<
String
,
Domain
>
domains
=
clientConfig
.
getDomains
();
m_domain
=
domains
.
isEmpty
()
?
"unknown"
:
domains
.
keySet
().
iterator
().
next
();
try
{
InetAddress
localHost
=
InetAddress
.
getLocalHost
();
...
...
@@ -138,9 +140,9 @@ public class DefaultMessageManager extends ContainerHolder implements MessageMan
m_factory
=
lookup
(
MessageIdFactory
.
class
);
// initialize domain and ip address
m_factory
.
initialize
(
m_
clientConfig
);
m_factory
.
initialize
(
m_
domain
);
// initialize milli
second resolution level timer
// initialize milli
-
second resolution level timer
MilliSecondTimer
.
initialize
();
}
...
...
cat-core/src/main/java/com/dianping/cat/message/internal/MessageIdFactory.java
浏览文件 @
51f3a125
...
...
@@ -3,8 +3,6 @@ package com.dianping.cat.message.internal;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
com.dianping.cat.configuration.model.entity.Config
;
public
class
MessageIdFactory
{
private
long
m_lastTimestamp
=
getTimestamp
();
...
...
@@ -44,12 +42,8 @@ public class MessageIdFactory {
return
MilliSecondTimer
.
currentTimeMillis
();
}
public
void
initialize
(
Config
clientConfig
)
{
try
{
m_domain
=
clientConfig
.
getApp
().
getDomain
();
}
catch
(
Exception
e
)
{
// ignore it
}
public
void
initialize
(
String
domain
)
{
m_domain
=
domain
;
if
(
m_ipAddress
==
null
)
{
try
{
...
...
cat-core/src/main/java/com/dianping/cat/message/io/TcpSocketReceiver.java
浏览文件 @
51f3a125
package
com.dianping.cat.message.io
;
import
java.net.InetSocketAddress
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
...
...
@@ -39,11 +42,13 @@ public class TcpSocketReceiver implements MessageReceiver, LogEnabled {
@Inject
private
MessageCodec
m_codec
;
private
BlockingQueue
<
ChannelBuffer
>
m_queue
;
private
ChannelFactory
m_factory
;
private
ChannelGroup
m_channelGroup
=
new
DefaultChannelGroup
();
private
MessageHandler
m_messageHandler
;
private
boolean
m_active
=
true
;
private
Logger
m_logger
;
...
...
@@ -62,6 +67,8 @@ public class TcpSocketReceiver implements MessageReceiver, LogEnabled {
address
=
new
InetSocketAddress
(
m_host
,
m_port
);
}
m_queue
=
new
LinkedBlockingQueue
<
ChannelBuffer
>();
ChannelFactory
factory
=
new
NioServerSocketChannelFactory
(
Executors
.
newCachedThreadPool
(),
Executors
.
newCachedThreadPool
());
ServerBootstrap
bootstrap
=
new
ServerBootstrap
(
factory
);
...
...
@@ -80,9 +87,35 @@ public class TcpSocketReceiver implements MessageReceiver, LogEnabled {
m_factory
=
factory
;
}
public
boolean
isActive
()
{
synchronized
(
this
)
{
return
m_active
;
}
}
@Override
public
void
onMessage
(
MessageHandler
handler
)
{
m_messageHandler
=
handler
;
try
{
while
(
true
)
{
ChannelBuffer
buf
=
m_queue
.
poll
(
1
,
TimeUnit
.
MILLISECONDS
);
if
(
buf
!=
null
)
{
MessageTree
tree
=
new
DefaultMessageTree
();
m_codec
.
decode
(
buf
,
tree
);
handler
.
handle
(
tree
);
}
else
if
(!
isActive
())
{
break
;
}
}
}
catch
(
InterruptedException
e
)
{
// ignore it
}
ChannelGroupFuture
future
=
m_channelGroup
.
close
();
future
.
awaitUninterruptibly
();
m_factory
.
releaseExternalResources
();
}
public
void
setCodec
(
MessageCodec
codec
)
{
...
...
@@ -99,10 +132,7 @@ public class TcpSocketReceiver implements MessageReceiver, LogEnabled {
@Override
public
void
shutdown
()
{
ChannelGroupFuture
future
=
m_channelGroup
.
close
();
future
.
awaitUninterruptibly
();
m_factory
.
releaseExternalResources
();
m_active
=
false
;
}
public
static
class
MyDecoder
extends
FrameDecoder
{
...
...
@@ -146,10 +176,8 @@ public class TcpSocketReceiver implements MessageReceiver, LogEnabled {
@Override
public
void
messageReceived
(
ChannelHandlerContext
ctx
,
MessageEvent
event
)
{
ChannelBuffer
buf
=
(
ChannelBuffer
)
event
.
getMessage
();
MessageTree
tree
=
new
DefaultMessageTree
();
m_codec
.
decode
(
buf
,
tree
);
m_messageHandler
.
handle
(
tree
);
m_queue
.
offer
(
buf
);
}
}
}
cat-core/src/main/java/com/dianping/cat/message/spi/MessagePathBuilder.java
浏览文件 @
51f3a125
package
com.dianping.cat.message.spi
;
import
java.io.File
;
import
java.net.URL
;
import
java.util.Date
;
public
interface
MessagePathBuilder
{
...
...
@@ -9,11 +8,9 @@ public interface MessagePathBuilder {
public
File
getLogViewBaseDir
();
public
URL
getLogViewBaseUrl
();
public
String
getLogViewPath
(
String
messageId
);
public
String
getMessagePath
(
String
domain
,
Date
timestamp
);
public
String
getReportPath
(
Date
timestamp
);
}
cat-core/src/main/java/com/dianping/cat/message/spi/internal/DefaultMessageHandler.java
浏览文件 @
51f3a125
...
...
@@ -2,6 +2,8 @@ package com.dianping.cat.message.spi.internal;
import
java.util.List
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
;
import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
;
...
...
@@ -17,7 +19,8 @@ import com.dianping.cat.message.spi.MessageTree;
import
com.site.lookup.ContainerHolder
;
import
com.site.lookup.annotation.Inject
;
public
class
DefaultMessageHandler
extends
ContainerHolder
implements
MessageHandler
,
Initializable
,
Runnable
{
public
class
DefaultMessageHandler
extends
ContainerHolder
implements
MessageHandler
,
Initializable
,
LogEnabled
,
Runnable
{
@Inject
private
MessageManager
m_manager
;
...
...
@@ -26,6 +29,13 @@ public class DefaultMessageHandler extends ContainerHolder implements MessageHan
private
MessageReceiver
m_receiver
;
private
Logger
m_logger
;
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
@Override
public
void
handle
(
MessageTree
tree
)
{
List
<
MessageConsumer
>
consumers
=
m_registry
.
getConsumers
();
...
...
@@ -37,7 +47,7 @@ public class DefaultMessageHandler extends ContainerHolder implements MessageHan
try
{
consumer
.
consume
(
tree
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
m_logger
.
error
(
"Error when consuming message in "
+
consumer
+
"!"
,
e
);
}
}
}
...
...
cat-core/src/main/java/com/dianping/cat/message/spi/internal/DefaultMessagePathBuilder.java
浏览文件 @
51f3a125
...
...
@@ -2,8 +2,6 @@ package com.dianping.cat.message.spi.internal;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.text.MessageFormat
;
import
java.util.Date
;
...
...
@@ -24,8 +22,6 @@ public class DefaultMessagePathBuilder implements MessagePathBuilder, Initializa
private
File
m_baseLogDir
;
private
URL
m_baseLogUrl
;
private
Logger
m_logger
;
@Override
...
...
@@ -55,11 +51,6 @@ public class DefaultMessagePathBuilder implements MessagePathBuilder, Initializa
return
m_baseLogDir
;
}
@Override
public
URL
getLogViewBaseUrl
()
{
return
m_baseLogUrl
;
}
@Override
public
String
getLogViewPath
(
String
messageId
)
{
return
messageId
+
"/logview.html"
;
...
...
@@ -88,7 +79,6 @@ public class DefaultMessagePathBuilder implements MessagePathBuilder, Initializa
}
String
baseLogDir
=
config
.
getBaseLogDir
();
String
baseLogUrl
=
config
.
getBaseLogUrl
();
try
{
m_baseLogDir
=
new
File
(
baseLogDir
).
getCanonicalFile
();
...
...
@@ -96,23 +86,9 @@ public class DefaultMessagePathBuilder implements MessagePathBuilder, Initializa
}
catch
(
IOException
e
)
{
throw
new
InitializationException
(
String
.
format
(
"Unable to create log directory(%s)!"
,
m_baseLogDir
),
e
);
}
try
{
if
(
baseLogUrl
==
null
)
{
m_baseLogUrl
=
m_baseLogDir
.
toURI
().
toURL
();
}
else
{
m_baseLogUrl
=
new
URL
(
baseLogUrl
);
}
}
catch
(
MalformedURLException
e
)
{
throw
new
InitializationException
(
"Unable to build base log URL!"
,
e
);
}
}
public
void
setBaseLogDir
(
File
baseLogDir
)
{
m_baseLogDir
=
baseLogDir
;
}
public
void
setBaseLogUrl
(
URL
baseLogUrl
)
{
m_baseLogUrl
=
baseLogUrl
;
}
}
cat-core/src/main/resources/META-INF/dal/model/codegen.xml
已删除
100644 → 0
浏览文件 @
8d61e6c4
<?xml version="1.0" encoding="UTF-8"?>
<model>
<entity
name=
"config"
root=
"true"
>
<attribute
name=
"mode"
value-type=
"String"
/>
<attribute
name=
"base-log-dir"
value-type=
"String"
/>
<attribute
name=
"base-log-url"
value-type=
"String"
/>
<entity-ref
name=
"app"
/>
<entity-ref
name=
"server"
type=
"list"
names=
"servers"
xml-indent=
"true"
/>
<entity-ref
name=
"bind"
/>
<entity-ref
name=
"filter"
/>
<entity-ref
name=
"property"
type=
"list"
names=
"properties"
xml-indent=
"true"
/>
</entity>
<entity
name=
"app"
>
<attribute
name=
"domain"
value-type=
"String"
/>
<attribute
name=
"ip"
value-type=
"String"
/>
</entity>
<entity
name=
"server"
>
<attribute
name=
"ip"
value-type=
"String"
/>
<attribute
name=
"port"
value-type=
"int"
/>
<attribute
name=
"enabled"
value-type=
"boolean"
/>
</entity>
<entity
name=
"bind"
>
<attribute
name=
"ip"
value-type=
"String"
/>
<attribute
name=
"port"
value-type=
"int"
/>
</entity>
<entity
name=
"filter"
>
<element
name=
"domain"
value-type=
"String"
type=
"list"
names=
"domains"
/>
</entity>
<entity
name=
"property"
>
<attribute
name=
"name"
value-type=
"String"
key=
"true"
/>
<attribute
name=
"value"
value-type=
"String"
text=
"true"
/>
</entity>
</model>
cat-core/src/main/resources/META-INF/dal/model/config-codegen.xml
0 → 100644
浏览文件 @
51f3a125
<?xml version="1.0" encoding="UTF-8"?>
<model>
<entity
name=
"config"
root=
"true"
>
<attribute
name=
"mode"
value-type=
"String"
/>
<entity-ref
name=
"server"
type=
"list"
names=
"servers"
xml-indent=
"true"
/>
<entity-ref
name=
"domain"
type=
"list"
names=
"domains"
/>
<entity-ref
name=
"bind"
/>
<entity-ref
name=
"property"
type=
"list"
names=
"properties"
xml-indent=
"true"
/>
</entity>
<entity
name=
"server"
>
<attribute
name=
"ip"
value-type=
"String"
/>
<attribute
name=
"port"
value-type=
"int"
/>
<attribute
name=
"enabled"
value-type=
"boolean"
/>
</entity>
<entity
name=
"domain"
>
<attribute
name=
"id"
value-type=
"String"
/>
<attribute
name=
"ip"
value-type=
"String"
/>
<attribute
name=
"enabled"
value-type=
"boolean"
/>
</entity>
<entity
name=
"bind"
>
<attribute
name=
"ip"
value-type=
"String"
/>
<attribute
name=
"port"
value-type=
"int"
/>
</entity>
<entity
name=
"property"
>
<attribute
name=
"name"
value-type=
"String"
/>
<element
name=
"text"
value-type=
"String"
text=
"true"
/>
</entity>
</model>
cat-core/src/main/resources/META-INF/dal/model/manifest.xml
→
cat-core/src/main/resources/META-INF/dal/model/
config-
manifest.xml
浏览文件 @
51f3a125
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<file
path=
"codegen.xml"
/>
<file
path=
"model.xml"
/>
<file
path=
"co
nfig-co
degen.xml"
/>
<file
path=
"
config-
model.xml"
/>
</manifest>
cat-core/src/main/resources/META-INF/dal/model/model.xml
→
cat-core/src/main/resources/META-INF/dal/model/
config-
model.xml
浏览文件 @
51f3a125
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.configuration.model"
enable-xml-parser=
"true"
enable-validator=
"true"
enable-xml-schema=
"true"
enable-
xml-sample
=
"true"
>
<entity
name=
"config"
root=
"true"
>
enable-xml-schema=
"true"
enable-
merger
=
"true"
>
<entity
name=
"config"
root=
"true"
dynamic-attributes=
"true"
>
<attribute
name=
"mode"
required=
"true"
/>
<attribute
name=
"base-log-dir"
default-value=
"target/catlog"
/>
<entity-ref
name=
"property"
type=
"map"
/>
</entity>
<entity
name=
"app"
>
<attribute
name=
"domain"
required=
"true"
/>
<element
name=
"base-log-dir"
value-type=
"String"
default-value=
"target/catlog"
/>
<entity-ref
name=
"domain"
type=
"map"
names=
"domains"
/>
<entity-ref
name=
"property"
type=
"map"
names=
"properties"
/>
</entity>
<entity
name=
"server"
>
<attribute
name=
"port"
default-value=
"2280"
/>
<attribute
name=
"enabled"
default-value=
"true"
/>
<attribute
name=
"ip"
value-type=
"String"
key=
"true"
/>
</entity>
<entity
name=
"domain"
>
<attribute
name=
"id"
value-type=
"String"
key=
"true"
/>
</entity>
<entity
name=
"bind"
>
<attribute
name=
"port"
default-value=
"2280"
/>
<attribute
name=
"port"
primitive=
"true"
default-value=
"2280"
/>
</entity>
<entity
name=
"property"
>
<attribute
name=
"name"
value-type=
"String"
key=
"true"
/>
</entity>
</model>
cat-core/src/main/resources/com/dianping/cat/configuration/model/config.xsd
浏览文件 @
51f3a125
...
...
@@ -3,7 +3,7 @@
<xs:element
name=
"config"
type=
"ConfigType"
/>
<xs:complexType
name=
"ConfigType"
>
<xs:sequence>
<xs:element
name=
"
app"
type=
"AppType
"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"
base-log-dir"
type=
"xs:string
"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"servers"
>
<xs:complexType>
<xs:sequence
minOccurs=
"0"
maxOccurs=
"unbounded"
>
...
...
@@ -11,8 +11,8 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element
minOccurs=
"0"
maxOccurs=
"unbounded"
name=
"domain"
type=
"DomainType"
/>
<xs:element
name=
"bind"
type=
"BindType"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"filter"
type=
"FilterType"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"properties"
>
<xs:complexType>
<xs:sequence
minOccurs=
"0"
maxOccurs=
"unbounded"
>
...
...
@@ -22,22 +22,21 @@
</xs:element>
</xs:sequence>
<xs:attribute
name=
"mode"
type=
"xs:string"
use=
"required"
/>
<xs:attribute
name=
"base-log-dir"
type=
"xs:string"
default=
"target/catlog"
/>
<xs:attribute
name=
"base-log-url"
type=
"xs:string"
/>
</xs:complexType>
<xs:complexType
name=
"
App
Type"
>
<xs:complexType
name=
"
Server
Type"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"domain"
type=
"xs:string"
use=
"required"
/>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"port"
type=
"xs:int"
default=
"2280"
/>
<xs:attribute
name=
"enabled"
type=
"xs:boolean"
default=
"true"
/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType
name=
"
Server
Type"
>
<xs:complexType
name=
"
Domain
Type"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"id"
type=
"xs:string"
use=
"required"
/>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"port"
type=
"xs:int"
default=
"2280"
/>
<xs:attribute
name=
"enabled"
type=
"xs:boolean"
default=
"true"
/>
</xs:extension>
</xs:simpleContent>
...
...
@@ -50,11 +49,6 @@
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType
name=
"FilterType"
>
<xs:sequence>
<xs:element
name=
"domain"
type=
"xs:string"
minOccurs=
"0"
maxOccurs=
"unbounded"
/>
</xs:sequence>
</xs:complexType>
<xs:complexType
name=
"PropertyType"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
...
...
cat-core/src/test/java/META-INF/MANIFEST.MF
已删除
100644 → 0
浏览文件 @
8d61e6c4
Manifest-Version: 1.0
Class-Path:
cat-core/src/test/java/com/dianping/cat/message/CatTestCase.java
浏览文件 @
51f3a125
...
...
@@ -9,8 +9,8 @@ import org.junit.After;
import
org.junit.Before
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.model.entity.App
;
import
com.dianping.cat.configuration.model.entity.Config
;
import
com.dianping.cat.configuration.model.entity.Domain
;
import
com.dianping.cat.configuration.model.entity.Server
;
import
com.site.helper.Files
;
import
com.site.lookup.ComponentTestCase
;
...
...
@@ -28,8 +28,8 @@ public abstract class CatTestCase extends ComponentTestCase {
Config
config
=
new
Config
();
config
.
setMode
(
"client"
);
config
.
setApp
(
new
App
().
setDomain
(
"Tes
t"
));
config
.
addServer
(
new
Server
(
).
setIp
(
"localhost"
).
setPort
(
2280
));
config
.
addDomain
(
new
Domain
(
"Ca
t"
));
config
.
addServer
(
new
Server
(
"localhost"
).
setPort
(
2280
));
File
file
=
new
File
(
"target/cat-config.xml"
);
...
...
cat-core/src/test/java/com/dianping/cat/message/configuration/ConfigTest.java
浏览文件 @
51f3a125
package
com.dianping.cat.message.configuration
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
import
javax.xml.transform.stream.StreamSource
;
import
javax.xml.validation.Schema
;
import
javax.xml.validation.SchemaFactory
;
import
javax.xml.validation.Validator
;
import
junit.framework.Assert
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.xml.sax.SAXException
;
import
com.dianping.cat.configuration.ClientConfigMerger
;
import
com.dianping.cat.configuration.ClientConfigValidator
;
import
com.dianping.cat.configuration.model.IEntity
;
import
com.dianping.cat.configuration.model.entity.Config
;
import
com.dianping.cat.configuration.model.entity.Server
;
import
com.dianping.cat.configuration.model.transform.DefaultXmlBuilder
;
import
com.dianping.cat.configuration.model.transform.DefaultXmlParser
;
import
com.site.helper.Files
;
public
class
ConfigTest
{
@Test
public
void
testClient
()
throws
Exception
{
InputStream
in
=
getClass
().
getResourceAsStream
(
"client.xml"
);
String
xml
=
Files
.
forIO
().
readFrom
(
in
,
"utf-8"
);
Config
config
=
new
DefaultXmlParser
().
parse
(
xml
);
Config
clientConfig
=
loadConfig
(
"client-config.xml"
);
Config
globalConfig
=
loadConfig
(
"global-config.xml"
);
Assert
.
assertEquals
(
"client"
,
clientConfig
.
getMode
());
globalConfig
.
accept
(
new
ClientConfigMerger
(
clientConfig
));
clientConfig
.
accept
(
new
ClientConfigValidator
());
Assert
.
assertEquals
(
"client"
,
config
.
getMode
()
);
Assert
.
assertEquals
(
"Review"
,
config
.
getApp
().
getDomain
());
Assert
.
assertEquals
(
"192.168.8.1"
,
config
.
getApp
().
getIp
()
);
// System.out.println(clientConfig
);
List
<
Server
>
servers
=
clientConfig
.
getServers
(
);
List
<
Server
>
servers
=
config
.
getServers
();
Assert
.
assertEquals
(
3
,
servers
.
size
());
Assert
.
assertEquals
(
2280
,
servers
.
get
(
0
).
getPort
().
intValue
());
Assert
.
assertEquals
(
true
,
servers
.
get
(
0
).
isEnabled
());
...
...
@@ -34,6 +48,44 @@ public class ConfigTest {
Assert
.
assertEquals
(
true
,
servers
.
get
(
2
).
isEnabled
());
}
private
Config
loadConfig
(
String
configXml
)
throws
IOException
,
SAXException
{
InputStream
in
=
getClass
().
getResourceAsStream
(
configXml
);
String
xml
=
Files
.
forIO
().
readFrom
(
in
,
"utf-8"
);
Config
clientConfig
=
new
DefaultXmlParser
().
parse
(
xml
);
return
clientConfig
;
}
@Test
public
void
testConfig
()
throws
Exception
{
DefaultXmlParser
parser
=
new
DefaultXmlParser
();
String
source
=
Files
.
forIO
().
readFrom
(
getClass
().
getResourceAsStream
(
"config.xml"
),
"utf-8"
);
Config
root
=
parser
.
parse
(
source
);
String
xml
=
new
DefaultXmlBuilder
().
buildXml
(
root
);
String
expected
=
source
;
Assert
.
assertEquals
(
"XML is not well parsed!"
,
expected
.
replace
(
"\r"
,
""
),
xml
.
replace
(
"\r"
,
""
));
}
@Test
@Ignore
public
void
testSchema
()
throws
Exception
{
// define the type of schema - we use W3C:
String
schemaLang
=
"http://www.w3.org/2001/XMLSchema"
;
// get validation driver:
SchemaFactory
factory
=
SchemaFactory
.
newInstance
(
schemaLang
);
// create schema by reading it from an XSD file:
String
path
=
"/"
+
IEntity
.
class
.
getPackage
().
getName
().
replace
(
'.'
,
'/'
);
Schema
schema
=
factory
.
newSchema
(
new
StreamSource
(
getClass
().
getResourceAsStream
(
path
+
"/config.xsd"
)));
Validator
validator
=
schema
.
newValidator
();
// at last perform validation:
validator
.
validate
(
new
StreamSource
(
getClass
().
getResourceAsStream
(
"client.xml"
)));
validator
.
validate
(
new
StreamSource
(
getClass
().
getResourceAsStream
(
"server.xml"
)));
validator
.
validate
(
new
StreamSource
(
getClass
().
getResourceAsStream
(
"config.xml"
)));
}
@Test
public
void
testServer
()
throws
Exception
{
InputStream
in
=
getClass
().
getResourceAsStream
(
"server.xml"
);
...
...
@@ -42,8 +94,6 @@ public class ConfigTest {
Assert
.
assertEquals
(
"server"
,
config
.
getMode
());
Assert
.
assertEquals
(
"192.168.8.21"
,
config
.
getBind
().
getIp
());
Assert
.
assertEquals
(
2280
,
config
.
getBind
().
getPort
().
intValue
());
Assert
.
assertEquals
(
"[Review, Group]"
,
config
.
getFilter
().
getDomains
().
toString
());
Assert
.
assertEquals
(
2280
,
config
.
getBind
().
getPort
());
}
}
cat-core/src/test/java/com/dianping/cat/message/internal/MessageIdFactoryTest.java
浏览文件 @
51f3a125
...
...
@@ -4,8 +4,6 @@ import junit.framework.Assert;
import
org.junit.Test
;
import
com.dianping.cat.configuration.model.entity.Config
;
public
class
MessageIdFactoryTest
{
private
long
m_timestamp
=
1330327814748L
;
...
...
@@ -35,7 +33,7 @@ public class MessageIdFactoryTest {
@Test
public
void
testNextId
()
throws
Exception
{
m_factory
.
initialize
(
new
Config
()
);
m_factory
.
initialize
(
"test"
);
check
(
"domain1"
,
"domain1-c0a83f99-1330327814748-0"
);
check
(
"domain1"
,
"domain1-c0a83f99-1330327814748-1"
);
...
...
cat-core/src/test/resources/com/dianping/cat/configuration/model/config.xml
已删除
100644 → 0
浏览文件 @
8d61e6c4
<?xml version="1.0" encoding="utf-8"?>
<config
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"config.xsd"
mode=
""
>
<app
domain=
""
/>
<servers>
<server/>
<!-- more server -->
</servers>
<bind/>
<filter>
<domain>
{domain}
</domain>
<!-- more domain -->
</filter>
<properties>
<property
name=
""
/>
<!-- more property -->
</properties>
</config>
cat-core/src/test/resources/com/dianping/cat/message/configuration/client-config.xml
0 → 100644
浏览文件 @
51f3a125
<config
mode=
"client"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation=
"config.xsd"
>
<domain
id=
"Group"
/>
</config>
cat-core/src/test/resources/com/dianping/cat/message/configuration/config.xml
0 → 100644
浏览文件 @
51f3a125
<config
mode=
"client"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation=
"config.xsd"
>
<servers>
<server
ip=
"192.168.8.21"
port=
"2280"
enabled=
"true"
/>
<server
ip=
"192.168.8.22"
port=
"2281"
enabled=
"false"
/>
<server
ip=
"192.168.8.23"
port=
"2280"
enabled=
"true"
/>
</servers>
<domain
id=
"Group"
enabled=
"true"
/>
<domain
id=
"Review"
ip=
"192.168.8.1"
enabled=
"false"
/>
<bind
ip=
"192.168.8.21"
port=
"2280"
/>
<properties>
<property
name=
"failure-base-dir"
>
/data/appdatas/cat/report/failure/
</property>
<property
name=
"transaction-base-dir"
>
/data/appdatas/cat/report/transaction/
</property>
</properties>
<base-log-dir>
target/catlog
</base-log-dir>
</config>
cat-core/src/test/resources/com/dianping/cat/message/configuration/config.xsd
浏览文件 @
51f3a125
...
...
@@ -3,7 +3,7 @@
<xs:element
name=
"config"
type=
"ConfigType"
/>
<xs:complexType
name=
"ConfigType"
>
<xs:sequence>
<xs:element
name=
"
app"
type=
"AppType
"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"
base-log-dir"
type=
"xs:string
"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"servers"
>
<xs:complexType>
<xs:sequence
minOccurs=
"0"
maxOccurs=
"unbounded"
>
...
...
@@ -11,27 +11,49 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element
minOccurs=
"0"
maxOccurs=
"unbounded"
name=
"domain"
type=
"DomainType"
/>
<xs:element
name=
"bind"
type=
"BindType"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"filter"
type=
"FilterType"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"properties"
>
<xs:complexType>
<xs:sequence
minOccurs=
"0"
maxOccurs=
"unbounded"
>
<xs:element
name=
"property"
type=
"PropertyType"
/>
</xs:sequence>
<xs:attribute
name=
"mode"
type=
"xs:string"
/>
</xs:complexType>
<
xs:complexType
name=
"AppType"
>
<
xs:attribute
name=
"domain"
type=
"xs:string"
/
>
<xs:attribute
name=
"
ip"
type=
"xs:string
"
/>
<
/xs:element
>
<
/xs:sequence
>
<xs:attribute
name=
"
mode"
type=
"xs:string"
use=
"required
"
/>
</xs:complexType>
<xs:complexType
name=
"ServerType"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"port"
type=
"xs:string"
/>
<xs:attribute
name=
"enabled"
type=
"xs:boolean"
default=
"false"
/>
<xs:attribute
name=
"port"
type=
"xs:int"
default=
"2280"
/>
<xs:attribute
name=
"enabled"
type=
"xs:boolean"
default=
"true"
/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType
name=
"DomainType"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"id"
type=
"xs:string"
/>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"enabled"
type=
"xs:boolean"
/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType
name=
"BindType"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"port"
type=
"xs:string"
/>
<xs:attribute
name=
"port"
type=
"xs:string"
default=
"2280"
/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType
name=
"FilterType"
>
<xs:sequence>
<xs:element
name=
"domain"
type=
"xs:string"
minOccurs=
"0"
maxOccurs=
"1"
/>
</xs:sequence>
<xs:complexType
name=
"PropertyType"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"name"
type=
"xs:string"
/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
cat-core/src/test/resources/com/dianping/cat/message/configuration/
client
.xml
→
cat-core/src/test/resources/com/dianping/cat/message/configuration/
global-config
.xml
浏览文件 @
51f3a125
<config
mode=
"client"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation=
"config.xsd"
>
<app
domain=
"Review"
ip=
"192.168.8.1"
/>
<servers>
<server
ip=
"192.168.8.21"
port=
"2280"
/>
<server
ip=
"192.168.8.22"
port=
"2281"
enabled=
"false"
/>
<server
ip=
"192.168.8.23"
/>
</servers>
</config>
\ No newline at end of file
<domain
id=
"Group"
enabled=
"false"
/>
<domain
id=
"Review"
ip=
"192.168.8.1"
/>
</config>
cat-core/src/test/resources/com/dianping/cat/message/configuration/server.xml
浏览文件 @
51f3a125
<config
mode=
"server"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation=
"config.xsd"
>
<bind
ip=
"192.168.8.21"
/>
<filter>
<domain>
Review
</domain>
<domain>
Group
</domain>
</filter>
<properties>
<property
name=
"failure-base-dir"
>
/data/appdatas/cat/report/failure/
</property>
<property
name=
"transaction-base-dir"
>
/data/appdatas/cat/report/transaction/
</property>
</properties>
</config>
\ No newline at end of file
</config>
cat-home/src/main/resources/META-INF/cat/client.xml
浏览文件 @
51f3a125
<config
mode=
"client"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation=
"config.xsd"
>
<app
domain=
"Cat"
/>
<servers>
<server
ip=
"127.0.0.1"
port=
"2280"
/>
</servers>
</config>
\ No newline at end of file
<domain
id=
"Cat"
/>
</config>
cat-home/src/main/resources/META-INF/cat/config.xsd
浏览文件 @
51f3a125
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
attributeFormDefault=
"unqualified"
>
<xs:element
name=
"config"
type=
"ConfigType"
/>
<xs:complexType
name=
"ConfigType"
>
<xs:sequence>
<xs:element
name=
"app"
type=
"AppType"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"servers"
>
<xs:complexType>
<xs:sequence
minOccurs=
"0"
maxOccurs=
"unbounded"
>
<xs:element
name=
"server"
type=
"ServerType"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element
name=
"bind"
type=
"BindType"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"filter"
type=
"FilterType"
minOccurs=
"0"
maxOccurs=
"1"
/>
</xs:sequence>
<xs:attribute
name=
"mode"
type=
"xs:string"
/>
</xs:complexType>
<xs:complexType
name=
"AppType"
>
<xs:attribute
name=
"domain"
type=
"xs:string"
/>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
</xs:complexType>
<xs:complexType
name=
"ServerType"
>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"port"
type=
"xs:string"
/>
<xs:attribute
name=
"enabled"
type=
"xs:boolean"
default=
"false"
/>
</xs:complexType>
<xs:complexType
name=
"BindType"
>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"port"
type=
"xs:string"
/>
</xs:complexType>
<xs:complexType
name=
"FilterType"
>
<xs:sequence>
<xs:element
name=
"domain"
type=
"xs:string"
minOccurs=
"0"
maxOccurs=
"1"
/>
</xs:sequence>
</xs:complexType>
<xs:element
name=
"config"
type=
"ConfigType"
/>
<xs:complexType
name=
"ConfigType"
>
<xs:sequence>
<xs:element
name=
"base-log-dir"
type=
"xs:string"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"servers"
>
<xs:complexType>
<xs:sequence
minOccurs=
"0"
maxOccurs=
"unbounded"
>
<xs:element
name=
"server"
type=
"ServerType"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element
minOccurs=
"0"
maxOccurs=
"unbounded"
name=
"domain"
type=
"DomainType"
/>
<xs:element
name=
"bind"
type=
"BindType"
minOccurs=
"0"
maxOccurs=
"1"
/>
<xs:element
name=
"properties"
>
<xs:complexType>
<xs:sequence
minOccurs=
"0"
maxOccurs=
"unbounded"
>
<xs:element
name=
"property"
type=
"PropertyType"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute
name=
"mode"
type=
"xs:string"
use=
"required"
/>
</xs:complexType>
<xs:complexType
name=
"ServerType"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"port"
type=
"xs:int"
default=
"2280"
/>
<xs:attribute
name=
"enabled"
type=
"xs:boolean"
default=
"true"
/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType
name=
"DomainType"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"id"
type=
"xs:string"
/>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"enabled"
type=
"xs:boolean"
/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType
name=
"BindType"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"ip"
type=
"xs:string"
/>
<xs:attribute
name=
"port"
type=
"xs:string"
default=
"2280"
/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType
name=
"PropertyType"
>
<xs:simpleContent>
<xs:extension
base=
"xs:string"
>
<xs:attribute
name=
"name"
type=
"xs:string"
/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
cat-job/src/test/java/com/dianping/cat/storage/hdfs/BucketTest.java
浏览文件 @
51f3a125
...
...
@@ -40,7 +40,6 @@ public class BucketTest extends ComponentTestCase {
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
String
id
=
"id"
+
i
;
String
t1
=
"value"
+
i
;
String
tag
=
"tag"
+
(
i
%
10
);
String
t2
=
new
String
(
bucket
.
findById
(
id
));
Assert
.
assertEquals
(
"Unable to find data after stored it."
,
t1
,
t2
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录