Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
58e00dfd
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,发现更多精彩内容 >>
提交
58e00dfd
编写于
7月 16, 2014
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #398 from youyong205/master
refactor
上级
f9097d9b
783adcd0
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
317 addition
and
172 deletion
+317
-172
cat-broker/pom.xml
cat-broker/pom.xml
+0
-12
cat-broker/src/main/java/com/dianping/cat/broker/api/app/AppData.java
...rc/main/java/com/dianping/cat/broker/api/app/AppData.java
+150
-0
cat-broker/src/main/java/com/dianping/cat/broker/api/app/AppDataConsumer.java
...java/com/dianping/cat/broker/api/app/AppDataConsumer.java
+1
-4
cat-broker/src/main/java/com/dianping/cat/broker/api/app/AppDataQueue.java
...in/java/com/dianping/cat/broker/api/app/AppDataQueue.java
+1
-3
cat-broker/src/main/java/com/dianping/cat/broker/api/app/BucketHandler.java
...n/java/com/dianping/cat/broker/api/app/BucketHandler.java
+15
-7
cat-broker/src/main/java/com/dianping/cat/broker/api/page/batch/Handler.java
.../java/com/dianping/cat/broker/api/page/batch/Handler.java
+28
-41
cat-broker/src/main/resources/META-INF/dal/model/appData-codegen.xml
...src/main/resources/META-INF/dal/model/appData-codegen.xml
+0
-19
cat-broker/src/main/resources/META-INF/dal/model/appData-manifest.xml
...rc/main/resources/META-INF/dal/model/appData-manifest.xml
+0
-6
cat-broker/src/main/resources/META-INF/dal/model/appData-model.xml
...r/src/main/resources/META-INF/dal/model/appData-model.xml
+0
-3
cat-broker/src/test/java/com/dianping/cat/broker/AppTest.java
...broker/src/test/java/com/dianping/cat/broker/AppTest.java
+5
-2
cat-core/src/main/java/com/dianping/cat/config/app/AppConfigManager.java
...in/java/com/dianping/cat/config/app/AppConfigManager.java
+35
-7
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
...main/java/com/dianping/cat/config/app/AppDataService.java
+15
-36
cat-core/src/main/resources/META-INF/dal/jdbc/app-dal.xml
cat-core/src/main/resources/META-INF/dal/jdbc/app-dal.xml
+7
-3
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
...n/java/com/dianping/cat/build/ComponentsConfigurator.java
+3
-0
cat-home/src/main/java/com/dianping/cat/report/page/app/Handler.java
...c/main/java/com/dianping/cat/report/page/app/Handler.java
+1
-1
cat-home/src/main/java/com/dianping/cat/report/page/app/Model.java
...src/main/java/com/dianping/cat/report/page/app/Model.java
+8
-8
cat-home/src/main/java/com/dianping/cat/report/page/app/graph/AppGraphCreator.java
...m/dianping/cat/report/page/app/graph/AppGraphCreator.java
+3
-3
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/CityManager.java
...com/dianping/cat/report/page/userMonitor/CityManager.java
+1
-1
cat-home/src/main/resources/config/default-app-config.xml
cat-home/src/main/resources/config/default-app-config.xml
+33
-3
cat-home/src/main/webapp/jsp/report/app.jsp
cat-home/src/main/webapp/jsp/report/app.jsp
+10
-12
script/Cat.sql
script/Cat.sql
+1
-1
未找到文件。
cat-broker/pom.xml
浏览文件 @
58e00dfd
...
...
@@ -132,18 +132,6 @@
<env>
dev
</env>
</configuration>
</execution>
<execution>
<id>
generate dal model files
</id>
<phase>
generate-sources
</phase>
<goals>
<goal>
dal-model
</goal>
</goals>
<configuration>
<manifest>
<![CDATA[
${basedir}/src/main/resources/META-INF/dal/model/appData-manifest.xml,
]]>
</manifest>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
...
...
cat-broker/src/main/java/com/dianping/cat/broker/api/app/AppData.java
0 → 100644
浏览文件 @
58e00dfd
package
com.dianping.cat.broker.api.app
;
public
class
AppData
{
private
long
m_timestamp
;
private
int
m_city
;
private
int
m_operator
;
private
int
m_network
;
private
int
m_version
;
private
int
m_connectType
;
private
int
m_command
;
private
int
m_code
;
private
int
m_platform
;
private
int
m_count
;
private
int
m_requestByte
;
private
int
m_responseByte
;
private
int
m_responseTime
;
public
AppData
()
{
}
public
int
getCity
()
{
return
m_city
;
}
public
int
getCode
()
{
return
m_code
;
}
public
int
getCommand
()
{
return
m_command
;
}
public
int
getConnectType
()
{
return
m_connectType
;
}
public
int
getCount
()
{
return
m_count
;
}
public
int
getNetwork
()
{
return
m_network
;
}
public
int
getOperator
()
{
return
m_operator
;
}
public
int
getPlatform
()
{
return
m_platform
;
}
public
int
getRequestByte
()
{
return
m_requestByte
;
}
public
int
getResponseByte
()
{
return
m_responseByte
;
}
public
int
getResponseTime
()
{
return
m_responseTime
;
}
public
long
getTimestamp
()
{
return
m_timestamp
;
}
public
int
getVersion
()
{
return
m_version
;
}
public
AppData
setCity
(
int
city
)
{
m_city
=
city
;
return
this
;
}
public
AppData
setCode
(
int
code
)
{
m_code
=
code
;
return
this
;
}
public
AppData
setCommand
(
int
command
)
{
m_command
=
command
;
return
this
;
}
public
AppData
setConnectType
(
int
connectType
)
{
m_connectType
=
connectType
;
return
this
;
}
public
AppData
setCount
(
int
count
)
{
m_count
=
count
;
return
this
;
}
public
AppData
setNetwork
(
int
network
)
{
m_network
=
network
;
return
this
;
}
public
AppData
setOperator
(
int
operator
)
{
m_operator
=
operator
;
return
this
;
}
public
AppData
setPlatform
(
int
platform
)
{
m_platform
=
platform
;
return
this
;
}
public
AppData
setRequestByte
(
int
requestByte
)
{
m_requestByte
=
requestByte
;
return
this
;
}
public
AppData
setResponseByte
(
int
responseByte
)
{
m_responseByte
=
responseByte
;
return
this
;
}
public
AppData
setResponseTime
(
int
responseTime
)
{
m_responseTime
=
responseTime
;
return
this
;
}
public
AppData
setTimestamp
(
long
timestamp
)
{
m_timestamp
=
timestamp
;
return
this
;
}
public
AppData
setVersion
(
int
version
)
{
m_version
=
version
;
return
this
;
}
}
cat-broker/src/main/java/com/dianping/cat/broker/api/app/AppDataConsumer.java
浏览文件 @
58e00dfd
...
...
@@ -12,7 +12,6 @@ import org.unidal.lookup.annotation.Inject;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.config.app.AppDataService
;
import
com.dianping.cat.service.appData.entity.AppData
;
public
class
AppDataConsumer
implements
Initializable
,
LogEnabled
{
...
...
@@ -44,7 +43,6 @@ public class AppDataConsumer implements Initializable, LogEnabled {
@Override
public
void
initialize
()
throws
InitializationException
{
m_dataLoss
=
0
;
m_appDataQueue
=
new
AppDataQueue
();
m_tasks
=
new
ConcurrentHashMap
<
Long
,
BucketHandler
>();
AppDataDispatcherThread
appDataDispatcherThread
=
new
AppDataDispatcherThread
();
...
...
@@ -136,7 +134,6 @@ public class AppDataConsumer implements Initializable, LogEnabled {
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
long
elapsedTime
=
System
.
currentTimeMillis
()
-
curTime
;
try
{
...
...
@@ -169,6 +166,6 @@ public class AppDataConsumer implements Initializable, LogEnabled {
m_tasks
.
put
(
next
,
nextBucketHandler
);
}
}
}
}
cat-broker/src/main/java/com/dianping/cat/broker/api/app/AppDataQueue.java
浏览文件 @
58e00dfd
...
...
@@ -4,10 +4,8 @@ import java.util.concurrent.BlockingQueue;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
com.dianping.cat.service.appData.entity.AppData
;
public
class
AppDataQueue
{
private
BlockingQueue
<
AppData
>
m_dataQueue
=
new
LinkedBlockingQueue
<
AppData
>();
private
BlockingQueue
<
AppData
>
m_dataQueue
=
new
LinkedBlockingQueue
<
AppData
>(
10000
);
public
boolean
offer
(
AppData
appData
)
{
return
m_dataQueue
.
offer
(
appData
);
...
...
cat-broker/src/main/java/com/dianping/cat/broker/api/app/BucketHandler.java
浏览文件 @
58e00dfd
...
...
@@ -12,16 +12,15 @@ import org.unidal.helper.Threads.Task;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.config.app.AppDataService
;
import
com.dianping.cat.service.appData.entity.AppData
;
public
class
BucketHandler
implements
Task
{
private
static
final
String
FILEDIRECTORY
=
"/data/appdatas/cat/app/"
;
private
static
int
ONE_DAY
=
24
*
60
*
60
*
1000
;
private
static
int
ONE_MINUTE
=
60
*
1000
;
private
static
int
ONE_DAY
=
24
*
60
*
ONE_MINUTE
;
private
AppDataQueue
m_appDataQueue
;
private
AppDataService
m_appDataService
;
...
...
@@ -65,10 +64,19 @@ public class BucketHandler implements Task {
}
private
void
processEntity
(
AppData
appData
)
{
Integer
command
=
appData
.
getCommand
();
String
key
=
m_startTime
+
":"
+
appData
.
getCity
()
+
":"
+
appData
.
getOperator
()
+
":"
+
appData
.
getConnectType
()
+
":"
+
appData
.
getVersion
()
+
":"
+
appData
.
getNetwork
()
+
":"
+
appData
.
getCode
()
+
":"
+
appData
.
getPlatform
();
int
command
=
appData
.
getCommand
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
m_startTime
).
append
(
":"
);
sb
.
append
(
appData
.
getCity
()).
append
(
":"
);
sb
.
append
(
appData
.
getOperator
()).
append
(
":"
);
sb
.
append
(
appData
.
getConnectType
()).
append
(
":"
);
sb
.
append
(
appData
.
getVersion
()).
append
(
":"
);
sb
.
append
(
appData
.
getNetwork
()).
append
(
":"
);
sb
.
append
(
appData
.
getCode
()).
append
(
":"
);
sb
.
append
(
appData
.
getPlatform
());
String
key
=
sb
.
toString
();
HashMap
<
String
,
AppData
>
secondMap
=
m_mergedData
.
get
(
command
);
if
(
secondMap
==
null
)
{
...
...
cat-broker/src/main/java/com/dianping/cat/broker/api/page/batch/Handler.java
浏览文件 @
58e00dfd
package
com.dianping.cat.broker.api.page.batch
;
import
java.io.IOException
;
import
java.util.List
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -16,6 +15,7 @@ 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.broker.api.app.AppData
;
import
com.dianping.cat.broker.api.app.AppDataConsumer
;
import
com.dianping.cat.broker.api.page.Constrants
;
import
com.dianping.cat.broker.api.page.IpService
;
...
...
@@ -24,8 +24,6 @@ import com.dianping.cat.broker.api.page.MonitorEntity;
import
com.dianping.cat.broker.api.page.MonitorManager
;
import
com.dianping.cat.broker.api.page.RequestUtils
;
import
com.dianping.cat.config.app.AppConfigManager
;
import
com.dianping.cat.configuration.app.entity.Item
;
import
com.dianping.cat.service.appData.entity.AppData
;
public
class
Handler
implements
PageHandler
<
Context
>,
LogEnabled
{
...
...
@@ -34,18 +32,18 @@ public class Handler implements PageHandler<Context>, LogEnabled {
@Inject
private
IpService
m_ipService
;
@Inject
private
AppConfigManager
m_appConfigManager
;
private
Logger
m_logger
;
@Inject
private
MonitorManager
m_manager
;
@Inject
private
RequestUtils
m_util
;
private
Logger
m_logger
;
@Override
public
void
enableLogging
(
Logger
logger
)
{
m_logger
=
logger
;
...
...
@@ -121,42 +119,33 @@ public class Handler implements PageHandler<Context>, LogEnabled {
if
(
userIp
!=
null
)
{
String
content
=
payload
.
getContent
();
String
records
[]
=
content
.
split
(
"\n"
);
IpInfo
ipInfo
=
m_ipService
.
findIpInfoByString
(
userIp
);
String
cityStr
=
ipInfo
.
getProvince
();
String
province
=
ipInfo
.
getProvince
();
String
operatorStr
=
ipInfo
.
getChannel
();
int
cityId
=
0
,
operatorId
=
0
;
List
<
Item
>
cityList
=
m_appConfigManager
.
queryConfigItem
(
AppConfigManager
.
CITY
);
List
<
Item
>
operatorList
=
m_appConfigManager
.
queryConfigItem
(
AppConfigManager
.
OPERATOR
);
for
(
Item
item
:
cityList
)
{
if
(
item
.
getName
().
equals
(
cityStr
))
{
cityId
=
item
.
getId
();
break
;
}
}
for
(
Item
item
:
operatorList
)
{
if
(
item
.
getName
().
equals
(
operatorStr
))
{
operatorId
=
item
.
getId
();
break
;
Integer
cityId
=
m_appConfigManager
.
getCities
().
get
(
province
);
Integer
operatorId
=
m_appConfigManager
.
getOperators
().
get
(
operatorStr
);
if
(
cityId
!=
null
&&
operatorId
!=
null
)
{
for
(
String
record
:
records
)
{
processOneRecord
(
cityId
,
operatorId
,
record
);
}
}
for
(
String
record
:
records
)
{
String
items
[]
=
record
.
split
(
"\t"
);
}
else
{
m_logger
.
info
(
"unknown http request, x-forwarded-for:"
+
request
.
getHeader
(
"x-forwarded-for"
));
}
}
if
(
items
.
length
!=
10
)
{
continue
;
}
private
void
processOneRecord
(
int
cityId
,
int
operatorId
,
String
record
)
{
String
items
[]
=
record
.
split
(
"\t"
);
AppData
appData
=
new
AppData
();
if
(
items
.
length
==
10
)
{
AppData
appData
=
new
AppData
();
try
{
appData
.
setTimestamp
(
Long
.
parseLong
(
items
[
0
]));
Integer
command
=
m_appConfigManager
.
getCommands
().
get
(
items
[
2
]);
if
(
command
==
null
)
{
continue
;
}
try
{
appData
.
setTimestamp
(
Long
.
parseLong
(
items
[
0
]));
Integer
command
=
m_appConfigManager
.
getCommands
().
get
(
items
[
2
]);
if
(
command
!=
null
)
{
appData
.
setCommand
(
command
);
appData
.
setNetwork
(
Integer
.
parseInt
(
items
[
2
]));
appData
.
setVersion
(
Integer
.
parseInt
(
items
[
3
]));
...
...
@@ -169,14 +158,12 @@ public class Handler implements PageHandler<Context>, LogEnabled {
appData
.
setCity
(
cityId
);
appData
.
setOperator
(
operatorId
);
appData
.
setCount
(
1
);
}
catch
(
Exception
e
)
{
m_
logger
.
error
(
e
.
getMessage
(),
e
);
m_
appDataConsumer
.
enqueue
(
appData
);
}
m_
appDataConsumer
.
enqueue
(
appData
);
}
catch
(
Exception
e
)
{
m_
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
else
{
m_logger
.
info
(
"unknown http request, x-forwarded-for:"
+
request
.
getHeader
(
"x-forwarded-for"
));
}
}
...
...
cat-broker/src/main/resources/META-INF/dal/model/appData-codegen.xml
已删除
100644 → 0
浏览文件 @
f9097d9b
<?xml version="1.0" encoding="UTF-8"?>
<model>
<entity
name=
"appData"
root=
"true"
>
<attribute
name=
"timestamp"
value-type=
"long"
/>
<attribute
name=
"city"
value-type=
"int"
/>
<attribute
name=
"operator"
value-type=
"int"
/>
<attribute
name=
"network"
value-type=
"int"
/>
<attribute
name=
"version"
value-type=
"int"
/>
<attribute
name=
"connectType"
value-type=
"int"
/>
<attribute
name=
"command"
value-type=
"int"
/>
<attribute
name=
"code"
value-type=
"int"
/>
<attribute
name=
"platform"
value-type=
"int"
/>
<attribute
name=
"count"
value-type=
"int"
/>
<attribute
name=
"requestByte"
value-type=
"int"
/>
<attribute
name=
"responseByte"
value-type=
"int"
/>
<attribute
name=
"responseTime"
value-type=
"int"
/>
</entity>
</model>
cat-broker/src/main/resources/META-INF/dal/model/appData-manifest.xml
已删除
100644 → 0
浏览文件 @
f9097d9b
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<file
path=
"appData-codegen.xml"
/>
<file
path=
"appData-model.xml"
/>
</manifest>
cat-broker/src/main/resources/META-INF/dal/model/appData-model.xml
已删除
100644 → 0
浏览文件 @
f9097d9b
<?xml version="1.0" encoding="UTF-8"?>
<model
model-package=
"com.dianping.cat.service.appData"
/>
cat-broker/src/test/java/com/dianping/cat/broker/AppTest.java
浏览文件 @
58e00dfd
...
...
@@ -2,6 +2,7 @@ package com.dianping.cat.broker;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLEncoder
;
...
...
@@ -9,12 +10,14 @@ import java.util.ArrayList;
import
java.util.List
;
public
class
AppTest
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
throws
UnsupportedEncodingException
{
List
<
String
>
urls
=
new
ArrayList
<
String
>();
String
url_pre
=
"http://localhost:2765/broker-service/api/batch"
;
long
timestamp
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
urls
.
add
(
url_pre
+
"?v=2&c="
+
timestamp
+
URLEncoder
.
encode
(
"\tshop.bin\t1\t1\t1\t1\t1\t1\t1\t1\n"
));
urls
.
add
(
url_pre
+
"?v=2&c="
+
timestamp
+
URLEncoder
.
encode
(
"\tshop.bin\t1\t1\t1\t1\t1\t1\t1\t1\n"
,
"utf-8"
));
}
for
(
String
url
:
urls
)
{
...
...
cat-core/src/main/java/com/dianping/cat/config/app/AppConfigManager.java
浏览文件 @
58e00dfd
...
...
@@ -34,6 +34,10 @@ public class AppConfigManager implements Initializable {
private
Map
<
String
,
Integer
>
m_commands
=
new
HashMap
<
String
,
Integer
>();
private
Map
<
String
,
Integer
>
m_cities
=
new
HashMap
<
String
,
Integer
>();
private
Map
<
String
,
Integer
>
m_operators
=
new
HashMap
<
String
,
Integer
>();
private
int
m_configId
;
private
static
final
String
CONFIG_NAME
=
"app-config"
;
...
...
@@ -52,7 +56,7 @@ public class AppConfigManager implements Initializable {
public
static
String
CITY
=
"城市"
;
public
static
String
C
HANNEL
=
"渠道
"
;
public
static
String
C
ONNECT_TYPE
=
"连接类型
"
;
public
AppConfig
getConfig
()
{
return
m_config
;
...
...
@@ -128,15 +132,39 @@ public class AppConfigManager implements Initializable {
public
Map
<
String
,
Integer
>
getCommands
()
{
return
m_commands
;
}
public
Map
<
String
,
Integer
>
getCities
()
{
return
m_cities
;
}
private
void
refreshCommand
()
{
Collection
<
Command
>
commands
=
m_config
.
getCommands
().
values
();
public
Map
<
String
,
Integer
>
getOperators
()
{
return
m_operators
;
}
m_commands
.
clear
();
private
void
refreshData
()
{
Collection
<
Command
>
commands
=
m_config
.
getCommands
().
values
();
Map
<
String
,
Integer
>
commandMap
=
new
HashMap
<
String
,
Integer
>();
for
(
Command
c
:
commands
)
{
m_commands
.
put
(
c
.
getName
(),
c
.
getId
());
commandMap
.
put
(
c
.
getName
(),
c
.
getId
());
}
m_commands
=
commandMap
;
Map
<
String
,
Integer
>
cityMap
=
new
HashMap
<
String
,
Integer
>();
ConfigItem
cities
=
m_config
.
findConfigItem
(
CITY
);
for
(
Item
item:
cities
.
getItems
().
values
()){
cityMap
.
put
(
item
.
getName
(),
item
.
getId
());
}
m_cities
=
cityMap
;
Map
<
String
,
Integer
>
operatorMap
=
new
HashMap
<
String
,
Integer
>();
ConfigItem
operations
=
m_config
.
findConfigItem
(
OPERATOR
);
for
(
Item
item:
operations
.
getItems
().
values
()){
operatorMap
.
put
(
item
.
getName
(),
item
.
getId
());
}
m_operators
=
operatorMap
;
}
public
Collection
<
Item
>
queryConfigItems
(
String
key
)
{
...
...
@@ -159,7 +187,7 @@ public class AppConfigManager implements Initializable {
AppConfig
appConfig
=
DefaultSaxParser
.
parse
(
content
);
m_config
=
appConfig
;
refresh
Command
();
refresh
Data
();
m_modifyTime
=
modifyTime
;
}
}
...
...
@@ -175,7 +203,7 @@ public class AppConfigManager implements Initializable {
config
.
setContent
(
m_config
.
toString
());
m_configDao
.
updateByPK
(
config
,
ConfigEntity
.
UPDATESET_FULL
);
refresh
Command
();
refresh
Data
();
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
return
false
;
...
...
cat-core/src/main/java/com/dianping/cat/config/app/AppDataService.java
浏览文件 @
58e00dfd
package
com.dianping.cat.config.app
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedList
;
...
...
@@ -72,16 +70,8 @@ public class AppDataService {
List
<
AppDataCommand
>
datas
;
try
{
datas
=
m_dao
.
findData
(
commandId
,
period
,
city
,
operator
,
network
,
appVersion
,
connnectType
,
code
,
platform
,
AppDataCommandEntity
.
READSET_DATA
);
Collections
.
sort
(
datas
,
new
Comparator
<
AppDataCommand
>()
{
@Override
public
int
compare
(
AppDataCommand
o1
,
AppDataCommand
o2
)
{
return
(
int
)
(
o2
.
getMinuteOrder
()
-
o1
.
getMinuteOrder
());
}
});
datas
=
m_dao
.
findDataByMinute
(
commandId
,
period
,
city
,
operator
,
network
,
appVersion
,
connnectType
,
code
,
platform
,
AppDataCommandEntity
.
READSET_COUNT_DATA
);
int
n
=
calculateSize
(
entity
.
getDate
().
getTime
());
if
(
SUCCESS_RATIO
.
equals
(
type
))
{
...
...
@@ -117,30 +107,24 @@ public class AppDataService {
public
Map
<
String
,
double
[]>
querySuccessRatio
(
List
<
AppDataCommand
>
datas
,
int
n
)
{
Map
<
String
,
double
[]>
values
=
new
LinkedHashMap
<
String
,
double
[]>();
double
[]
value
=
new
double
[
n
];
int
i
=
0
;
try
{
Map
<
Integer
,
List
<
AppDataCommand
>>
dataMap
=
convert2AppDataCommandMap
(
datas
);
int
size
=
dataMap
.
size
();
if
(
size
<=
n
)
{
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
dataMap
.
entrySet
())
{
long
success
=
0
;
long
sum
=
0
;
for
(
Entry
<
Integer
,
List
<
AppDataCommand
>>
entry
:
dataMap
.
entrySet
()
)
{
int
key
=
entry
.
getKey
();
long
success
=
0
;
long
sum
=
0
;
for
(
AppDataCommand
data
:
entry
.
getValue
())
{
long
number
=
data
.
getAccessNumberSum
();
for
(
AppDataCommand
data
:
entry
.
getValue
())
{
long
number
=
data
.
getAccessNumberSum
();
if
(
isSuccessStatus
(
data
))
{
success
+=
number
;
}
sum
+=
number
;
if
(
isSuccessStatus
(
data
))
{
success
+=
number
;
}
value
[
i
++]
=
(
double
)
success
/
sum
;
sum
+=
number
;
}
}
else
{
Cat
.
logError
(
new
RuntimeException
(
"query database minute number "
+
size
+
" lagger than expected size "
+
n
));
value
[
key
/
5
]
=
(
double
)
success
/
sum
;
}
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
...
...
@@ -165,14 +149,11 @@ public class AppDataService {
public
Map
<
String
,
double
[]>
queryRequestCount
(
List
<
AppDataCommand
>
datas
,
int
n
)
{
Map
<
String
,
double
[]>
values
=
new
LinkedHashMap
<
String
,
double
[]>();
double
[]
value
=
new
double
[
n
];
int
i
=
0
;
for
(
AppDataCommand
data
:
datas
)
{
long
count
=
data
.
getAccessNumberSum
();
if
(
i
<
n
)
{
value
[
i
++]
=
count
;
}
value
[
data
.
getMinuteOrder
()
/
5
]
=
count
;
}
values
.
put
(
DELAY_AVG
,
value
);
return
values
;
...
...
@@ -181,16 +162,13 @@ public class AppDataService {
public
Map
<
String
,
double
[]>
queryDelayAvg
(
List
<
AppDataCommand
>
datas
,
int
n
)
{
Map
<
String
,
double
[]>
values
=
new
LinkedHashMap
<
String
,
double
[]>();
double
[]
value
=
new
double
[
n
];
int
i
=
0
;
for
(
AppDataCommand
data
:
datas
)
{
long
count
=
data
.
getAccessNumberSum
();
long
sum
=
data
.
getResponseSumTimeSum
();
double
avg
=
sum
/
count
;
if
(
i
<
n
)
{
value
[
i
++]
=
avg
;
}
value
[
data
.
getMinuteOrder
()
/
5
]
=
avg
;
}
values
.
put
(
DELAY_AVG
,
value
);
return
values
;
...
...
@@ -203,6 +181,7 @@ public class AppDataService {
if
(
startTime
+
oneDay
>
System
.
currentTimeMillis
())
{
long
current
=
System
.
currentTimeMillis
();
long
endTime
=
current
-
current
%
300000
;
n
=
(
int
)
(
endTime
-
startTime
)
/
300000
;
}
return
n
;
...
...
cat-core/src/main/resources/META-INF/dal/jdbc/app-dal.xml
浏览文件 @
58e00dfd
...
...
@@ -11,7 +11,11 @@
<var
name=
"key-id"
value-type=
"int"
key-member=
"id"
/>
<var
name=
"command-id"
value-type=
"int"
/>
<readsets>
<readset
name=
"DATA"
>
<readset
name=
"COUNT-DATA"
>
<member
name=
"minute-order"
/>
<member
name=
"access-number-sum"
/>
</readset>
<readset
name=
"AVG-DATA"
>
<member
name=
"minute-order"
/>
<member
name=
"access-number-sum"
/>
<member
name=
"response-sum-time-sum"
/>
...
...
@@ -28,7 +32,7 @@
<statement>
<![CDATA[INSERT INTO <TABLE/>
(
<FIELDS/>
)
VALUES(
<VALUES/>
)]]>
</statement>
</query>
<query
name=
"find-data"
type=
"SELECT"
multiple=
"true"
>
<query
name=
"find-data
-by-minute
"
type=
"SELECT"
multiple=
"true"
>
<param
name=
"command-id"
/><param
name=
"period"
/>
<param
name=
"period"
/>
<param
name=
"city"
/>
...
...
@@ -64,7 +68,7 @@
</IF>
group by
<FIELD
name=
'minute-order'
/>
]]>
</statement>
</query>
<query
name=
"find-
success-data
"
type=
"SELECT"
multiple=
"true"
>
<query
name=
"find-
data-by-minute-code
"
type=
"SELECT"
multiple=
"true"
>
<param
name=
"command-id"
/><param
name=
"period"
/>
<param
name=
"period"
/>
<param
name=
"city"
/>
...
...
cat-home/src/main/java/com/dianping/cat/build/ComponentsConfigurator.java
浏览文件 @
58e00dfd
...
...
@@ -162,8 +162,11 @@ public class ComponentsConfigurator extends AbstractResourceConfigurator {
List
<
Component
>
all
=
new
ArrayList
<
Component
>();
all
.
addAll
(
defineCommonComponents
());
all
.
addAll
(
defineConfigComponents
());
all
.
addAll
(
defineMetricComponents
());
all
.
addAll
(
defineAlertComponents
());
all
.
add
(
C
(
Module
.
class
,
CatHomeModule
.
ID
,
CatHomeModule
.
class
));
...
...
cat-home/src/main/java/com/dianping/cat/report/page/app/Handler.java
浏览文件 @
58e00dfd
...
...
@@ -43,7 +43,7 @@ public class Handler implements PageHandler<Context> {
model
.
setAction
(
Action
.
VIEW
);
model
.
setPage
(
ReportPage
.
APP
);
model
.
setC
hannels
(
m_manager
.
queryConfigItem
(
AppConfigManager
.
CHANNEL
));
model
.
setC
onnectionTypes
(
m_manager
.
queryConfigItem
(
AppConfigManager
.
CONNECT_TYPE
));
model
.
setCities
(
m_manager
.
queryConfigItem
(
AppConfigManager
.
CITY
));
model
.
setNetworks
(
m_manager
.
queryConfigItem
(
AppConfigManager
.
NETWORK
));
model
.
setOperators
(
m_manager
.
queryConfigItem
(
AppConfigManager
.
OPERATOR
));
...
...
cat-home/src/main/java/com/dianping/cat/report/page/app/Model.java
浏览文件 @
58e00dfd
...
...
@@ -24,7 +24,7 @@ public class Model extends AbstractReportModel<Action, Context> {
private
List
<
Item
>
m_versions
;
private
List
<
Item
>
m_c
hannel
s
;
private
List
<
Item
>
m_c
onnectionType
s
;
private
List
<
Item
>
m_operators
;
...
...
@@ -61,10 +61,6 @@ public class Model extends AbstractReportModel<Action, Context> {
super
(
ctx
);
}
public
List
<
Item
>
getChannels
()
{
return
m_channels
;
}
public
List
<
Item
>
getCities
()
{
return
m_cities
;
}
...
...
@@ -100,9 +96,13 @@ public class Model extends AbstractReportModel<Action, Context> {
return
m_versions
;
}
public
void
setChannels
(
List
<
Item
>
channels
)
{
m_channels
=
channels
;
}
public
List
<
Item
>
getConnectionTypes
()
{
return
m_connectionTypes
;
}
public
void
setConnectionTypes
(
List
<
Item
>
connectionTypes
)
{
m_connectionTypes
=
connectionTypes
;
}
public
void
setCities
(
List
<
Item
>
cities
)
{
m_cities
=
cities
;
...
...
cat-home/src/main/java/com/dianping/cat/report/page/app/graph/AppGraphCreator.java
浏览文件 @
58e00dfd
...
...
@@ -3,8 +3,8 @@ package com.dianping.cat.report.page.app.graph;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Map.Entry
;
import
java.util.Random
;
import
org.unidal.lookup.annotation.Inject
;
...
...
@@ -31,7 +31,7 @@ public class AppGraphCreator extends AbstractGraphCreator {
}
private
Map
<
String
,
double
[]>
prepareAllData
(
QueryEntity
queryEntity
,
String
type
)
{
Map
<
String
,
double
[]>
value
=
new
AppDataServiceMock
()
.
queryValue
(
queryEntity
,
type
);
Map
<
String
,
double
[]>
value
=
m_appDataService
.
queryValue
(
queryEntity
,
type
);
return
value
;
}
...
...
@@ -109,6 +109,6 @@ public class AppGraphCreator extends AbstractGraphCreator {
return
makeMockValue
(
REQUEST_COUNT
);
}
}
}
cat-home/src/main/java/com/dianping/cat/report/page/userMonitor/CityManager.java
浏览文件 @
58e00dfd
...
...
@@ -16,7 +16,7 @@ import com.dianping.cat.report.page.JsonBuilder;
public
class
CityManager
implements
Initializable
{
public
Map
<
String
,
List
<
City
>>
maps
=
new
LinkedHashMap
<
String
,
List
<
City
>>();
public
String
getCityInfo
()
{
return
new
JsonBuilder
().
toJson
(
maps
);
}
...
...
cat-home/src/main/resources/config/default-app-config.xml
浏览文件 @
58e00dfd
...
...
@@ -17,14 +17,44 @@
<item
id=
"2"
name=
"ios"
></item>
</config-item>
<config-item
id=
"城市"
>
<item
id=
"1"
name=
"上海"
></item>
<item
id=
"2"
name=
"北京"
></item>
<item
id=
"1"
name=
"上海市"
></item>
<item
id=
"2"
name=
"安徽省"
></item>
<item
id=
"3"
name=
"北京市"
></item>
<item
id=
"4"
name=
"重庆市"
></item>
<item
id=
"5"
name=
"福建省"
></item>
<item
id=
"6"
name=
"甘肃省"
></item>
<item
id=
"7"
name=
"广东省"
></item>
<item
id=
"8"
name=
"广西壮族自治区"
></item>
<item
id=
"9"
name=
"贵州省"
></item>
<item
id=
"10"
name=
"海南省"
></item>
<item
id=
"11"
name=
"河北省"
></item>
<item
id=
"12"
name=
"河南省"
></item>
<item
id=
"13"
name=
"黑龙江省"
></item>
<item
id=
"14"
name=
"湖北省"
></item>
<item
id=
"15"
name=
"湖南省"
></item>
<item
id=
"16"
name=
"吉林省"
></item>
<item
id=
"17"
name=
"江苏省"
></item>
<item
id=
"18"
name=
"江西省"
></item>
<item
id=
"19"
name=
"辽宁省"
></item>
<item
id=
"20"
name=
"内蒙古自治区"
></item>
<item
id=
"21"
name=
"宁夏回族自治区"
></item>
<item
id=
"22"
name=
"青海省"
></item>
<item
id=
"23"
name=
"山东省"
></item>
<item
id=
"24"
name=
"山西省"
></item>
<item
id=
"25"
name=
"陕西省"
></item>
<item
id=
"26"
name=
"四川省"
></item>
<item
id=
"27"
name=
"天津市"
></item>
<item
id=
"28"
name=
"西藏自治区"
></item>
<item
id=
"29"
name=
"香港特别行政区"
></item>
<item
id=
"30"
name=
"新疆维吾尔自治区"
></item>
<item
id=
"31"
name=
"云南省"
></item>
<item
id=
"32"
name=
"浙江省"
></item>
</config-item>
<config-item
id=
"渠道"
>
<item
id=
"1"
name=
"360"
></item>
<item
id=
"2"
name=
"apple"
></item>
</config-item>
<config-item
id=
"类型"
>
<config-item
id=
"
连接
类型"
>
<item
id=
"1"
name=
"长连接"
></item>
<item
id=
"2"
name=
"短连接"
></item>
</config-item>
...
...
cat-home/src/main/webapp/jsp/report/app.jsp
浏览文件 @
58e00dfd
...
...
@@ -66,13 +66,13 @@
var
code
=
$
(
"
#code
"
).
val
();
var
network
=
$
(
"
#network
"
).
val
();
var
version
=
$
(
"
#version
"
).
val
();
var
c
hannel
=
$
(
"
#channel
"
).
val
();
var
c
onnectionType
=
$
(
"
#connectionType
"
).
val
();
var
palteform
=
$
(
"
#platform
"
).
val
();
var
city
=
$
(
"
#city
"
).
val
();
var
operator
=
$
(
"
#operator
"
).
val
();
var
split
=
"
;
"
;
var
query1
=
time
+
split
+
command
+
split
+
code
+
split
+
network
+
split
+
version
+
split
+
c
hannel
+
split
+
network
+
split
+
version
+
split
+
c
onnectionType
+
split
+
palteform
+
split
+
city
+
split
+
operator
;
var
query2
=
""
;
var
value
=
document
.
getElementById
(
"
checkbox
"
).
checked
;
...
...
@@ -83,12 +83,12 @@
var
code2
=
$
(
"
#code2
"
).
val
();
var
network2
=
$
(
"
#network2
"
).
val
();
var
version2
=
$
(
"
#version2
"
).
val
();
var
c
hannel2
=
$
(
"
#channel
2
"
).
val
();
var
c
onnectionType2
=
$
(
"
#connectionType
2
"
).
val
();
var
palteform2
=
$
(
"
#platform2
"
).
val
();
var
city2
=
$
(
"
#city2
"
).
val
();
var
operator2
=
$
(
"
#operator2
"
).
val
();
query2
=
time2
+
split
+
command2
+
split
+
code2
+
split
+
network2
+
split
+
version2
+
split
+
c
hannel
2
+
network2
+
split
+
version2
+
split
+
c
onnectionType
2
+
split
+
palteform2
+
split
+
city2
+
split
+
operator2
;
}
...
...
@@ -133,7 +133,7 @@
$
(
"
#code
"
).
val
(
words
[
2
]);
$
(
"
#network
"
).
val
(
words
[
3
]);
$
(
"
#version
"
).
val
(
words
[
4
]);
$
(
"
#c
hannel
"
).
val
(
words
[
5
]);
$
(
"
#c
onnectionType
"
).
val
(
words
[
5
]);
$
(
"
#platform
"
).
val
(
words
[
6
]);
$
(
"
#city
"
).
val
(
words
[
7
]);
$
(
"
#operator
"
).
val
(
words
[
8
]);
...
...
@@ -154,7 +154,7 @@
$
(
"
#code2
"
).
val
(
words
[
2
]);
$
(
"
#network2
"
).
val
(
words
[
3
]);
$
(
"
#version2
"
).
val
(
words
[
4
]);
$
(
"
#c
hannel
2
"
).
val
(
words
[
5
]);
$
(
"
#c
onnectionType
2
"
).
val
(
words
[
5
]);
$
(
"
#platform2
"
).
val
(
words
[
6
]);
$
(
"
#city2
"
).
val
(
words
[
7
]);
$
(
"
#operator2
"
).
val
(
words
[
8
]);
...
...
@@ -188,7 +188,6 @@
data-date-icon=
"icon-calendar"
>
</i>
</span>
</div>
命令字
<select
id=
"command"
style=
"width: 350px;"
>
<option
value=
'0'
>
All
</option>
<c:forEach
var=
"item"
items=
"
${
model
.
commands
}
"
varStatus=
"status"
>
<option
value=
'${item.id}'
>
${item.name}
</option>
</c:forEach>
...
...
@@ -207,9 +206,9 @@
<c:forEach
var=
"item"
items=
"
${
model
.
versions
}
"
varStatus=
"status"
>
<option
value=
'${item.id}'
>
${item.name}
</option>
</c:forEach>
</select>
渠道
<select
id=
"channel
"
style=
"width: 100px;"
>
</select>
连接类型
<select
id=
"connectionType
"
style=
"width: 100px;"
>
<option
value=
'0'
>
All
</option>
<c:forEach
var=
"item"
items=
"
${
model
.
c
hannel
s
}
"
varStatus=
"status"
>
<c:forEach
var=
"item"
items=
"
${
model
.
c
onnectionType
s
}
"
varStatus=
"status"
>
<option
value=
'${item.id}'
>
${item.name}
</option>
</c:forEach>
</select>
平台
<select
id=
"platform"
style=
"width: 100px;"
>
...
...
@@ -248,7 +247,6 @@
data-date-icon=
"icon-calendar"
>
</i>
</span>
</div>
命令字
<select
id=
"command2"
style=
"width: 350px;"
>
<option
value=
'0'
>
All
</option>
<c:forEach
var=
"item"
items=
"
${
model
.
commands
}
"
varStatus=
"status"
>
<option
value=
'${item.id}'
>
${item.name}
</option>
</c:forEach>
...
...
@@ -268,9 +266,9 @@
<c:forEach
var=
"item"
items=
"
${
model
.
versions
}
"
varStatus=
"status"
>
<option
value=
'${item.id}'
>
${item.name}
</option>
</c:forEach>
</select>
渠道
<select
id=
"channel
2"
style=
"width: 100px;"
>
</select>
连接类型
<select
id=
"connectionType
2"
style=
"width: 100px;"
>
<option
value=
'0'
>
All
</option>
<c:forEach
var=
"item"
items=
"
${
model
.
c
hannel
s
}
"
varStatus=
"status"
>
<c:forEach
var=
"item"
items=
"
${
model
.
c
onnectionType
s
}
"
varStatus=
"status"
>
<option
value=
'${item.id}'
>
${item.name}
</option>
</c:forEach>
</select>
平台
<select
id=
"platform2"
style=
"width: 100px;"
>
...
...
script/Cat.sql
浏览文件 @
58e00dfd
...
...
@@ -347,7 +347,7 @@ CREATE TABLE `app_data_command_1` (
`creation_date`
datetime
NOT
NULL
COMMENT
'数据插入时间'
,
PRIMARY
KEY
(
`id`
),
KEY
IX_period_city_minute
(
period
,
city
,
minute_order
),
KEY
IX_period_operator_minute
(
period
,
network
,
minute_order
),
KEY
IX_period_operator_minute
(
period
,
operator
,
minute_order
),
KEY
IX_period_network_minute
(
period
,
network
,
minute_order
),
KEY
IX_period_version_minute
(
period
,
app_version
,
minute_order
),
KEY
IX_period_connnect_minute
(
period
,
connnect_type
,
minute_order
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录