Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
javalover123888
SkyWalking
提交
62477a53
S
SkyWalking
项目概览
javalover123888
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / SkyWalking
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
62477a53
编写于
2月 07, 2018
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Provide the getServiceTopology query.
上级
2c6b03bf
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
551 addition
and
447 deletion
+551
-447
apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json
...tty-provider/src/test/resources/json/dubbox-provider.json
+1
-1
apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java
...tor/analysis/metric/define/graph/MetricGraphIdDefine.java
+1
-0
apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java
...or/analysis/metric/define/graph/MetricWorkerIdDefine.java
+37
-27
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationSpanListener.java
.../provider/worker/segment/SegmentDurationSpanListener.java
+1
-1
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ServiceNameCacheService.java
.../apm/collector/cache/service/ServiceNameCacheService.java
+2
-4
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java
...tor/cache/guava/service/ServiceNameCacheGuavaService.java
+10
-25
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java
...pache/skywalking/apm/collector/storage/StorageModule.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IServiceNameCacheDAO.java
...apm/collector/storage/dao/cache/IServiceNameCacheDAO.java
+2
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java
...ing/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java
+6
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceMetricUIDAO.java
...ollector/storage/dao/ui/IServiceReferenceMetricUIDAO.java
+17
-4
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java
.../skywalking/apm/collector/storage/ui/common/Topology.java
+6
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java
...walking/apm/collector/storage/ui/service/ServiceNode.java
+3
-3
apm-collector/apm-collector-storage/collector-storage-define/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.Module
...es/org.apache.skywalking.apm.collector.core.module.Module
+1
-2
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java
...ing/apm/collector/storage/es/StorageModuleEsProvider.java
+3
-3
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java
...collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java
+9
-6
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
...apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
+53
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsMetricUIDAO.java
...ctor/storage/es/dao/ui/ServiceReferenceEsMetricUIDAO.java
+200
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java
.../collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java
+0
-115
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java
...ing/apm/collector/storage/h2/StorageModuleH2Provider.java
+3
-3
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java
...collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java
+9
-8
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
...apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
+8
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2MetricUIDAO.java
...ctor/storage/h2/dao/ui/ServiceReferenceH2MetricUIDAO.java
+57
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java
.../collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java
+0
-103
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define
...ovider/src/main/resources/META-INF/defines/storage.define
+2
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java
...pache/skywalking/apm/collector/ui/query/ServiceQuery.java
+13
-2
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java
...king/apm/collector/ui/service/ServiceTopologyService.java
+93
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java
...ywalking/apm/collector/ui/service/ServiceTreeService.java
+0
-123
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java
...ache/skywalking/apm/collector/ui/service/SpanService.java
+6
-7
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java
...kywalking/apm/collector/ui/service/TraceStackService.java
+4
-4
apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls
...ocol/src/main/resources/ui-graphql/service-layer.graphqls
+2
-3
未找到文件。
apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json
浏览文件 @
62477a53
...
...
@@ -26,7 +26,7 @@
"pii"
:
2
,
//上级的实例编号
"psp"
:
1
,
//上级的埋点编号span_id
"psi"
:
0
,
//上级的服务编号(org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()注册后的ID)
"psn"
:
"
org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()
"
,
//上级的服务名
"psn"
:
"
/dubbox-case/case/dubbox-rest
"
,
//上级的服务名
"ni"
:
0
,
//上级调用时使用的地址注册后的ID
"nn"
:
"172.25.0.4:20880"
,
//上级的地址
"eii"
:
2
,
//入口的实例编号
...
...
apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java
浏览文件 @
62477a53
...
...
@@ -32,6 +32,7 @@ public class MetricGraphIdDefine {
public
static
final
int
APPLICATION_COMPONENT_GRAPH_ID
=
406
;
public
static
final
int
APPLICATION_MAPPING_GRAPH_ID
=
407
;
public
static
final
int
SERVICE_MAPPING_GRAPH_ID
=
408
;
public
static
final
int
GLOBAL_TRACE_GRAPH_ID
=
409
;
public
static
final
int
SEGMENT_DURATION_GRAPH_ID
=
410
;
public
static
final
int
INSTANCE_MAPPING_GRAPH_ID
=
411
;
...
...
apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java
浏览文件 @
62477a53
...
...
@@ -22,35 +22,45 @@ package org.apache.skywalking.apm.collector.analysis.metric.define.graph;
* @author peng-yongsheng
*/
public
class
MetricWorkerIdDefine
{
public
static
final
int
SERVICE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID
=
4
10
0
;
public
static
final
int
SERVICE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID
=
4
10
1
;
public
static
final
int
SERVICE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID
=
4
10
2
;
public
static
final
int
SERVICE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID
=
4
10
3
;
public
static
final
int
SERVICE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID
=
4
10
4
;
public
static
final
int
SERVICE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID
=
4
10
5
;
public
static
final
int
SERVICE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID
=
4
10
6
;
public
static
final
int
SERVICE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID
=
4
10
7
;
public
static
final
int
SERVICE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID
=
4
10
8
;
public
static
final
int
SERVICE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID
=
4
01
0
;
public
static
final
int
SERVICE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID
=
4
01
1
;
public
static
final
int
SERVICE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID
=
4
01
2
;
public
static
final
int
SERVICE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID
=
4
01
3
;
public
static
final
int
SERVICE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID
=
4
01
4
;
public
static
final
int
SERVICE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID
=
4
01
5
;
public
static
final
int
SERVICE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID
=
4
01
6
;
public
static
final
int
SERVICE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID
=
4
01
7
;
public
static
final
int
SERVICE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID
=
4
01
8
;
public
static
final
int
INSTANCE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID
=
4
20
0
;
public
static
final
int
INSTANCE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID
=
4
20
1
;
public
static
final
int
INSTANCE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID
=
4
20
2
;
public
static
final
int
INSTANCE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID
=
4
20
3
;
public
static
final
int
INSTANCE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID
=
4
20
4
;
public
static
final
int
INSTANCE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID
=
4
20
5
;
public
static
final
int
INSTANCE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID
=
4
20
6
;
public
static
final
int
INSTANCE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID
=
4
20
7
;
public
static
final
int
INSTANCE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID
=
4
20
8
;
public
static
final
int
INSTANCE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID
=
4
02
0
;
public
static
final
int
INSTANCE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID
=
4
02
1
;
public
static
final
int
INSTANCE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID
=
4
02
2
;
public
static
final
int
INSTANCE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID
=
4
02
3
;
public
static
final
int
INSTANCE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID
=
4
02
4
;
public
static
final
int
INSTANCE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID
=
4
02
5
;
public
static
final
int
INSTANCE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID
=
4
02
6
;
public
static
final
int
INSTANCE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID
=
4
02
7
;
public
static
final
int
INSTANCE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID
=
4
02
8
;
public
static
final
int
APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID
=
4300
;
public
static
final
int
APPLICATION_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID
=
4301
;
public
static
final
int
APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID
=
4302
;
public
static
final
int
APPLICATION_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID
=
4303
;
public
static
final
int
APPLICATION_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID
=
4304
;
public
static
final
int
APPLICATION_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID
=
4305
;
public
static
final
int
APPLICATION_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID
=
4306
;
public
static
final
int
APPLICATION_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID
=
4307
;
public
static
final
int
APPLICATION_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID
=
4308
;
public
static
final
int
APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID
=
4030
;
public
static
final
int
APPLICATION_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID
=
4031
;
public
static
final
int
APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID
=
4032
;
public
static
final
int
APPLICATION_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID
=
4033
;
public
static
final
int
APPLICATION_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID
=
4034
;
public
static
final
int
APPLICATION_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID
=
4035
;
public
static
final
int
APPLICATION_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID
=
4036
;
public
static
final
int
APPLICATION_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID
=
4037
;
public
static
final
int
APPLICATION_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID
=
4038
;
public
static
final
int
SERVICE_MAPPING_MINUTE_AGGREGATION_WORKER_ID
=
4040
;
public
static
final
int
SERVICE_MAPPING_MINUTE_REMOTE_WORKER_ID
=
4041
;
public
static
final
int
SERVICE_MAPPING_MINUTE_PERSISTENCE_WORKER_ID
=
4042
;
public
static
final
int
SERVICE_MAPPING_HOUR_PERSISTENCE_WORKER_ID
=
4043
;
public
static
final
int
SERVICE_MAPPING_HOUR_TRANSFORM_NODE_ID
=
4044
;
public
static
final
int
SERVICE_MAPPING_DAY_PERSISTENCE_WORKER_ID
=
4045
;
public
static
final
int
SERVICE_MAPPING_DAY_TRANSFORM_NODE_ID
=
4046
;
public
static
final
int
SERVICE_MAPPING_MONTH_PERSISTENCE_WORKER_ID
=
4047
;
public
static
final
int
SERVICE_MAPPING_MONTH_TRANSFORM_NODE_ID
=
4048
;
public
static
final
int
SERVICE_MINUTE_METRIC_AGGREGATION_WORKER_ID
=
4400
;
public
static
final
int
SERVICE_MINUTE_METRIC_REMOTE_WORKER_ID
=
4401
;
...
...
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationSpanListener.java
浏览文件 @
62477a53
...
...
@@ -71,7 +71,7 @@ public class SegmentDurationSpanListener implements EntrySpanListener, ExitSpanL
if
(
spanDecorator
.
getOperationNameId
()
==
0
)
{
segmentDuration
.
setServiceName
(
spanDecorator
.
getOperationName
());
}
else
{
segmentDuration
.
setServiceName
(
serviceNameCacheService
.
get
SplitServiceName
(
serviceNameCacheService
.
get
(
spanDecorator
.
getOperationNameId
())
));
segmentDuration
.
setServiceName
(
serviceNameCacheService
.
get
(
spanDecorator
.
getOperationNameId
()).
getServiceName
(
));
}
segmentDurations
.
add
(
segmentDuration
);
...
...
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ServiceNameCacheService.java
浏览文件 @
62477a53
...
...
@@ -16,16 +16,14 @@
*
*/
package
org.apache.skywalking.apm.collector.cache.service
;
import
org.apache.skywalking.apm.collector.core.module.Service
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceName
;
/**
* @author peng-yongsheng
*/
public
interface
ServiceNameCacheService
extends
Service
{
String
get
(
int
serviceId
);
String
getSplitServiceName
(
String
serviceName
);
ServiceName
get
(
int
serviceId
);
}
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java
浏览文件 @
62477a53
...
...
@@ -16,18 +16,16 @@
*
*/
package
org.apache.skywalking.apm.collector.cache.guava.service
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.core.util.ObjectUtils
;
import
org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService
;
import
org.apache.skywalking.apm.collector.core.util.StringUtils
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceName
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -38,7 +36,7 @@ public class ServiceNameCacheGuavaService implements ServiceNameCacheService {
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceNameCacheGuavaService
.
class
);
private
final
Cache
<
Integer
,
S
tring
>
serviceNam
eCache
=
CacheBuilder
.
newBuilder
().
maximumSize
(
10000
).
build
();
private
final
Cache
<
Integer
,
S
erviceName
>
servic
eCache
=
CacheBuilder
.
newBuilder
().
maximumSize
(
10000
).
build
();
private
final
ModuleManager
moduleManager
;
private
IServiceNameCacheDAO
serviceNameCacheDAO
;
...
...
@@ -54,34 +52,21 @@ public class ServiceNameCacheGuavaService implements ServiceNameCacheService {
return
this
.
serviceNameCacheDAO
;
}
public
S
tring
get
(
int
serviceId
)
{
S
tring
serviceName
=
Const
.
EMPTY_STRING
;
public
S
erviceName
get
(
int
serviceId
)
{
S
erviceName
serviceName
=
null
;
try
{
serviceName
=
service
NameCache
.
get
(
serviceId
,
()
->
getServiceNameCacheDAO
().
getServiceName
(
serviceId
));
serviceName
=
service
Cache
.
get
(
serviceId
,
()
->
getServiceNameCacheDAO
().
get
(
serviceId
));
}
catch
(
Throwable
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
if
(
String
Utils
.
isEmpty
(
serviceName
))
{
serviceName
=
getServiceNameCacheDAO
().
get
ServiceName
(
serviceId
);
if
(
String
Utils
.
isNotEmpty
(
serviceName
))
{
service
Name
Cache
.
put
(
serviceId
,
serviceName
);
if
(
Object
Utils
.
isEmpty
(
serviceName
))
{
serviceName
=
getServiceNameCacheDAO
().
get
(
serviceId
);
if
(
Object
Utils
.
isNotEmpty
(
serviceName
))
{
serviceCache
.
put
(
serviceId
,
serviceName
);
}
}
return
serviceName
;
}
public
String
getSplitServiceName
(
String
serviceName
)
{
if
(
StringUtils
.
isNotEmpty
(
serviceName
))
{
String
[]
serviceNames
=
serviceName
.
split
(
Const
.
ID_SPLIT
,
2
);
if
(
serviceNames
.
length
==
2
)
{
return
serviceNames
[
1
];
}
else
{
return
Const
.
EMPTY_STRING
;
}
}
else
{
return
Const
.
EMPTY_STRING
;
}
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java
浏览文件 @
62477a53
...
...
@@ -117,7 +117,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
import
org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReference
Metric
UIDAO
;
/**
* @author peng-yongsheng
...
...
@@ -251,7 +251,7 @@ public class StorageModule extends Module {
classes
.
add
(
IApplicationReferenceMetricUIDAO
.
class
);
classes
.
add
(
ISegmentDurationUIDAO
.
class
);
classes
.
add
(
ISegmentUIDAO
.
class
);
classes
.
add
(
IServiceReferenceUIDAO
.
class
);
classes
.
add
(
IServiceReference
Metric
UIDAO
.
class
);
}
private
void
addAlarmDAO
(
List
<
Class
>
classes
)
{
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IServiceNameCacheDAO.java
浏览文件 @
62477a53
...
...
@@ -19,12 +19,13 @@
package
org.apache.skywalking.apm.collector.storage.dao.cache
;
import
org.apache.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceName
;
/**
* @author peng-yongsheng
*/
public
interface
IServiceNameCacheDAO
extends
DAO
{
S
tring
getServiceName
(
int
serviceId
);
S
erviceName
get
(
int
serviceId
);
int
getServiceId
(
int
applicationId
,
String
serviceName
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java
浏览文件 @
62477a53
...
...
@@ -18,8 +18,11 @@
package
org.apache.skywalking.apm.collector.storage.dao.ui
;
import
java.util.Collection
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.apache.skywalking.apm.collector.storage.table.MetricSource
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Node
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.utils.DurationPoint
;
...
...
@@ -30,4 +33,7 @@ public interface IServiceMetricUIDAO extends DAO {
List
<
Integer
>
getServiceResponseTimeTrend
(
int
serviceId
,
Step
step
,
List
<
DurationPoint
>
durationPoints
);
List
<
Integer
>
getServiceSLATrend
(
int
serviceId
,
Step
step
,
List
<
DurationPoint
>
durationPoints
);
List
<
Node
>
getServicesMetric
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
Collection
<
Integer
>
serviceIds
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceUIDAO.java
→
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReference
Metric
UIDAO.java
浏览文件 @
62477a53
...
...
@@ -18,13 +18,26 @@
package
org.apache.skywalking.apm.collector.storage.dao.ui
;
import
com.google.gson.JsonObject
;
import
java.util.Map
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.apache.skywalking.apm.collector.storage.table.MetricSource
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Call
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
/**
* @author peng-yongsheng
*/
public
interface
IServiceReferenceUIDAO
extends
DAO
{
Map
<
String
,
JsonObject
>
load
(
int
entryServiceId
,
long
startTime
,
long
endTime
);
public
interface
IServiceReferenceMetricUIDAO
extends
DAO
{
List
<
Call
>
getFrontServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
int
behindServiceId
);
List
<
Call
>
getBehindServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
int
frontServiceId
);
List
<
Call
>
getFrontServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
List
<
Integer
>
behindServiceIds
);
List
<
Call
>
getBehindServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
List
<
Integer
>
frontServiceIds
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java
浏览文件 @
62477a53
...
...
@@ -18,6 +18,7 @@
package
org.apache.skywalking.apm.collector.storage.ui.common
;
import
java.util.LinkedList
;
import
java.util.List
;
/**
...
...
@@ -28,6 +29,11 @@ public class Topology {
private
List
<
Node
>
nodes
;
private
List
<
Call
>
calls
;
public
Topology
()
{
this
.
nodes
=
new
LinkedList
<>();
this
.
calls
=
new
LinkedList
<>();
}
public
List
<
Node
>
getNodes
()
{
return
nodes
;
}
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java
浏览文件 @
62477a53
...
...
@@ -24,16 +24,16 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Node;
* @author peng-yongsheng
*/
public
class
ServiceNode
extends
Node
{
private
floa
t
sla
;
private
in
t
sla
;
private
long
calls
;
private
int
numOfServiceAlarm
;
private
int
applicationId
;
public
floa
t
getSla
()
{
public
in
t
getSla
()
{
return
sla
;
}
public
void
setSla
(
floa
t
sla
)
{
public
void
setSla
(
in
t
sla
)
{
this
.
sla
=
sla
;
}
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.Module
浏览文件 @
62477a53
...
...
@@ -16,5 +16,4 @@
#
#
org
.
apache
.
skywalking
.
apm
.
collector
.
storage
.
StorageModule
org
.
apache
.
skywalking
.
apm
.
collector
.
storage
.
StorageModule
\ No newline at end of file
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java
浏览文件 @
62477a53
...
...
@@ -126,7 +126,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
import
org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReference
Metric
UIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO
;
import
org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchStorageInstaller
;
import
org.apache.skywalking.apm.collector.storage.es.dao.GlobalTraceEsPersistenceDAO
;
...
...
@@ -224,7 +224,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentDurationEsUI
import
org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentEsUIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceMetricEsUIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceNameServiceEsUIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceReferenceEsUIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceReferenceEs
Metric
UIDAO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -410,7 +410,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
this
.
registerServiceImplementation
(
IApplicationReferenceMetricUIDAO
.
class
,
new
ApplicationReferenceMetricEsUIDAO
(
elasticSearchClient
));
this
.
registerServiceImplementation
(
ISegmentDurationUIDAO
.
class
,
new
SegmentDurationEsUIDAO
(
elasticSearchClient
));
this
.
registerServiceImplementation
(
ISegmentUIDAO
.
class
,
new
SegmentEsUIDAO
(
elasticSearchClient
));
this
.
registerServiceImplementation
(
IServiceReference
UIDAO
.
class
,
new
ServiceReferenceEs
UIDAO
(
elasticSearchClient
));
this
.
registerServiceImplementation
(
IServiceReference
MetricUIDAO
.
class
,
new
ServiceReferenceEsMetric
UIDAO
(
elasticSearchClient
));
}
private
void
registerAlarmDAO
()
throws
ServiceNotProvidedException
{
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java
浏览文件 @
62477a53
...
...
@@ -19,9 +19,9 @@
package
org.apache.skywalking.apm.collector.storage.es.dao.cache
;
import
org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO
;
import
org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceName
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable
;
import
org.elasticsearch.action.get.GetRequestBuilder
;
import
org.elasticsearch.action.get.GetResponse
;
...
...
@@ -41,16 +41,19 @@ public class ServiceNameEsCacheDAO extends EsDAO implements IServiceNameCacheDAO
super
(
client
);
}
@Override
public
S
tring
getServiceName
(
int
serviceId
)
{
@Override
public
S
erviceName
get
(
int
serviceId
)
{
GetRequestBuilder
getRequestBuilder
=
getClient
().
prepareGet
(
ServiceNameTable
.
TABLE
,
String
.
valueOf
(
serviceId
));
GetResponse
getResponse
=
getRequestBuilder
.
get
();
if
(
getResponse
.
isExists
())
{
String
serviceName
=
(
String
)
getResponse
.
getSource
().
get
(
ServiceNameTable
.
COLUMN_SERVICE_NAME
);
int
applicationId
=
((
Number
)
getResponse
.
getSource
().
get
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
)).
intValue
();
return
applicationId
+
Const
.
ID_SPLIT
+
serviceName
;
ServiceName
serviceName
=
new
ServiceName
();
serviceName
.
setApplicationId
(((
Number
)
getResponse
.
getSource
().
get
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
)).
intValue
());
serviceName
.
setServiceId
(
serviceId
);
serviceName
.
setServiceName
((
String
)
getResponse
.
getSource
().
get
(
ServiceNameTable
.
COLUMN_SERVICE_NAME
));
return
serviceName
;
}
return
Const
.
EMPTY_STRING
;
return
null
;
}
@Override
public
int
getServiceId
(
int
applicationId
,
String
serviceName
)
{
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
浏览文件 @
62477a53
...
...
@@ -18,6 +18,7 @@
package
org.apache.skywalking.apm.collector.storage.es.dao.ui
;
import
java.util.Collection
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
...
...
@@ -26,12 +27,23 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO;
import
org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.apache.skywalking.apm.collector.storage.table.MetricSource
;
import
org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Node
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.ui.service.ServiceNode
;
import
org.apache.skywalking.apm.collector.storage.utils.DurationPoint
;
import
org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder
;
import
org.elasticsearch.action.get.MultiGetItemResponse
;
import
org.elasticsearch.action.get.MultiGetRequestBuilder
;
import
org.elasticsearch.action.get.MultiGetResponse
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder
;
import
org.elasticsearch.search.aggregations.metrics.sum.Sum
;
/**
* @author peng-yongsheng
...
...
@@ -90,4 +102,45 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO {
}
return
trends
;
}
@Override
public
List
<
Node
>
getServicesMetric
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
Collection
<
Integer
>
serviceIds
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ServiceMetricTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ServiceMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termsQuery
(
ServiceMetricTable
.
COLUMN_SERVICE_ID
,
serviceIds
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ServiceMetricTable
.
COLUMN_SOURCE_VALUE
,
metricSource
.
getValue
()));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
ServiceMetricTable
.
COLUMN_SERVICE_ID
).
field
(
ServiceMetricTable
.
COLUMN_SERVICE_ID
).
size
(
100
);
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceMetricTable
.
COLUMN_TRANSACTION_CALLS
).
field
(
ServiceMetricTable
.
COLUMN_TRANSACTION_CALLS
));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
).
field
(
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
));
searchRequestBuilder
.
addAggregation
(
aggregationBuilder
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
List
<
Node
>
nodes
=
new
LinkedList
<>();
Terms
serviceIdTerms
=
searchResponse
.
getAggregations
().
get
(
ServiceMetricTable
.
COLUMN_SERVICE_ID
);
serviceIdTerms
.
getBuckets
().
forEach
(
serviceIdBucket
->
{
int
serviceId
=
serviceIdBucket
.
getKeyAsNumber
().
intValue
();
Sum
callsSum
=
serviceIdBucket
.
getAggregations
().
get
(
ServiceMetricTable
.
COLUMN_TRANSACTION_CALLS
);
Sum
errorCallsSum
=
serviceIdBucket
.
getAggregations
().
get
(
ServiceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
);
ServiceNode
serviceNode
=
new
ServiceNode
();
serviceNode
.
setId
(
serviceId
);
serviceNode
.
setCalls
((
long
)
callsSum
.
getValue
());
serviceNode
.
setSla
((
int
)(((
callsSum
.
getValue
()
-
errorCallsSum
.
getValue
())
/
callsSum
.
getValue
())
*
10000
));
nodes
.
add
(
serviceNode
);
});
return
nodes
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsMetricUIDAO.java
0 → 100644
浏览文件 @
62477a53
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.storage.es.dao.ui
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.apache.skywalking.apm.collector.storage.table.MetricSource
;
import
org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Call
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder
;
import
org.elasticsearch.search.aggregations.metrics.sum.Sum
;
/**
* @author peng-yongsheng
*/
public
class
ServiceReferenceEsMetricUIDAO
extends
EsDAO
implements
IServiceReferenceMetricUIDAO
{
public
ServiceReferenceEsMetricUIDAO
(
ElasticSearchClient
client
)
{
super
(
client
);
}
@Override
public
List
<
Call
>
getFrontServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
int
behindServiceId
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ServiceReferenceMetricTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ServiceReferenceMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceReferenceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
,
behindServiceId
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ServiceReferenceMetricTable
.
COLUMN_SOURCE_VALUE
,
metricSource
.
getValue
()));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
).
field
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
).
size
(
100
);
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
));
searchRequestBuilder
.
addAggregation
(
aggregationBuilder
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
List
<
Call
>
calls
=
new
LinkedList
<>();
Terms
frontServiceIdTerms
=
searchResponse
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
);
buildNodeByBehindServiceId
(
calls
,
frontServiceIdTerms
,
behindServiceId
);
return
calls
;
}
@Override
public
List
<
Call
>
getBehindServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
int
frontServiceId
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ServiceReferenceMetricTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ServiceReferenceMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceReferenceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
,
frontServiceId
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ServiceReferenceMetricTable
.
COLUMN_SOURCE_VALUE
,
metricSource
.
getValue
()));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
).
field
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
).
size
(
100
);
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
));
searchRequestBuilder
.
addAggregation
(
aggregationBuilder
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
List
<
Call
>
calls
=
new
LinkedList
<>();
Terms
behindServiceIdTerms
=
searchResponse
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
);
buildNodeByFrontServiceId
(
calls
,
behindServiceIdTerms
,
frontServiceId
);
return
calls
;
}
@Override
public
List
<
Call
>
getFrontServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
List
<
Integer
>
behindServiceIds
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ServiceReferenceMetricTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ServiceReferenceMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceReferenceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termsQuery
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
,
behindServiceIds
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ServiceReferenceMetricTable
.
COLUMN_SOURCE_VALUE
,
metricSource
.
getValue
()));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
return
executeAggregation
(
searchRequestBuilder
);
}
@Override
public
List
<
Call
>
getBehindServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
List
<
Integer
>
frontServiceIds
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ServiceReferenceMetricTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ServiceReferenceMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceReferenceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termsQuery
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
,
frontServiceIds
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ServiceReferenceMetricTable
.
COLUMN_SOURCE_VALUE
,
metricSource
.
getValue
()));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
return
executeAggregation
(
searchRequestBuilder
);
}
private
List
<
Call
>
executeAggregation
(
SearchRequestBuilder
searchRequestBuilder
)
{
TermsAggregationBuilder
frontAggregationBuilder
=
AggregationBuilders
.
terms
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
).
field
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
).
size
(
100
);
TermsAggregationBuilder
behindAggregationBuilder
=
AggregationBuilders
.
terms
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
).
field
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
).
size
(
100
);
behindAggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
));
behindAggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
));
frontAggregationBuilder
.
subAggregation
(
behindAggregationBuilder
);
searchRequestBuilder
.
addAggregation
(
frontAggregationBuilder
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
List
<
Call
>
nodes
=
new
LinkedList
<>();
Terms
frontServiceIdTerms
=
searchResponse
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
);
frontServiceIdTerms
.
getBuckets
().
forEach
(
frontServiceIdBucket
->
{
int
frontServiceId
=
frontServiceIdBucket
.
getKeyAsNumber
().
intValue
();
Terms
behindServiceIdTerms
=
frontServiceIdBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
);
buildNodeByFrontServiceId
(
nodes
,
behindServiceIdTerms
,
frontServiceId
);
});
return
nodes
;
}
private
void
buildNodeByFrontServiceId
(
List
<
Call
>
calls
,
Terms
behindServiceIdTerms
,
int
frontServiceId
)
{
behindServiceIdTerms
.
getBuckets
().
forEach
(
behindServiceIdBucket
->
{
int
behindServiceId
=
behindServiceIdBucket
.
getKeyAsNumber
().
intValue
();
Sum
callsSum
=
behindServiceIdBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
);
Sum
responseTimes
=
behindServiceIdBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
);
Call
call
=
new
Call
();
call
.
setSource
(
frontServiceId
);
call
.
setTarget
(
behindServiceId
);
call
.
setCalls
((
int
)
callsSum
.
getValue
());
call
.
setResponseTimes
((
int
)
responseTimes
.
getValue
());
calls
.
add
(
call
);
});
}
private
void
buildNodeByBehindServiceId
(
List
<
Call
>
calls
,
Terms
frontServiceIdTerms
,
int
behindServiceId
)
{
frontServiceIdTerms
.
getBuckets
().
forEach
(
frontServiceIdBucket
->
{
int
frontServiceId
=
frontServiceIdBucket
.
getKeyAsNumber
().
intValue
();
Sum
callsSum
=
frontServiceIdBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
);
Sum
responseTimes
=
frontServiceIdBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
);
Call
call
=
new
Call
();
call
.
setTarget
(
behindServiceId
);
call
.
setSource
(
frontServiceId
);
call
.
setCalls
((
int
)
callsSum
.
getValue
());
call
.
setResponseTimes
((
int
)
responseTimes
.
getValue
());
calls
.
add
(
call
);
});
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java
已删除
100644 → 0
浏览文件 @
2c6b03bf
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.storage.es.dao.ui
;
import
com.google.gson.JsonObject
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.apache.skywalking.apm.collector.core.util.ColumnNameUtils
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.metrics.sum.Sum
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ServiceReferenceEsUIDAO
extends
EsDAO
implements
IServiceReferenceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceReferenceEsUIDAO
.
class
);
public
ServiceReferenceEsUIDAO
(
ElasticSearchClient
client
)
{
super
(
client
);
}
@Override
public
Map
<
String
,
JsonObject
>
load
(
int
entryServiceId
,
long
startTime
,
long
endTime
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
ServiceReferenceMetricTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
ServiceReferenceMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceReferenceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceReferenceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
return
load
(
searchRequestBuilder
);
}
private
Map
<
String
,
JsonObject
>
load
(
SearchRequestBuilder
searchRequestBuilder
)
{
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
terms
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
).
field
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
terms
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
).
field
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
))
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
))
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
))
.
subAggregation
(
AggregationBuilders
.
sum
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
).
field
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
))));
Map
<
String
,
JsonObject
>
serviceReferenceMap
=
new
LinkedHashMap
<>();
SearchResponse
searchResponse
=
searchRequestBuilder
.
get
();
Terms
frontServiceIdTerms
=
searchResponse
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
);
for
(
Terms
.
Bucket
frontServiceBucket
:
frontServiceIdTerms
.
getBuckets
())
{
int
frontServiceId
=
frontServiceBucket
.
getKeyAsNumber
().
intValue
();
if
(
frontServiceId
!=
0
)
{
parseSubAggregate
(
serviceReferenceMap
,
frontServiceBucket
,
frontServiceId
);
}
}
return
serviceReferenceMap
;
}
private
void
parseSubAggregate
(
Map
<
String
,
JsonObject
>
serviceReferenceMap
,
Terms
.
Bucket
frontServiceBucket
,
int
frontServiceId
)
{
Terms
behindServiceIdTerms
=
frontServiceBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
);
for
(
Terms
.
Bucket
behindServiceIdBucket
:
behindServiceIdTerms
.
getBuckets
())
{
int
behindServiceId
=
behindServiceIdBucket
.
getKeyAsNumber
().
intValue
();
if
(
behindServiceId
!=
0
)
{
Sum
calls
=
behindServiceIdBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
);
Sum
errorCalls
=
behindServiceIdBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
);
Sum
durationSum
=
behindServiceIdBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
);
Sum
errorDurationSum
=
behindServiceIdBucket
.
getAggregations
().
get
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
);
JsonObject
serviceReference
=
new
JsonObject
();
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
),
frontServiceId
);
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
),
behindServiceId
);
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
),
(
long
)
calls
.
getValue
());
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
),
(
long
)
errorCalls
.
getValue
());
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
),
(
long
)
durationSum
.
getValue
());
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
),
(
long
)
errorDurationSum
.
getValue
());
String
id
=
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
))
+
Const
.
ID_SPLIT
+
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
));
serviceReferenceMap
.
put
(
id
,
serviceReference
);
}
}
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java
浏览文件 @
62477a53
...
...
@@ -122,7 +122,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
import
org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReference
Metric
UIDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO
;
import
org.apache.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller
;
import
org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO
;
...
...
@@ -220,7 +220,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentDurationH2UI
import
org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentH2UIDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceMetricH2UIDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceNameServiceH2UIDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceReferenceH2UIDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceReferenceH2
Metric
UIDAO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -386,7 +386,7 @@ public class StorageModuleH2Provider extends ModuleProvider {
this
.
registerServiceImplementation
(
IApplicationReferenceMetricUIDAO
.
class
,
new
ApplicationReferenceMetricH2UIDAO
(
h2Client
));
this
.
registerServiceImplementation
(
ISegmentDurationUIDAO
.
class
,
new
SegmentDurationH2UIDAO
(
h2Client
));
this
.
registerServiceImplementation
(
ISegmentUIDAO
.
class
,
new
SegmentH2UIDAO
(
h2Client
));
this
.
registerServiceImplementation
(
IServiceReference
UIDAO
.
class
,
new
ServiceReferenceH2
UIDAO
(
h2Client
));
this
.
registerServiceImplementation
(
IServiceReference
MetricUIDAO
.
class
,
new
ServiceReferenceH2Metric
UIDAO
(
h2Client
));
}
private
void
registerAlarmDAO
()
throws
ServiceNotProvidedException
{
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java
浏览文件 @
62477a53
...
...
@@ -16,17 +16,16 @@
*
*/
package
org.apache.skywalking.apm.collector.storage.h2.dao.cache
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.apache.skywalking.apm.collector.client.h2.H2Client
;
import
org.apache.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceName
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -45,21 +44,23 @@ public class ServiceNameH2CacheDAO extends H2DAO implements IServiceNameCacheDAO
super
(
client
);
}
@Override
public
S
tring
getServiceName
(
int
serviceId
)
{
@Override
public
S
erviceName
get
(
int
serviceId
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SERVICE_NAME_SQL
,
ServiceNameTable
.
COLUMN_APPLICATION_ID
,
ServiceNameTable
.
COLUMN_SERVICE_NAME
,
ServiceNameTable
.
TABLE
,
ServiceNameTable
.
COLUMN_SERVICE_ID
);
Object
[]
params
=
new
Object
[]
{
serviceId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
String
serviceName
=
rs
.
getString
(
ServiceNameTable
.
COLUMN_SERVICE_NAME
);
int
applicationId
=
rs
.
getInt
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
);
return
applicationId
+
Const
.
ID_SPLIT
+
serviceName
;
ServiceName
serviceName
=
new
ServiceName
();
serviceName
.
setServiceId
(
serviceId
);
serviceName
.
setApplicationId
(
rs
.
getInt
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
));
serviceName
.
setServiceName
(
rs
.
getString
(
ServiceNameTable
.
COLUMN_SERVICE_NAME
));
return
serviceName
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
Const
.
EMPTY_STRING
;
return
null
;
}
@Override
public
int
getServiceId
(
int
applicationId
,
String
serviceName
)
{
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
浏览文件 @
62477a53
...
...
@@ -20,6 +20,7 @@ package org.apache.skywalking.apm.collector.storage.h2.dao.ui;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.Collection
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.client.h2.H2Client
;
...
...
@@ -30,6 +31,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO;
import
org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.apache.skywalking.apm.collector.storage.table.MetricSource
;
import
org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Node
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.utils.DurationPoint
;
import
org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder
;
...
...
@@ -103,4 +105,10 @@ public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO {
return
trends
;
}
@Override
public
List
<
Node
>
getServicesMetric
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
Collection
<
Integer
>
serviceIds
)
{
return
null
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2MetricUIDAO.java
0 → 100644
浏览文件 @
62477a53
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.storage.h2.dao.ui
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.client.h2.H2Client
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.apache.skywalking.apm.collector.storage.table.MetricSource
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Call
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
/**
* @author peng-yongsheng
*/
public
class
ServiceReferenceH2MetricUIDAO
extends
H2DAO
implements
IServiceReferenceMetricUIDAO
{
public
ServiceReferenceH2MetricUIDAO
(
H2Client
client
)
{
super
(
client
);
}
@Override
public
List
<
Call
>
getFrontServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
int
behindServiceId
)
{
return
null
;
}
@Override
public
List
<
Call
>
getBehindServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
int
frontServiceId
)
{
return
null
;
}
@Override
public
List
<
Call
>
getFrontServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
List
<
Integer
>
behindServiceIds
)
{
return
null
;
}
@Override
public
List
<
Call
>
getBehindServices
(
Step
step
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
,
List
<
Integer
>
frontServiceIds
)
{
return
null
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java
已删除
100644 → 0
浏览文件 @
2c6b03bf
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.storage.h2.dao.ui
;
import
com.google.gson.JsonObject
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
org.apache.skywalking.apm.collector.client.h2.H2Client
;
import
org.apache.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.apache.skywalking.apm.collector.core.util.ColumnNameUtils
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
ServiceReferenceH2UIDAO
extends
H2DAO
implements
IServiceReferenceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceReferenceH2UIDAO
.
class
);
public
ServiceReferenceH2UIDAO
(
H2Client
client
)
{
super
(
client
);
}
private
static
final
String
GET_SRV_REF_LOAD1
=
"select {3}, {4}, sum({5}) as {5}, sum({6}) as {6}, sum({7}) as {7}"
+
",sum({8}) as {8} from {0} where {1} >= ? and {1} <= ? and {2} = ? group by {3}, {4}"
;
@Override
public
Map
<
String
,
JsonObject
>
load
(
int
entryServiceId
,
long
startTime
,
long
endTime
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SRV_REF_LOAD1
,
ServiceReferenceMetricTable
.
TABLE
,
ServiceReferenceMetricTable
.
COLUMN_TIME_BUCKET
,
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
,
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
,
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
,
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
,
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
,
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
);
Object
[]
params
=
new
Object
[]
{
startTime
,
endTime
,
entryServiceId
};
return
load
(
client
,
params
,
sql
);
}
private
Map
<
String
,
JsonObject
>
load
(
H2Client
client
,
Object
[]
params
,
String
sql
)
{
Map
<
String
,
JsonObject
>
serviceReferenceMap
=
new
LinkedHashMap
<>();
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
int
frontServiceId
=
rs
.
getInt
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
);
parseSubAggregate
(
serviceReferenceMap
,
rs
,
frontServiceId
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
serviceReferenceMap
;
}
private
void
parseSubAggregate
(
Map
<
String
,
JsonObject
>
serviceReferenceMap
,
ResultSet
rs
,
int
frontServiceId
)
{
try
{
int
behindServiceId
=
rs
.
getInt
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
);
if
(
behindServiceId
!=
0
)
{
long
calls
=
rs
.
getLong
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
);
long
errorCalls
=
rs
.
getLong
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
);
long
durationSum
=
rs
.
getLong
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
);
long
errorDurationSum
=
rs
.
getLong
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
);
JsonObject
serviceReference
=
new
JsonObject
();
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
),
frontServiceId
);
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
),
behindServiceId
);
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
),
calls
);
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
),
errorCalls
);
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
),
durationSum
);
serviceReference
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
),
errorDurationSum
);
String
id
=
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
))
+
Const
.
ID_SPLIT
+
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
));
serviceReferenceMap
.
put
(
id
,
serviceReference
);
}
}
catch
(
SQLException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define
浏览文件 @
62477a53
...
...
@@ -80,10 +80,12 @@ org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmH2Ta
org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmListH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationReferenceAlarmH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationReferenceAlarmListH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.alarm.InstanceAlarmH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.alarm.InstanceAlarmListH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.alarm.InstanceReferenceAlarmH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.alarm.InstanceReferenceAlarmListH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.alarm.ServiceAlarmH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.alarm.ServiceAlarmListH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.alarm.ServiceReferenceAlarmH2TableDefine
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java
浏览文件 @
62477a53
...
...
@@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
import
org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo
;
import
org.apache.skywalking.apm.collector.ui.graphql.Query
;
import
org.apache.skywalking.apm.collector.ui.service.ServiceNameService
;
import
org.apache.skywalking.apm.collector.ui.service.ServiceTopologyService
;
import
org.apache.skywalking.apm.collector.ui.utils.DurationUtils
;
/**
...
...
@@ -39,6 +40,7 @@ public class ServiceQuery implements Query {
private
final
ModuleManager
moduleManager
;
private
ServiceNameService
serviceNameService
;
private
ServiceTopologyService
serviceTopologyService
;
public
ServiceQuery
(
ModuleManager
moduleManager
)
{
this
.
moduleManager
=
moduleManager
;
...
...
@@ -51,6 +53,13 @@ public class ServiceQuery implements Query {
return
serviceNameService
;
}
private
ServiceTopologyService
getServiceTopologyService
()
{
if
(
ObjectUtils
.
isEmpty
(
serviceTopologyService
))
{
this
.
serviceTopologyService
=
new
ServiceTopologyService
(
moduleManager
);
}
return
serviceTopologyService
;
}
public
List
<
ServiceInfo
>
searchService
(
String
keyword
,
int
topN
)
throws
ParseException
{
return
getServiceNameService
().
searchService
(
keyword
,
topN
);
}
...
...
@@ -71,7 +80,9 @@ public class ServiceQuery implements Query {
return
getServiceNameService
().
getServiceSLATrend
(
serviceId
,
duration
.
getStep
(),
start
,
end
);
}
public
Topology
getServiceTopology
(
int
serviceId
,
Duration
duration
)
{
return
null
;
public
Topology
getServiceTopology
(
int
serviceId
,
Duration
duration
)
throws
ParseException
{
long
start
=
DurationUtils
.
INSTANCE
.
exchangeToTimeBucket
(
duration
.
getStart
());
long
end
=
DurationUtils
.
INSTANCE
.
exchangeToTimeBucket
(
duration
.
getEnd
());
return
getServiceTopologyService
().
getServiceTopology
(
duration
.
getStep
(),
serviceId
,
start
,
end
);
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java
0 → 100644
浏览文件 @
62477a53
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.ui.service
;
import
java.text.ParseException
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.skywalking.apm.collector.cache.CacheModule
;
import
org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO
;
import
org.apache.skywalking.apm.collector.storage.table.MetricSource
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceName
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Call
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Node
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Topology
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ServiceTopologyService
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceTopologyService
.
class
);
private
final
IApplicationComponentUIDAO
applicationComponentUIDAO
;
private
final
IServiceMetricUIDAO
serviceMetricUIDAO
;
private
final
IServiceReferenceMetricUIDAO
serviceReferenceMetricUIDAO
;
private
final
ServiceNameCacheService
serviceNameCacheService
;
public
ServiceTopologyService
(
ModuleManager
moduleManager
)
{
this
.
serviceMetricUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IServiceMetricUIDAO
.
class
);
this
.
serviceReferenceMetricUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IServiceReferenceMetricUIDAO
.
class
);
this
.
applicationComponentUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IApplicationComponentUIDAO
.
class
);
this
.
serviceNameCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ServiceNameCacheService
.
class
);
}
public
Topology
getServiceTopology
(
Step
step
,
int
serviceId
,
long
start
,
long
end
)
throws
ParseException
{
logger
.
debug
(
"start: {}, end: {}"
,
start
,
end
);
List
<
IApplicationComponentUIDAO
.
ApplicationComponent
>
applicationComponents
=
applicationComponentUIDAO
.
load
(
step
,
start
,
end
);
Map
<
Integer
,
String
>
components
=
new
HashMap
<>();
applicationComponents
.
forEach
(
component
->
components
.
put
(
component
.
getApplicationId
(),
ComponentsDefine
.
getInstance
().
getComponentName
(
component
.
getComponentId
())));
List
<
Call
>
calleeCalls
=
serviceReferenceMetricUIDAO
.
getFrontServices
(
step
,
start
,
end
,
MetricSource
.
Callee
,
serviceId
);
calleeCalls
.
addAll
(
serviceReferenceMetricUIDAO
.
getBehindServices
(
step
,
start
,
end
,
MetricSource
.
Caller
,
serviceId
));
Set
<
Integer
>
nodeIds
=
new
HashSet
<>();
calleeCalls
.
forEach
(
call
->
{
call
.
setCallType
(
Const
.
EMPTY_STRING
);
nodeIds
.
add
(
call
.
getSource
());
nodeIds
.
add
(
call
.
getTarget
());
});
List
<
Node
>
serviceNodes
=
serviceMetricUIDAO
.
getServicesMetric
(
step
,
start
,
end
,
MetricSource
.
Callee
,
nodeIds
);
serviceNodes
.
forEach
(
serviceNode
->
{
ServiceName
serviceName
=
serviceNameCacheService
.
get
(
serviceNode
.
getId
());
serviceNode
.
setName
(
serviceName
.
getServiceName
());
});
Topology
topology
=
new
Topology
();
topology
.
setCalls
(
calleeCalls
);
topology
.
setNodes
(
serviceNodes
);
return
topology
;
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java
已删除
100644 → 0
浏览文件 @
2c6b03bf
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.ui.service
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.Iterator
;
import
java.util.Map
;
import
org.apache.skywalking.apm.collector.cache.CacheModule
;
import
org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService
;
import
org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.core.util.ColumnNameUtils
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.core.util.ObjectUtils
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable
;
/**
* @author peng-yongsheng
*/
public
class
ServiceTreeService
{
private
final
IServiceReferenceUIDAO
serviceReferenceDAO
;
private
final
ApplicationCacheService
applicationCacheService
;
private
final
ServiceNameCacheService
serviceNameCacheService
;
public
ServiceTreeService
(
ModuleManager
moduleManager
)
{
this
.
serviceReferenceDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IServiceReferenceUIDAO
.
class
);
this
.
applicationCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ApplicationCacheService
.
class
);
this
.
serviceNameCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ServiceNameCacheService
.
class
);
}
public
JsonArray
loadServiceTree
(
int
entryServiceId
,
long
startTime
,
long
endTime
)
{
Map
<
String
,
JsonObject
>
serviceReferenceMap
=
serviceReferenceDAO
.
load
(
entryServiceId
,
startTime
,
endTime
);
serviceReferenceMap
.
values
().
forEach
(
serviceReference
->
{
int
frontServiceId
=
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
)).
getAsInt
();
int
behindServiceId
=
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
)).
getAsInt
();
String
frontServiceName
=
serviceNameCacheService
.
getSplitServiceName
(
serviceNameCacheService
.
get
(
frontServiceId
));
String
behindServiceName
=
serviceNameCacheService
.
getSplitServiceName
(
serviceNameCacheService
.
get
(
behindServiceId
));
serviceReference
.
addProperty
(
"frontServiceName"
,
frontServiceName
);
serviceReference
.
addProperty
(
"behindServiceName"
,
behindServiceName
);
});
return
buildTreeData
(
serviceReferenceMap
);
}
private
JsonArray
buildTreeData
(
Map
<
String
,
JsonObject
>
serviceReferenceMap
)
{
JsonArray
serviceReferenceArray
=
new
JsonArray
();
JsonObject
rootServiceReference
=
findRoot
(
serviceReferenceMap
);
if
(
ObjectUtils
.
isNotEmpty
(
rootServiceReference
))
{
serviceReferenceArray
.
add
(
rootServiceReference
);
String
id
=
rootServiceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
))
+
Const
.
ID_SPLIT
+
rootServiceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
));
serviceReferenceMap
.
remove
(
id
);
int
rootServiceId
=
rootServiceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
)).
getAsInt
();
sortAsTree
(
rootServiceId
,
serviceReferenceArray
,
serviceReferenceMap
);
}
return
serviceReferenceArray
;
}
private
JsonObject
findRoot
(
Map
<
String
,
JsonObject
>
serviceReferenceMap
)
{
for
(
JsonObject
serviceReference
:
serviceReferenceMap
.
values
())
{
int
frontServiceId
=
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
)).
getAsInt
();
if
(
frontServiceId
==
1
)
{
return
serviceReference
;
}
}
return
null
;
}
private
void
sortAsTree
(
int
serviceId
,
JsonArray
serviceReferenceArray
,
Map
<
String
,
JsonObject
>
serviceReferenceMap
)
{
Iterator
<
JsonObject
>
iterator
=
serviceReferenceMap
.
values
().
iterator
();
while
(
iterator
.
hasNext
())
{
JsonObject
serviceReference
=
iterator
.
next
();
int
frontServiceId
=
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
)).
getAsInt
();
if
(
serviceId
==
frontServiceId
)
{
serviceReferenceArray
.
add
(
serviceReference
);
int
behindServiceId
=
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
)).
getAsInt
();
sortAsTree
(
behindServiceId
,
serviceReferenceArray
,
serviceReferenceMap
);
}
}
}
private
void
merge
(
Map
<
String
,
JsonObject
>
serviceReferenceMap
,
JsonObject
serviceReference
)
{
String
id
=
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_FRONT_SERVICE_ID
))
+
Const
.
ID_SPLIT
+
serviceReference
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_BEHIND_SERVICE_ID
));
if
(
serviceReferenceMap
.
containsKey
(
id
))
{
JsonObject
reference
=
serviceReferenceMap
.
get
(
id
);
add
(
reference
,
serviceReference
,
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
));
add
(
reference
,
serviceReference
,
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_CALLS
));
add
(
reference
,
serviceReference
,
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
));
add
(
reference
,
serviceReference
,
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceReferenceMetricTable
.
COLUMN_TRANSACTION_ERROR_DURATION_SUM
));
}
else
{
serviceReferenceMap
.
put
(
id
,
serviceReference
);
}
}
private
void
add
(
JsonObject
oldReference
,
JsonObject
newReference
,
String
key
)
{
long
oldValue
=
oldReference
.
get
(
key
).
getAsLong
();
long
newValue
=
newReference
.
get
(
key
).
getAsLong
();
oldReference
.
addProperty
(
key
,
oldValue
+
newValue
);
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java
浏览文件 @
62477a53
...
...
@@ -16,25 +16,24 @@
*
*/
package
org.apache.skywalking.apm.collector.ui.service
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.cache.CacheModule
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService
;
import
org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.core.util.StringUtils
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceName
;
import
org.apache.skywalking.apm.network.proto.KeyWithStringValue
;
import
org.apache.skywalking.apm.network.proto.LogMessage
;
import
org.apache.skywalking.apm.network.proto.SpanObject
;
import
org.apache.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
/**
* @author peng-yongsheng
...
...
@@ -60,9 +59,9 @@ public class SpanService {
if
(
spanId
==
spanObject
.
getSpanId
())
{
String
operationName
=
spanObject
.
getOperationName
();
if
(
spanObject
.
getOperationNameId
()
!=
0
)
{
S
tring
serviceName
=
serviceNameCacheService
.
get
(
spanObject
.
getOperationNameId
());
S
erviceName
serviceName
=
serviceNameCacheService
.
get
(
spanObject
.
getOperationNameId
());
if
(
StringUtils
.
isNotEmpty
(
serviceName
))
{
operationName
=
serviceName
.
split
(
Const
.
ID_SPLIT
)[
1
]
;
operationName
=
serviceName
.
getServiceName
()
;
}
}
spanJson
.
addProperty
(
"operationName"
,
operationName
);
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java
浏览文件 @
62477a53
...
...
@@ -29,10 +29,10 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import
org.apache.skywalking.apm.collector.core.util.CollectionUtils
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.core.util.ObjectUtils
;
import
org.apache.skywalking.apm.collector.core.util.StringUtils
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.ServiceName
;
import
org.apache.skywalking.apm.collector.storage.ui.trace.KeyValue
;
import
org.apache.skywalking.apm.collector.storage.ui.trace.LogEntity
;
import
org.apache.skywalking.apm.collector.storage.ui.trace.Ref
;
...
...
@@ -137,9 +137,9 @@ public class TraceStackService {
String
operationName
=
spanObject
.
getOperationName
();
if
(
spanObject
.
getOperationNameId
()
!=
0
)
{
S
tring
serviceName
=
serviceNameCacheService
.
get
(
spanObject
.
getOperationNameId
());
if
(
String
Utils
.
isNotEmpty
(
serviceName
))
{
operationName
=
serviceName
.
split
(
Const
.
ID_SPLIT
)[
1
]
;
S
erviceName
serviceName
=
serviceNameCacheService
.
get
(
spanObject
.
getOperationNameId
());
if
(
Object
Utils
.
isNotEmpty
(
serviceName
))
{
operationName
=
serviceName
.
getServiceName
()
;
}
else
{
operationName
=
Const
.
EMPTY_STRING
;
}
...
...
apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls
浏览文件 @
62477a53
...
...
@@ -3,9 +3,8 @@ type ServiceNode implements Node {
name: String!
type: String
# Success rate of all incoming requests.
# Max value is 100.
# 2 Digits after floating point.
sla: Float!
# Max value is 10000.
sla: Int!
# The number of incoming calls
calls: Long!
# The number of services alerting
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录