Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
9c8a2b26
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,发现更多精彩内容 >>
提交
9c8a2b26
编写于
1月 12, 2012
作者:
F
Frankie Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
prepare cat-home
上级
d4a5fe21
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
596 addition
and
39 deletion
+596
-39
cat-consumer/pom.xml
cat-consumer/pom.xml
+0
-1
cat-core/pom.xml
cat-core/pom.xml
+0
-1
cat-core/src/main/java/com/dianping/cat/Cat.java
cat-core/src/main/java/com/dianping/cat/Cat.java
+55
-28
cat-core/src/main/java/com/dianping/cat/message/io/TcpSocketReceiver.java
...n/java/com/dianping/cat/message/io/TcpSocketReceiver.java
+11
-1
cat-core/src/main/resources/META-INF/dal/model/model.xml
cat-core/src/main/resources/META-INF/dal/model/model.xml
+0
-1
cat-home/pom.xml
cat-home/pom.xml
+4
-0
cat-home/src/main/java/com/dianping/cat/report/ReportModule.java
...e/src/main/java/com/dianping/cat/report/ReportModule.java
+2
-0
cat-home/src/main/java/com/dianping/cat/report/ReportPage.java
...ome/src/main/java/com/dianping/cat/report/ReportPage.java
+2
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Action.java
...java/com/dianping/cat/report/page/transaction/Action.java
+26
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Context.java
...ava/com/dianping/cat/report/page/transaction/Context.java
+7
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
...ava/com/dianping/cat/report/page/transaction/Handler.java
+41
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/JspFile.java
...ava/com/dianping/cat/report/page/transaction/JspFile.java
+17
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/JspViewer.java
...a/com/dianping/cat/report/page/transaction/JspViewer.java
+18
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Model.java
.../java/com/dianping/cat/report/page/transaction/Model.java
+34
-0
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Payload.java
...ava/com/dianping/cat/report/page/transaction/Payload.java
+36
-0
cat-home/src/main/java/com/dianping/cat/servlet/CatServlet.java
...me/src/main/java/com/dianping/cat/servlet/CatServlet.java
+95
-0
cat-home/src/main/resources/META-INF/cat/config.xsd
cat-home/src/main/resources/META-INF/cat/config.xsd
+37
-0
cat-home/src/main/resources/META-INF/cat/server.xml
cat-home/src/main/resources/META-INF/cat/server.xml
+3
-0
cat-home/src/main/resources/META-INF/plexus/components.xml
cat-home/src/main/resources/META-INF/plexus/components.xml
+22
-0
cat-home/src/main/resources/META-INF/wizard/webapp/wizard.xml
...home/src/main/resources/META-INF/wizard/webapp/wizard.xml
+1
-0
cat-home/src/main/webapp/WEB-INF/app.tld
cat-home/src/main/webapp/WEB-INF/app.tld
+39
-0
cat-home/src/main/webapp/WEB-INF/tags/body.tag
cat-home/src/main/webapp/WEB-INF/tags/body.tag
+28
-0
cat-home/src/main/webapp/WEB-INF/web.xml
cat-home/src/main/webapp/WEB-INF/web.xml
+29
-0
cat-home/src/main/webapp/jsp/report/home.jsp
cat-home/src/main/webapp/jsp/report/home.jsp
+1
-1
cat-home/src/main/webapp/jsp/report/transaction.jsp
cat-home/src/main/webapp/jsp/report/transaction.jsp
+78
-0
cat-home/src/test/java/com/dianping/cat/SimpleServer.java
cat-home/src/test/java/com/dianping/cat/SimpleServer.java
+4
-0
pom.xml
pom.xml
+6
-6
未找到文件。
cat-consumer/pom.xml
浏览文件 @
9c8a2b26
...
...
@@ -13,7 +13,6 @@
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-core
</artifactId>
<version>
1.0.0
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
...
...
cat-core/pom.xml
浏览文件 @
9c8a2b26
...
...
@@ -8,7 +8,6 @@
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
cat-core
</artifactId>
<version>
1.0.0
</version>
<name>
CAT Core
</name>
<dependencies>
<dependency>
...
...
cat-core/src/main/java/com/dianping/cat/Cat.java
浏览文件 @
9c8a2b26
...
...
@@ -21,43 +21,42 @@ import com.site.helper.Files;
* @author Frankie Wu
*/
public
class
Cat
{
public
static
final
String
CAT_C
ONFIG_XML
=
"/META-INF/cat/config
.xml"
;
public
static
final
String
CAT_C
LIENT_XML
=
"/META-INF/cat/client
.xml"
;
private
static
PlexusContainer
s_container
;
private
static
Cat
s_instance
=
new
Cat
()
;
private
static
MessageProducer
s_producer
;
private
volatile
boolean
m_initialized
;
private
static
MessageManager
s_manag
er
;
private
MessageProducer
m_produc
er
;
static
{
try
{
s_container
=
new
DefaultPlexusContainer
();
}
catch
(
PlexusContainerException
e
)
{
throw
new
RuntimeException
(
"Error when creating Plexus container, "
+
"please make sure the environment was setup correctly!"
,
e
);
}
private
MessageManager
m_manager
;
try
{
s_manager
=
(
MessageManager
)
s_container
.
lookup
(
MessageManager
.
class
);
}
catch
(
ComponentLookupException
e
)
{
throw
new
RuntimeException
(
"Unable to get instance of MessageManager, "
+
"please make sure the environment was setup correctly!"
,
e
);
}
private
Cat
()
{
}
try
{
s_producer
=
(
MessageProducer
)
s_container
.
lookup
(
MessageProducer
.
class
);
}
catch
(
ComponentLookupException
e
)
{
throw
new
RuntimeException
(
"Unable to get instance of MessageProducer, "
+
"please make sure the environment was setup correctly!"
,
e
);
static
Cat
getInstance
()
{
if
(!
s_instance
.
m_initialized
)
{
try
{
s_instance
.
setContainer
(
new
DefaultPlexusContainer
());
}
catch
(
PlexusContainerException
e
)
{
throw
new
RuntimeException
(
"Error when creating Plexus container, "
+
"please make sure the environment was setup correctly!"
,
e
);
}
}
return
s_instance
;
}
public
static
MessageProducer
getProducer
()
{
return
s
_producer
;
return
getInstance
().
m
_producer
;
}
// this should be called during application initialization time
public
static
void
initialize
(
File
configFile
)
{
initialize
(
null
,
configFile
);
}
public
static
void
initialize
(
PlexusContainer
container
,
File
configFile
)
{
Config
config
=
null
;
// read config from local file system
...
...
@@ -69,10 +68,10 @@ public class Cat {
}
if
(
config
==
null
)
{
InputStream
in
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
CAT_C
ONFIG
_XML
);
InputStream
in
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
CAT_C
LIENT
_XML
);
if
(
in
==
null
)
{
in
=
Cat
.
class
.
getResourceAsStream
(
CAT_C
ONFIG
_XML
);
in
=
Cat
.
class
.
getResourceAsStream
(
CAT_C
LIENT
_XML
);
}
if
(
in
!=
null
)
{
...
...
@@ -85,22 +84,50 @@ public class Cat {
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
);
}
else
{
throw
new
RuntimeException
(
"Cat has already been initialized before!"
);
}
}
if
(
config
!=
null
)
{
ClientConfigValidator
validator
=
new
ClientConfigValidator
();
config
.
accept
(
validator
);
s_manager
.
initialize
(
config
);
getInstance
().
m_manager
.
initialize
(
config
);
}
else
{
System
.
out
.
println
(
"[WARN] Cat is disabled!"
);
}
}
// this should be called when a thread ends to clean some thread local data
public
static
void
reset
()
{
s
_manager
.
reset
();
getInstance
().
m
_manager
.
reset
();
}
// this should be called when a thread starts to create some thread local
// data
public
static
void
setup
(
String
sessionToken
,
String
requestToken
)
{
s_manager
.
setup
(
sessionToken
,
requestToken
);
getInstance
().
m_manager
.
setup
(
sessionToken
,
requestToken
);
}
void
setContainer
(
PlexusContainer
container
)
{
m_initialized
=
true
;
try
{
m_manager
=
(
MessageManager
)
container
.
lookup
(
MessageManager
.
class
);
}
catch
(
ComponentLookupException
e
)
{
throw
new
RuntimeException
(
"Unable to get instance of MessageManager, "
+
"please make sure the environment was setup correctly!"
,
e
);
}
try
{
m_producer
=
(
MessageProducer
)
container
.
lookup
(
MessageProducer
.
class
);
}
catch
(
ComponentLookupException
e
)
{
throw
new
RuntimeException
(
"Unable to get instance of MessageProducer, "
+
"please make sure the environment was setup correctly!"
,
e
);
}
}
}
cat-core/src/main/java/com/dianping/cat/message/io/TcpSocketReceiver.java
浏览文件 @
9c8a2b26
...
...
@@ -3,6 +3,8 @@ package com.dianping.cat.message.io;
import
java.net.InetSocketAddress
;
import
java.util.concurrent.Executors
;
import
org.codehaus.plexus.logging.LogEnabled
;
import
org.codehaus.plexus.logging.Logger
;
import
org.jboss.netty.bootstrap.ServerBootstrap
;
import
org.jboss.netty.buffer.ChannelBuffer
;
import
org.jboss.netty.channel.Channel
;
...
...
@@ -27,7 +29,7 @@ import com.dianping.cat.message.spi.MessageTree;
import
com.dianping.cat.message.spi.internal.DefaultMessageTree
;
import
com.site.lookup.annotation.Inject
;
public
class
TcpSocketReceiver
implements
MessageReceiver
{
public
class
TcpSocketReceiver
implements
MessageReceiver
,
LogEnabled
{
@Inject
private
String
m_host
;
...
...
@@ -43,6 +45,13 @@ public class TcpSocketReceiver implements MessageReceiver {
private
MessageHandler
m_messageHandler
;
private
Logger
m_logger
;
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
}
@Override
public
void
initialize
()
{
InetSocketAddress
address
;
...
...
@@ -67,6 +76,7 @@ public class TcpSocketReceiver implements MessageReceiver {
bootstrap
.
setOption
(
"child.keepAlive"
,
true
);
bootstrap
.
bind
(
address
);
m_logger
.
info
(
"CAT server started at "
+
address
);
m_factory
=
factory
;
}
...
...
cat-core/src/main/resources/META-INF/dal/model/model.xml
浏览文件 @
9c8a2b26
...
...
@@ -9,7 +9,6 @@
<attribute
name=
"domain"
required=
"true"
/>
</entity>
<entity
name=
"server"
>
<attribute
name=
"ip"
required=
"true"
/>
<attribute
name=
"port"
default-value=
"2280"
/>
<attribute
name=
"enabled"
default-value=
"true"
/>
</entity>
...
...
cat-home/pom.xml
浏览文件 @
9c8a2b26
...
...
@@ -11,6 +11,10 @@
<name>
CAT Home
</name>
<packaging>
war
</packaging>
<dependencies>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-consumer
</artifactId>
</dependency>
<dependency>
<groupId>
com.site.app
</groupId>
<artifactId>
app-core
</artifactId>
...
...
cat-home/src/main/java/com/dianping/cat/report/ReportModule.java
浏览文件 @
9c8a2b26
...
...
@@ -9,6 +9,8 @@ import com.site.web.mvc.annotation.ModulePagesMeta;
com
.
dianping
.
cat
.
report
.
page
.
home
.
Handler
.
class
,
com
.
dianping
.
cat
.
report
.
page
.
transaction
.
Handler
.
class
,
})
public
class
ReportModule
extends
AbstractModule
{
...
...
cat-home/src/main/java/com/dianping/cat/report/ReportPage.java
浏览文件 @
9c8a2b26
...
...
@@ -7,6 +7,8 @@ public enum ReportPage implements Page {
HOME
(
"home"
,
"Home"
,
true
),
TRANSACTION
(
"transaction"
,
"Transaction"
,
true
),
;
private
String
m_name
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Action.java
0 → 100644
浏览文件 @
9c8a2b26
package
com.dianping.cat.report.page.transaction
;
public
enum
Action
implements
com
.
site
.
web
.
mvc
.
Action
{
VIEW
(
"view"
);
private
String
m_name
;
private
Action
(
String
name
)
{
m_name
=
name
;
}
public
static
Action
getByName
(
String
name
,
Action
defaultAction
)
{
for
(
Action
action
:
Action
.
values
())
{
if
(
action
.
getName
().
equals
(
name
))
{
return
action
;
}
}
return
defaultAction
;
}
@Override
public
String
getName
()
{
return
m_name
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Context.java
0 → 100644
浏览文件 @
9c8a2b26
package
com.dianping.cat.report.page.transaction
;
import
com.dianping.cat.report.ReportContext
;
public
class
Context
extends
ReportContext
<
Payload
>
{
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Handler.java
0 → 100644
浏览文件 @
9c8a2b26
package
com.dianping.cat.report.page.transaction
;
import
java.io.IOException
;
import
javax.servlet.ServletException
;
import
com.dianping.cat.consumer.transaction.TransactionReportMessageAnalyzer
;
import
com.dianping.cat.message.spi.MessageAnalyzer
;
import
com.dianping.cat.report.ReportPage
;
import
com.site.lookup.annotation.Inject
;
import
com.site.web.mvc.PageHandler
;
import
com.site.web.mvc.annotation.InboundActionMeta
;
import
com.site.web.mvc.annotation.OutboundActionMeta
;
import
com.site.web.mvc.annotation.PayloadMeta
;
public
class
Handler
implements
PageHandler
<
Context
>
{
@Inject
private
JspViewer
m_jspViewer
;
@Inject
(
type
=
MessageAnalyzer
.
class
,
value
=
"transaction"
)
private
TransactionReportMessageAnalyzer
m_analyzer
;
@Override
@PayloadMeta
(
Payload
.
class
)
@InboundActionMeta
(
name
=
"t"
)
public
void
handleInbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
// display only, no action here
}
@Override
@OutboundActionMeta
(
name
=
"t"
)
public
void
handleOutbound
(
Context
ctx
)
throws
ServletException
,
IOException
{
Model
model
=
new
Model
(
ctx
);
model
.
setAction
(
Action
.
VIEW
);
model
.
setPage
(
ReportPage
.
TRANSACTION
);
model
.
setReport
(
m_analyzer
.
generate
());
m_jspViewer
.
view
(
ctx
,
model
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/JspFile.java
0 → 100644
浏览文件 @
9c8a2b26
package
com.dianping.cat.report.page.transaction
;
public
enum
JspFile
{
VIEW
(
"/jsp/report/transaction.jsp"
),
;
private
String
m_path
;
private
JspFile
(
String
path
)
{
m_path
=
path
;
}
public
String
getPath
()
{
return
m_path
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/JspViewer.java
0 → 100644
浏览文件 @
9c8a2b26
package
com.dianping.cat.report.page.transaction
;
import
com.dianping.cat.report.ReportPage
;
import
com.site.web.mvc.view.BaseJspViewer
;
public
class
JspViewer
extends
BaseJspViewer
<
ReportPage
,
Action
,
Context
,
Model
>
{
@Override
protected
String
getJspFilePath
(
Context
ctx
,
Model
model
)
{
Action
action
=
model
.
getAction
();
switch
(
action
)
{
case
VIEW:
return
JspFile
.
VIEW
.
getPath
();
}
throw
new
RuntimeException
(
"Unknown action: "
+
action
);
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Model.java
0 → 100644
浏览文件 @
9c8a2b26
package
com.dianping.cat.report.page.transaction
;
import
com.dianping.cat.consumer.transaction.model.entity.TransactionReport
;
import
com.dianping.cat.consumer.transaction.model.transform.DefaultJsonBuilder
;
import
com.dianping.cat.report.ReportPage
;
import
com.site.web.mvc.ViewModel
;
public
class
Model
extends
ViewModel
<
ReportPage
,
Action
,
Context
>
{
private
TransactionReport
m_report
;
public
Model
(
Context
ctx
)
{
super
(
ctx
);
}
@Override
public
Action
getDefaultAction
()
{
return
Action
.
VIEW
;
}
public
TransactionReport
getReport
()
{
return
m_report
;
}
public
String
getReportInJson
()
{
DefaultJsonBuilder
builder
=
new
DefaultJsonBuilder
();
m_report
.
accept
(
builder
);
return
builder
.
getString
();
}
public
void
setReport
(
TransactionReport
report
)
{
m_report
=
report
;
}
}
cat-home/src/main/java/com/dianping/cat/report/page/transaction/Payload.java
0 → 100644
浏览文件 @
9c8a2b26
package
com.dianping.cat.report.page.transaction
;
import
com.dianping.cat.report.ReportPage
;
import
com.site.web.mvc.ActionContext
;
import
com.site.web.mvc.ActionPayload
;
import
com.site.web.mvc.payload.annotation.FieldMeta
;
public
class
Payload
implements
ActionPayload
<
ReportPage
,
Action
>
{
private
ReportPage
m_page
;
@FieldMeta
(
"op"
)
private
Action
m_action
;
public
void
setAction
(
Action
action
)
{
m_action
=
action
;
}
@Override
public
Action
getAction
()
{
return
m_action
;
}
@Override
public
ReportPage
getPage
()
{
return
m_page
;
}
@Override
public
void
setPage
(
String
page
)
{
m_page
=
ReportPage
.
getByName
(
page
,
ReportPage
.
TRANSACTION
);
}
@Override
public
void
validate
(
ActionContext
<?>
ctx
)
{
}
}
cat-home/src/main/java/com/dianping/cat/servlet/CatServlet.java
0 → 100644
浏览文件 @
9c8a2b26
package
com.dianping.cat.servlet
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.PrintWriter
;
import
javax.servlet.ServletConfig
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.configuration.model.entity.Config
;
import
com.dianping.cat.configuration.model.transform.DefaultParser
;
import
com.dianping.cat.message.spi.MessageHandler
;
import
com.dianping.cat.message.spi.MessageManager
;
import
com.dianping.cat.message.spi.internal.DefaultMessageHandler
;
import
com.site.helper.Files
;
import
com.site.web.AbstractContainerServlet
;
public
class
CatServlet
extends
AbstractContainerServlet
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
String
CAT_SERVER_XML
=
"/META-INF/cat/server.xml"
;
private
Exception
m_exception
;
@Override
protected
void
initComponents
(
ServletConfig
servletConfig
)
throws
ServletException
{
String
catServerXml
=
servletConfig
.
getInitParameter
(
"cat-server-xml"
);
Config
config
=
loadConfig
(
catServerXml
);
try
{
MessageManager
manager
=
lookup
(
MessageManager
.
class
);
manager
.
initialize
(
config
);
DefaultMessageHandler
handler
=
(
DefaultMessageHandler
)
lookup
(
MessageHandler
.
class
);
new
Thread
(
handler
).
start
();
}
catch
(
Exception
e
)
{
m_exception
=
e
;
throw
new
RuntimeException
(
"Error when initializing CatServlet, "
+
"please make sure the environment was setup correctly!"
,
e
);
}
}
protected
Config
loadConfig
(
String
configFile
)
{
Config
config
=
null
;
// read config from local file system
try
{
if
(
configFile
!=
null
)
{
String
xml
=
Files
.
forIO
().
readFrom
(
new
File
(
configFile
).
getCanonicalFile
(),
"utf-8"
);
config
=
new
DefaultParser
().
parse
(
xml
);
}
if
(
config
==
null
)
{
InputStream
in
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
CAT_SERVER_XML
);
if
(
in
==
null
)
{
in
=
Cat
.
class
.
getResourceAsStream
(
CAT_SERVER_XML
);
}
if
(
in
!=
null
)
{
String
xml
=
Files
.
forIO
().
readFrom
(
in
,
"utf-8"
);
config
=
new
DefaultParser
().
parse
(
xml
);
}
}
}
catch
(
Exception
e
)
{
m_exception
=
e
;
throw
new
RuntimeException
(
String
.
format
(
"Error when loading configuration file: %s!"
,
configFile
),
e
);
}
return
config
;
}
@Override
protected
void
service
(
HttpServletRequest
req
,
HttpServletResponse
res
)
throws
ServletException
,
IOException
{
res
.
setCharacterEncoding
(
"utf-8"
);
res
.
setContentType
(
"text/plain"
);
PrintWriter
writer
=
res
.
getWriter
();
if
(
m_exception
!=
null
)
{
writer
.
write
(
"Server has NOT been initialized successfully! \r\n\r\n"
);
m_exception
.
printStackTrace
(
writer
);
}
else
{
writer
.
write
(
"Not implemented yet!"
);
}
}
}
cat-home/src/main/resources/META-INF/cat/config.xsd
0 → 100644
浏览文件 @
9c8a2b26
<?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:schema>
cat-home/src/main/resources/META-INF/cat/server.xml
0 → 100644
浏览文件 @
9c8a2b26
<config
mode=
"server"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema"
xsi:noNamespaceSchemaLocation=
"config.xsd"
>
<bind
port=
"2280"
/>
</config>
\ No newline at end of file
cat-home/src/main/resources/META-INF/plexus/components.xml
浏览文件 @
9c8a2b26
...
...
@@ -26,5 +26,27 @@
<role>
com.dianping.cat.report.page.home.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.home.JspViewer
</implementation>
</component>
<component>
<role>
com.dianping.cat.report.page.transaction.Handler
</role>
<implementation>
com.dianping.cat.report.page.transaction.Handler
</implementation>
<requirements>
<requirement>
<role>
com.dianping.cat.report.page.transaction.JspViewer
</role>
</requirement>
<requirement>
<role>
com.dianping.cat.message.spi.MessageAnalyzer
</role>
<role-hint>
transaction
</role-hint>
<field-name>
m_analyzer
</field-name>
</requirement>
</requirements>
</component>
<component>
<role>
com.dianping.cat.report.page.transaction.JspViewer
</role>
<implementation>
com.dianping.cat.report.page.transaction.JspViewer
</implementation>
</component>
<component>
<role>
com.dianping.cat.consumer.transaction.TransactionReportMessageAnalyzer
</role>
<implementation>
com.dianping.cat.consumer.transaction.TransactionReportMessageAnalyzer
</implementation>
</component>
</components>
</plexus>
cat-home/src/main/resources/META-INF/wizard/webapp/wizard.xml
浏览文件 @
9c8a2b26
...
...
@@ -2,6 +2,7 @@
<wizard
package=
"com.dianping.cat"
webres=
"false"
>
<module
name=
"report"
path=
"r"
>
<page
name=
"home"
description=
"Home"
default=
"true"
/>
<page
name=
"transaction"
description=
"Transaction"
/>
</module>
</wizard>
cat-home/src/main/webapp/WEB-INF/app.tld
0 → 100644
浏览文件 @
9c8a2b26
<?xml version="1.0" encoding="UTF-8"?>
<taglib
xmlns=
"http://java.sun.com/xml/ns/j2ee"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version=
"2.0"
>
<description>
Application Specific JSP Tag Library
</description>
<tlib-version>
1.0
</tlib-version>
<short-name>
a
</short-name>
<tag>
<name>
errors
</name>
<tag-class>
com.dianping.garden.view.ErrorsTag
</tag-class>
<body-content>
JSP
</body-content>
</tag>
<tag-file>
<name>
body
</name>
<path>
/WEB-INF/tags/body.tag
</path>
</tag-file>
<function>
<description>
Build form action for given id
</description>
<name>
action
</name>
<function-class>
com.dianping.garden.view.UriBuilder
</function-class>
<function-signature>
String action(com.site.web.mvc.ViewModel, java.lang.Object)
</function-signature>
<example>
${a:action(model, 123)}
</example>
</function>
<function>
<description>
Build uri for given id
</description>
<name>
uri
</name>
<function-class>
com.dianping.garden.view.UriBuilder
</function-class>
<function-signature>
String uri(com.site.web.mvc.ViewModel, java.lang.Object)
</function-signature>
<example>
${a:uri(model, 123)}
</example>
</function>
<function>
<description>
Build uri for given id with additional query string
</description>
<name>
uri2
</name>
<function-class>
com.dianping.garden.view.UriBuilder
</function-class>
<function-signature>
String uri2(com.site.web.mvc.ViewModel, java.lang.Object, java.lang.String)
</function-signature>
<example>
${a:uri2(model, 123, 'a=1
&
b=2')}
</example>
</function>
</taglib>
\ No newline at end of file
cat-home/src/main/webapp/WEB-INF/tags/body.tag
0 → 100644
浏览文件 @
9c8a2b26
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<
%@
taglib
prefix=
"res"
uri=
"http://www.ebay.com/webres"
%
>
<jsp:useBean
id=
"navBar"
class=
"com.dianping.garden.view.NavigationBar"
scope=
"page"
/>
<res:bean
id=
"res"
/>
<html>
<head>
<title>
Garden - ${model.page.description}
</title>
<meta
http-equiv=
"content-type"
content=
"text/html; charset=UTF-8"
/>
<res:cssSlot
id=
"head-css"
/>
<res:jsSlot
id=
"head-js"
/>
<res:useCss
value=
'${res.css.local.default_css}'
target=
"head-css"
/>
</head>
<body>
<h1>
${model.page.description}
</h1>
<ul
class=
"tabs"
>
<c:forEach
var=
"page"
items=
"${navBar.visiblePages}"
>
<c:if
test=
"${page.realPage}"
>
<li
${
model.page.name =
=
page.name
?
'
class=
"selected"
'
:
''}
><a
href=
"${model.webapp}/${page.moduleName}/${page.name}"
>
${page.description}
</a></li>
</c:if>
</c:forEach>
</ul>
<jsp:doBody
/>
</body>
</html>
cat-home/src/main/webapp/WEB-INF/web.xml
0 → 100644
浏览文件 @
9c8a2b26
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns=
"http://java.sun.com/xml/ns/javaee"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version=
"2.5"
>
<servlet>
<servlet-name>
mvc-servlet
</servlet-name>
<servlet-class>
com.site.web.MVC
</servlet-class>
<load-on-startup>
1
</load-on-startup>
</servlet>
<servlet>
<servlet-name>
cat-servlet
</servlet-name>
<servlet-class>
com.dianping.cat.servlet.CatServlet
</servlet-class>
<load-on-startup>
2
</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>
mvc-servlet
</servlet-name>
<url-pattern>
/r/*
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
cat-servlet
</servlet-name>
<url-pattern>
/s/*
</url-pattern>
</servlet-mapping>
<jsp-config>
<taglib>
<taglib-uri>
/WEB-INF/app.tld
</taglib-uri>
<taglib-location>
/WEB-INF/app.tld
</taglib-location>
</taglib>
</jsp-config>
</web-app>
cat-home/src/main/webapp/jsp/report/home.jsp
浏览文件 @
9c8a2b26
...
...
@@ -3,4 +3,4 @@
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.home.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.home.Model"
scope=
"request"
/>
View of home page under report
\ No newline at end of file
View of home page under report....
\ No newline at end of file
cat-home/src/main/webapp/jsp/report/transaction.jsp
0 → 100644
浏览文件 @
9c8a2b26
<%@ page
contentType=
"text/html; charset=utf-8"
%>
<jsp:useBean
id=
"ctx"
type=
"com.dianping.cat.report.page.transaction.Context"
scope=
"request"
/>
<jsp:useBean
id=
"payload"
type=
"com.dianping.cat.report.page.transaction.Payload"
scope=
"request"
/>
<jsp:useBean
id=
"model"
type=
"com.dianping.cat.report.page.transaction.Model"
scope=
"request"
/>
<!DOCTYPE HTML>
<html>
<head>
<meta
charset=
"utf-8"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"../jquery/jquery-ui-1.8.16.custom.css"
/>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"../jquery/ui.jqgrid.css"
/>
<script
type=
"text/javascript"
src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
></script>
<script
type=
"text/javascript"
src=
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"
></script>
<script
type=
"text/javascript"
src=
"../jquery/grid.locale-en.js"
></script>
<script
type=
"text/javascript"
src=
"../jquery/jquery.jqGrid.min.js"
></script>
</head>
<body>
<script
type=
"text/javascript"
>
var
data
=
{
"
transaction-report
"
:
$
{
model
.
reportInJson
}
};
var
tabledata
=
[];
$
(
function
(){
var
types
=
data
[
"
transaction-report
"
][
"
type
"
];
for
(
i
in
types
)
{
var
type
=
types
[
i
];
var
sampleid
=
type
.
failid
==
null
?
type
.
successid
:
type
.
failid
;
var
stat
=
""
+
type
.
min
+
"
/
"
+
type
.
max
+
"
/
"
+
type
.
avg
+
"
/
"
+
type
.
std
;
tabledata
.
push
({
"
type
"
:
type
.
id
,
"
total
"
:
type
.
totalCount
,
"
fail
"
:
type
.
failCount
,
"
failPercent
"
:
type
.
failPercent
,
"
sample
"
:
sampleid
,
"
stat
"
:
stat
});
}
}
);
$
(
function
()
{
$
(
"
#gridTable
"
).
jqGrid
({
datatype
:
"
local
"
,
colNames
:[
'
Type
'
,
'
TotalCount
'
,
'
FailCount
'
,
'
Fail%
'
,
'
Sample Link
'
,
'
M/M/A/µ
'
],
colModel
:[
{
name
:
'
type
'
,
index
:
'
type
'
},
{
name
:
'
total
'
,
index
:
'
total
'
,
sorttype
:
"
int
"
},
{
name
:
'
fail
'
,
index
:
'
fail
'
,
sorttype
:
"
int
"
},
{
name
:
'
failPercent
'
,
index
:
'
failPercent
'
,
sorttype
:
"
float
"
},
{
name
:
'
sample
'
,
index
:
'
sample
'
},
{
name
:
'
stat
'
}
],
sortname
:
'
type
'
,
sortorder
:
'
asc
'
,
caption
:
"
Transaction Report
"
,
height
:
250
,
loadComplete
:
function
()
{
var
grid
=
$
(
"
#gridTable
"
);
var
ids
=
grid
.
getDataIDs
();
for
(
var
i
=
0
;
i
<
ids
.
length
;
i
++
)
{
grid
.
setRowData
(
ids
[
i
],
false
,
{
height
:
20
}
);
}
grid
.
setGridHeight
(
'
auto
'
);
}
}).
navGrid
(
'
#pager2
'
,{
edit
:
false
,
add
:
false
,
del
:
false
});
for
(
var
i
=
0
;
i
<=
tabledata
.
length
;
i
++
)
{
jQuery
(
"
#gridTable
"
).
jqGrid
(
'
addRowData
'
,
i
+
1
,
tabledata
[
i
]);
}
}
);
</script>
<table
id=
"gridTable"
></table>
<div
id=
"gridPager"
></div>
</body>
</html>
\ No newline at end of file
cat-home/src/test/java/com/dianping/cat/SimpleServer.java
浏览文件 @
9c8a2b26
...
...
@@ -12,6 +12,7 @@ import org.mortbay.jetty.servlet.Context;
import
org.mortbay.jetty.servlet.ServletHolder
;
import
org.mortbay.servlet.GzipFilter
;
import
com.dianping.cat.servlet.CatServlet
;
import
com.ebay.webres.server.support.SimpleServerSupport
;
import
com.ebay.webres.taglib.support.JettyTestSupport
;
import
com.site.lookup.ComponentTestCase
;
...
...
@@ -22,6 +23,8 @@ public class SimpleServer extends SimpleServerSupport {
private
static
ComponentAdaptor
s_adaptor
=
new
ComponentAdaptor
();
private
static
MVC
s_mvc
=
new
MVC
();
private
static
CatServlet
s_cat
=
new
CatServlet
();
@AfterClass
public
static
void
afterClass
()
throws
Exception
{
...
...
@@ -69,6 +72,7 @@ public class SimpleServer extends SimpleServerSupport {
@Override
protected
void
postConfigure
(
Context
ctx
)
{
ctx
.
addServlet
(
new
ServletHolder
(
s_mvc
),
"/r/*"
);
ctx
.
addServlet
(
new
ServletHolder
(
s_cat
),
"/s/*"
);
ctx
.
addFilter
(
GzipFilter
.
class
,
"/r/*"
,
Handler
.
ALL
);
super
.
postConfigure
(
ctx
);
}
...
...
pom.xml
浏览文件 @
9c8a2b26
...
...
@@ -18,18 +18,18 @@
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-core
</artifactId>
<version>
1.0.0
</version>
<version>
0.1.0
</version>
</dependency>
<dependency>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-consumer
</artifactId>
<version>
0.1.0
</version>
</dependency>
<dependency>
<groupId>
com.site.common
</groupId>
<artifactId>
lookup
</artifactId>
<version>
1.0.0
</version>
</dependency>
<dependency>
<groupId>
com.site.common
</groupId>
<artifactId>
test-framework
</artifactId>
<version>
1.0.0
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录