Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
killuaz丶x
SkyWalking
提交
9a6520fb
S
SkyWalking
项目概览
killuaz丶x
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
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,发现更多精彩内容 >>
提交
9a6520fb
编写于
1月 26, 2018
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Provide the application topology query, but only completed es storage.
上级
e755bba3
变更
56
隐藏空白更改
内联
并排
Showing
56 changed file
with
988 addition
and
419 deletion
+988
-419
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
+17
-0
apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorker.java
...tor/analysis/alarm/provider/worker/AlarmAssertWorker.java
+1
-1
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentCopy.java
...orker/application/component/ApplicationComponentCopy.java
+1
-1
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentSpanListener.java
...plication/component/ApplicationComponentSpanListener.java
+13
-4
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingCopy.java
...er/worker/application/mapping/ApplicationMappingCopy.java
+1
-1
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingSpanListener.java
...r/application/mapping/ApplicationMappingSpanListener.java
+13
-3
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricSpanListener.java
...service/refmetric/ServiceReferenceMetricSpanListener.java
+1
-1
apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java
...provider/parser/standardization/ReferenceIdExchanger.java
+0
-3
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java
.../apm/collector/cache/service/ApplicationCacheService.java
+2
-1
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java
...tor/cache/guava/service/ApplicationCacheGuavaService.java
+10
-11
apm-collector/apm-collector-core/pom.xml
apm-collector/apm-collector-core/pom.xml
+5
-0
apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java
...e/skywalking/apm/collector/core/util/TimeBucketUtils.java
+9
-9
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java
...apm/collector/storage/dao/IApplicationComponentUIDAO.java
+25
-2
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java
...g/apm/collector/storage/dao/IApplicationMappingUIDAO.java
+24
-2
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java
...llector/storage/dao/IApplicationReferenceMetricUIDAO.java
+9
-2
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java
.../skywalking/apm/collector/storage/dao/IInstanceUIDAO.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IApplicationCacheDAO.java
...apm/collector/storage/dao/cache/IApplicationCacheDAO.java
+2
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/MetricSource.java
.../skywalking/apm/collector/storage/table/MetricSource.java
+36
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java
...ector/storage/table/application/ApplicationComponent.java
+4
-4
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponentTable.java
.../storage/table/application/ApplicationComponentTable.java
+1
-2
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java
...llector/storage/table/application/ApplicationMapping.java
+4
-4
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMappingTable.java
...or/storage/table/application/ApplicationMappingTable.java
+1
-2
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java
...apm/collector/storage/ui/application/ApplicationNode.java
+0
-9
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java
...ache/skywalking/apm/collector/storage/ui/common/Call.java
+89
-5
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java
...ache/skywalking/apm/collector/storage/ui/common/Node.java
+3
-3
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
+17
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java
.../collector/storage/utils/TimePyramidTableNameBuilder.java
+50
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java
...collector/storage/es/dao/ApplicationComponentEsUIDAO.java
+21
-24
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java
...m/collector/storage/es/dao/ApplicationMappingEsUIDAO.java
+18
-13
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java
...tor/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java
+80
-48
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java
...walking/apm/collector/storage/es/dao/InstanceEsUIDAO.java
+9
-2
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/AbstractApplicationComponentEsPersistenceDAO.java
...dao/acp/AbstractApplicationComponentEsPersistenceDAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java
.../dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ApplicationEsCacheDAO.java
...collector/storage/es/dao/cache/ApplicationEsCacheDAO.java
+8
-4
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/AbstractApplicationComponentEsTableDefine.java
...ne/appcomp/AbstractApplicationComponentEsTableDefine.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/AbstractApplicationMappingEsTableDefine.java
...e/appmapping/AbstractApplicationMappingEsTableDefine.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java
...collector/storage/h2/dao/ApplicationComponentH2UIDAO.java
+20
-21
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java
...m/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java
+19
-15
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java
...tor/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java
+13
-4
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java
...walking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java
...dao/acp/AbstractApplicationComponentH2PersistenceDAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ampp/AbstractApplicationMappingH2PersistenceDAO.java
.../dao/ampp/AbstractApplicationMappingH2PersistenceDAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java
...collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java
+10
-6
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java
...ne/appcomp/AbstractApplicationComponentH2TableDefine.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appmapping/AbstractApplicationMappingH2TableDefine.java
...e/appmapping/AbstractApplicationMappingH2TableDefine.java
+1
-1
apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java
...walking/apm/collector/ui/utils/DurationUtilsTestCase.java
+32
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
...e/skywalking/apm/collector/ui/query/ApplicationQuery.java
+17
-28
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java
...ywalking/apm/collector/ui/service/ApplicationService.java
+3
-3
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java
.../apm/collector/ui/service/ApplicationTopologyService.java
+129
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java
...lking/apm/collector/ui/service/InstanceHealthService.java
+1
-1
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
+1
-1
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
.../skywalking/apm/collector/ui/service/TopologyBuilder.java
+153
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java
...walking/apm/collector/ui/service/TraceDagDataBuilder.java
+0
-153
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
+1
-1
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java
...ache/skywalking/apm/collector/ui/utils/DurationUtils.java
+91
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java
...king/apm/collector/ui/query/ApplicationQueryTestCase.java
+10
-10
未找到文件。
apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json
浏览文件 @
9a6520fb
...
...
@@ -46,6 +46,23 @@
}
],
"lo"
:
[]
},
{
"si"
:
1
,
"tv"
:
1
,
"lv"
:
1
,
"ps"
:
0
,
"st"
:
1501858094726
,
"et"
:
1501858095804
,
"ci"
:
9
,
"cn"
:
""
,
"oi"
:
0
,
"on"
:
"mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"
,
"pi"
:
0
,
"pn"
:
"localhost:27017"
,
"ie"
:
false
,
"to"
:
[],
"lo"
:
[]
}
]
}
...
...
apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorker.java
浏览文件 @
9a6520fb
...
...
@@ -18,7 +18,7 @@
package
org.apache.skywalking.apm.collector.analysis.alarm.provider.worker
;
import
org.apache.skywalking.apm.collector.
analysis.metric.defin
e.MetricSource
;
import
org.apache.skywalking.apm.collector.
storage.tabl
e.MetricSource
;
import
org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorker
;
import
org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException
;
import
org.apache.skywalking.apm.collector.core.data.StreamData
;
...
...
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentCopy.java
浏览文件 @
9a6520fb
...
...
@@ -31,7 +31,7 @@ public class ApplicationComponentCopy {
newApplicationComponent
.
setMetricId
(
applicationComponent
.
getMetricId
());
newApplicationComponent
.
setComponentId
(
applicationComponent
.
getComponentId
());
newApplicationComponent
.
set
PeerId
(
applicationComponent
.
getPeer
Id
());
newApplicationComponent
.
set
ApplicationId
(
applicationComponent
.
getApplication
Id
());
newApplicationComponent
.
setTimeBucket
(
newApplicationComponent
.
getTimeBucket
());
return
newApplicationComponent
;
}
...
...
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentSpanListener.java
浏览文件 @
9a6520fb
...
...
@@ -27,6 +27,8 @@ import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listen
import
org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener
;
import
org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener
;
import
org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory
;
import
org.apache.skywalking.apm.collector.cache.CacheModule
;
import
org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService
;
import
org.apache.skywalking.apm.collector.core.graph.Graph
;
import
org.apache.skywalking.apm.collector.core.graph.GraphManager
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
...
...
@@ -39,17 +41,24 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application
*/
public
class
ApplicationComponentSpanListener
implements
EntrySpanListener
,
ExitSpanListener
,
FirstSpanListener
{
private
final
ApplicationCacheService
applicationCacheService
;
private
List
<
ApplicationComponent
>
applicationComponents
=
new
ArrayList
<>();
private
long
timeBucket
;
ApplicationComponentSpanListener
(
ModuleManager
moduleManager
)
{
this
.
applicationCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ApplicationCacheService
.
class
);
}
@Override
public
void
parseExit
(
SpanDecorator
spanDecorator
,
int
applicationId
,
int
instanceId
,
String
segmentId
)
{
String
metricId
=
spanDecorator
.
getPeerId
()
+
Const
.
ID_SPLIT
+
String
.
valueOf
(
spanDecorator
.
getComponentId
());
int
applicationIdFromPeerId
=
applicationCacheService
.
getApplicationIdByAddressId
(
spanDecorator
.
getPeerId
());
String
metricId
=
applicationIdFromPeerId
+
Const
.
ID_SPLIT
+
String
.
valueOf
(
spanDecorator
.
getComponentId
());
ApplicationComponent
applicationComponent
=
new
ApplicationComponent
();
applicationComponent
.
setMetricId
(
metricId
);
applicationComponent
.
setComponentId
(
spanDecorator
.
getComponentId
());
applicationComponent
.
set
PeerId
(
spanDecorator
.
getPeerId
()
);
applicationComponent
.
set
ApplicationId
(
applicationIdFromPeerId
);
applicationComponents
.
add
(
applicationComponent
);
}
...
...
@@ -60,7 +69,7 @@ public class ApplicationComponentSpanListener implements EntrySpanListener, Exit
ApplicationComponent
applicationComponent
=
new
ApplicationComponent
();
applicationComponent
.
setMetricId
(
metricId
);
applicationComponent
.
setComponentId
(
spanDecorator
.
getComponentId
());
applicationComponent
.
set
Peer
Id
(
applicationId
);
applicationComponent
.
set
Application
Id
(
applicationId
);
applicationComponents
.
add
(
applicationComponent
);
}
...
...
@@ -82,7 +91,7 @@ public class ApplicationComponentSpanListener implements EntrySpanListener, Exit
public
static
class
Factory
implements
SpanListenerFactory
{
@Override
public
SpanListener
create
(
ModuleManager
moduleManager
)
{
return
new
ApplicationComponentSpanListener
();
return
new
ApplicationComponentSpanListener
(
moduleManager
);
}
}
}
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingCopy.java
浏览文件 @
9a6520fb
...
...
@@ -32,7 +32,7 @@ public class ApplicationMappingCopy {
newApplicationMapping
.
setTimeBucket
(
applicationMapping
.
getTimeBucket
());
newApplicationMapping
.
setApplicationId
(
applicationMapping
.
getApplicationId
());
newApplicationMapping
.
set
AddressId
(
applicationMapping
.
getAddress
Id
());
newApplicationMapping
.
set
MappingApplicationId
(
applicationMapping
.
getMappingApplication
Id
());
return
newApplicationMapping
;
}
}
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingSpanListener.java
浏览文件 @
9a6520fb
...
...
@@ -26,6 +26,8 @@ import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listen
import
org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener
;
import
org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener
;
import
org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory
;
import
org.apache.skywalking.apm.collector.cache.CacheModule
;
import
org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService
;
import
org.apache.skywalking.apm.collector.core.graph.Graph
;
import
org.apache.skywalking.apm.collector.core.graph.GraphManager
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
...
...
@@ -42,18 +44,26 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationMappingSpanListener
.
class
);
private
final
ApplicationCacheService
applicationCacheService
;
private
List
<
ApplicationMapping
>
applicationMappings
=
new
LinkedList
<>();
private
long
timeBucket
;
ApplicationMappingSpanListener
(
ModuleManager
moduleManager
)
{
this
.
applicationCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ApplicationCacheService
.
class
);
}
@Override
public
void
parseEntry
(
SpanDecorator
spanDecorator
,
int
applicationId
,
int
instanceId
,
String
segmentId
)
{
logger
.
debug
(
"application mapping listener parse reference"
);
if
(
spanDecorator
.
getRefsCount
()
>
0
)
{
for
(
int
i
=
0
;
i
<
spanDecorator
.
getRefsCount
();
i
++)
{
ApplicationMapping
applicationMapping
=
new
ApplicationMapping
();
applicationMapping
.
setApplicationId
(
applicationId
);
applicationMapping
.
setAddressId
(
spanDecorator
.
getRefs
(
i
).
getNetworkAddressId
());
String
metricId
=
String
.
valueOf
(
applicationId
)
+
Const
.
ID_SPLIT
+
String
.
valueOf
(
applicationMapping
.
getAddressId
());
int
addressId
=
spanDecorator
.
getRefs
(
i
).
getNetworkAddressId
();
int
mappingApplicationId
=
applicationCacheService
.
getApplicationIdByAddressId
(
addressId
);
applicationMapping
.
setMappingApplicationId
(
mappingApplicationId
);
String
metricId
=
String
.
valueOf
(
applicationId
)
+
Const
.
ID_SPLIT
+
String
.
valueOf
(
applicationMapping
.
getMappingApplicationId
());
applicationMapping
.
setMetricId
(
metricId
);
applicationMappings
.
add
(
applicationMapping
);
}
...
...
@@ -79,7 +89,7 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS
public
static
class
Factory
implements
SpanListenerFactory
{
@Override
public
SpanListener
create
(
ModuleManager
moduleManager
)
{
return
new
ApplicationMappingSpanListener
();
return
new
ApplicationMappingSpanListener
(
moduleManager
);
}
}
}
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricSpanListener.java
浏览文件 @
9a6520fb
...
...
@@ -20,7 +20,7 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.serv
import
java.util.LinkedList
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.
analysis.metric.defin
e.MetricSource
;
import
org.apache.skywalking.apm.collector.
storage.tabl
e.MetricSource
;
import
org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine
;
import
org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator
;
import
org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator
;
...
...
apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java
浏览文件 @
9a6520fb
...
...
@@ -19,7 +19,6 @@
package
org.apache.skywalking.apm.collector.analysis.segment.parser.provider.parser.standardization
;
import
org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule
;
import
org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService
;
import
org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService
;
import
org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService
;
import
org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator
;
...
...
@@ -39,7 +38,6 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ReferenceIdExchanger
.
class
);
private
static
ReferenceIdExchanger
EXCHANGER
;
private
final
IApplicationIDService
applicationIDService
;
private
final
IServiceNameService
serviceNameService
;
private
final
InstanceCacheService
instanceCacheService
;
private
final
INetworkAddressIDService
networkAddressIDService
;
...
...
@@ -52,7 +50,6 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
}
private
ReferenceIdExchanger
(
ModuleManager
moduleManager
)
{
this
.
applicationIDService
=
moduleManager
.
find
(
AnalysisRegisterModule
.
NAME
).
getService
(
IApplicationIDService
.
class
);
this
.
serviceNameService
=
moduleManager
.
find
(
AnalysisRegisterModule
.
NAME
).
getService
(
IServiceNameService
.
class
);
this
.
networkAddressIDService
=
moduleManager
.
find
(
AnalysisRegisterModule
.
NAME
).
getService
(
INetworkAddressIDService
.
class
);
this
.
instanceCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
InstanceCacheService
.
class
);
...
...
apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java
浏览文件 @
9a6520fb
...
...
@@ -19,6 +19,7 @@
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.Application
;
/**
* @author peng-yongsheng
...
...
@@ -26,7 +27,7 @@ import org.apache.skywalking.apm.collector.core.module.Service;
public
interface
ApplicationCacheService
extends
Service
{
int
getApplicationIdByCode
(
String
applicationCode
);
String
getApplicationCode
ById
(
int
applicationId
);
Application
getApplication
ById
(
int
applicationId
);
int
getApplicationIdByAddressId
(
int
addressId
);
}
apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java
浏览文件 @
9a6520fb
...
...
@@ -22,11 +22,10 @@ import com.google.common.cache.Cache;
import
com.google.common.cache.CacheBuilder
;
import
org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService
;
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.core.util.StringUtils
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.Application
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -70,23 +69,23 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService {
return
applicationId
;
}
private
final
Cache
<
Integer
,
String
>
id
Cache
=
CacheBuilder
.
newBuilder
().
maximumSize
(
1000
).
build
();
private
final
Cache
<
Integer
,
Application
>
application
Cache
=
CacheBuilder
.
newBuilder
().
maximumSize
(
1000
).
build
();
@Override
public
String
getApplicationCode
ById
(
int
applicationId
)
{
String
applicationCode
=
Const
.
EMPTY_STRING
;
@Override
public
Application
getApplication
ById
(
int
applicationId
)
{
Application
application
=
null
;
try
{
application
Code
=
idCache
.
get
(
applicationId
,
()
->
getApplicationCacheDAO
().
getApplicationCode
(
applicationId
));
application
=
applicationCache
.
get
(
applicationId
,
()
->
getApplicationCacheDAO
().
getApplication
(
applicationId
));
}
catch
(
Throwable
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
if
(
StringUtils
.
isEmpty
(
applicationCode
))
{
application
Code
=
getApplicationCacheDAO
().
getApplicationCode
(
applicationId
);
if
(
StringUtils
.
isNotEmpty
(
applicationCode
))
{
codeCache
.
put
(
applicationCode
,
applicationId
);
if
(
ObjectUtils
.
isEmpty
(
application
))
{
application
=
getApplicationCacheDAO
().
getApplication
(
applicationId
);
if
(
ObjectUtils
.
isNotEmpty
(
application
))
{
applicationCache
.
put
(
applicationId
,
application
);
}
}
return
application
Code
;
return
application
;
}
private
final
Cache
<
Integer
,
Integer
>
addressIdCache
=
CacheBuilder
.
newBuilder
().
maximumSize
(
1000
).
build
();
...
...
apm-collector/apm-collector-core/pom.xml
浏览文件 @
9a6520fb
...
...
@@ -36,5 +36,10 @@
<artifactId>
gson
</artifactId>
<version>
2.8.1
</version>
</dependency>
<dependency>
<groupId>
joda-time
</groupId>
<artifactId>
joda-time
</artifactId>
<version>
2.9.9
</version>
</dependency>
</dependencies>
</project>
apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java
浏览文件 @
9a6520fb
...
...
@@ -27,37 +27,37 @@ import java.util.Calendar;
public
enum
TimeBucketUtils
{
INSTANCE
;
p
rivate
final
SimpleDateFormat
monthDateFormat
=
new
SimpleDateFormat
(
"yyyyMM"
);
p
rivate
final
SimpleDateFormat
dayDateFormat
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
p
rivate
final
SimpleDateFormat
hourDateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
p
rivate
final
SimpleDateFormat
minuteDateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHHmm"
);
p
rivate
final
SimpleDateFormat
secondDateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
p
ublic
static
final
SimpleDateFormat
MONTH_DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyyMM"
);
p
ublic
static
final
SimpleDateFormat
DAY_DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
p
ublic
static
final
SimpleDateFormat
HOUR_DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyyMMddHH"
);
p
ublic
static
final
SimpleDateFormat
MINUTE_DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyyMMddHHmm"
);
p
ublic
static
final
SimpleDateFormat
SECOND_DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
public
long
getMinuteTimeBucket
(
long
time
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTimeInMillis
(
time
);
String
timeStr
=
minuteDateFormat
.
format
(
calendar
.
getTime
());
String
timeStr
=
MINUTE_DATE_FORMAT
.
format
(
calendar
.
getTime
());
return
Long
.
valueOf
(
timeStr
);
}
public
long
getSecondTimeBucket
(
long
time
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTimeInMillis
(
time
);
String
timeStr
=
secondDateFormat
.
format
(
calendar
.
getTime
());
String
timeStr
=
SECOND_DATE_FORMAT
.
format
(
calendar
.
getTime
());
return
Long
.
valueOf
(
timeStr
);
}
public
long
getHourTimeBucket
(
long
time
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTimeInMillis
(
time
);
String
timeStr
=
hourDateFormat
.
format
(
calendar
.
getTime
())
+
"00"
;
String
timeStr
=
HOUR_DATE_FORMAT
.
format
(
calendar
.
getTime
())
+
"00"
;
return
Long
.
valueOf
(
timeStr
);
}
public
long
getDayTimeBucket
(
long
time
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTimeInMillis
(
time
);
String
timeStr
=
dayDateFormat
.
format
(
calendar
.
getTime
())
+
"0000"
;
String
timeStr
=
DAY_DATE_FORMAT
.
format
(
calendar
.
getTime
())
+
"0000"
;
return
Long
.
valueOf
(
timeStr
);
}
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -18,12 +18,35 @@
package
org.apache.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonArray
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
/**
* @author peng-yongsheng
*/
public
interface
IApplicationComponentUIDAO
extends
DAO
{
JsonArray
load
(
long
startTime
,
long
endTime
);
List
<
ApplicationComponent
>
load
(
Step
step
,
long
startTime
,
long
endTime
);
class
ApplicationComponent
{
private
int
componentId
;
private
int
applicationId
;
public
int
getComponentId
()
{
return
componentId
;
}
public
void
setComponentId
(
int
componentId
)
{
this
.
componentId
=
componentId
;
}
public
int
getApplicationId
()
{
return
applicationId
;
}
public
void
setApplicationId
(
int
applicationId
)
{
this
.
applicationId
=
applicationId
;
}
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -18,12 +18,34 @@
package
org.apache.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonArray
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
/**
* @author peng-yongsheng
*/
public
interface
IApplicationMappingUIDAO
extends
DAO
{
JsonArray
load
(
long
startTime
,
long
endTime
);
List
<
ApplicationMapping
>
load
(
Step
step
,
long
startTime
,
long
endTime
);
class
ApplicationMapping
{
private
int
applicationId
;
private
int
mappingApplicationId
;
public
int
getApplicationId
()
{
return
applicationId
;
}
public
void
setApplicationId
(
int
applicationId
)
{
this
.
applicationId
=
applicationId
;
}
public
int
getMappingApplicationId
()
{
return
mappingApplicationId
;
}
public
void
setMappingApplicationId
(
int
mappingApplicationId
)
{
this
.
mappingApplicationId
=
mappingApplicationId
;
}
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -18,12 +18,19 @@
package
org.apache.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonArray
;
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
IApplicationReferenceMetricUIDAO
extends
DAO
{
JsonArray
load
(
long
startTime
,
long
endTime
);
List
<
Call
>
getFrontApplications
(
Step
step
,
int
applicationId
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
);
List
<
Call
>
getBehindApplications
(
Step
step
,
int
applicationId
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -31,7 +31,7 @@ public interface IInstanceUIDAO extends DAO {
Long
instanceLastHeartBeatTime
(
long
applicationInstanceId
);
List
<
Application
>
getApplications
(
long
startTime
,
long
endTime
);
List
<
Application
>
getApplications
(
long
startTime
,
long
endTime
,
int
...
applicationIds
);
Instance
getInstance
(
int
instanceId
);
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IApplicationCacheDAO.java
浏览文件 @
9a6520fb
...
...
@@ -19,6 +19,7 @@
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.Application
;
/**
* @author peng-yongsheng
...
...
@@ -26,7 +27,7 @@ import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
public
interface
IApplicationCacheDAO
extends
DAO
{
int
getApplicationIdByCode
(
String
applicationCode
);
String
getApplicationCode
(
int
applicationId
);
Application
getApplication
(
int
applicationId
);
int
getApplicationIdByAddressId
(
int
addressId
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/MetricSource.java
0 → 100644
浏览文件 @
9a6520fb
/*
* 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.table
;
/**
* @author peng-yongsheng
*/
public
enum
MetricSource
{
Caller
(
0
),
Callee
(
1
);
private
final
int
value
;
private
MetricSource
(
int
value
)
{
this
.
value
=
value
;
}
public
int
getValue
()
{
return
value
;
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java
浏览文件 @
9a6520fb
...
...
@@ -41,7 +41,7 @@ public class ApplicationComponent extends StreamData {
private
static
final
Column
[]
INTEGER_COLUMNS
=
{
new
Column
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
,
new
CoverOperation
()),
new
Column
(
ApplicationComponentTable
.
COLUMN_
PEER
_ID
,
new
CoverOperation
()),
new
Column
(
ApplicationComponentTable
.
COLUMN_
APPLICATION
_ID
,
new
CoverOperation
()),
};
private
static
final
Column
[]
BYTE_COLUMNS
=
{};
...
...
@@ -82,11 +82,11 @@ public class ApplicationComponent extends StreamData {
setDataInteger
(
0
,
componentId
);
}
public
Integer
get
Peer
Id
()
{
public
Integer
get
Application
Id
()
{
return
getDataInteger
(
1
);
}
public
void
set
PeerId
(
Integer
peer
Id
)
{
setDataInteger
(
1
,
peer
Id
);
public
void
set
ApplicationId
(
Integer
application
Id
)
{
setDataInteger
(
1
,
application
Id
);
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponentTable.java
浏览文件 @
9a6520fb
...
...
@@ -16,7 +16,6 @@
*
*/
package
org.apache.skywalking.apm.collector.storage.table.application
;
import
org.apache.skywalking.apm.collector.core.data.CommonTable
;
...
...
@@ -27,5 +26,5 @@ import org.apache.skywalking.apm.collector.core.data.CommonTable;
public
class
ApplicationComponentTable
extends
CommonTable
{
public
static
final
String
TABLE
=
"application_component"
;
public
static
final
String
COLUMN_COMPONENT_ID
=
"component_id"
;
public
static
final
String
COLUMN_
PEER_ID
=
"peer
_id"
;
public
static
final
String
COLUMN_
APPLICATION_ID
=
"application
_id"
;
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java
浏览文件 @
9a6520fb
...
...
@@ -41,7 +41,7 @@ public class ApplicationMapping extends StreamData {
private
static
final
Column
[]
INTEGER_COLUMNS
=
{
new
Column
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
,
new
CoverOperation
()),
new
Column
(
ApplicationMappingTable
.
COLUMN_
ADDRESS
_ID
,
new
CoverOperation
()),
new
Column
(
ApplicationMappingTable
.
COLUMN_
MAPPING_APPLICATION
_ID
,
new
CoverOperation
()),
};
private
static
final
Column
[]
BYTE_COLUMNS
=
{};
...
...
@@ -74,12 +74,12 @@ public class ApplicationMapping extends StreamData {
setDataInteger
(
0
,
applicationId
);
}
public
int
get
Address
Id
()
{
public
int
get
MappingApplication
Id
()
{
return
getDataInteger
(
1
);
}
public
void
set
AddressId
(
int
address
Id
)
{
setDataInteger
(
1
,
address
Id
);
public
void
set
MappingApplicationId
(
int
mappingApplication
Id
)
{
setDataInteger
(
1
,
mappingApplication
Id
);
}
public
long
getTimeBucket
()
{
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMappingTable.java
浏览文件 @
9a6520fb
...
...
@@ -16,7 +16,6 @@
*
*/
package
org.apache.skywalking.apm.collector.storage.table.application
;
import
org.apache.skywalking.apm.collector.core.data.CommonTable
;
...
...
@@ -27,5 +26,5 @@ import org.apache.skywalking.apm.collector.core.data.CommonTable;
public
class
ApplicationMappingTable
extends
CommonTable
{
public
static
final
String
TABLE
=
"application_mapping"
;
public
static
final
String
COLUMN_APPLICATION_ID
=
"application_id"
;
public
static
final
String
COLUMN_
ADDRESS_ID
=
"address
_id"
;
public
static
final
String
COLUMN_
MAPPING_APPLICATION_ID
=
"mapping_application
_id"
;
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java
浏览文件 @
9a6520fb
...
...
@@ -28,7 +28,6 @@ public class ApplicationNode extends Node {
private
Float
sla
;
private
Long
callsPerSec
;
private
Integer
responseTimePerSec
;
private
Long
calls
;
private
Float
apdex
;
private
Boolean
isAlarm
;
private
Integer
numOfServer
;
...
...
@@ -59,14 +58,6 @@ public class ApplicationNode extends Node {
this
.
responseTimePerSec
=
responseTimePerSec
;
}
public
Long
getCalls
()
{
return
calls
;
}
public
void
setCalls
(
Long
calls
)
{
this
.
calls
=
calls
;
}
public
Float
getApdex
()
{
return
apdex
;
}
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java
浏览文件 @
9a6520fb
...
...
@@ -22,10 +22,94 @@ package org.apache.skywalking.apm.collector.storage.ui.common;
* @author peng-yongsheng
*/
public
class
Call
{
private
String
source
;
private
String
target
;
private
Boolean
isAlert
;
private
int
source
;
private
String
sourceName
;
private
int
target
;
private
String
targetName
;
private
boolean
isAlert
;
private
String
callType
;
private
Integer
callsPerSec
;
private
Integer
responseTimePerSec
;
private
int
calls
;
private
int
callsPerSec
;
private
long
responseTimes
;
private
int
responseTimePerSec
;
public
int
getSource
()
{
return
source
;
}
public
void
setSource
(
int
source
)
{
this
.
source
=
source
;
}
public
String
getSourceName
()
{
return
sourceName
;
}
public
void
setSourceName
(
String
sourceName
)
{
this
.
sourceName
=
sourceName
;
}
public
int
getTarget
()
{
return
target
;
}
public
void
setTarget
(
int
target
)
{
this
.
target
=
target
;
}
public
String
getTargetName
()
{
return
targetName
;
}
public
void
setTargetName
(
String
targetName
)
{
this
.
targetName
=
targetName
;
}
public
boolean
isAlert
()
{
return
isAlert
;
}
public
void
setAlert
(
boolean
alert
)
{
isAlert
=
alert
;
}
public
String
getCallType
()
{
return
callType
;
}
public
void
setCallType
(
String
callType
)
{
this
.
callType
=
callType
;
}
public
int
getCalls
()
{
return
calls
;
}
public
void
setCalls
(
int
calls
)
{
this
.
calls
=
calls
;
}
public
int
getCallsPerSec
()
{
return
callsPerSec
;
}
public
void
setCallsPerSec
(
int
callsPerSec
)
{
this
.
callsPerSec
=
callsPerSec
;
}
public
long
getResponseTimes
()
{
return
responseTimes
;
}
public
void
setResponseTimes
(
long
responseTimes
)
{
this
.
responseTimes
=
responseTimes
;
}
public
int
getResponseTimePerSec
()
{
return
responseTimePerSec
;
}
public
void
setResponseTimePerSec
(
int
responseTimePerSec
)
{
this
.
responseTimePerSec
=
responseTimePerSec
;
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java
浏览文件 @
9a6520fb
...
...
@@ -22,15 +22,15 @@ package org.apache.skywalking.apm.collector.storage.ui.common;
* @author peng-yongsheng
*/
public
abstract
class
Node
{
private
String
id
;
private
int
id
;
private
String
name
;
private
String
type
;
public
String
getId
()
{
public
int
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java
浏览文件 @
9a6520fb
...
...
@@ -24,6 +24,23 @@ import java.util.List;
* @author peng-yongsheng
*/
public
class
Topology
{
private
List
<
Node
>
nodes
;
private
List
<
Call
>
calls
;
public
List
<
Node
>
getNodes
()
{
return
nodes
;
}
public
void
setNodes
(
List
<
Node
>
nodes
)
{
this
.
nodes
=
nodes
;
}
public
List
<
Call
>
getCalls
()
{
return
calls
;
}
public
void
setCalls
(
List
<
Call
>
calls
)
{
this
.
calls
=
calls
;
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java
0 → 100644
浏览文件 @
9a6520fb
/*
* 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.utils
;
import
org.apache.skywalking.apm.collector.core.storage.TimePyramid
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
/**
* @author peng-yongsheng
*/
public
class
TimePyramidTableNameBuilder
{
private
TimePyramidTableNameBuilder
()
{
}
public
static
String
build
(
Step
step
,
String
tableName
)
{
switch
(
step
)
{
case
MONTH:
tableName
=
tableName
+
Const
.
ID_SPLIT
+
TimePyramid
.
Month
.
getName
();
break
;
case
DAY:
tableName
=
tableName
+
Const
.
ID_SPLIT
+
TimePyramid
.
Day
.
getName
();
break
;
case
HOUR:
tableName
=
tableName
+
Const
.
ID_SPLIT
+
TimePyramid
.
Day
.
getName
();
break
;
case
MINUTE:
tableName
=
tableName
+
Const
.
ID_SPLIT
+
TimePyramid
.
Minute
.
getName
();
break
;
}
return
tableName
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -18,13 +18,14 @@
package
org.apache.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObjec
t
;
import
java.util.LinkedList
;
import
java.util.Lis
t
;
import
org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentMinuteEsPersistenceDAO
;
import
org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable
;
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
;
...
...
@@ -39,51 +40,47 @@ import org.slf4j.LoggerFactory;
*/
public
class
ApplicationComponentEsUIDAO
extends
EsDAO
implements
IApplicationComponentUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationComponent
MinuteEsPersistence
DAO
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationComponent
EsUI
DAO
.
class
);
public
ApplicationComponentEsUIDAO
(
ElasticSearchClient
client
)
{
super
(
client
);
}
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
@Override
public
List
<
ApplicationComponent
>
load
(
Step
step
,
long
startTime
,
long
endTime
)
{
logger
.
debug
(
"application component load, start time: {}, end time: {}"
,
startTime
,
endTime
);
JsonArray
applicationComponentArray
=
new
JsonArray
();
applicationComponentArray
.
addAll
(
aggregationByComponentId
(
startTime
,
endTime
));
return
applicationComponentArray
;
}
private
JsonArray
aggregationByComponentId
(
long
startTime
,
long
endTime
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
ApplicationComponentTable
.
TABLE
);
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ApplicationComponentTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ApplicationComponentTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
rangeQuery
(
ApplicationComponentTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
searchRequestBuilder
.
setSize
(
0
);
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
terms
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
).
field
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
terms
(
ApplicationComponentTable
.
COLUMN_
PEER_ID
).
field
(
ApplicationComponentTable
.
COLUMN_PEER
_ID
).
size
(
100
)));
.
subAggregation
(
AggregationBuilders
.
terms
(
ApplicationComponentTable
.
COLUMN_
APPLICATION_ID
).
field
(
ApplicationComponentTable
.
COLUMN_APPLICATION
_ID
).
size
(
100
)));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
Terms
componentIdTerms
=
searchResponse
.
getAggregations
().
get
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
);
JsonArray
applicationComponentArray
=
new
JsonArray
();
List
<
ApplicationComponent
>
applicationComponents
=
new
LinkedList
<>();
for
(
Terms
.
Bucket
componentIdBucket
:
componentIdTerms
.
getBuckets
())
{
int
componentId
=
componentIdBucket
.
getKeyAsNumber
().
intValue
();
build
ComponentArray
(
componentIdBucket
,
componentId
,
applicationComponentArray
);
build
ApplicationComponents
(
componentIdBucket
,
componentId
,
applicationComponents
);
}
return
applicationComponent
Array
;
return
applicationComponent
s
;
}
private
void
build
ComponentArray
(
Terms
.
Bucket
componentBucket
,
int
componentId
,
JsonArray
applicationComponentArray
)
{
Terms
peerIdTerms
=
componentBucket
.
getAggregations
().
get
(
ApplicationComponentTable
.
COLUMN_
PEER
_ID
);
private
void
build
ApplicationComponents
(
Terms
.
Bucket
componentBucket
,
int
componentId
,
List
<
ApplicationComponent
>
applicationComponents
)
{
Terms
peerIdTerms
=
componentBucket
.
getAggregations
().
get
(
ApplicationComponentTable
.
COLUMN_
APPLICATION
_ID
);
for
(
Terms
.
Bucket
peerIdBucket
:
peerIdTerms
.
getBuckets
())
{
int
peer
Id
=
peerIdBucket
.
getKeyAsNumber
().
intValue
();
int
application
Id
=
peerIdBucket
.
getKeyAsNumber
().
intValue
();
JsonObject
applicationComponentObj
=
new
JsonObjec
t
();
applicationComponent
Obj
.
addProperty
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
,
componentId
);
applicationComponent
Obj
.
addProperty
(
ApplicationComponentTable
.
COLUMN_PEER_ID
,
peer
Id
);
applicationComponent
Array
.
add
(
applicationComponentObj
);
ApplicationComponent
applicationComponent
=
new
ApplicationComponen
t
();
applicationComponent
.
setComponentId
(
componentId
);
applicationComponent
.
setApplicationId
(
application
Id
);
applicationComponent
s
.
add
(
applicationComponent
);
}
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -18,12 +18,14 @@
package
org.apache.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObjec
t
;
import
java.util.LinkedList
;
import
java.util.Lis
t
;
import
org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO
;
import
org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable
;
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
;
...
...
@@ -44,8 +46,10 @@ public class ApplicationMappingEsUIDAO extends EsDAO implements IApplicationMapp
super
(
client
);
}
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
ApplicationMappingTable
.
TABLE
);
@Override
public
List
<
ApplicationMapping
>
load
(
Step
step
,
long
startTime
,
long
endTime
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ApplicationMappingTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ApplicationMappingTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
rangeQuery
(
ApplicationMappingTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
...
...
@@ -53,24 +57,25 @@ public class ApplicationMappingEsUIDAO extends EsDAO implements IApplicationMapp
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
terms
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
).
field
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
terms
(
ApplicationMappingTable
.
COLUMN_
ADDRESS_ID
).
field
(
ApplicationMappingTable
.
COLUMN_ADDRESS
_ID
).
size
(
100
)));
.
subAggregation
(
AggregationBuilders
.
terms
(
ApplicationMappingTable
.
COLUMN_
MAPPING_APPLICATION_ID
).
field
(
ApplicationMappingTable
.
COLUMN_MAPPING_APPLICATION
_ID
).
size
(
100
)));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
Terms
applicationIdTerms
=
searchResponse
.
getAggregations
().
get
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
);
JsonArray
applicationMappingArray
=
new
JsonArray
();
List
<
ApplicationMapping
>
applicationMappings
=
new
LinkedList
<>
();
for
(
Terms
.
Bucket
applicationIdBucket
:
applicationIdTerms
.
getBuckets
())
{
int
applicationId
=
applicationIdBucket
.
getKeyAsNumber
().
intValue
();
Terms
addressIdTerms
=
applicationIdBucket
.
getAggregations
().
get
(
ApplicationMappingTable
.
COLUMN_
ADDRESS
_ID
);
Terms
addressIdTerms
=
applicationIdBucket
.
getAggregations
().
get
(
ApplicationMappingTable
.
COLUMN_
MAPPING_APPLICATION
_ID
);
for
(
Terms
.
Bucket
addressIdBucket
:
addressIdTerms
.
getBuckets
())
{
int
addressId
=
addressIdBucket
.
getKeyAsNumber
().
intValue
();
JsonObject
applicationMappingObj
=
new
JsonObject
();
applicationMappingObj
.
addProperty
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
,
applicationId
);
applicationMappingObj
.
addProperty
(
ApplicationMappingTable
.
COLUMN_ADDRESS_ID
,
addressId
);
applicationMappingArray
.
add
(
applicationMappingObj
);
ApplicationMapping
applicationMapping
=
new
ApplicationMapping
();
applicationMapping
.
setApplicationId
(
applicationId
);
applicationMapping
.
setMappingApplicationId
(
addressId
);
applicationMappings
.
add
(
applicationMapping
);
}
}
logger
.
debug
(
"application mapping data: {}"
,
applicationMapping
Array
.
toString
());
return
applicationMapping
Array
;
logger
.
debug
(
"application mapping data: {}"
,
applicationMapping
s
.
toString
());
return
applicationMapping
s
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -18,82 +18,114 @@
package
org.apache.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
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.IApplicationReferenceMetricUIDAO
;
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.application.ApplicationReferenceMetricTable
;
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.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.elasticsearch.search.aggregations.metrics.sum.Sum
;
/**
* @author peng-yongsheng
*/
public
class
ApplicationReferenceMetricEsUIDAO
extends
EsDAO
implements
IApplicationReferenceMetricUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationReferenceMetricEsUIDAO
.
class
);
public
ApplicationReferenceMetricEsUIDAO
(
ElasticSearchClient
client
)
{
super
(
client
);
}
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
ApplicationReferenceMetricTable
.
TABLE
);
@Override
public
List
<
Call
>
getFrontApplications
(
Step
step
,
int
applicationId
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ApplicationReferenceMetricTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ApplicationReferenceMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
rangeQuery
(
ApplicationReferenceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ApplicationReferenceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ApplicationReferenceMetricTable
.
COLUMN_BEHIND_APPLICATION_ID
,
applicationId
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ApplicationReferenceMetricTable
.
COLUMN_SOURCE_VALUE
,
metricSource
.
getValue
()));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
ApplicationReferenceMetricTable
.
COLUMN_FRONT_APPLICATION_ID
).
field
(
ApplicationReferenceMetricTable
.
COLUMN_FRONT_APPLICATION_ID
).
size
(
100
);
// aggregationBuilder.subAggregation(AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100)
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S1_LTE).field(ApplicationReferenceMetricTable.COLUMN_S1_LTE))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S3_LTE).field(ApplicationReferenceMetricTable.COLUMN_S3_LTE))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_LTE).field(ApplicationReferenceMetricTable.COLUMN_S5_LTE))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_GT).field(ApplicationReferenceMetricTable.COLUMN_S5_GT))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_SUMMARY).field(ApplicationReferenceMetricTable.COLUMN_SUMMARY))
// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_ERROR).field(ApplicationReferenceMetricTable.COLUMN_ERROR)));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
).
field
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
).
field
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
));
searchRequestBuilder
.
addAggregation
(
aggregationBuilder
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
JsonArray
applicationReferenceMetricArray
=
new
JsonArray
();
// Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
// for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) {
// int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue();
// Terms behindApplicationIdTerms = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID);
// for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) {
// int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue();
//
// if (behindApplicationId != 0) {
// Sum s1LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S1_LTE);
// Sum s3LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S3_LTE);
// Sum s5LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_LTE);
// Sum s5GT = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_GT);
// Sum summary = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_SUMMARY);
// Sum error = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_ERROR);
// logger.debug("frontApplicationId: {}, behindApplicationId: {}, s1LTE: {}, s3LTE: {}, s5LTE: {}, s5GT: {}, error: {}, summary: {}", frontApplicationId,
// behindApplicationId, s1LTE.getValue(), s3LTE.getValue(), s5LTE.getValue(), s5GT.getValue(), error.getValue(), summary.getValue());
//
// JsonObject nodeRefResSumObj = new JsonObject();
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId);
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId);
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), s1LTE.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), s3LTE.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), s5LTE.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), s5GT.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), error.getValue());
// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), summary.getValue());
// nodeRefResSumArray.add(nodeRefResSumObj);
// }
// }
// }
return
applicationReferenceMetricArray
;
List
<
Call
>
nodes
=
new
LinkedList
<>();
Terms
frontApplicationIdTerms
=
searchResponse
.
getAggregations
().
get
(
ApplicationReferenceMetricTable
.
COLUMN_FRONT_APPLICATION_ID
);
for
(
Terms
.
Bucket
frontApplicationIdBucket
:
frontApplicationIdTerms
.
getBuckets
())
{
int
frontApplicationId
=
frontApplicationIdBucket
.
getKeyAsNumber
().
intValue
();
Sum
calls
=
frontApplicationIdBucket
.
getAggregations
().
get
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
);
Sum
responseTimes
=
frontApplicationIdBucket
.
getAggregations
().
get
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
);
Call
call
=
new
Call
();
call
.
setSource
(
frontApplicationId
);
call
.
setTarget
(
applicationId
);
call
.
setCalls
((
int
)
calls
.
getValue
());
call
.
setResponseTimes
((
int
)
responseTimes
.
getValue
());
nodes
.
add
(
call
);
}
return
nodes
;
}
@Override
public
List
<
Call
>
getBehindApplications
(
Step
step
,
int
applicationId
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ApplicationReferenceMetricTable
.
TABLE
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
tableName
);
searchRequestBuilder
.
setTypes
(
ApplicationReferenceMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ApplicationReferenceMetricTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ApplicationReferenceMetricTable
.
COLUMN_FRONT_APPLICATION_ID
,
applicationId
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
ApplicationReferenceMetricTable
.
COLUMN_SOURCE_VALUE
,
metricSource
.
getValue
()));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
ApplicationReferenceMetricTable
.
COLUMN_BEHIND_APPLICATION_ID
).
field
(
ApplicationReferenceMetricTable
.
COLUMN_BEHIND_APPLICATION_ID
).
size
(
100
);
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
).
field
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
sum
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
).
field
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
));
searchRequestBuilder
.
addAggregation
(
aggregationBuilder
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
List
<
Call
>
nodes
=
new
LinkedList
<>();
Terms
behindApplicationIdTerms
=
searchResponse
.
getAggregations
().
get
(
ApplicationReferenceMetricTable
.
COLUMN_BEHIND_APPLICATION_ID
);
for
(
Terms
.
Bucket
behindApplicationIdBucket
:
behindApplicationIdTerms
.
getBuckets
())
{
int
behindApplicationId
=
behindApplicationIdBucket
.
getKeyAsNumber
().
intValue
();
Sum
calls
=
behindApplicationIdBucket
.
getAggregations
().
get
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
);
Sum
responseTimes
=
behindApplicationIdBucket
.
getAggregations
().
get
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_DURATION_SUM
);
Call
call
=
new
Call
();
call
.
setTarget
(
behindApplicationId
);
call
.
setSource
(
applicationId
);
call
.
setCalls
((
int
)
calls
.
getValue
());
call
.
setResponseTimes
((
int
)
responseTimes
.
getValue
());
nodes
.
add
(
call
);
}
return
nodes
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -94,12 +94,19 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO {
return
heartBeatTime
;
}
@Override
public
List
<
Application
>
getApplications
(
long
startTime
,
long
endTime
)
{
@Override
public
List
<
Application
>
getApplications
(
long
startTime
,
long
endTime
,
int
...
applicationIds
)
{
logger
.
debug
(
"application list get, start time: {}, end time: {}"
,
startTime
,
endTime
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
InstanceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
InstanceTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
rangeQuery
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
).
gte
(
startTime
));
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
).
gte
(
startTime
));
if
(
applicationIds
.
length
>
0
)
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
termsQuery
(
InstanceTable
.
COLUMN_APPLICATION_ID
,
applicationIds
));
}
searchRequestBuilder
.
setQuery
(
boolQueryBuilder
);
searchRequestBuilder
.
setSize
(
0
);
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
terms
(
InstanceTable
.
COLUMN_APPLICATION_ID
).
field
(
InstanceTable
.
COLUMN_APPLICATION_ID
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
count
(
InstanceTable
.
COLUMN_INSTANCE_ID
).
field
(
InstanceTable
.
COLUMN_INSTANCE_ID
)));
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/AbstractApplicationComponentEsPersistenceDAO.java
浏览文件 @
9a6520fb
...
...
@@ -44,7 +44,7 @@ public abstract class AbstractApplicationComponentEsPersistenceDAO extends Abstr
applicationComponent
.
setMetricId
((
String
)
source
.
get
(
ApplicationComponentTable
.
COLUMN_METRIC_ID
));
applicationComponent
.
setComponentId
(((
Number
)
source
.
get
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
)).
intValue
());
applicationComponent
.
set
PeerId
(((
Number
)
source
.
get
(
ApplicationComponentTable
.
COLUMN_PEER
_ID
)).
intValue
());
applicationComponent
.
set
ApplicationId
(((
Number
)
source
.
get
(
ApplicationComponentTable
.
COLUMN_APPLICATION
_ID
)).
intValue
());
applicationComponent
.
setTimeBucket
(((
Number
)
source
.
get
(
ApplicationComponentTable
.
COLUMN_TIME_BUCKET
)).
longValue
());
return
applicationComponent
;
}
...
...
@@ -55,7 +55,7 @@ public abstract class AbstractApplicationComponentEsPersistenceDAO extends Abstr
source
.
put
(
ApplicationComponentTable
.
COLUMN_METRIC_ID
,
streamData
.
getMetricId
());
source
.
put
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
,
streamData
.
getComponentId
());
source
.
put
(
ApplicationComponentTable
.
COLUMN_
PEER_ID
,
streamData
.
getPeer
Id
());
source
.
put
(
ApplicationComponentTable
.
COLUMN_
APPLICATION_ID
,
streamData
.
getApplication
Id
());
source
.
put
(
ApplicationComponentTable
.
COLUMN_TIME_BUCKET
,
streamData
.
getTimeBucket
());
return
source
;
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java
浏览文件 @
9a6520fb
...
...
@@ -44,7 +44,7 @@ public abstract class AbstractApplicationMappingEsPersistenceDAO extends Abstrac
applicationMapping
.
setMetricId
((
String
)
source
.
get
(
ApplicationMappingTable
.
COLUMN_METRIC_ID
));
applicationMapping
.
setApplicationId
(((
Number
)
source
.
get
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
)).
intValue
());
applicationMapping
.
set
AddressId
(((
Number
)
source
.
get
(
ApplicationMappingTable
.
COLUMN_ADDRESS
_ID
)).
intValue
());
applicationMapping
.
set
MappingApplicationId
(((
Number
)
source
.
get
(
ApplicationMappingTable
.
COLUMN_MAPPING_APPLICATION
_ID
)).
intValue
());
applicationMapping
.
setTimeBucket
(((
Number
)
source
.
get
(
ApplicationMappingTable
.
COLUMN_TIME_BUCKET
)).
longValue
());
return
applicationMapping
;
}
...
...
@@ -55,7 +55,7 @@ public abstract class AbstractApplicationMappingEsPersistenceDAO extends Abstrac
source
.
put
(
ApplicationMappingTable
.
COLUMN_METRIC_ID
,
streamData
.
getMetricId
());
source
.
put
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
,
streamData
.
getApplicationId
());
source
.
put
(
ApplicationMappingTable
.
COLUMN_
ADDRESS_ID
,
streamData
.
getAddress
Id
());
source
.
put
(
ApplicationMappingTable
.
COLUMN_
MAPPING_APPLICATION_ID
,
streamData
.
getMappingApplication
Id
());
source
.
put
(
ApplicationMappingTable
.
COLUMN_TIME_BUCKET
,
streamData
.
getTimeBucket
());
return
source
;
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ApplicationEsCacheDAO.java
浏览文件 @
9a6520fb
...
...
@@ -20,9 +20,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.BooleanUtils
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO
;
import
org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.Application
;
import
org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable
;
import
org.elasticsearch.action.get.GetRequestBuilder
;
import
org.elasticsearch.action.get.GetResponse
;
...
...
@@ -68,16 +68,20 @@ public class ApplicationEsCacheDAO extends EsDAO implements IApplicationCacheDAO
return
0
;
}
@Override
public
String
getApplicationCode
(
int
applicationId
)
{
@Override
public
Application
getApplication
(
int
applicationId
)
{
logger
.
debug
(
"get application code, applicationId: {}"
,
applicationId
);
ElasticSearchClient
client
=
getClient
();
GetRequestBuilder
getRequestBuilder
=
client
.
prepareGet
(
ApplicationTable
.
TABLE
,
String
.
valueOf
(
applicationId
));
GetResponse
getResponse
=
getRequestBuilder
.
get
();
if
(
getResponse
.
isExists
())
{
return
(
String
)
getResponse
.
getSource
().
get
(
ApplicationTable
.
COLUMN_APPLICATION_CODE
);
Application
application
=
new
Application
();
application
.
setApplicationId
(
applicationId
);
application
.
setApplicationCode
((
String
)
getResponse
.
getSource
().
get
(
ApplicationTable
.
COLUMN_APPLICATION_CODE
));
application
.
setIsAddress
(((
Number
)
getResponse
.
getSource
().
get
(
ApplicationTable
.
COLUMN_IS_ADDRESS
)).
intValue
());
return
application
;
}
return
Const
.
EMPTY_STRING
;
return
null
;
}
@Override
public
int
getApplicationIdByAddressId
(
int
addressId
)
{
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/AbstractApplicationComponentEsTableDefine.java
浏览文件 @
9a6520fb
...
...
@@ -34,7 +34,7 @@ public abstract class AbstractApplicationComponentEsTableDefine extends ElasticS
@Override
public
final
void
initialize
()
{
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationComponentTable
.
COLUMN_METRIC_ID
,
ElasticSearchColumnDefine
.
Type
.
Keyword
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationComponentTable
.
COLUMN_
PEER
_ID
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationComponentTable
.
COLUMN_
APPLICATION
_ID
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationComponentTable
.
COLUMN_TIME_BUCKET
,
ElasticSearchColumnDefine
.
Type
.
Long
.
name
()));
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/AbstractApplicationMappingEsTableDefine.java
浏览文件 @
9a6520fb
...
...
@@ -34,7 +34,7 @@ public abstract class AbstractApplicationMappingEsTableDefine extends ElasticSea
@Override
public
final
void
initialize
()
{
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationMappingTable
.
COLUMN_METRIC_ID
,
ElasticSearchColumnDefine
.
Type
.
Keyword
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationMappingTable
.
COLUMN_
ADDRESS
_ID
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationMappingTable
.
COLUMN_
MAPPING_APPLICATION
_ID
,
ElasticSearchColumnDefine
.
Type
.
Integer
.
name
()));
addColumn
(
new
ElasticSearchColumnDefine
(
ApplicationMappingTable
.
COLUMN_TIME_BUCKET
,
ElasticSearchColumnDefine
.
Type
.
Long
.
name
()));
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -16,19 +16,20 @@
*
*/
package
org.apache.skywalking.apm.collector.storage.h2.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.LinkedList
;
import
java.util.List
;
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.IApplicationComponentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable
;
import
org.apache.skywalking.apm.collector.
client.h2.H2ClientException
;
import
org.apache.skywalking.apm.collector.storage.
dao.IApplicationComponentUIDAO
;
import
org.apache.skywalking.apm.collector.
storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.
utils.TimePyramidTableNameBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -44,31 +45,29 @@ public class ApplicationComponentH2UIDAO extends H2DAO implements IApplicationCo
super
(
client
);
}
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
JsonArray
applicationComponentArray
=
new
JsonArray
();
applicationComponentArray
.
addAll
(
aggregationComponent
(
startTime
,
endTime
));
return
applicationComponentArray
;
}
private
JsonArray
aggregationComponent
(
long
startTime
,
long
endTime
)
{
@Override
public
List
<
ApplicationComponent
>
load
(
Step
step
,
long
startTime
,
long
endTime
)
{
H2Client
client
=
getClient
();
JsonArray
applicationComponentArray
=
new
JsonArray
();
String
sql
=
SqlBuilder
.
buildSql
(
AGGREGATE_COMPONENT_SQL
,
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
,
ApplicationComponentTable
.
COLUMN_PEER_ID
,
ApplicationComponentTable
.
TABLE
,
ApplicationComponentTable
.
COLUMN_TIME_BUCKET
);
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ApplicationComponentTable
.
TABLE
);
List
<
ApplicationComponent
>
applicationComponents
=
new
LinkedList
<>();
String
sql
=
SqlBuilder
.
buildSql
(
AGGREGATE_COMPONENT_SQL
,
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
,
ApplicationComponentTable
.
COLUMN_APPLICATION_ID
,
tableName
,
ApplicationComponentTable
.
COLUMN_TIME_BUCKET
);
Object
[]
params
=
new
Object
[]
{
startTime
,
endTime
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
int
peerId
=
rs
.
getInt
(
ApplicationComponentTable
.
COLUMN_PEER
_ID
);
int
applicationId
=
rs
.
getInt
(
ApplicationComponentTable
.
COLUMN_APPLICATION
_ID
);
int
componentId
=
rs
.
getInt
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
);
JsonObject
applicationComponentObj
=
new
JsonObject
();
applicationComponentObj
.
addProperty
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
,
componentId
);
applicationComponentObj
.
addProperty
(
ApplicationComponentTable
.
COLUMN_PEER_ID
,
peerId
);
applicationComponentArray
.
add
(
applicationComponentObj
);
ApplicationComponent
applicationComponent
=
new
ApplicationComponent
();
applicationComponent
.
setComponentId
(
componentId
);
applicationComponent
.
setApplicationId
(
applicationId
);
applicationComponents
.
add
(
applicationComponent
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
applicationComponent
Array
;
return
applicationComponent
s
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -16,19 +16,20 @@
*
*/
package
org.apache.skywalking.apm.collector.storage.h2.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.LinkedList
;
import
java.util.List
;
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.IApplicationMappingUIDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable
;
import
org.apache.skywalking.apm.collector.
client.h2.H2ClientException
;
import
org.apache.skywalking.apm.collector.storage.
dao.IApplicationMappingUIDAO
;
import
org.apache.skywalking.apm.collector.
storage.ui.common.Step
;
import
org.apache.skywalking.apm.collector.storage.
utils.TimePyramidTableNameBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -44,26 +45,29 @@ public class ApplicationMappingH2UIDAO extends H2DAO implements IApplicationMapp
super
(
client
);
}
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
@Override
public
List
<
ApplicationMapping
>
load
(
Step
step
,
long
startTime
,
long
endTime
)
{
String
tableName
=
TimePyramidTableNameBuilder
.
build
(
step
,
ApplicationMappingTable
.
TABLE
);
H2Client
client
=
getClient
();
JsonArray
applicationMappingArray
=
new
JsonArray
();
String
sql
=
SqlBuilder
.
buildSql
(
APPLICATION_MAPPING_SQL
,
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
,
ApplicationMappingTable
.
COLUMN_
ADDRESS_ID
,
ApplicationMappingTable
.
TABLE
,
ApplicationMappingTable
.
COLUMN_TIME_BUCKET
);
ApplicationMappingTable
.
COLUMN_
MAPPING_APPLICATION_ID
,
tableName
,
ApplicationMappingTable
.
COLUMN_TIME_BUCKET
);
List
<
ApplicationMapping
>
applicationMappings
=
new
LinkedList
<>();
Object
[]
params
=
new
Object
[]
{
startTime
,
endTime
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
int
applicationId
=
rs
.
getInt
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
);
int
addressId
=
rs
.
getInt
(
ApplicationMappingTable
.
COLUMN_ADDRESS_ID
);
JsonObject
applicationMappingObj
=
new
JsonObject
();
applicationMappingObj
.
addProperty
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
,
applicationId
);
applicationMappingObj
.
addProperty
(
ApplicationMappingTable
.
COLUMN_ADDRESS_ID
,
addressId
);
applicationMappingArray
.
add
(
applicationMappingObj
);
int
addressId
=
rs
.
getInt
(
ApplicationMappingTable
.
COLUMN_MAPPING_APPLICATION_ID
);
ApplicationMapping
applicationMapping
=
new
ApplicationMapping
();
applicationMapping
.
setApplicationId
(
applicationId
);
applicationMapping
.
setMappingApplicationId
(
addressId
);
applicationMappings
.
add
(
applicationMapping
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
logger
.
debug
(
"node mapping data: {}"
,
applicationMapping
Array
.
toString
());
return
applicationMapping
Array
;
logger
.
debug
(
"node mapping data: {}"
,
applicationMapping
s
.
toString
());
return
applicationMapping
s
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -16,13 +16,16 @@
*
*/
package
org.apache.skywalking.apm.collector.storage.h2.dao
;
import
com.google.gson.JsonArray
;
import
java.util.List
;
import
org.apache.skywalking.apm.collector.client.h2.H2Client
;
import
org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO
;
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
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -39,7 +42,8 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica
super
(
client
);
}
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
@Override
public
List
<
Call
>
getFrontApplications
(
Step
step
,
int
applicationId
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
)
{
H2Client
client
=
getClient
();
JsonArray
applicationReferenceMetricArray
=
new
JsonArray
();
// String sql = SqlBuilder.buildSql(APPLICATION_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE,
...
...
@@ -67,6 +71,11 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica
// } catch (SQLException | H2ClientException e) {
// logger.error(e.getMessage(), e);
// }
return
applicationReferenceMetricArray
;
return
null
;
}
@Override
public
List
<
Call
>
getBehindApplications
(
Step
step
,
int
applicationId
,
long
startTime
,
long
endTime
,
MetricSource
metricSource
)
{
return
null
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java
浏览文件 @
9a6520fb
...
...
@@ -87,7 +87,7 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO {
}
@Override
public
List
<
Application
>
getApplications
(
long
startTime
,
long
endTime
)
{
public
List
<
Application
>
getApplications
(
long
startTime
,
long
endTime
,
int
...
applicationIds
)
{
H2Client
client
=
getClient
();
List
<
Application
>
applications
=
new
LinkedList
<>();
String
sql
=
SqlBuilder
.
buildSql
(
GET_APPLICATIONS_SQL
,
InstanceTable
.
COLUMN_INSTANCE_ID
,
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java
浏览文件 @
9a6520fb
...
...
@@ -42,7 +42,7 @@ public abstract class AbstractApplicationComponentH2PersistenceDAO extends Abstr
applicationComponent
.
setMetricId
(
resultSet
.
getString
(
ApplicationComponentTable
.
COLUMN_METRIC_ID
));
applicationComponent
.
setComponentId
(
resultSet
.
getInt
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
));
applicationComponent
.
set
PeerId
(
resultSet
.
getInt
(
ApplicationComponentTable
.
COLUMN_PEER
_ID
));
applicationComponent
.
set
ApplicationId
(
resultSet
.
getInt
(
ApplicationComponentTable
.
COLUMN_APPLICATION
_ID
));
applicationComponent
.
setTimeBucket
(
resultSet
.
getLong
(
ApplicationComponentTable
.
COLUMN_TIME_BUCKET
));
return
applicationComponent
;
}
...
...
@@ -52,7 +52,7 @@ public abstract class AbstractApplicationComponentH2PersistenceDAO extends Abstr
source
.
put
(
ApplicationComponentTable
.
COLUMN_METRIC_ID
,
streamData
.
getMetricId
());
source
.
put
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
,
streamData
.
getComponentId
());
source
.
put
(
ApplicationComponentTable
.
COLUMN_
PEER_ID
,
streamData
.
getPeer
Id
());
source
.
put
(
ApplicationComponentTable
.
COLUMN_
APPLICATION_ID
,
streamData
.
getApplication
Id
());
source
.
put
(
ApplicationComponentTable
.
COLUMN_TIME_BUCKET
,
streamData
.
getTimeBucket
());
return
source
;
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ampp/AbstractApplicationMappingH2PersistenceDAO.java
浏览文件 @
9a6520fb
...
...
@@ -42,7 +42,7 @@ public abstract class AbstractApplicationMappingH2PersistenceDAO extends Abstrac
applicationMapping
.
setMetricId
(
resultSet
.
getString
(
ApplicationMappingTable
.
COLUMN_METRIC_ID
));
applicationMapping
.
setApplicationId
(
resultSet
.
getInt
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
));
applicationMapping
.
set
AddressId
(
resultSet
.
getInt
(
ApplicationMappingTable
.
COLUMN_ADDRESS
_ID
));
applicationMapping
.
set
MappingApplicationId
(
resultSet
.
getInt
(
ApplicationMappingTable
.
COLUMN_MAPPING_APPLICATION
_ID
));
applicationMapping
.
setTimeBucket
(
resultSet
.
getLong
(
ApplicationMappingTable
.
COLUMN_TIME_BUCKET
));
return
applicationMapping
;
}
...
...
@@ -52,7 +52,7 @@ public abstract class AbstractApplicationMappingH2PersistenceDAO extends Abstrac
source
.
put
(
ApplicationMappingTable
.
COLUMN_METRIC_ID
,
streamData
.
getMetricId
());
source
.
put
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
,
streamData
.
getApplicationId
());
source
.
put
(
ApplicationMappingTable
.
COLUMN_
ADDRESS_ID
,
streamData
.
getAddress
Id
());
source
.
put
(
ApplicationMappingTable
.
COLUMN_
MAPPING_APPLICATION_ID
,
streamData
.
getMappingApplication
Id
());
source
.
put
(
ApplicationMappingTable
.
COLUMN_TIME_BUCKET
,
streamData
.
getTimeBucket
());
return
source
;
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java
浏览文件 @
9a6520fb
...
...
@@ -22,10 +22,10 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
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.Const
;
import
org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO
;
import
org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.Application
;
import
org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -38,7 +38,7 @@ public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationH2CacheDAO
.
class
);
private
static
final
String
GET_APPLICATION_ID_SQL
=
"select {0} from {1} where {2} = ? and {3} = ?"
;
private
static
final
String
GET_APPLICATION_
CODE_SQL
=
"select {0} from {1} where {2
} = ?"
;
private
static
final
String
GET_APPLICATION_
SQL
=
"select {0},{1} from {2} where {3
} = ?"
;
public
ApplicationH2CacheDAO
(
H2Client
client
)
{
super
(
client
);
...
...
@@ -61,19 +61,23 @@ public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO
return
0
;
}
@Override
public
String
getApplicationCode
(
int
applicationId
)
{
@Override
public
Application
getApplication
(
int
applicationId
)
{
logger
.
debug
(
"get application code, applicationId: {}"
,
applicationId
);
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_APPLICATION_
CODE_SQL
,
ApplicationTable
.
COLUMN_APPLICATION_CODE
,
ApplicationTable
.
TABLE
,
ApplicationTable
.
COLUMN_APPLICATION_ID
);
String
sql
=
SqlBuilder
.
buildSql
(
GET_APPLICATION_
SQL
,
ApplicationTable
.
COLUMN_APPLICATION_CODE
,
ApplicationTable
.
COLUMN_IS_ADDRESS
,
ApplicationTable
.
TABLE
,
ApplicationTable
.
COLUMN_APPLICATION_ID
);
Object
[]
params
=
new
Object
[]
{
applicationId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getString
(
1
);
Application
application
=
new
Application
();
application
.
setApplicationId
(
applicationId
);
application
.
setApplicationCode
(
rs
.
getString
(
1
));
application
.
setIsAddress
(
rs
.
getInt
(
2
));
return
application
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
Const
.
EMPTY_STRING
;
return
null
;
}
@Override
public
int
getApplicationIdByAddressId
(
int
addressId
)
{
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java
浏览文件 @
9a6520fb
...
...
@@ -35,7 +35,7 @@ public abstract class AbstractApplicationComponentH2TableDefine extends H2TableD
addColumn
(
new
H2ColumnDefine
(
ApplicationComponentTable
.
COLUMN_ID
,
H2ColumnDefine
.
Type
.
Varchar
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationComponentTable
.
COLUMN_METRIC_ID
,
H2ColumnDefine
.
Type
.
Varchar
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationComponentTable
.
COLUMN_
PEER
_ID
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationComponentTable
.
COLUMN_
APPLICATION
_ID
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationComponentTable
.
COLUMN_TIME_BUCKET
,
H2ColumnDefine
.
Type
.
Bigint
.
name
()));
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appmapping/AbstractApplicationMappingH2TableDefine.java
浏览文件 @
9a6520fb
...
...
@@ -35,7 +35,7 @@ public abstract class AbstractApplicationMappingH2TableDefine extends H2TableDef
addColumn
(
new
H2ColumnDefine
(
ApplicationMappingTable
.
COLUMN_ID
,
H2ColumnDefine
.
Type
.
Varchar
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationMappingTable
.
COLUMN_METRIC_ID
,
H2ColumnDefine
.
Type
.
Varchar
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationMappingTable
.
COLUMN_
ADDRESS
_ID
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationMappingTable
.
COLUMN_
MAPPING_APPLICATION
_ID
,
H2ColumnDefine
.
Type
.
Int
.
name
()));
addColumn
(
new
H2ColumnDefine
(
ApplicationMappingTable
.
COLUMN_TIME_BUCKET
,
H2ColumnDefine
.
Type
.
Bigint
.
name
()));
}
}
apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java
0 → 100644
浏览文件 @
9a6520fb
/*
* 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.utils
;
import
java.text.ParseException
;
import
org.junit.Test
;
/**
* @author peng-yongsheng
*/
public
class
DurationUtilsTestCase
{
@Test
public
void
test
()
throws
ParseException
{
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
浏览文件 @
9a6520fb
...
...
@@ -28,8 +28,9 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
import
org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo
;
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.graphql.utils.DurationUtils
;
import
org.apache.skywalking.apm.collector.ui.service.ApplicationService
;
import
org.apache.skywalking.apm.collector.ui.service.ApplicationTopologyService
;
import
org.apache.skywalking.apm.collector.ui.utils.DurationUtils
;
/**
* @author peng-yongsheng
...
...
@@ -38,6 +39,7 @@ public class ApplicationQuery implements Query {
private
final
ModuleManager
moduleManager
;
private
ApplicationService
applicationService
;
private
ApplicationTopologyService
applicationTopologyService
;
public
ApplicationQuery
(
ModuleManager
moduleManager
)
{
this
.
moduleManager
=
moduleManager
;
...
...
@@ -50,38 +52,25 @@ public class ApplicationQuery implements Query {
return
applicationService
;
}
public
List
<
Application
>
getAllApplication
(
Duration
duration
)
throws
ParseException
{
long
start
=
0
;
long
end
=
0
;
switch
(
duration
.
getStep
())
{
case
MONTH:
start
=
DurationUtils
.
INSTANCE
.
monthDurationToSecondTimeBucket
(
duration
.
getStart
());
end
=
DurationUtils
.
INSTANCE
.
monthDurationToSecondTimeBucket
(
duration
.
getEnd
());
break
;
case
DAY:
start
=
DurationUtils
.
INSTANCE
.
dayDurationToSecondTimeBucket
(
duration
.
getStart
());
end
=
DurationUtils
.
INSTANCE
.
dayDurationToSecondTimeBucket
(
duration
.
getEnd
());
break
;
case
HOUR:
start
=
DurationUtils
.
INSTANCE
.
hourDurationToSecondTimeBucket
(
duration
.
getStart
());
end
=
DurationUtils
.
INSTANCE
.
hourDurationToSecondTimeBucket
(
duration
.
getEnd
());
break
;
case
MINUTE:
start
=
DurationUtils
.
INSTANCE
.
minuteDurationToSecondTimeBucket
(
duration
.
getStart
());
end
=
DurationUtils
.
INSTANCE
.
minuteDurationToSecondTimeBucket
(
duration
.
getEnd
());
break
;
case
SECOND:
start
=
DurationUtils
.
INSTANCE
.
exchangeToTimeBucket
(
duration
.
getStart
());
end
=
DurationUtils
.
INSTANCE
.
exchangeToTimeBucket
(
duration
.
getEnd
());
break
;
private
ApplicationTopologyService
getApplicationTopologyService
()
{
if
(
ObjectUtils
.
isEmpty
(
applicationTopologyService
))
{
this
.
applicationTopologyService
=
new
ApplicationTopologyService
(
moduleManager
);
}
return
applicationTopologyService
;
}
public
List
<
Application
>
getAllApplication
(
Duration
duration
)
throws
ParseException
{
long
start
=
DurationUtils
.
INSTANCE
.
durationToSecondTimeBucket
(
duration
.
getStep
(),
duration
.
getStart
());
long
end
=
DurationUtils
.
INSTANCE
.
durationToSecondTimeBucket
(
duration
.
getStep
(),
duration
.
getEnd
());
return
getApplicationService
().
getApplications
(
start
,
end
);
}
public
Topology
getApplicationTopology
(
int
applicationId
,
Duration
duration
)
{
return
null
;
public
Topology
getApplicationTopology
(
int
applicationId
,
Duration
duration
)
throws
ParseException
{
long
start
=
DurationUtils
.
INSTANCE
.
exchangeToTimeBucket
(
duration
.
getStart
());
long
end
=
DurationUtils
.
INSTANCE
.
exchangeToTimeBucket
(
duration
.
getEnd
());
return
getApplicationTopologyService
().
getApplicationTopology
(
duration
.
getStep
(),
applicationId
,
start
,
end
);
}
public
List
<
ServiceInfo
>
getSlowService
(
int
applicationId
,
Duration
duration
,
Integer
top
)
{
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java
浏览文件 @
9a6520fb
...
...
@@ -39,11 +39,11 @@ public class ApplicationService {
this
.
applicationCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ApplicationCacheService
.
class
);
}
public
List
<
Application
>
getApplications
(
long
startTime
,
long
endTime
)
{
List
<
Application
>
applications
=
instanceDAO
.
getApplications
(
startTime
,
endTime
);
public
List
<
Application
>
getApplications
(
long
startTime
,
long
endTime
,
int
...
applicationIds
)
{
List
<
Application
>
applications
=
instanceDAO
.
getApplications
(
startTime
,
endTime
,
applicationIds
);
applications
.
forEach
(
application
->
{
String
applicationCode
=
applicationCacheService
.
getApplication
CodeById
(
application
.
getId
()
);
String
applicationCode
=
applicationCacheService
.
getApplication
ById
(
application
.
getId
()).
getApplicationCode
(
);
application
.
setName
(
applicationCode
);
});
return
applications
;
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java
0 → 100644
浏览文件 @
9a6520fb
/*
* 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.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.storage.StorageModule
;
import
org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO
;
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
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Topology
;
import
org.apache.skywalking.apm.collector.ui.utils.DurationUtils
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ApplicationTopologyService
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationTopologyService
.
class
);
private
final
IApplicationComponentUIDAO
applicationComponentUIDAO
;
private
final
IApplicationMappingUIDAO
applicationMappingUIDAO
;
private
final
IApplicationReferenceMetricUIDAO
applicationReferenceMetricUIDAO
;
private
final
ModuleManager
moduleManager
;
public
ApplicationTopologyService
(
ModuleManager
moduleManager
)
{
this
.
moduleManager
=
moduleManager
;
this
.
applicationComponentUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IApplicationComponentUIDAO
.
class
);
this
.
applicationMappingUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IApplicationMappingUIDAO
.
class
);
this
.
applicationReferenceMetricUIDAO
=
moduleManager
.
find
(
StorageModule
.
NAME
).
getService
(
IApplicationReferenceMetricUIDAO
.
class
);
}
public
Topology
getApplicationTopology
(
Step
step
,
int
applicationId
,
long
startTime
,
long
endTime
)
throws
ParseException
{
logger
.
debug
(
"startTime: {}, endTime: {}"
,
startTime
,
endTime
);
List
<
IApplicationComponentUIDAO
.
ApplicationComponent
>
applicationComponents
=
applicationComponentUIDAO
.
load
(
step
,
startTime
,
endTime
);
List
<
IApplicationMappingUIDAO
.
ApplicationMapping
>
applicationMappings
=
applicationMappingUIDAO
.
load
(
step
,
startTime
,
endTime
);
Map
<
Integer
,
String
>
components
=
new
HashMap
<>();
applicationComponents
.
forEach
(
component
->
components
.
put
(
component
.
getApplicationId
(),
ComponentsDefine
.
getInstance
().
getComponentName
(
component
.
getComponentId
())));
List
<
Call
>
callerCalls
=
applicationReferenceMetricUIDAO
.
getFrontApplications
(
step
,
applicationId
,
startTime
,
endTime
,
MetricSource
.
Caller
);
callerCalls
.
addAll
(
applicationReferenceMetricUIDAO
.
getBehindApplications
(
step
,
applicationId
,
startTime
,
endTime
,
MetricSource
.
Caller
));
callerCalls
.
forEach
(
callerCall
->
callerCall
.
setCallType
(
components
.
get
(
callerCall
.
getTarget
())));
List
<
Call
>
calleeCalls
=
applicationReferenceMetricUIDAO
.
getFrontApplications
(
step
,
applicationId
,
startTime
,
endTime
,
MetricSource
.
Callee
);
calleeCalls
.
addAll
(
applicationReferenceMetricUIDAO
.
getBehindApplications
(
step
,
applicationId
,
startTime
,
endTime
,
MetricSource
.
Callee
));
calleeCalls
.
forEach
(
calleeCall
->
calleeCall
.
setCallType
(
components
.
get
(
calleeCall
.
getTarget
())));
Set
<
Integer
>
mappings
=
new
HashSet
<>();
applicationMappings
.
forEach
(
mapping
->
{
if
(
applicationId
==
mapping
.
getApplicationId
())
{
mappings
.
add
(
mapping
.
getMappingApplicationId
());
}
});
mappings
.
forEach
(
mappingApplicationId
->
{
List
<
Call
>
frontCallerApplications
=
applicationReferenceMetricUIDAO
.
getFrontApplications
(
step
,
mappingApplicationId
,
startTime
,
endTime
,
MetricSource
.
Caller
);
frontCallerApplications
.
forEach
(
call
->
{
call
.
setCallType
(
components
.
get
(
call
.
getTarget
()));
call
.
setTarget
(
applicationId
);
callerCalls
.
add
(
call
);
});
List
<
Call
>
behindCallerApplications
=
applicationReferenceMetricUIDAO
.
getBehindApplications
(
step
,
mappingApplicationId
,
startTime
,
endTime
,
MetricSource
.
Caller
);
behindCallerApplications
.
forEach
(
call
->
{
call
.
setCallType
(
components
.
get
(
call
.
getTarget
()));
call
.
setSource
(
applicationId
);
callerCalls
.
add
(
call
);
});
List
<
Call
>
frontCalleeApplications
=
applicationReferenceMetricUIDAO
.
getFrontApplications
(
step
,
mappingApplicationId
,
startTime
,
endTime
,
MetricSource
.
Callee
);
frontCalleeApplications
.
forEach
(
call
->
{
call
.
setCallType
(
components
.
get
(
call
.
getTarget
()));
call
.
setTarget
(
applicationId
);
calleeCalls
.
add
(
call
);
});
List
<
Call
>
behindCalleeApplications
=
applicationReferenceMetricUIDAO
.
getBehindApplications
(
step
,
mappingApplicationId
,
startTime
,
endTime
,
MetricSource
.
Callee
);
behindCalleeApplications
.
forEach
(
call
->
{
call
.
setCallType
(
components
.
get
(
call
.
getTarget
()));
call
.
setSource
(
applicationId
);
calleeCalls
.
add
(
call
);
});
});
TopologyBuilder
builder
=
new
TopologyBuilder
(
moduleManager
);
long
secondsBetween
=
DurationUtils
.
INSTANCE
.
secondsBetween
(
step
,
startTime
,
endTime
);
Topology
topology
=
builder
.
build
(
applicationComponents
,
applicationMappings
,
callerCalls
,
calleeCalls
,
secondsBetween
);
topology
.
getCalls
().
forEach
(
call
->
{
int
calls
=
call
.
getCalls
();
long
responseTimes
=
call
.
getResponseTimes
();
call
.
setCallsPerSec
((
int
)(
calls
/
secondsBetween
));
call
.
setResponseTimePerSec
((
int
)(
responseTimes
/
secondsBetween
));
});
return
topology
;
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java
浏览文件 @
9a6520fb
...
...
@@ -60,7 +60,7 @@ public class InstanceHealthService {
response
.
add
(
"instances"
,
instances
);
// instanceList.forEach(instance -> {
// response.addProperty("applicationCode", applicationCacheService.getApplication
Code
ById(applicationId));
// response.addProperty("applicationCode", applicationCacheService.getApplicationById(applicationId));
// response.addProperty("applicationId", applicationId);
//
// IInstanceMetricUIDAO.InstanceMetric performance = instanceMetricUIDAO.get(timeBuckets, instance.getInstanceId());
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java
浏览文件 @
9a6520fb
...
...
@@ -108,7 +108,7 @@ public class SpanService {
if
(
spanObject
.
getPeerId
()
==
0
)
{
peerJson
.
addProperty
(
"value"
,
spanObject
.
getPeer
());
}
else
{
peerJson
.
addProperty
(
"value"
,
applicationCacheService
.
getApplication
CodeById
(
spanObject
.
getPeerId
()
));
peerJson
.
addProperty
(
"value"
,
applicationCacheService
.
getApplication
ById
(
spanObject
.
getPeerId
()).
getApplicationCode
(
));
}
tagsArray
.
add
(
peerJson
);
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
0 → 100644
浏览文件 @
9a6520fb
/*
* 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.util.HashMap
;
import
java.util.HashSet
;
import
java.util.LinkedList
;
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.ApplicationCacheService
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.core.util.BooleanUtils
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO
;
import
org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO
;
import
org.apache.skywalking.apm.collector.storage.table.register.Application
;
import
org.apache.skywalking.apm.collector.storage.ui.application.ApplicationNode
;
import
org.apache.skywalking.apm.collector.storage.ui.application.ConjecturalNode
;
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.Topology
;
import
org.apache.skywalking.apm.collector.storage.ui.common.VisualUserNode
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
/**
* @author peng-yongsheng
*/
class
TopologyBuilder
{
private
final
ApplicationCacheService
applicationCacheService
;
TopologyBuilder
(
ModuleManager
moduleManager
)
{
this
.
applicationCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ApplicationCacheService
.
class
);
}
Topology
build
(
List
<
IApplicationComponentUIDAO
.
ApplicationComponent
>
applicationComponents
,
List
<
IApplicationMappingUIDAO
.
ApplicationMapping
>
applicationMappings
,
List
<
Call
>
callerCalls
,
List
<
Call
>
calleeCalls
,
long
secondsBetween
)
{
Map
<
Integer
,
String
>
components
=
changeNodeComp2Map
(
applicationComponents
);
Map
<
String
,
String
>
mappings
=
changeMapping2Map
(
applicationMappings
);
List
<
Call
>
calls
=
buildCalls
(
callerCalls
,
calleeCalls
);
Set
<
Integer
>
nodeIds
=
new
HashSet
<>();
calls
.
forEach
(
call
->
{
String
sourceName
=
applicationCacheService
.
getApplicationById
(
call
.
getSource
()).
getApplicationCode
();
String
targetName
=
applicationCacheService
.
getApplicationById
(
call
.
getTarget
()).
getApplicationCode
();
call
.
setSourceName
(
sourceName
);
call
.
setTargetName
(
targetName
);
nodeIds
.
add
(
call
.
getSource
());
nodeIds
.
add
(
call
.
getTarget
());
});
List
<
Node
>
nodes
=
new
LinkedList
<>();
nodeIds
.
forEach
(
nodeId
->
{
Application
application
=
applicationCacheService
.
getApplicationById
(
nodeId
);
if
(
BooleanUtils
.
valueToBoolean
(
application
.
getAddressId
()))
{
ConjecturalNode
conjecturalNode
=
new
ConjecturalNode
();
conjecturalNode
.
setId
(
nodeId
);
conjecturalNode
.
setName
(
application
.
getApplicationCode
());
conjecturalNode
.
setType
(
components
.
getOrDefault
(
application
.
getApplicationId
(),
Const
.
UNKNOWN
));
nodes
.
add
(
conjecturalNode
);
}
else
{
if
(
nodeId
==
Const
.
NONE_APPLICATION_ID
)
{
VisualUserNode
node
=
new
VisualUserNode
();
node
.
setId
(
nodeId
);
node
.
setName
(
Const
.
USER_CODE
);
node
.
setType
(
Const
.
USER_CODE
.
toUpperCase
());
nodes
.
add
(
node
);
}
else
{
ApplicationNode
applicationNode
=
new
ApplicationNode
();
applicationNode
.
setId
(
nodeId
);
applicationNode
.
setName
(
application
.
getApplicationCode
());
applicationNode
.
setType
(
components
.
getOrDefault
(
application
.
getApplicationId
(),
Const
.
UNKNOWN
));
calleeCalls
.
forEach
(
call
->
{
if
(
call
.
getTarget
()
==
nodeId
)
{
call
.
setCallsPerSec
((
int
)(
call
.
getCalls
()
/
secondsBetween
));
call
.
setResponseTimePerSec
((
int
)(
call
.
getResponseTimes
()
/
secondsBetween
));
}
});
nodes
.
add
(
applicationNode
);
}
}
});
Topology
topology
=
new
Topology
();
topology
.
setCalls
(
calls
);
topology
.
setNodes
(
nodes
);
return
topology
;
}
private
Map
<
String
,
String
>
changeMapping2Map
(
List
<
IApplicationMappingUIDAO
.
ApplicationMapping
>
applicationMappings
)
{
Map
<
String
,
String
>
mappings
=
new
HashMap
<>();
applicationMappings
.
forEach
(
applicationMapping
->
{
String
applicationCode
=
applicationCacheService
.
getApplicationById
(
applicationMapping
.
getApplicationId
()).
getApplicationCode
();
String
address
=
applicationCacheService
.
getApplicationById
(
applicationMapping
.
getMappingApplicationId
()).
getApplicationCode
();
mappings
.
put
(
address
,
applicationCode
);
});
return
mappings
;
}
private
Map
<
Integer
,
String
>
changeNodeComp2Map
(
List
<
IApplicationComponentUIDAO
.
ApplicationComponent
>
applicationComponents
)
{
Map
<
Integer
,
String
>
components
=
new
HashMap
<>();
applicationComponents
.
forEach
(
applicationComponent
->
{
String
componentName
=
ComponentsDefine
.
getInstance
().
getComponentName
(
applicationComponent
.
getComponentId
());
components
.
put
(
applicationComponent
.
getApplicationId
(),
componentName
);
});
return
components
;
}
private
List
<
Call
>
buildCalls
(
List
<
Call
>
callerCalls
,
List
<
Call
>
calleeCalls
)
{
List
<
Call
>
calls
=
new
LinkedList
<>();
Set
<
String
>
distinctCalls
=
new
HashSet
<>();
callerCalls
.
forEach
(
callerCall
->
{
distinctCalls
.
add
(
callerCall
.
getSource
()
+
Const
.
ID_SPLIT
+
callerCall
.
getTarget
());
calls
.
add
(
callerCall
);
});
calleeCalls
.
forEach
(
calleeCall
->
{
String
call
=
calleeCall
.
getSource
()
+
Const
.
ID_SPLIT
+
calleeCall
.
getTarget
();
if
(!
distinctCalls
.
contains
(
call
))
{
distinctCalls
.
add
(
call
);
calls
.
add
(
calleeCall
);
}
});
return
calls
;
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java
已删除
100644 → 0
浏览文件 @
e755bba3
/*
* 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.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
org.apache.skywalking.apm.collector.cache.CacheModule
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable
;
import
org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable
;
import
org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable
;
import
org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService
;
import
org.apache.skywalking.apm.collector.core.module.ModuleManager
;
import
org.apache.skywalking.apm.collector.core.util.ColumnNameUtils
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
TraceDagDataBuilder
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TraceDagDataBuilder
.
class
);
private
Integer
nodeId
=
-
1
;
private
Map
<
String
,
String
>
mappingMap
=
new
HashMap
<>();
private
Map
<
String
,
String
>
nodeCompMap
=
new
HashMap
<>();
private
Map
<
String
,
Integer
>
nodeIdMap
=
new
HashMap
<>();
private
JsonArray
pointArray
=
new
JsonArray
();
private
JsonArray
lineArray
=
new
JsonArray
();
private
final
ApplicationCacheService
applicationCacheService
;
public
TraceDagDataBuilder
(
ModuleManager
moduleManager
)
{
this
.
applicationCacheService
=
moduleManager
.
find
(
CacheModule
.
NAME
).
getService
(
ApplicationCacheService
.
class
);
}
public
JsonObject
build
(
JsonArray
nodeCompArray
,
JsonArray
nodesMappingArray
,
JsonArray
resSumArray
)
{
changeNodeComp2Map
(
nodeCompArray
);
changeMapping2Map
(
nodesMappingArray
);
Map
<
String
,
JsonObject
>
mergedResSumMap
=
getApplicationCode
(
resSumArray
);
mergedResSumMap
.
values
().
forEach
(
nodeRefJsonObj
->
{
String
front
=
nodeRefJsonObj
.
get
(
"front"
).
getAsString
();
String
behind
=
nodeRefJsonObj
.
get
(
"behind"
).
getAsString
();
if
(
hasMapping
(
behind
))
{
return
;
}
JsonObject
lineJsonObj
=
new
JsonObject
();
lineJsonObj
.
addProperty
(
"from"
,
findOrCreateNode
(
front
));
lineJsonObj
.
addProperty
(
"to"
,
findOrCreateNode
(
behind
));
lineJsonObj
.
addProperty
(
"resSum"
,
nodeRefJsonObj
.
get
(
ApplicationReferenceMetricTable
.
COLUMN_TRANSACTION_CALLS
).
getAsInt
());
lineArray
.
add
(
lineJsonObj
);
logger
.
debug
(
"line: {}"
,
lineJsonObj
);
});
JsonObject
dagJsonObj
=
new
JsonObject
();
dagJsonObj
.
add
(
"nodes"
,
pointArray
);
dagJsonObj
.
add
(
"nodeRefs"
,
lineArray
);
return
dagJsonObj
;
}
private
Integer
findOrCreateNode
(
String
peers
)
{
if
(
nodeIdMap
.
containsKey
(
peers
)
&&
!
peers
.
equals
(
Const
.
USER_CODE
))
{
return
nodeIdMap
.
get
(
peers
);
}
else
{
nodeId
++;
JsonObject
nodeJsonObj
=
new
JsonObject
();
nodeJsonObj
.
addProperty
(
"id"
,
nodeId
);
nodeJsonObj
.
addProperty
(
"peer"
,
peers
);
if
(
peers
.
equals
(
Const
.
USER_CODE
))
{
nodeJsonObj
.
addProperty
(
"component"
,
Const
.
USER_CODE
);
}
else
{
nodeJsonObj
.
addProperty
(
"component"
,
nodeCompMap
.
get
(
peers
));
}
pointArray
.
add
(
nodeJsonObj
);
nodeIdMap
.
put
(
peers
,
nodeId
);
logger
.
debug
(
"node: {}"
,
nodeJsonObj
);
}
return
nodeId
;
}
private
void
changeMapping2Map
(
JsonArray
nodesMappingArray
)
{
for
(
int
i
=
0
;
i
<
nodesMappingArray
.
size
();
i
++)
{
JsonObject
nodesMappingJsonObj
=
nodesMappingArray
.
get
(
i
).
getAsJsonObject
();
int
applicationId
=
nodesMappingJsonObj
.
get
(
ApplicationMappingTable
.
COLUMN_APPLICATION_ID
).
getAsInt
();
String
applicationCode
=
applicationCacheService
.
getApplicationCodeById
(
applicationId
);
int
addressId
=
nodesMappingJsonObj
.
get
(
ApplicationMappingTable
.
COLUMN_ADDRESS_ID
).
getAsInt
();
String
address
=
applicationCacheService
.
getApplicationCodeById
(
addressId
);
mappingMap
.
put
(
address
,
applicationCode
);
}
}
private
void
changeNodeComp2Map
(
JsonArray
nodeCompArray
)
{
for
(
int
i
=
0
;
i
<
nodeCompArray
.
size
();
i
++)
{
JsonObject
nodesJsonObj
=
nodeCompArray
.
get
(
i
).
getAsJsonObject
();
logger
.
debug
(
nodesJsonObj
.
toString
());
int
componentId
=
nodesJsonObj
.
get
(
ApplicationComponentTable
.
COLUMN_COMPONENT_ID
).
getAsInt
();
String
componentName
=
ComponentsDefine
.
getInstance
().
getComponentName
(
componentId
);
int
peerId
=
nodesJsonObj
.
get
(
ApplicationComponentTable
.
COLUMN_PEER_ID
).
getAsInt
();
String
peer
=
applicationCacheService
.
getApplicationCodeById
(
peerId
);
nodeCompMap
.
put
(
peer
,
componentName
);
}
}
private
boolean
hasMapping
(
String
peers
)
{
return
mappingMap
.
containsKey
(
peers
);
}
private
Map
<
String
,
JsonObject
>
getApplicationCode
(
JsonArray
nodeReference
)
{
Map
<
String
,
JsonObject
>
mergedRef
=
new
LinkedHashMap
<>();
for
(
int
i
=
0
;
i
<
nodeReference
.
size
();
i
++)
{
JsonObject
nodeRefJsonObj
=
nodeReference
.
get
(
i
).
getAsJsonObject
();
int
frontApplicationId
=
nodeRefJsonObj
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ApplicationReferenceMetricTable
.
COLUMN_FRONT_APPLICATION_ID
)).
getAsInt
();
int
behindApplicationId
=
nodeRefJsonObj
.
get
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ApplicationReferenceMetricTable
.
COLUMN_BEHIND_APPLICATION_ID
)).
getAsInt
();
String
front
=
applicationCacheService
.
getApplicationCodeById
(
frontApplicationId
);
String
behind
=
applicationCacheService
.
getApplicationCodeById
(
behindApplicationId
);
String
id
=
front
+
Const
.
ID_SPLIT
+
behind
;
nodeRefJsonObj
.
addProperty
(
"front"
,
front
);
nodeRefJsonObj
.
addProperty
(
"behind"
,
behind
);
mergedRef
.
put
(
id
,
nodeRefJsonObj
);
}
return
mergedRef
;
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java
浏览文件 @
9a6520fb
...
...
@@ -134,7 +134,7 @@ public class TraceStackService {
operationName
=
Const
.
EMPTY_STRING
;
}
}
String
applicationCode
=
applicationCacheService
.
getApplication
CodeById
(
segment
.
getApplicationId
()
);
String
applicationCode
=
applicationCacheService
.
getApplication
ById
(
segment
.
getApplicationId
()).
getApplicationCode
(
);
long
cost
=
spanObject
.
getEndTime
()
-
spanObject
.
getStartTime
();
if
(
cost
==
0
)
{
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java
0 → 100644
浏览文件 @
9a6520fb
/*
* 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.utils
;
import
java.text.ParseException
;
import
java.util.Date
;
import
org.apache.skywalking.apm.collector.core.util.Const
;
import
org.apache.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.apache.skywalking.apm.collector.storage.ui.common.Step
;
import
org.joda.time.DateTime
;
import
org.joda.time.Seconds
;
/**
* @author peng-yongsheng
*/
public
enum
DurationUtils
{
INSTANCE
;
public
long
exchangeToTimeBucket
(
String
dateStr
)
throws
ParseException
{
dateStr
=
dateStr
.
replaceAll
(
"-"
,
Const
.
EMPTY_STRING
);
dateStr
=
dateStr
.
replaceAll
(
" "
,
Const
.
EMPTY_STRING
);
return
Long
.
valueOf
(
dateStr
);
}
public
long
durationToSecondTimeBucket
(
Step
step
,
String
dateStr
)
throws
ParseException
{
long
secondTimeBucket
=
0
;
switch
(
step
)
{
case
MONTH:
secondTimeBucket
=
exchangeToTimeBucket
(
dateStr
)
*
100
*
100
*
100
*
100
;
break
;
case
DAY:
secondTimeBucket
=
exchangeToTimeBucket
(
dateStr
)
*
100
*
100
*
100
;
break
;
case
HOUR:
secondTimeBucket
=
exchangeToTimeBucket
(
dateStr
)
*
100
*
100
;
break
;
case
MINUTE:
secondTimeBucket
=
exchangeToTimeBucket
(
dateStr
)
*
100
;
break
;
case
SECOND:
secondTimeBucket
=
exchangeToTimeBucket
(
dateStr
);
break
;
}
return
secondTimeBucket
;
}
public
long
secondsBetween
(
Step
step
,
long
start
,
long
end
)
throws
ParseException
{
Date
startDate
=
null
;
Date
endDate
=
null
;
switch
(
step
)
{
case
MONTH:
startDate
=
TimeBucketUtils
.
MONTH_DATE_FORMAT
.
parse
(
String
.
valueOf
(
start
));
endDate
=
TimeBucketUtils
.
MONTH_DATE_FORMAT
.
parse
(
String
.
valueOf
(
end
));
break
;
case
DAY:
startDate
=
TimeBucketUtils
.
DAY_DATE_FORMAT
.
parse
(
String
.
valueOf
(
start
));
endDate
=
TimeBucketUtils
.
DAY_DATE_FORMAT
.
parse
(
String
.
valueOf
(
end
));
break
;
case
HOUR:
startDate
=
TimeBucketUtils
.
HOUR_DATE_FORMAT
.
parse
(
String
.
valueOf
(
start
));
endDate
=
TimeBucketUtils
.
HOUR_DATE_FORMAT
.
parse
(
String
.
valueOf
(
end
));
break
;
case
MINUTE:
startDate
=
TimeBucketUtils
.
MINUTE_DATE_FORMAT
.
parse
(
String
.
valueOf
(
start
));
endDate
=
TimeBucketUtils
.
MINUTE_DATE_FORMAT
.
parse
(
String
.
valueOf
(
end
));
break
;
case
SECOND:
startDate
=
TimeBucketUtils
.
SECOND_DATE_FORMAT
.
parse
(
String
.
valueOf
(
start
));
endDate
=
TimeBucketUtils
.
SECOND_DATE_FORMAT
.
parse
(
String
.
valueOf
(
end
));
break
;
}
return
Seconds
.
secondsBetween
(
new
DateTime
(
startDate
),
new
DateTime
(
endDate
)).
getSeconds
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java
浏览文件 @
9a6520fb
...
...
@@ -40,8 +40,8 @@ public class ApplicationQueryTestCase {
Mockito
.
when
(
applicationService
.
getApplications
(
Mockito
.
anyLong
(),
Mockito
.
anyLong
())).
then
(
invocation
->
{
Object
[]
arguments
=
invocation
.
getArguments
();
Assert
.
assertEquals
(
20170100000000
l
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170100000000
l
,
arguments
[
1
]);
Assert
.
assertEquals
(
20170100000000
L
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170100000000
L
,
arguments
[
1
]);
return
null
;
});
...
...
@@ -61,8 +61,8 @@ public class ApplicationQueryTestCase {
Mockito
.
when
(
applicationService
.
getApplications
(
Mockito
.
anyLong
(),
Mockito
.
anyLong
())).
then
(
invocation
->
{
Object
[]
arguments
=
invocation
.
getArguments
();
Assert
.
assertEquals
(
20170101000000
l
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170101000000
l
,
arguments
[
1
]);
Assert
.
assertEquals
(
20170101000000
L
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170101000000
L
,
arguments
[
1
]);
return
null
;
});
...
...
@@ -82,8 +82,8 @@ public class ApplicationQueryTestCase {
Mockito
.
when
(
applicationService
.
getApplications
(
Mockito
.
anyLong
(),
Mockito
.
anyLong
())).
then
(
invocation
->
{
Object
[]
arguments
=
invocation
.
getArguments
();
Assert
.
assertEquals
(
20170101010000
l
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170101010000
l
,
arguments
[
1
]);
Assert
.
assertEquals
(
20170101010000
L
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170101010000
L
,
arguments
[
1
]);
return
null
;
});
...
...
@@ -103,8 +103,8 @@ public class ApplicationQueryTestCase {
Mockito
.
when
(
applicationService
.
getApplications
(
Mockito
.
anyLong
(),
Mockito
.
anyLong
())).
then
(
invocation
->
{
Object
[]
arguments
=
invocation
.
getArguments
();
Assert
.
assertEquals
(
20170101010100
l
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170101010100
l
,
arguments
[
1
]);
Assert
.
assertEquals
(
20170101010100
L
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170101010100
L
,
arguments
[
1
]);
return
null
;
});
...
...
@@ -124,8 +124,8 @@ public class ApplicationQueryTestCase {
Mockito
.
when
(
applicationService
.
getApplications
(
Mockito
.
anyLong
(),
Mockito
.
anyLong
())).
then
(
invocation
->
{
Object
[]
arguments
=
invocation
.
getArguments
();
Assert
.
assertEquals
(
20170101010101
l
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170101010101
l
,
arguments
[
1
]);
Assert
.
assertEquals
(
20170101010101
L
,
arguments
[
0
]);
Assert
.
assertEquals
(
20170101010101
L
,
arguments
[
1
]);
return
null
;
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录