Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
f705887f
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,发现更多精彩内容 >>
提交
f705887f
编写于
7月 31, 2014
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #430 from youyong205/master
refactor
上级
dec8abcf
f7e7a0a0
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
261 addition
and
155 deletion
+261
-155
cat-client/src/main/java/com/dianping/cat/message/internal/MessageIdFactory.java
...a/com/dianping/cat/message/internal/MessageIdFactory.java
+1
-3
cat-client/src/main/java/com/dianping/cat/message/io/ChannelManager.java
...main/java/com/dianping/cat/message/io/ChannelManager.java
+177
-91
cat-core/src/main/java/com/dianping/cat/ServerConfigManager.java
...e/src/main/java/com/dianping/cat/ServerConfigManager.java
+1
-1
cat-core/src/main/java/com/dianping/cat/config/app/AppConfigManager.java
...in/java/com/dianping/cat/config/app/AppConfigManager.java
+2
-1
cat-home/src/main/java/com/dianping/cat/report/service/impl/RouterConfigService.java
...dianping/cat/report/service/impl/RouterConfigService.java
+2
-2
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/AlertManager.java
...m/dianping/cat/report/task/alert/sender/AlertManager.java
+0
-1
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
...main/java/com/dianping/cat/report/view/NavigationBar.java
+0
-2
cat-home/src/main/java/com/dianping/cat/system/config/RouterConfigManager.java
...a/com/dianping/cat/system/config/RouterConfigManager.java
+11
-8
cat-home/src/main/java/com/dianping/cat/system/page/router/Handler.java
...ain/java/com/dianping/cat/system/page/router/Handler.java
+25
-19
cat-home/src/main/resources/chrome/cat.crx
cat-home/src/main/resources/chrome/cat.crx
+0
-0
cat-home/src/main/resources/chrome/cat/manifest.json
cat-home/src/main/resources/chrome/cat/manifest.json
+1
-1
cat-home/src/main/resources/config/default-router-config.xml
cat-home/src/main/resources/config/default-router-config.xml
+1
-1
cat-home/src/main/webapp/WEB-INF/tags/body.tag
cat-home/src/main/webapp/WEB-INF/tags/body.tag
+40
-12
cat-home/src/main/webapp/jsp/system/alarm/alarmRecordDetail.jsp
...me/src/main/webapp/jsp/system/alarm/alarmRecordDetail.jsp
+0
-3
cat-home/src/main/webapp/jsp/system/alarm/alarmRecordList.jsp
...home/src/main/webapp/jsp/system/alarm/alarmRecordList.jsp
+0
-4
cat-home/src/main/webapp/jsp/system/alarm/alarmTemplateUpdate.jsp
.../src/main/webapp/jsp/system/alarm/alarmTemplateUpdate.jsp
+0
-3
cat-home/src/main/webapp/jsp/system/alarm/scheduledReports.jsp
...ome/src/main/webapp/jsp/system/alarm/scheduledReports.jsp
+0
-3
未找到文件。
cat-client/src/main/java/com/dianping/cat/message/internal/MessageIdFactory.java
浏览文件 @
f705887f
...
...
@@ -88,9 +88,7 @@ public class MessageIdFactory {
m_ipAddress
=
sb
.
toString
();
}
String
tmpDir
=
System
.
getProperty
(
"java.io.tmpdir"
);
File
mark
=
new
File
(
tmpDir
,
"cat-"
+
domain
+
".mark"
);
File
mark
=
new
File
(
"/data/appdatas/cat/"
,
"cat-"
+
domain
+
".mark"
);
m_markFile
=
new
RandomAccessFile
(
mark
,
"rw"
);
m_byteBuffer
=
m_markFile
.
getChannel
().
map
(
MapMode
.
READ_WRITE
,
0
,
20
);
...
...
cat-client/src/main/java/com/dianping/cat/message/io/ChannelManager.java
浏览文件 @
f705887f
...
...
@@ -6,7 +6,6 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
org.codehaus.plexus.logging.Logger
;
import
org.jboss.netty.bootstrap.ClientBootstrap
;
...
...
@@ -32,35 +31,22 @@ import com.dianping.cat.message.spi.MessageQueue;
import
com.site.helper.Splitters
;
public
class
ChannelManager
implements
Task
{
private
List
<
InetSocketAddress
>
m_serverAddresses
;
private
ClientConfigManager
m_configManager
;
private
ClientBootstrap
m_bootstrap
;
private
ChannelFuture
m_activeFuture
;
private
Logger
m_logger
;
private
ChannelFuture
m_lastFuture
;
private
boolean
m_active
=
true
;
private
int
m_activeIndex
=
-
1
;
private
int
m_retriedTimes
=
0
;
private
int
m_count
=
1
;
private
volatile
int
m_error
=
-
1
;
public
static
final
int
SIZE
=
10000
;
private
AtomicInteger
m_reconnects
=
new
AtomicInteger
(
99
);
private
int
m_count
=
-
10
;
private
MessageQueue
m_queue
;
private
String
m_activeServerConfig
;
private
ChannelHolder
m_activeChannelHolder
;
public
ChannelManager
(
Logger
logger
,
List
<
InetSocketAddress
>
serverAddresses
,
MessageQueue
queue
,
ClientConfigManager
configManager
)
{
...
...
@@ -87,24 +73,35 @@ public class ChannelManager implements Task {
String
serverConfig
=
loadServerConfig
();
if
(
serverConfig
!=
null
)
{
if
(
StringUtils
.
isNotEmpty
(
serverConfig
)
)
{
List
<
InetSocketAddress
>
configedAddresses
=
parseSocketAddress
(
serverConfig
);
ChannelHolder
holder
=
initChannel
(
configedAddresses
,
serverConfig
);
initChannel
(
configedAddresses
,
serverConfig
)
;
m_activeChannelHolder
=
holder
;
}
else
{
initChannel
(
serverAddresses
,
null
);
ChannelHolder
holder
=
initChannel
(
serverAddresses
,
null
);
m_activeChannelHolder
=
holder
;
}
}
private
void
close
AllChannel
(
)
{
private
void
close
Channel
(
ChannelFuture
channel
)
{
try
{
if
(
m_activeFuture
!=
null
)
{
m_activeFuture
.
getChannel
().
close
();
}
if
(
m_lastFuture
!=
null
)
{
m_lastFuture
.
getChannel
().
close
();
if
(
channel
!=
null
)
{
m_logger
.
info
(
"close channel "
+
channel
.
getChannel
().
getRemoteAddress
());
channel
.
getChannel
().
close
();
}
m_activeIndex
=
-
1
;
}
catch
(
Exception
e
)
{
// ignore
}
}
private
void
closeChannelHolder
(
ChannelHolder
channelHolder
)
{
try
{
ChannelFuture
channel
=
channelHolder
.
getActiveFuture
();
closeChannel
(
channel
);
channelHolder
.
setActiveIndex
(-
1
);
}
catch
(
Exception
e
)
{
// ignore
}
...
...
@@ -118,12 +115,8 @@ public class ChannelManager implements Task {
future
.
awaitUninterruptibly
(
100
,
TimeUnit
.
MILLISECONDS
);
// 100 ms
if
(!
future
.
isSuccess
())
{
int
count
=
m_reconnects
.
incrementAndGet
();
if
(
count
%
100
==
0
)
{
m_logger
.
error
(
"Error when try to connecting to "
+
address
+
", message: "
+
future
.
getCause
());
}
future
.
getChannel
().
close
();
m_logger
.
error
(
"Error when try to connecting to "
+
address
);
closeChannel
(
future
);
}
else
{
m_logger
.
info
(
"Connected to CAT server at "
+
address
);
return
future
;
...
...
@@ -132,14 +125,14 @@ public class ChannelManager implements Task {
m_logger
.
error
(
"Error when connect server "
+
address
.
getAddress
(),
e
);
if
(
future
!=
null
)
{
future
.
getChannel
().
close
(
);
closeChannel
(
future
);
}
}
return
null
;
}
public
ChannelFuture
getChannel
()
{
return
m_active
Future
;
return
m_active
ChannelHolder
.
getActiveFuture
()
;
}
@Override
...
...
@@ -147,47 +140,63 @@ public class ChannelManager implements Task {
return
"TcpSocketSender-ChannelManager"
;
}
private
void
initChannel
(
List
<
InetSocketAddress
>
addresses
,
String
serverConfig
)
{
try
{
StringBuilder
sb
=
new
StringBuilder
();
private
ChannelHolder
initChannel
(
List
<
InetSocketAddress
>
addresses
,
String
serverConfig
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
InetSocketAddress
address
:
addresses
)
{
sb
.
append
(
address
.
getAddress
().
getHostAddress
()).
append
(
":"
).
append
(
address
.
getPort
()).
append
(
','
);
}
m_logger
.
info
(
"init CAT server:"
+
sb
.
toString
());
for
(
InetSocketAddress
address
:
addresses
)
{
sb
.
append
(
address
.
getAddress
().
getHostAddress
()).
append
(
":"
).
append
(
address
.
getPort
()).
append
(
','
);
}
m_serverAddresses
=
addresses
;
try
{
int
len
=
addresses
.
size
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
ChannelFuture
future
=
createChannel
(
addresses
.
get
(
i
));
InetSocketAddress
address
=
addresses
.
get
(
i
);
String
hostAddress
=
address
.
getAddress
().
getHostAddress
();
ChannelHolder
holder
=
null
;
if
(
m_activeChannelHolder
!=
null
&&
hostAddress
.
equals
(
m_activeChannelHolder
.
getIp
()))
{
holder
=
new
ChannelHolder
();
holder
.
setActiveFuture
(
m_activeChannelHolder
.
getActiveFuture
()).
setConnectChanged
(
false
);
}
else
{
ChannelFuture
future
=
createChannel
(
address
);
if
(
future
!=
null
)
{
holder
=
new
ChannelHolder
();
holder
.
setActiveFuture
(
future
).
setConnectChanged
(
true
);
}
}
if
(
holder
!=
null
)
{
holder
.
setActiveIndex
(
i
).
setIp
(
hostAddress
);
holder
.
setActiveServerConfig
(
serverConfig
).
setServerAddresses
(
addresses
);
if
(
future
!=
null
)
{
m_activeFuture
=
future
;
m_activeIndex
=
i
;
m_activeServerConfig
=
serverConfig
;
break
;
m_logger
.
info
(
"success when init CAT server, new active holder"
+
holder
.
toString
());
return
holder
;
}
}
}
catch
(
Exception
e
)
{
m_logger
.
error
(
e
.
getMessage
(),
e
);
// ignore
}
m_logger
.
info
(
"Error when init CAT server "
+
sb
.
toString
());
return
null
;
}
private
boolean
isChannelDisabled
(
ChannelFuture
activeFuture
)
{
return
activeFuture
!=
null
&&
!
activeFuture
.
getChannel
().
isOpen
();
}
private
boolean
isChannelStalled
()
{
private
boolean
isChannelStalled
(
ChannelFuture
activeFuture
)
{
m_retriedTimes
++;
int
size
=
m_queue
.
size
();
boolean
stalled
=
m_activeFuture
!=
null
&&
size
>=
SIZE
-
1
;
boolean
stalled
=
activeFuture
!=
null
&&
size
>=
TcpSocketSender
.
SIZE
-
10
;
if
(
stalled
)
{
if
(
m_retriedTimes
>=
5
)
{
m_retriedTimes
=
0
;
m_logger
.
info
(
"need to set active future to null. queue size:"
+
size
+
",activeIndex:"
+
m_activeIndex
);
return
true
;
}
else
{
m_logger
.
info
(
"no need set active future to null due to retry time is not enough. queue size:"
+
size
+
",retriedTimes:"
+
m_retriedTimes
+
",activeIndex:"
+
m_activeIndex
);
return
false
;
}
}
else
{
...
...
@@ -203,7 +212,7 @@ public class ChannelManager implements Task {
return
content
.
trim
();
}
catch
(
Exception
e
)
{
m_logger
.
error
(
e
.
getMessage
(),
e
);
// ignore
}
return
null
;
}
...
...
@@ -234,44 +243,48 @@ public class ChannelManager implements Task {
Pair
<
Boolean
,
String
>
pair
=
serverConfigChanged
();
if
(
pair
.
getKey
())
{
closeAllChannel
();
String
servers
=
pair
.
getValue
();
List
<
InetSocketAddress
>
serverAddresses
=
parseSocketAddress
(
servers
);
initChannel
(
serverAddresses
,
servers
);
ChannelHolder
newHolder
=
initChannel
(
serverAddresses
,
servers
);
if
(
newHolder
!=
null
)
{
if
(
newHolder
.
isConnectChanged
())
{
ChannelHolder
last
=
m_activeChannelHolder
;
m_activeChannelHolder
=
newHolder
;
closeChannelHolder
(
last
);
m_logger
.
info
(
"switch active channel to "
+
m_activeChannelHolder
);
}
else
{
m_activeChannelHolder
=
newHolder
;
}
}
}
}
ChannelFuture
activeFuture
=
m_activeChannelHolder
.
getActiveFuture
();
List
<
InetSocketAddress
>
serverAddresses
=
m_activeChannelHolder
.
getServerAddresses
();
try
{
if
(
isChannelStalled
())
{
m_activeFuture
.
getChannel
().
close
();
m_activeFuture
=
null
;
m_activeIndex
=
-
1
;
}
if
(
m_activeFuture
!=
null
&&
!
m_activeFuture
.
getChannel
().
isOpen
())
{
m_activeFuture
.
getChannel
().
close
();
m_activeFuture
=
null
;
m_activeIndex
=
m_serverAddresses
.
size
();
}
if
(
m_activeIndex
==
-
1
)
{
m_activeIndex
=
m_serverAddresses
.
size
();
}
if
(
m_lastFuture
!=
null
&&
m_lastFuture
!=
m_activeFuture
)
{
m_lastFuture
.
getChannel
().
close
();
m_lastFuture
=
null
;
if
(
isChannelStalled
(
activeFuture
)
||
isChannelDisabled
(
activeFuture
))
{
closeChannelHolder
(
m_activeChannelHolder
);
}
}
catch
(
Throwable
e
)
{
m_logger
.
error
(
e
.
getMessage
(),
e
);
}
try
{
for
(
int
i
=
0
;
i
<
m_activeIndex
;
i
++)
{
ChannelFuture
future
=
createChannel
(
m_serverAddresses
.
get
(
i
));
int
reconnectServers
=
m_activeChannelHolder
.
getActiveIndex
();
if
(
reconnectServers
==
-
1
)
{
reconnectServers
=
serverAddresses
.
size
();
}
for
(
int
i
=
0
;
i
<
reconnectServers
;
i
++)
{
ChannelFuture
future
=
createChannel
(
serverAddresses
.
get
(
i
));
if
(
future
!=
null
)
{
m_lastFuture
=
m_activeFuture
;
m_activeFuture
=
future
;
m_activeIndex
=
i
;
ChannelFuture
lastFuture
=
activeFuture
;
m_activeChannelHolder
.
setActiveFuture
(
future
);
m_activeChannelHolder
.
setActiveIndex
(
i
);
closeChannel
(
lastFuture
);
break
;
}
}
...
...
@@ -280,7 +293,7 @@ public class ChannelManager implements Task {
}
try
{
Thread
.
sleep
(
2
*
1000L
);
// check every 2 seconds
Thread
.
sleep
(
10
*
1000L
);
// check every 2 seconds
}
catch
(
InterruptedException
e
)
{
// ignore
}
...
...
@@ -290,7 +303,7 @@ public class ChannelManager implements Task {
private
Pair
<
Boolean
,
String
>
serverConfigChanged
()
{
String
current
=
loadServerConfig
();
if
(!
StringUtils
.
isEmpty
(
current
)
&&
!
current
.
equals
(
m_active
ServerConfig
))
{
if
(!
StringUtils
.
isEmpty
(
current
)
&&
!
current
.
equals
(
m_active
ChannelHolder
.
getActiveServerConfig
()
))
{
return
new
Pair
<
Boolean
,
String
>(
true
,
current
);
}
else
{
return
new
Pair
<
Boolean
,
String
>(
false
,
current
);
...
...
@@ -300,7 +313,7 @@ public class ChannelManager implements Task {
private
boolean
shouldCheckServerConfig
(
int
count
)
{
int
duration
=
60
*
5
;
if
(
count
%
(
duration
)
==
0
||
m_activeIndex
==
-
1
)
{
if
(
count
%
duration
==
0
||
m_activeChannelHolder
.
getActiveIndex
()
==
-
1
)
{
return
true
;
}
else
{
return
false
;
...
...
@@ -312,22 +325,95 @@ public class ChannelManager implements Task {
m_active
=
false
;
}
public
static
class
ChannelHolder
{
private
ChannelFuture
m_activeFuture
;
private
int
m_activeIndex
=
-
1
;
private
String
m_activeServerConfig
;
private
List
<
InetSocketAddress
>
m_serverAddresses
;
private
String
m_ip
;
private
boolean
m_connectChanged
;
public
ChannelFuture
getActiveFuture
()
{
return
m_activeFuture
;
}
public
int
getActiveIndex
()
{
return
m_activeIndex
;
}
public
String
getActiveServerConfig
()
{
return
m_activeServerConfig
;
}
public
String
getIp
()
{
return
m_ip
;
}
public
List
<
InetSocketAddress
>
getServerAddresses
()
{
return
m_serverAddresses
;
}
public
boolean
isConnectChanged
()
{
return
m_connectChanged
;
}
public
ChannelHolder
setActiveFuture
(
ChannelFuture
activeFuture
)
{
m_activeFuture
=
activeFuture
;
return
this
;
}
public
ChannelHolder
setActiveIndex
(
int
activeIndex
)
{
m_activeIndex
=
activeIndex
;
return
this
;
}
public
ChannelHolder
setActiveServerConfig
(
String
activeServerConfig
)
{
m_activeServerConfig
=
activeServerConfig
;
return
this
;
}
public
ChannelHolder
setConnectChanged
(
boolean
connectChanged
)
{
m_connectChanged
=
connectChanged
;
return
this
;
}
public
ChannelHolder
setIp
(
String
ip
)
{
m_ip
=
ip
;
return
this
;
}
public
ChannelHolder
setServerAddresses
(
List
<
InetSocketAddress
>
serverAddresses
)
{
m_serverAddresses
=
serverAddresses
;
return
this
;
}
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"active future :"
).
append
(
m_activeFuture
.
getChannel
().
getRemoteAddress
());
sb
.
append
(
" index:"
).
append
(
m_activeIndex
);
sb
.
append
(
" ip:"
).
append
(
m_ip
);
sb
.
append
(
" server config:"
).
append
(
m_activeServerConfig
);
return
sb
.
toString
();
}
}
private
class
ExceptionHandler
extends
SimpleChannelHandler
{
@Override
public
void
channelDisconnected
(
ChannelHandlerContext
ctx
,
ChannelStateEvent
e
)
throws
Exception
{
m_error
++;
if
(
m_error
%
1000
==
0
)
{
m_logger
.
warn
(
"Channel disconnected by remote address: "
+
e
.
getChannel
().
getRemoteAddress
());
}
m_logger
.
warn
(
"Channel disconnected by remote address: "
+
e
.
getChannel
().
getRemoteAddress
());
}
@Override
public
void
exceptionCaught
(
ChannelHandlerContext
ctx
,
ExceptionEvent
e
)
{
m_error
++;
if
(
m_error
%
1000
==
0
)
{
m_logger
.
warn
(
"Channel disconnected due to "
+
e
.
getCause
());
}
m_logger
.
warn
(
"Channel disconnected due to "
+
e
.
getCause
());
}
}
...
...
cat-core/src/main/java/com/dianping/cat/ServerConfigManager.java
浏览文件 @
f705887f
...
...
@@ -346,5 +346,5 @@ public class ServerConfigManager implements Initializable, LogEnabled {
public
boolean
validateDomain
(
String
domain
)
{
return
!
domain
.
equals
(
Constants
.
FRONT_END
)
&&
filterDomain
(
domain
);
}
}
cat-core/src/main/java/com/dianping/cat/config/app/AppConfigManager.java
浏览文件 @
f705887f
...
...
@@ -188,8 +188,8 @@ public class AppConfigManager implements Initializable {
AppConfig
appConfig
=
DefaultSaxParser
.
parse
(
content
);
m_config
=
appConfig
;
refreshData
();
m_modifyTime
=
modifyTime
;
refreshData
();
}
}
}
...
...
@@ -224,6 +224,7 @@ public class AppConfigManager implements Initializable {
boolean
active
=
true
;
while
(
active
)
{
try
{
refreshAppConfigConfig
();
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
...
...
cat-home/src/main/java/com/dianping/cat/report/service/impl/RouterConfigService.java
浏览文件 @
f705887f
package
com.dianping.cat.report.service.impl
;
import
java.util.Date
;
import
java.util.
Linked
HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.unidal.dal.jdbc.DalException
;
...
...
@@ -19,7 +19,7 @@ import com.dianping.cat.report.service.AbstractReportService;
public
class
RouterConfigService
extends
AbstractReportService
<
RouterConfig
>
{
private
Map
<
Long
,
RouterConfig
>
m_configs
=
new
Linked
HashMap
<
Long
,
RouterConfig
>();
private
Map
<
Long
,
RouterConfig
>
m_configs
=
new
HashMap
<
Long
,
RouterConfig
>();
@Override
public
RouterConfig
makeReport
(
String
domain
,
Date
start
,
Date
end
)
{
...
...
cat-home/src/main/java/com/dianping/cat/report/task/alert/sender/AlertManager.java
浏览文件 @
f705887f
...
...
@@ -97,7 +97,6 @@ public class AlertManager implements Initializable {
@Override
public
void
shutdown
()
{
}
}
@Override
...
...
cat-home/src/main/java/com/dianping/cat/report/view/NavigationBar.java
浏览文件 @
f705887f
...
...
@@ -57,8 +57,6 @@ public class NavigationBar {
SystemPage
.
ALARM
,
SystemPage
.
CONFIG
,
ReportPage
.
LOGVIEW
,
};
}
}
cat-home/src/main/java/com/dianping/cat/system/config/RouterConfigManager.java
浏览文件 @
f705887f
package
com.dianping.cat.system.config
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
...
...
@@ -49,22 +47,28 @@ public class RouterConfigManager implements Initializable, LogEnabled {
return
new
Server
().
setId
(
m_routerConfig
.
getBackupServer
()).
setPort
(
m_routerConfig
.
getBackupServerPort
());
}
private
void
addServerList
(
List
<
Server
>
servers
,
Server
server
)
{
for
(
Server
s
:
servers
)
{
if
(
s
.
getId
().
equals
(
server
.
getId
()))
{
return
;
}
}
servers
.
add
(
server
);
}
public
List
<
Server
>
queryServersByDomain
(
String
domain
)
{
Domain
domainConfig
=
m_routerConfig
.
findDomain
(
domain
);
List
<
Server
>
result
=
new
ArrayList
<
Server
>();
if
(
domainConfig
==
null
)
{
Map
<
Server
,
Integer
>
map
=
new
HashMap
<
Server
,
Integer
>();
List
<
Server
>
servers
=
queryEnableServers
();
int
length
=
servers
.
size
();
int
index
=
domain
.
hashCode
();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
map
.
put
(
servers
.
get
((
index
+
i
)
%
length
),
0
);
addServerList
(
result
,
servers
.
get
((
index
+
i
)
%
length
)
);
}
map
.
put
(
queryBackUpServer
(),
0
);
result
=
new
ArrayList
<
Server
>(
map
.
keySet
());
addServerList
(
result
,
queryBackUpServer
());
}
else
{
for
(
Server
server
:
domainConfig
.
getServers
())
{
result
.
add
(
server
);
...
...
@@ -82,7 +86,6 @@ public class RouterConfigManager implements Initializable, LogEnabled {
result
.
add
(
new
Server
().
setId
(
server
.
getId
()).
setPort
(
server
.
getPort
()));
}
}
return
result
;
}
...
...
cat-home/src/main/java/com/dianping/cat/system/page/router/Handler.java
浏览文件 @
f705887f
...
...
@@ -6,6 +6,12 @@ import java.util.List;
import
javax.servlet.ServletException
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.web.mvc.PageHandler
;
import
org.unidal.web.mvc.annotation.InboundActionMeta
;
import
org.unidal.web.mvc.annotation.OutboundActionMeta
;
import
org.unidal.web.mvc.annotation.PayloadMeta
;
import
com.dianping.cat.Constants
;
import
com.dianping.cat.helper.TimeUtil
;
import
com.dianping.cat.home.router.entity.Domain
;
...
...
@@ -15,12 +21,6 @@ import com.dianping.cat.report.service.ReportServiceManager;
import
com.dianping.cat.system.SystemPage
;
import
com.dianping.cat.system.config.RouterConfigManager
;
import
org.unidal.lookup.annotation.Inject
;
import
org.unidal.web.mvc.PageHandler
;
import
org.unidal.web.mvc.annotation.InboundActionMeta
;
import
org.unidal.web.mvc.annotation.OutboundActionMeta
;
import
org.unidal.web.mvc.annotation.PayloadMeta
;
public
class
Handler
implements
PageHandler
<
Context
>
{
@Inject
private
JspViewer
m_jspViewer
;
...
...
@@ -50,26 +50,32 @@ public class Handler implements PageHandler<Context> {
switch
(
action
)
{
case
API:
if
(
report
!=
null
)
{
Domain
domain
=
report
.
findDomain
(
payload
.
getDomain
());
String
str
=
null
;
Domain
domainConfig
=
m_configManager
.
getRouterConfig
().
findDomain
(
payload
.
getDomain
());
if
(
domain
==
null
)
{
m_configManager
.
getRouterConfig
().
getDefaultServers
();
if
(
domainConfig
==
null
)
{
if
(
report
!=
null
)
{
Domain
domain
=
report
.
findDomain
(
payload
.
getDomain
());
String
str
=
null
;
List
<
Server
>
servers
=
m_configManager
.
queryServersByDomain
(
payload
.
getDomain
());
if
(
domain
==
null
)
{
m_configManager
.
getRouterConfig
().
getDefaultServers
();
str
=
buildServerStr
(
servers
);
List
<
Server
>
servers
=
m_configManager
.
queryServersByDomain
(
payload
.
getDomain
());
str
=
buildServerStr
(
servers
);
}
else
{
List
<
Server
>
servers
=
domain
.
getServers
();
str
=
buildServerStr
(
servers
);
}
model
.
setContent
(
str
);
}
else
{
List
<
Server
>
servers
=
domain
.
getServers
(
);
List
<
Server
>
servers
=
m_configManager
.
queryServersByDomain
(
payload
.
getDomain
()
);
str
=
buildServerStr
(
servers
);
model
.
setContent
(
buildServerStr
(
servers
)
);
}
model
.
setContent
(
str
);
}
else
{
List
<
Server
>
servers
=
m_configManager
.
queryServersByDomain
(
payload
.
getDomain
());
model
.
setContent
(
buildServerStr
(
servers
));
model
.
setContent
(
buildServerStr
(
domainConfig
.
getServers
()));
}
break
;
case
MODEL:
...
...
cat-home/src/main/resources/chrome/cat.crx
浏览文件 @
f705887f
无法预览此类型文件
cat-home/src/main/resources/chrome/cat/manifest.json
浏览文件 @
f705887f
{
"manifest_version"
:
2
,
"name"
:
"CAT Extension"
,
"version"
:
"0.
1
"
,
"version"
:
"0.
2
"
,
"description"
:
"CAT Extension"
,
"page_action"
:
{
"default_title"
:
"CAT Logview"
,
...
...
cat-home/src/main/resources/config/default-router-config.xml
浏览文件 @
f705887f
...
...
@@ -10,8 +10,8 @@
<default-server
id=
"10.1.6.126"
port=
"2280"
enable=
"true"
/>
<default-server
id=
"10.1.6.145"
port=
"2280"
enable=
"true"
/>
<domain
id=
"Cat"
>
<server
id=
"127.0.0.1"
port=
"2280"
/>
<server
id=
"10.1.6.37"
port=
"2280"
/>
<server
id=
"10.1.6.128"
port=
"2280"
/>
<server
id=
"127.0.0.1"
port=
"2280"
/>
</domain>
</router-config>
cat-home/src/main/webapp/WEB-INF/tags/body.tag
浏览文件 @
f705887f
...
...
@@ -18,8 +18,6 @@
<res:useCss
value=
'${res.css.local.tiny_css}'
media=
"screen and (max-width: 1050px)"
target=
"head-css"
/>
<res:useCss
value=
'${res.css.local.large_css}'
media=
"screen and (min-width: 1050px)"
target=
"head-css"
/>
</head>
<div
class=
"navbar navbar-inverse"
>
<div
class=
"navbar-inner"
>
<div
class=
"container-fluid"
>
...
...
@@ -41,19 +39,49 @@
</c:if>
</c:forEach>
</ul>
<ul
class=
"nav"
>
<li
class=
"dropdown"
><a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Config
<b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
<li
class=
'nav-header'
style=
"margin-top:0px;"
>
全局配置
</li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=projects"
>
项目信息配置
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=topologyProductLines"
>
项目分组配置
</a></li>
<li
class=
'nav-header'
style=
"margin-top:0px;"
>
应用监控配置
</li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=topologyGraphNodeConfigList"
>
拓扑节点阀值
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=topologyGraphEdgeConfigList"
>
拓扑依赖阀值
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=exception"
>
异常告警配置
</a></li>
<li
class=
'nav-header'
style=
"margin-top:0px;"
>
外部监控配置
</li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=urlPatterns"
>
URL合并规则
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=aggregations"
>
JS合并规则
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=appConfigUpdate"
>
APP监控配置
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=thirdPartyConfigUpdate"
>
第三方监控配置
</a></li>
<li
class=
'nav-header'
style=
"margin-top:0px;"
>
业务监控配置
</li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=metricConfigList"
>
业务监控规则
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=metricGroupConfigUpdate"
>
业务指标分组
</a></li>
<li
class=
'nav-header'
style=
"margin-top:0px;"
>
网络监控配置
</li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=networkRuleConfigUpdate"
>
网络告警配置
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=netGraphConfigUpdate"
>
网络拓扑配置
</a></li>
<li
class=
'nav-header'
style=
"margin-top:0px;"
>
监控告警配置
</li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=systemRuleConfigUpdate"
>
系统告警配置
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=alertDefaultReceivers"
>
默认告警配置
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=alertPolicy"
>
告警类型设置
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"?op=bugConfigUpdate"
>
异常类型配置
</a></li>
<li
class=
'nav-header'
style=
"margin-top:0px;"
>
其他监控配置
</li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=domainGroupConfigUpdate"
>
机器分组配置
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/config?op=routerConfigUpdate"
>
客户端路由配置
</a></li>
</ul>
</li>
</ul>
<ul
class=
"nav"
>
<li
class=
"dropdown"
><a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Other
<b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
<li
class=
"nav-header"
>
Report
</li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/matrix?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
matrix
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/network?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
network
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/cdn?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
cdn
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/system?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
system
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/alteration?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
change
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/r/statistics?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
statistics
</a></li>
<li
class=
"nav-header"
>
System
</li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/s/alarm?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
alarm
</a></li>
<li><a
style=
"padding:3px 30px"
href=
"/cat/s/config?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
config
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/r/matrix?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
matrix
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/r/network?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
network
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/r/cdn?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
cdn
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/r/system?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
system
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/r/alteration?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
change
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/r/statistics?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
statistics
</a></li>
<li><a
style=
"padding:1px 30px"
href=
"/cat/s/alarm?domain=${model.domain}&ip=${model.ipAddress}&date=${model.date}&reportType=${payload.reportType}&op=${payload.action.name}"
>
alarm
</a></li>
</ul>
</li>
</ul>
...
...
@@ -67,7 +95,7 @@
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h
4
id=
"myModalLabel"
class=
"text-success text-center"
>
用户登录
</h4
>
<h
5
id=
"myModalLabel"
class=
"text-success text-center"
>
用户登录
</h5
>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label text-success"
for=
"account"
>
用户名
</label>
...
...
cat-home/src/main/webapp/jsp/system/alarm/alarmRecordDetail.jsp
浏览文件 @
f705887f
...
...
@@ -21,9 +21,6 @@
<a:body>
<res:useJs
value=
"
${
res
.
js
.
local
[
'alarm_js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'bootstrap.min.js'
]
}
"
target=
"head-js"
/>
<res:useCss
value=
'
${
res
.
css
.
local
.
table_css
}
'
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jquery.dataTables.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'tableInit.js'
]
}
"
target=
"head-js"
/>
...
...
cat-home/src/main/webapp/jsp/system/alarm/alarmRecordList.jsp
浏览文件 @
f705887f
...
...
@@ -9,12 +9,8 @@
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.system.page.alarm.Model"
scope=
"request"
/>
<a:body>
<res:useJs
value=
"
${
res
.
js
.
local
[
'alarm_js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'bootstrap.min.js'
]
}
"
target=
"head-js"
/>
<res:useCss
value=
'
${
res
.
css
.
local
.
table_css
}
'
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jquery.dataTables.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'tableInit.js'
]
}
"
target=
"head-js"
/>
<script
type=
"text/javascript"
>
...
...
cat-home/src/main/webapp/jsp/system/alarm/alarmTemplateUpdate.jsp
浏览文件 @
f705887f
...
...
@@ -11,9 +11,6 @@
<a:body>
<res:useJs
value=
"
${
res
.
js
.
local
[
'alarm_js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'bootstrap.min.js'
]
}
"
target=
"head-js"
/>
<res:useCss
value=
'
${
res
.
css
.
local
.
table_css
}
'
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jquery.dataTables.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'tableInit.js'
]
}
"
target=
"head-js"
/>
<script
type=
"text/javascript"
>
...
...
cat-home/src/main/webapp/jsp/system/alarm/scheduledReports.jsp
浏览文件 @
f705887f
...
...
@@ -10,9 +10,6 @@
<a:body>
<res:useJs
value=
"
${
res
.
js
.
local
[
'alarm_js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'bootstrap.min.js'
]
}
"
target=
"head-js"
/>
<res:useCss
value=
'
${
res
.
css
.
local
.
table_css
}
'
target=
"head-css"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'jquery.dataTables.min.js'
]
}
"
target=
"head-js"
/>
<res:useJs
value=
"
${
res
.
js
.
local
[
'tableInit.js'
]
}
"
target=
"head-js"
/>
<script
type=
"text/javascript"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录