Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
dd07c6a9
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,体验更适合开发者的 AI 搜索 >>
提交
dd07c6a9
编写于
9月 30, 2017
作者:
F
Frankie Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bugs fix
上级
84d9abe2
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
151 addition
and
65 deletion
+151
-65
cat-client/src/main/java/com/dianping/cat/message/io/ChannelManager.java
...main/java/com/dianping/cat/message/io/ChannelManager.java
+8
-2
cat-core/src/main/java/com/dianping/cat/config/app/command/CommandFormatConfigManager.java
...ng/cat/config/app/command/CommandFormatConfigManager.java
+3
-1
cat-core/src/main/java/com/dianping/cat/config/server/ServerConfigManager.java
...a/com/dianping/cat/config/server/ServerConfigManager.java
+1
-1
cat-hadoop/pom.xml
cat-hadoop/pom.xml
+4
-0
cat-home/pom.xml
cat-home/pom.xml
+4
-19
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
+19
-17
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+2
-4
cat-home/src/main/java/com/dianping/cat/report/page/event/Handler.java
...main/java/com/dianping/cat/report/page/event/Handler.java
+4
-1
cat-home/src/main/resources/config/alertConfig.xml
cat-home/src/main/resources/config/alertConfig.xml
+1
-0
cat-home/src/main/resources/config/routerConfig.xml
cat-home/src/main/resources/config/routerConfig.xml
+3
-0
cat-home/src/test/java/com/dianping/cat/TestServer.java
cat-home/src/test/java/com/dianping/cat/TestServer.java
+1
-13
cat-maven-plugin/pom.xml
cat-maven-plugin/pom.xml
+0
-5
cat-maven-plugin/src/main/java/com/dianping/cat/plugin/InstallMojo.java
...in/src/main/java/com/dianping/cat/plugin/InstallMojo.java
+2
-2
cat-maven-plugin/src/main/java/com/dianping/cat/plugin/PropertyProviders.java
.../main/java/com/dianping/cat/plugin/PropertyProviders.java
+99
-0
未找到文件。
cat-client/src/main/java/com/dianping/cat/message/io/ChannelManager.java
浏览文件 @
dd07c6a9
...
...
@@ -13,6 +13,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
import
java.io.InputStream
;
import
java.net.InetSocketAddress
;
import
java.net.SocketAddress
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ThreadFactory
;
...
...
@@ -57,7 +58,7 @@ public class ChannelManager implements Task {
private
JsonBuilder
m_jsonBuilder
=
new
JsonBuilder
();
public
ChannelManager
(
Logger
logger
,
List
<
InetSocketAddress
>
serverAddresses
,
MessageQueue
queue
,
ClientConfigManager
configManager
,
MessageIdFactory
idFactory
)
{
ClientConfigManager
configManager
,
MessageIdFactory
idFactory
)
{
m_logger
=
logger
;
m_queue
=
queue
;
m_configManager
=
configManager
;
...
...
@@ -142,7 +143,12 @@ public class ChannelManager implements Task {
private
void
closeChannel
(
ChannelFuture
channel
)
{
try
{
if
(
channel
!=
null
)
{
m_logger
.
info
(
"close channel "
+
channel
.
channel
().
remoteAddress
());
SocketAddress
ip
=
channel
.
channel
().
remoteAddress
();
if
(
ip
!=
null
)
{
m_logger
.
info
(
"close channel "
+
ip
);
}
channel
.
channel
().
close
();
}
}
catch
(
Exception
e
)
{
...
...
cat-core/src/main/java/com/dianping/cat/config/app/command/CommandFormatConfigManager.java
浏览文件 @
dd07c6a9
...
...
@@ -2,6 +2,7 @@ package com.dianping.cat.config.app.command;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -115,7 +116,8 @@ public class CommandFormatConfigManager implements Initializable {
private
void
refreshData
(
Config
config
)
throws
SAXException
,
IOException
{
Map
<
String
,
Rule
>
map
=
new
HashMap
<
String
,
Rule
>();
String
content
=
config
.
getContent
();
long
modifyTime
=
config
.
getModifyDate
().
getTime
();
Date
modifyDate
=
config
.
getModifyDate
();
long
modifyTime
=
modifyDate
==
null
?
System
.
currentTimeMillis
()
:
modifyDate
.
getTime
();
CommandFormat
format
=
DefaultSaxParser
.
parse
(
content
);
for
(
Rule
rule
:
format
.
getRules
())
{
...
...
cat-core/src/main/java/com/dianping/cat/config/server/ServerConfigManager.java
浏览文件 @
dd07c6a9
...
...
@@ -80,7 +80,7 @@ public class ServerConfigManager implements LogEnabled {
}
}
return
""
;
return
"
127.0.0.1:2281
"
;
}
public
String
getHdfsBaseDir
(
String
id
)
{
...
...
cat-hadoop/pom.xml
浏览文件 @
dd07c6a9
...
...
@@ -33,6 +33,10 @@
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jetty-util
</artifactId>
</exclusion>
<exclusion>
<groupId>
javax.servlet
</groupId>
<artifactId>
servlet-api
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
...
...
cat-home/pom.xml
浏览文件 @
dd07c6a9
...
...
@@ -26,29 +26,19 @@
<groupId>
org.unidal.framework
</groupId>
<artifactId>
web-framework
</artifactId>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
servlet-api
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
dal-jdbc
</artifactId>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
jstl
</artifactId>
<version>
1.2
</version>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jsp-api-2.1
</artifactId>
<artifactId>
javax.servlet-api
</artifactId>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
js
p-2.1
</artifactId>
<
scope>
provided
</scope
>
<groupId>
javax.servlet
</groupId>
<artifactId>
js
tl
</artifactId>
<
version>
1.2
</version
>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
...
...
@@ -65,11 +55,6 @@
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mortbay.jetty
</groupId>
<artifactId>
jetty
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
test-framework
</artifactId>
...
...
cat-home/src/main/java/com/dianping/cat/CatHomeModule.java
浏览文件 @
dd07c6a9
...
...
@@ -6,13 +6,12 @@ import org.unidal.helper.Threads;
import
org.unidal.initialization.AbstractModule
;
import
org.unidal.initialization.Module
;
import
org.unidal.initialization.ModuleContext
;
import
org.unidal.lookup.annotation.Named
;
import
com.dianping.cat.analysis.MessageConsumer
;
import
com.dianping.cat.analysis.TcpSocketReceiver
;
import
com.dianping.cat.config.server.ServerConfigManager
;
import
com.dianping.cat.consumer.CatConsumerModule
;
import
com.dianping.cat.report.page.ConfigReloadTask
;
import
com.dianping.cat.report.task.DefaultTaskConsumer
;
import
com.dianping.cat.report.alert.app.AppAlert
;
import
com.dianping.cat.report.alert.business.BusinessAlert
;
import
com.dianping.cat.report.alert.database.DatabaseAlert
;
...
...
@@ -28,7 +27,10 @@ import com.dianping.cat.report.alert.thirdParty.ThirdPartyAlert;
import
com.dianping.cat.report.alert.thirdParty.ThirdPartyAlertBuilder
;
import
com.dianping.cat.report.alert.transaction.TransactionAlert
;
import
com.dianping.cat.report.alert.web.WebAlert
;
import
com.dianping.cat.report.page.ConfigReloadTask
;
import
com.dianping.cat.report.task.DefaultTaskConsumer
;
@Named
(
type
=
Module
.
class
,
value
=
CatHomeModule
.
ID
)
public
class
CatHomeModule
extends
AbstractModule
{
public
static
final
String
ID
=
"cat-home"
;
...
...
@@ -83,7 +85,6 @@ public class CatHomeModule extends AbstractModule {
final
MessageConsumer
consumer
=
ctx
.
lookup
(
MessageConsumer
.
class
);
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
()
{
@Override
public
void
run
()
{
consumer
.
doCheckpoint
();
...
...
@@ -98,20 +99,21 @@ public class CatHomeModule extends AbstractModule {
@Override
protected
void
setup
(
ModuleContext
ctx
)
throws
Exception
{
File
serverConfigFile
=
ctx
.
getAttribute
(
"cat-server-config-file"
);
ServerConfigManager
serverConfigManager
=
ctx
.
lookup
(
ServerConfigManager
.
class
);
final
TcpSocketReceiver
messageReceiver
=
ctx
.
lookup
(
TcpSocketReceiver
.
class
);
serverConfigManager
.
initialize
(
serverConfigFile
);
messageReceiver
.
init
();
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
()
{
@Override
public
void
run
()
{
messageReceiver
.
destory
();
}
});
if
(!
isInitialized
())
{
File
serverConfigFile
=
ctx
.
getAttribute
(
"cat-server-config-file"
);
ServerConfigManager
serverConfigManager
=
ctx
.
lookup
(
ServerConfigManager
.
class
);
final
TcpSocketReceiver
messageReceiver
=
ctx
.
lookup
(
TcpSocketReceiver
.
class
);
serverConfigManager
.
initialize
(
serverConfigFile
);
messageReceiver
.
init
();
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
()
{
@Override
public
void
run
()
{
messageReceiver
.
destory
();
}
});
}
}
}
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
dd07c6a9
...
...
@@ -6,8 +6,6 @@ import java.util.List;
import
org.unidal.dal.jdbc.configuration.AbstractJdbcResourceConfigurator
;
import
org.unidal.dal.jdbc.mapping.TableProvider
;
import
org.unidal.initialization.DefaultModuleManager
;
import
org.unidal.initialization.Module
;
import
org.unidal.initialization.ModuleManager
;
import
org.unidal.lookup.configuration.Component
;
import
com.dianping.cat.CatHomeModule
;
...
...
@@ -146,9 +144,9 @@ public class ComponentsConfigurator extends AbstractJdbcResourceConfigurator {
all
.
addAll
(
defineMetricComponents
());
all
.
add
(
C
(
Module
.
class
,
CatHomeModule
.
ID
,
CatHomeModule
.
class
));
all
.
add
(
A
(
CatHomeModule
.
class
));
all
.
add
(
C
(
ModuleManager
.
class
,
DefaultModuleManager
.
class
)
//
all
.
add
(
A
(
DefaultModuleManager
.
class
)
//
.
config
(
E
(
"topLevelModules"
).
value
(
CatHomeModule
.
ID
)));
// report serivce
...
...
cat-home/src/main/java/com/dianping/cat/report/page/event/Handler.java
浏览文件 @
dd07c6a9
...
...
@@ -200,7 +200,10 @@ public class Handler implements PageHandler<Context> {
switch
(
action
)
{
case
HOURLY_REPORT:
EventReport
report
=
getHourlyReport
(
payload
);
report
=
m_mergeHelper
.
mergeAllIps
(
report
,
ipAddress
);
if
(
report
!=
null
)
{
report
=
m_mergeHelper
.
mergeAllIps
(
report
,
ipAddress
);
}
if
(
report
!=
null
)
{
model
.
setReport
(
report
);
...
...
cat-home/src/main/resources/config/alertConfig.xml
浏览文件 @
dd07c6a9
...
...
@@ -25,6 +25,7 @@
<receiver
id=
"Web"
enable=
"true"
>
<email>
test@test.com
</email>
<phone>
1520*****
</phone>
</receiver>
<receiver
id=
"Heartbeat"
enable=
"true"
>
<email>
test@test.com
</email>
</receiver>
...
...
cat-home/src/main/resources/config/routerConfig.xml
浏览文件 @
dd07c6a9
<?xml version="1.0" encoding="utf-8"?>
<router-config
backup-server=
"127.0.0.1"
backup-server-port=
"2280"
>
<default-server
id=
"127.0.0.1"
port=
"2280"
enable=
"true"
/>
<!--
<default-server id="10.10.10.1" port="2280" enable="true"/>
<default-server id="10.10.10.2" port="2280" enable="true"/>
-->
</router-config>
cat-home/src/test/java/com/dianping/cat/TestServer.java
浏览文件 @
dd07c6a9
package
com.dianping.cat
;
import
java.util.EnumSet
;
import
javax.servlet.DispatcherType
;
import
org.eclipse.jetty.webapp.WebAppContext
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
import
org.mortbay.servlet.GzipFilter
;
import
org.unidal.test.jetty.JettyServer
;
@RunWith
(
JUnit4
.
class
)
...
...
@@ -21,12 +15,6 @@ public class TestServer extends JettyServer {
server
.
startWebApp
();
server
.
stopServer
();
}
@Before
public
void
before
()
throws
Exception
{
System
.
setProperty
(
"devMode"
,
"true"
);
super
.
startServer
();
}
@Override
protected
String
getContextPath
()
{
...
...
@@ -40,7 +28,7 @@ public class TestServer extends JettyServer {
@Override
protected
void
postConfigure
(
WebAppContext
context
)
{
context
.
addFilter
(
GzipFilter
.
class
,
"/*"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
));
//
context.addFilter(GzipFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
}
@Test
...
...
cat-maven-plugin/pom.xml
浏览文件 @
dd07c6a9
...
...
@@ -24,11 +24,6 @@
<artifactId>
mysql-connector-java
</artifactId>
<scope>
runtime
</scope>
</dependency>
<dependency>
<groupId>
org.unidal.maven.plugins
</groupId>
<artifactId>
common
</artifactId>
<version>
2.4.2
</version>
</dependency>
<dependency>
<groupId>
org.unidal.framework
</groupId>
<artifactId>
foundation-service
</artifactId>
...
...
cat-maven-plugin/src/main/java/com/dianping/cat/plugin/InstallMojo.java
浏览文件 @
dd07c6a9
...
...
@@ -15,8 +15,8 @@ import org.apache.maven.plugin.MojoExecutionException;
import
org.apache.maven.plugin.MojoFailureException
;
import
org.unidal.helper.Files
;
import
org.unidal.helper.Files.AutoClose
;
import
org.unidal.maven.plugin.common.PropertyProviders
;
import
org.unidal.maven.plugin.commo
n.PropertyProviders.IValidator
;
import
com.dianping.cat.plugi
n.PropertyProviders.IValidator
;
/**
* @goal install
...
...
cat-maven-plugin/src/main/java/com/dianping/cat/plugin/PropertyProviders.java
0 → 100644
浏览文件 @
dd07c6a9
package
com.dianping.cat.plugin
;
import
java.util.List
;
public
class
PropertyProviders
{
public
static
ConsoleProvider
fromConsole
()
{
return
ConsoleProvider
.
INSTANCE
;
}
public
static
enum
ConsoleProvider
{
INSTANCE
;
public
String
forString
(
String
name
,
String
prompt
,
List
<
String
>
availableValues
,
String
defaultValue
,
IValidator
<
String
>
validator
)
{
String
value
=
getString
(
name
,
prompt
,
availableValues
,
defaultValue
);
if
(
validator
!=
null
)
{
while
(!
validator
.
validate
(
value
))
{
value
=
getString
(
name
,
prompt
,
availableValues
,
defaultValue
);
}
}
return
value
;
}
private
String
getString
(
String
name
,
String
prompt
,
List
<
String
>
availableValues
,
String
defaultValue
)
{
String
value
=
name
==
null
?
null
:
System
.
getProperty
(
name
);
if
(
value
!=
null
)
{
return
value
;
}
StringBuilder
sb
=
new
StringBuilder
(
64
);
byte
[]
buffer
=
new
byte
[
256
];
while
(
value
==
null
)
{
sb
.
setLength
(
0
);
sb
.
append
(
prompt
);
if
(
defaultValue
!=
null
)
{
sb
.
append
(
'['
).
append
(
defaultValue
).
append
(
']'
);
}
boolean
withOptions
=
availableValues
!=
null
&&
!
availableValues
.
isEmpty
();
int
count
=
0
;
if
(
withOptions
)
{
System
.
out
.
println
(
sb
.
toString
());
for
(
String
availableValue
:
availableValues
)
{
System
.
out
.
println
((
count
++)
+
": "
+
availableValue
);
}
System
.
out
.
print
(
"Please select:"
);
}
else
{
System
.
out
.
print
(
sb
.
toString
());
}
System
.
out
.
flush
();
try
{
int
size
=
System
.
in
.
read
(
buffer
);
while
(
size
>
0
&&
(
buffer
[
size
-
1
]
==
'\n'
||
buffer
[
size
-
1
]
==
'\r'
))
{
size
--;
}
if
(
size
<=
0
)
{
value
=
defaultValue
;
}
else
{
value
=
new
String
(
buffer
,
0
,
size
);
if
(
withOptions
)
{
try
{
int
pos
=
Integer
.
parseInt
(
value
);
if
(
pos
>=
0
&&
pos
<
count
)
{
value
=
availableValues
.
get
(
pos
);
}
else
{
value
=
null
;
}
}
catch
(
Exception
e
)
{
// ignore it
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
value
;
}
}
public
static
interface
IValidator
<
T
>
{
public
boolean
validate
(
T
value
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录