Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
24a03753
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
提交
24a03753
编写于
11月 06, 2017
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the implement of UI module.
上级
0664a619
变更
96
展开全部
隐藏空白更改
内联
并排
Showing
96 changed file
with
5457 addition
and
89 deletion
+5457
-89
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/data/CommonTable.java
...a/org/skywalking/apm/collector/core/data/CommonTable.java
+1
-1
apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteModule.java
...ava/org/skywalking/apm/collector/remote/RemoteModule.java
+3
-3
apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteClientService.java
...ing/apm/collector/remote/service/RemoteClientService.java
+1
-3
apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteSenderService.java
...ing/apm/collector/remote/service/RemoteSenderService.java
+29
-0
apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteSerializeService.java
.../apm/collector/remote/service/RemoteSerializeService.java
+1
-2
apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/skywalking/apm/collector/remote/grpc/RemoteModuleGRPCProvider.java
...g/apm/collector/remote/grpc/RemoteModuleGRPCProvider.java
+6
-8
apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemoteSenderService.java
...ollector/remote/grpc/service/GRPCRemoteSenderService.java
+8
-2
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/AbstractDAO.java
...kywalking/apm/collector/storage/base/dao/AbstractDAO.java
+36
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/DAO.java
...va/org/skywalking/apm/collector/storage/base/dao/DAO.java
+1
-12
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/DAOContainer.java
...ywalking/apm/collector/storage/base/dao/DAOContainer.java
+4
-4
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IApplicationCacheDAO.java
...lking/apm/collector/storage/dao/IApplicationCacheDAO.java
+3
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IApplicationStreamDAO.java
...king/apm/collector/storage/dao/IApplicationStreamDAO.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ICpuMetricStreamDAO.java
...alking/apm/collector/storage/dao/ICpuMetricStreamDAO.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java
...skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java
+31
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGCMetricStreamDAO.java
...walking/apm/collector/storage/dao/IGCMetricStreamDAO.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java
.../skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java
+64
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGlobalTraceStreamDAO.java
...king/apm/collector/storage/dao/IGlobalTraceStreamDAO.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java
...ywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java
+31
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstPerformanceUIDAO.java
...king/apm/collector/storage/dao/IInstPerformanceUIDAO.java
+61
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceStreamDAO.java
...walking/apm/collector/storage/dao/IInstanceStreamDAO.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java
.../skywalking/apm/collector/storage/dao/IInstanceUIDAO.java
+57
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java
...walking/apm/collector/storage/dao/IMemoryMetricUIDAO.java
+31
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java
...ing/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java
+31
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeComponentUIDAO.java
...alking/apm/collector/storage/dao/INodeComponentUIDAO.java
+29
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeMappingUIDAO.java
...ywalking/apm/collector/storage/dao/INodeMappingUIDAO.java
+29
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeReferenceUIDAO.java
...alking/apm/collector/storage/dao/INodeReferenceUIDAO.java
+29
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java
...ywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java
+39
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java
...g/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java
+29
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceEntryUIDAO.java
...walking/apm/collector/storage/dao/IServiceEntryUIDAO.java
+29
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java
...ing/apm/collector/storage/dao/IServiceReferenceUIDAO.java
+30
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/service/DAOService.java
.../skywalking/apm/collector/storage/service/DAOService.java
+1
-1
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/base/dao/EsDAO.java
...g/skywalking/apm/collector/storage/es/base/dao/EsDAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEsStreamDAO.java
.../apm/collector/storage/es/dao/ApplicationEsStreamDAO.java
+3
-3
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/CpuMetricEsStreamDAO.java
...ng/apm/collector/storage/es/dao/CpuMetricEsStreamDAO.java
+3
-3
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java
...alking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java
+70
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GCMetricEsStreamDAO.java
...ing/apm/collector/storage/es/dao/GCMetricEsStreamDAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java
...walking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java
+150
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GlobalTraceEsDAO.java
...alking/apm/collector/storage/es/dao/GlobalTraceEsDAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java
...king/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java
+78
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstPerformanceEsUIDAO.java
.../apm/collector/storage/es/dao/InstPerformanceEsUIDAO.java
+138
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceEsStreamDAO.java
...ing/apm/collector/storage/es/dao/InstanceEsStreamDAO.java
+3
-3
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java
...walking/apm/collector/storage/es/dao/InstanceEsUIDAO.java
+162
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java
...ing/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java
+84
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeComponentEsUIDAO.java
...ng/apm/collector/storage/es/dao/NodeComponentEsUIDAO.java
+131
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeMappingEsUIDAO.java
...king/apm/collector/storage/es/dao/NodeMappingEsUIDAO.java
+92
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeReferenceEsUIDAO.java
...ng/apm/collector/storage/es/dao/NodeReferenceEsUIDAO.java
+136
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java
...king/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java
+124
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java
...ywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java
+54
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceEntryEsUIDAO.java
...ing/apm/collector/storage/es/dao/ServiceEntryEsUIDAO.java
+93
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/service/ElasticSearchDAOService.java
...collector/storage/es/service/ElasticSearchDAOService.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/base/dao/H2DAO.java
...g/skywalking/apm/collector/storage/h2/base/dao/H2DAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2StreamDAO.java
.../apm/collector/storage/h2/dao/ApplicationH2StreamDAO.java
+3
-3
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/CpuMetricH2StreamDAO.java
...ng/apm/collector/storage/h2/dao/CpuMetricH2StreamDAO.java
+3
-3
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java
...alking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java
+88
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GCMetricH2StreamDAO.java
...ing/apm/collector/storage/h2/dao/GCMetricH2StreamDAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java
...walking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java
+156
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GlobalTraceH2DAO.java
...alking/apm/collector/storage/h2/dao/GlobalTraceH2DAO.java
+2
-2
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GlobalTraceH2UIDAO.java
...king/apm/collector/storage/h2/dao/GlobalTraceH2UIDAO.java
+79
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstPerformanceH2UIDAO.java
.../apm/collector/storage/h2/dao/InstPerformanceH2UIDAO.java
+164
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2StreamDAO.java
...ing/apm/collector/storage/h2/dao/InstanceH2StreamDAO.java
+3
-3
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java
...walking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java
+148
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java
...ing/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java
+102
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeComponentH2UIDAO.java
...ng/apm/collector/storage/h2/dao/NodeComponentH2UIDAO.java
+85
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeMappingH2UIDAO.java
...king/apm/collector/storage/h2/dao/NodeMappingH2UIDAO.java
+78
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeReferenceH2UIDAO.java
...ng/apm/collector/storage/h2/dao/NodeReferenceH2UIDAO.java
+93
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/SegmentCostH2UIDAO.java
...king/apm/collector/storage/h2/dao/SegmentCostH2UIDAO.java
+158
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/SegmentH2UIDAO.java
...ywalking/apm/collector/storage/h2/dao/SegmentH2UIDAO.java
+60
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2UIDAO.java
...ing/apm/collector/storage/h2/dao/ServiceEntryH2UIDAO.java
+97
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/service/H2DAOService.java
...alking/apm/collector/storage/h2/service/H2DAOService.java
+2
-2
apm-collector/apm-collector-stream/collector-stream-provider/src/main/java/org/skywalking/apm/collector/stream/StreamModuleProvider.java
...skywalking/apm/collector/stream/StreamModuleProvider.java
+2
-2
apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml
...ctor/apm-collector-ui/collector-ui-jetty-provider/pom.xml
+5
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java
...walking/apm/collector/ui/jetty/UIModuleJettyProvider.java
+36
-4
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/SegmentTopGetHandler.java
.../apm/collector/ui/jetty/handler/SegmentTopGetHandler.java
+140
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/SpanGetHandler.java
...alking/apm/collector/ui/jetty/handler/SpanGetHandler.java
+65
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/TraceDagGetHandler.java
...ng/apm/collector/ui/jetty/handler/TraceDagGetHandler.java
+76
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/TraceStackGetHandler.java
.../apm/collector/ui/jetty/handler/TraceStackGetHandler.java
+57
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java
.../ui/jetty/handler/application/ApplicationsGetHandler.java
+8
-7
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java
...etty/handler/instancehealth/InstanceHealthGetHandler.java
+84
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java
...instancemetric/InstanceMetricGetOneTimeBucketHandler.java
+85
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java
...stancemetric/InstanceMetricGetRangeTimeBucketHandler.java
+93
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java
...etty/handler/instancemetric/InstanceOsInfoGetHandler.java
+64
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/servicetree/EntryServiceGetHandler.java
.../ui/jetty/handler/servicetree/EntryServiceGetHandler.java
+103
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java
.../jetty/handler/servicetree/ServiceTreeGetByIdHandler.java
+84
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/time/AllInstanceLastTimeGetHandler.java
.../ui/jetty/handler/time/AllInstanceLastTimeGetHandler.java
+70
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/time/OneInstanceLastTimeGetHandler.java
.../ui/jetty/handler/time/OneInstanceLastTimeGetHandler.java
+69
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/ApplicationService.java
...ywalking/apm/collector/ui/service/ApplicationService.java
+50
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/InstanceHealthService.java
...lking/apm/collector/ui/service/InstanceHealthService.java
+108
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/InstanceJVMService.java
...ywalking/apm/collector/ui/service/InstanceJVMService.java
+155
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/SegmentTopService.java
...kywalking/apm/collector/ui/service/SegmentTopService.java
+57
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/ServiceTreeService.java
...ywalking/apm/collector/ui/service/ServiceTreeService.java
+131
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/SpanService.java
.../org/skywalking/apm/collector/ui/service/SpanService.java
+127
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TimeSynchronousService.java
...king/apm/collector/ui/service/TimeSynchronousService.java
+48
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java
...walking/apm/collector/ui/service/TraceDagDataBuilder.java
+140
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceDagService.java
.../skywalking/apm/collector/ui/service/TraceDagService.java
+59
-0
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceStackService.java
...kywalking/apm/collector/ui/service/TraceStackService.java
+263
-0
apm-collector/apm-collector-ui/pom.xml
apm-collector/apm-collector-ui/pom.xml
+5
-0
未找到文件。
apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/data/CommonTable.java
浏览文件 @
24a03753
...
...
@@ -23,7 +23,7 @@ package org.skywalking.apm.collector.core.data;
*/
public
class
CommonTable
{
public
static
final
String
TABLE_TYPE
=
"type"
;
public
static
final
String
COLUMN_ID
=
"
getI
d"
;
public
static
final
String
COLUMN_ID
=
"
i
d"
;
public
static
final
String
COLUMN_AGG
=
"agg"
;
public
static
final
String
COLUMN_TIME_BUCKET
=
"time_bucket"
;
}
apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/RemoteModule.java
浏览文件 @
24a03753
...
...
@@ -19,9 +19,9 @@
package
org.skywalking.apm.collector.remote
;
import
org.skywalking.apm.collector.core.module.Module
;
import
org.skywalking.apm.collector.remote.service.RemoteClientService
;
import
org.skywalking.apm.collector.remote.service.RemoteServerService
;
import
org.skywalking.apm.collector.remote.service.RemoteSenderService
;
import
org.skywalking.apm.collector.remote.service.RemoteSerializeService
;
import
org.skywalking.apm.collector.remote.service.RemoteServerService
;
/**
* @author peng-yongsheng
...
...
@@ -35,6 +35,6 @@ public class RemoteModule extends Module {
}
@Override
public
Class
[]
services
()
{
return
new
Class
[]
{
RemoteServerService
.
class
,
Remote
ClientService
.
class
,
RemoteSerialize
Service
.
class
};
return
new
Class
[]
{
RemoteServerService
.
class
,
Remote
SerializeService
.
class
,
RemoteSender
Service
.
class
};
}
}
apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteClientService.java
浏览文件 @
24a03753
...
...
@@ -18,11 +18,9 @@
package
org.skywalking.apm.collector.remote.service
;
import
org.skywalking.apm.collector.core.module.Service
;
/**
* @author peng-yongsheng
*/
public
interface
RemoteClientService
extends
Service
{
public
interface
RemoteClientService
{
RemoteClient
create
(
String
host
,
int
port
);
}
apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteSenderService.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.remote.service
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.core.module.Service
;
/**
* @author peng-yongsheng
*/
public
interface
RemoteSenderService
extends
Service
{
void
send
(
int
graph
,
int
nodeId
,
Data
data
);
}
apm-collector/apm-collector-remote/collector-remote-define/src/main/java/org/skywalking/apm/collector/remote/service/RemoteSerializeService.java
浏览文件 @
24a03753
...
...
@@ -19,11 +19,10 @@
package
org.skywalking.apm.collector.remote.service
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.core.module.Service
;
/**
* @author peng-yongsheng
*/
public
interface
RemoteSerializeService
<
Builder
>
extends
Service
{
public
interface
RemoteSerializeService
<
Builder
>
{
Builder
serialize
(
Data
data
);
}
apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/skywalking/apm/collector/remote/grpc/RemoteModuleGRPCProvider.java
浏览文件 @
24a03753
...
...
@@ -12,13 +12,10 @@ import org.skywalking.apm.collector.grpc.manager.GRPCManagerModule;
import
org.skywalking.apm.collector.grpc.manager.service.GRPCManagerService
;
import
org.skywalking.apm.collector.remote.RemoteModule
;
import
org.skywalking.apm.collector.remote.grpc.handler.RemoteCommonServiceHandler
;
import
org.skywalking.apm.collector.remote.grpc.service.GRPCRemoteClientService
;
import
org.skywalking.apm.collector.remote.grpc.service.GRPCRemoteListener
;
import
org.skywalking.apm.collector.remote.grpc.service.GRPCRemoteSerializeService
;
import
org.skywalking.apm.collector.remote.grpc.service.GRPCRemoteSenderService
;
import
org.skywalking.apm.collector.remote.grpc.service.GRPCRemoteServerService
;
import
org.skywalking.apm.collector.remote.service.DataReceiverRegisterListener
;
import
org.skywalking.apm.collector.remote.service.RemoteClientService
;
import
org.skywalking.apm.collector.remote.service.RemoteSerializeService
;
import
org.skywalking.apm.collector.remote.service.RemoteSenderService
;
import
org.skywalking.apm.collector.remote.service.RemoteServerService
;
import
org.skywalking.apm.collector.server.Server
;
...
...
@@ -31,6 +28,7 @@ public class RemoteModuleGRPCProvider extends ModuleProvider {
private
static
final
String
HOST
=
"host"
;
private
static
final
String
PORT
=
"port"
;
private
final
DataReceiverRegisterListener
listener
=
new
DataReceiverRegisterListener
();
private
GRPCRemoteSenderService
remoteSenderService
;
@Override
public
String
name
()
{
return
NAME
;
...
...
@@ -41,9 +39,9 @@ public class RemoteModuleGRPCProvider extends ModuleProvider {
}
@Override
public
void
prepare
(
Properties
config
)
throws
ServiceNotProvidedException
{
remoteSenderService
=
new
GRPCRemoteSenderService
();
this
.
registerServiceImplementation
(
RemoteServerService
.
class
,
new
GRPCRemoteServerService
(
listener
));
this
.
registerServiceImplementation
(
RemoteClientService
.
class
,
new
GRPCRemoteClientService
());
this
.
registerServiceImplementation
(
RemoteSerializeService
.
class
,
new
GRPCRemoteSerializeService
());
this
.
registerServiceImplementation
(
RemoteSenderService
.
class
,
remoteSenderService
);
}
@Override
public
void
start
(
Properties
config
)
throws
ServiceNotProvidedException
{
...
...
@@ -59,7 +57,7 @@ public class RemoteModuleGRPCProvider extends ModuleProvider {
moduleRegisterService
.
register
(
RemoteModule
.
NAME
,
this
.
name
(),
new
RemoteModuleGRPCRegistration
(
host
,
port
));
ModuleListenerService
moduleListenerService
=
getManager
().
find
(
ClusterModule
.
NAME
).
getService
(
ModuleListenerService
.
class
);
moduleListenerService
.
addListener
(
new
GRPCRemoteListener
()
);
moduleListenerService
.
addListener
(
remoteSenderService
);
}
catch
(
ModuleNotFoundException
e
)
{
throw
new
ServiceNotProvidedException
(
e
.
getMessage
());
}
...
...
apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemote
Listener
.java
→
apm-collector/apm-collector-remote/collector-remote-grpc-provider/src/main/java/org/skywalking/apm/collector/remote/grpc/service/GRPCRemote
SenderService
.java
浏览文件 @
24a03753
...
...
@@ -21,20 +21,26 @@ package org.skywalking.apm.collector.remote.grpc.service;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.skywalking.apm.collector.cluster.ClusterModuleListener
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.remote.RemoteModule
;
import
org.skywalking.apm.collector.remote.grpc.RemoteModuleGRPCProvider
;
import
org.skywalking.apm.collector.remote.service.RemoteClient
;
import
org.skywalking.apm.collector.remote.service.RemoteSenderService
;
/**
* @author peng-yongsheng
*/
public
class
GRPCRemote
Listener
extends
ClusterModuleListener
{
public
class
GRPCRemote
SenderService
extends
ClusterModuleListener
implements
RemoteSenderService
{
public
static
final
String
PATH
=
"/"
+
RemoteModule
.
NAME
+
"/"
+
RemoteModuleGRPCProvider
.
NAME
;
private
final
GRPCRemoteClientService
service
;
private
final
Map
<
String
,
RemoteClient
>
clientMap
;
public
GRPCRemoteListener
()
{
@Override
public
void
send
(
int
graph
,
int
nodeId
,
Data
data
)
{
}
public
GRPCRemoteSenderService
()
{
this
.
service
=
new
GRPCRemoteClientService
();
this
.
clientMap
=
new
ConcurrentHashMap
<>();
}
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/AbstractDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.base.dao
;
import
org.skywalking.apm.collector.client.Client
;
/**
* @author peng-yongsheng
*/
public
abstract
class
AbstractDAO
<
C
extends
Client
>
implements
DAO
{
private
C
client
;
public
final
C
getClient
()
{
return
client
;
}
public
final
void
setClient
(
C
client
)
{
this
.
client
=
client
;
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/DAO.java
浏览文件 @
24a03753
...
...
@@ -18,19 +18,8 @@
package
org.skywalking.apm.collector.storage.base.dao
;
import
org.skywalking.apm.collector.client.Client
;
/**
* @author peng-yongsheng
*/
public
abstract
class
DAO
<
C
extends
Client
>
{
private
C
client
;
public
final
C
getClient
()
{
return
client
;
}
public
final
void
setClient
(
C
client
)
{
this
.
client
=
client
;
}
public
interface
DAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/DAOContainer.java
浏览文件 @
24a03753
...
...
@@ -25,13 +25,13 @@ import java.util.Map;
* @author peng-yongsheng
*/
public
class
DAOContainer
{
private
Map
<
String
,
DAO
>
daos
=
new
HashMap
<>();
private
Map
<
String
,
Abstract
DAO
>
daos
=
new
HashMap
<>();
public
void
put
(
String
interfaceName
,
DAO
d
ao
)
{
daos
.
put
(
interfaceName
,
d
ao
);
public
void
put
(
String
interfaceName
,
AbstractDAO
abstractD
ao
)
{
daos
.
put
(
interfaceName
,
abstractD
ao
);
}
public
DAO
get
(
String
interfaceName
)
{
public
Abstract
DAO
get
(
String
interfaceName
)
{
return
daos
.
get
(
interfaceName
);
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IApplicationCacheDAO.java
浏览文件 @
24a03753
...
...
@@ -18,10 +18,12 @@
package
org.skywalking.apm.collector.storage.dao
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IApplicationCacheDAO
{
public
interface
IApplicationCacheDAO
extends
DAO
{
int
getApplicationId
(
String
applicationCode
);
String
getApplicationCode
(
int
applicationId
);
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IApplicationDAO.java
→
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IApplication
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -23,7 +23,7 @@ import org.skywalking.apm.collector.storage.table.register.Application;
/**
* @author peng-yongsheng
*/
public
interface
IApplicationDAO
{
public
interface
IApplication
Stream
DAO
{
int
getMaxApplicationId
();
int
getMinApplicationId
();
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ICpuMetricDAO.java
→
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ICpuMetric
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -21,5 +21,5 @@ package org.skywalking.apm.collector.storage.dao;
/**
* @author peng-yongsheng
*/
public
interface
ICpuMetricDAO
{
public
interface
ICpuMetric
Stream
DAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonArray
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
ICpuMetricUIDAO
extends
DAO
{
int
getMetric
(
int
instanceId
,
long
timeBucket
);
JsonArray
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IG
lobalTrace
DAO.java
→
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IG
CMetricStream
DAO.java
浏览文件 @
24a03753
...
...
@@ -21,5 +21,5 @@ package org.skywalking.apm.collector.storage.dao;
/**
* @author peng-yongsheng
*/
public
interface
IG
lobalTrace
DAO
{
public
interface
IG
CMetricStream
DAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonObject
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IGCMetricUIDAO
extends
DAO
{
GCCount
getGCCount
(
long
[]
timeBuckets
,
int
instanceId
);
JsonObject
getMetric
(
int
instanceId
,
long
timeBucket
);
JsonObject
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
);
class
GCCount
{
private
int
young
;
private
int
old
;
private
int
full
;
public
int
getYoung
()
{
return
young
;
}
public
int
getOld
()
{
return
old
;
}
public
int
getFull
()
{
return
full
;
}
public
void
setYoung
(
int
young
)
{
this
.
young
=
young
;
}
public
void
setOld
(
int
old
)
{
this
.
old
=
old
;
}
public
void
setFull
(
int
full
)
{
this
.
full
=
full
;
}
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IG
CMetric
DAO.java
→
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IG
lobalTraceStream
DAO.java
浏览文件 @
24a03753
...
...
@@ -21,5 +21,5 @@ package org.skywalking.apm.collector.storage.dao;
/**
* @author peng-yongsheng
*/
public
interface
IG
CMetric
DAO
{
public
interface
IG
lobalTraceStream
DAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
java.util.List
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IGlobalTraceUIDAO
extends
DAO
{
List
<
String
>
getGlobalTraceId
(
String
segmentId
);
List
<
String
>
getSegmentIds
(
String
globalTraceId
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstPerformanceUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonArray
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IInstPerformanceUIDAO
extends
DAO
{
InstPerformance
get
(
long
[]
timeBuckets
,
int
instanceId
);
int
getTpsMetric
(
int
instanceId
,
long
timeBucket
);
JsonArray
getTpsMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
);
int
getRespTimeMetric
(
int
instanceId
,
long
timeBucket
);
JsonArray
getRespTimeMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
);
class
InstPerformance
{
private
final
int
instanceId
;
private
final
int
calls
;
private
final
long
costTotal
;
public
InstPerformance
(
int
instanceId
,
int
calls
,
long
costTotal
)
{
this
.
instanceId
=
instanceId
;
this
.
calls
=
calls
;
this
.
costTotal
=
costTotal
;
}
public
int
getInstanceId
()
{
return
instanceId
;
}
public
int
getCalls
()
{
return
calls
;
}
public
long
getCostTotal
()
{
return
costTotal
;
}
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceDAO.java
→
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstance
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -23,7 +23,7 @@ import org.skywalking.apm.collector.storage.table.register.Instance;
/**
* @author peng-yongsheng
*/
public
interface
IInstanceDAO
{
public
interface
IInstance
Stream
DAO
{
int
getInstanceId
(
int
applicationId
,
String
agentUUID
);
int
getMaxInstanceId
();
...
...
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonArray
;
import
java.util.List
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.skywalking.apm.collector.storage.table.register.Instance
;
/**
* @author peng-yongsheng
*/
public
interface
IInstanceUIDAO
extends
DAO
{
Long
lastHeartBeatTime
();
Long
instanceLastHeartBeatTime
(
long
applicationInstanceId
);
JsonArray
getApplications
(
long
startTime
,
long
endTime
);
Instance
getInstance
(
int
instanceId
);
List
<
Instance
>
getInstances
(
int
applicationId
,
long
timeBucket
);
class
Application
{
private
final
int
applicationId
;
private
final
long
count
;
public
Application
(
int
applicationId
,
long
count
)
{
this
.
applicationId
=
applicationId
;
this
.
count
=
count
;
}
public
int
getApplicationId
()
{
return
applicationId
;
}
public
long
getCount
()
{
return
count
;
}
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonObject
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IMemoryMetricUIDAO
extends
DAO
{
JsonObject
getMetric
(
int
instanceId
,
long
timeBucket
,
boolean
isHeap
);
JsonObject
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
,
boolean
isHeap
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonObject
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IMemoryPoolMetricUIDAO
extends
DAO
{
JsonObject
getMetric
(
int
instanceId
,
long
timeBucket
,
int
poolType
);
JsonObject
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
,
int
poolType
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeComponentUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonArray
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
INodeComponentUIDAO
extends
DAO
{
JsonArray
load
(
long
startTime
,
long
endTime
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeMappingUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonArray
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
INodeMappingUIDAO
extends
DAO
{
JsonArray
load
(
long
startTime
,
long
endTime
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeReferenceUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonArray
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
INodeReferenceUIDAO
extends
DAO
{
JsonArray
load
(
long
startTime
,
long
endTime
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonObject
;
import
java.util.List
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
ISegmentCostUIDAO
extends
DAO
{
JsonObject
loadTop
(
long
startTime
,
long
endTime
,
long
minCost
,
long
maxCost
,
String
operationName
,
Error
error
,
int
applicationId
,
List
<
String
>
segmentIds
,
int
limit
,
int
from
,
Sort
sort
);
enum
Sort
{
Cost
,
Time
}
enum
Error
{
All
,
True
,
False
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
/**
* @author peng-yongsheng
*/
public
interface
ISegmentUIDAO
extends
DAO
{
TraceSegmentObject
load
(
String
segmentId
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceEntryUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonObject
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IServiceEntryUIDAO
extends
DAO
{
JsonObject
load
(
int
applicationId
,
String
entryServiceName
,
long
startTime
,
long
endTime
,
int
from
,
int
size
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.dao
;
import
com.google.gson.JsonObject
;
import
java.util.Map
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
/**
* @author peng-yongsheng
*/
public
interface
IServiceReferenceUIDAO
extends
DAO
{
Map
<
String
,
JsonObject
>
load
(
int
entryServiceId
,
long
startTime
,
long
endTime
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/service/DAOService.java
浏览文件 @
24a03753
...
...
@@ -25,5 +25,5 @@ import org.skywalking.apm.collector.storage.base.dao.DAO;
* @author peng-yongsheng
*/
public
interface
DAOService
extends
Service
{
DAO
get
(
Class
<
DAO
>
daoInterfaceClass
);
DAO
get
(
Class
<
?
extends
DAO
>
daoInterfaceClass
);
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/base/dao/EsDAO.java
浏览文件 @
24a03753
...
...
@@ -26,12 +26,12 @@ import org.elasticsearch.search.aggregations.metrics.max.MaxAggregationBuilder;
import
org.elasticsearch.search.aggregations.metrics.min.Min
;
import
org.elasticsearch.search.aggregations.metrics.min.MinAggregationBuilder
;
import
org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.skywalking.apm.collector.storage.base.dao.
Abstract
DAO
;
/**
* @author peng-yongsheng
*/
public
abstract
class
EsDAO
extends
DAO
<
ElasticSearchClient
>
{
public
abstract
class
EsDAO
extends
Abstract
DAO
<
ElasticSearchClient
>
{
public
final
int
getMaxId
(
String
indexName
,
String
columnName
)
{
ElasticSearchClient
client
=
getClient
();
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEsDAO.java
→
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEs
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -23,7 +23,7 @@ import java.util.Map;
import
org.elasticsearch.action.index.IndexResponse
;
import
org.elasticsearch.action.support.WriteRequest
;
import
org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.skywalking.apm.collector.storage.dao.IApplicationDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplication
Stream
DAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.register.Application
;
import
org.skywalking.apm.collector.storage.table.register.ApplicationTable
;
...
...
@@ -33,9 +33,9 @@ import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public
class
ApplicationEs
DAO
extends
EsDAO
implements
IApplication
DAO
{
public
class
ApplicationEs
StreamDAO
extends
EsDAO
implements
IApplicationStream
DAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationEsDAO
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationEs
Stream
DAO
.
class
);
@Override
public
int
getMaxApplicationId
()
{
return
getMaxId
(
ApplicationTable
.
TABLE
,
ApplicationTable
.
COLUMN_APPLICATION_ID
);
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/CpuMetricEsDAO.java
→
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/CpuMetricEs
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -23,7 +23,7 @@ import java.util.Map;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.dao.ICpuMetricDAO
;
import
org.skywalking.apm.collector.storage.dao.ICpuMetric
Stream
DAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.jvm.CpuMetric
;
import
org.skywalking.apm.collector.storage.table.jvm.CpuMetricTable
;
...
...
@@ -33,9 +33,9 @@ import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public
class
CpuMetricEs
DAO
extends
EsDAO
implements
ICpuMetric
DAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
,
CpuMetric
>
{
public
class
CpuMetricEs
StreamDAO
extends
EsDAO
implements
ICpuMetricStream
DAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
,
CpuMetric
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CpuMetricEsDAO
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CpuMetricEs
Stream
DAO
.
class
);
@Override
public
CpuMetric
get
(
String
id
)
{
return
null
;
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.get.MultiGetItemResponse
;
import
org.elasticsearch.action.get.MultiGetRequestBuilder
;
import
org.elasticsearch.action.get.MultiGetResponse
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.jvm.CpuMetricTable
;
/**
* @author peng-yongsheng
*/
public
class
CpuMetricEsUIDAO
extends
EsDAO
implements
ICpuMetricUIDAO
{
@Override
public
int
getMetric
(
int
instanceId
,
long
timeBucket
)
{
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
GetResponse
getResponse
=
getClient
().
prepareGet
(
CpuMetricTable
.
TABLE
,
id
).
get
();
if
(
getResponse
.
isExists
())
{
return
((
Number
)
getResponse
.
getSource
().
get
(
CpuMetricTable
.
COLUMN_USAGE_PERCENT
)).
intValue
();
}
return
0
;
}
@Override
public
JsonArray
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
)
{
MultiGetRequestBuilder
prepareMultiGet
=
getClient
().
prepareMultiGet
();
long
timeBucket
=
startTimeBucket
;
do
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
prepareMultiGet
.
add
(
CpuMetricTable
.
TABLE
,
CpuMetricTable
.
TABLE_TYPE
,
id
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
metrics
=
new
JsonArray
();
MultiGetResponse
multiGetResponse
=
prepareMultiGet
.
get
();
for
(
MultiGetItemResponse
response
:
multiGetResponse
.
getResponses
())
{
if
(
response
.
getResponse
().
isExists
())
{
double
cpuUsed
=
((
Number
)
response
.
getResponse
().
getSource
().
get
(
CpuMetricTable
.
COLUMN_USAGE_PERCENT
)).
doubleValue
();
metrics
.
add
((
int
)(
cpuUsed
*
100
));
}
else
{
metrics
.
add
(
0
);
}
}
return
metrics
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GCMetricEsDAO.java
→
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GCMetricEs
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -23,7 +23,7 @@ import java.util.Map;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.dao.IGCMetricDAO
;
import
org.skywalking.apm.collector.storage.dao.IGCMetric
Stream
DAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.jvm.GCMetric
;
import
org.skywalking.apm.collector.storage.table.jvm.GCMetricTable
;
...
...
@@ -31,7 +31,7 @@ import org.skywalking.apm.collector.storage.table.jvm.GCMetricTable;
/**
* @author peng-yongsheng
*/
public
class
GCMetricEs
DAO
extends
EsDAO
implements
IGCMetric
DAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
,
GCMetric
>
{
public
class
GCMetricEs
StreamDAO
extends
EsDAO
implements
IGCMetricStream
DAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
,
GCMetric
>
{
@Override
public
GCMetric
get
(
String
id
)
{
return
null
;
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.get.MultiGetItemResponse
;
import
org.elasticsearch.action.get.MultiGetRequestBuilder
;
import
org.elasticsearch.action.get.MultiGetResponse
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.metrics.sum.Sum
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.jvm.GCMetricTable
;
import
org.skywalking.apm.network.proto.GCPhrase
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
GCMetricEsUIDAO
extends
EsDAO
implements
IGCMetricUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GCMetricEsUIDAO
.
class
);
@Override
public
GCCount
getGCCount
(
long
[]
timeBuckets
,
int
instanceId
)
{
logger
.
debug
(
"get gc count, timeBuckets: {}, instanceId: {}"
,
timeBuckets
,
instanceId
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
GCMetricTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
GCMetricTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
GCMetricTable
.
COLUMN_INSTANCE_ID
,
instanceId
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termsQuery
(
GCMetricTable
.
COLUMN_TIME_BUCKET
,
timeBuckets
));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
terms
(
GCMetricTable
.
COLUMN_PHRASE
).
field
(
GCMetricTable
.
COLUMN_PHRASE
)
.
subAggregation
(
AggregationBuilders
.
sum
(
GCMetricTable
.
COLUMN_COUNT
).
field
(
GCMetricTable
.
COLUMN_COUNT
)));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
GCCount
gcCount
=
new
GCCount
();
Terms
phraseAggregation
=
searchResponse
.
getAggregations
().
get
(
GCMetricTable
.
COLUMN_PHRASE
);
for
(
Terms
.
Bucket
phraseBucket
:
phraseAggregation
.
getBuckets
())
{
int
phrase
=
phraseBucket
.
getKeyAsNumber
().
intValue
();
Sum
sumAggregation
=
phraseBucket
.
getAggregations
().
get
(
GCMetricTable
.
COLUMN_COUNT
);
int
count
=
(
int
)
sumAggregation
.
getValue
();
if
(
phrase
==
GCPhrase
.
NEW_VALUE
)
{
gcCount
.
setYoung
(
count
);
}
else
if
(
phrase
==
GCPhrase
.
OLD_VALUE
)
{
gcCount
.
setOld
(
count
);
}
}
return
gcCount
;
}
@Override
public
JsonObject
getMetric
(
int
instanceId
,
long
timeBucket
)
{
JsonObject
response
=
new
JsonObject
();
String
youngId
=
timeBucket
+
Const
.
ID_SPLIT
+
GCPhrase
.
NEW_VALUE
+
instanceId
;
GetResponse
youngResponse
=
getClient
().
prepareGet
(
GCMetricTable
.
TABLE
,
youngId
).
get
();
if
(
youngResponse
.
isExists
())
{
response
.
addProperty
(
"ygc"
,
((
Number
)
youngResponse
.
getSource
().
get
(
GCMetricTable
.
COLUMN_COUNT
)).
intValue
());
}
String
oldId
=
timeBucket
+
Const
.
ID_SPLIT
+
GCPhrase
.
OLD_VALUE
+
instanceId
;
GetResponse
oldResponse
=
getClient
().
prepareGet
(
GCMetricTable
.
TABLE
,
oldId
).
get
();
if
(
oldResponse
.
isExists
())
{
response
.
addProperty
(
"ogc"
,
((
Number
)
oldResponse
.
getSource
().
get
(
GCMetricTable
.
COLUMN_COUNT
)).
intValue
());
}
return
response
;
}
@Override
public
JsonObject
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
)
{
JsonObject
response
=
new
JsonObject
();
MultiGetRequestBuilder
youngPrepareMultiGet
=
getClient
().
prepareMultiGet
();
long
timeBucket
=
startTimeBucket
;
do
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
String
youngId
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
+
Const
.
ID_SPLIT
+
GCPhrase
.
NEW_VALUE
;
youngPrepareMultiGet
.
add
(
GCMetricTable
.
TABLE
,
GCMetricTable
.
TABLE_TYPE
,
youngId
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
youngArray
=
new
JsonArray
();
MultiGetResponse
multiGetResponse
=
youngPrepareMultiGet
.
get
();
for
(
MultiGetItemResponse
itemResponse
:
multiGetResponse
.
getResponses
())
{
if
(
itemResponse
.
getResponse
().
isExists
())
{
youngArray
.
add
(((
Number
)
itemResponse
.
getResponse
().
getSource
().
get
(
GCMetricTable
.
COLUMN_COUNT
)).
intValue
());
}
else
{
youngArray
.
add
(
0
);
}
}
response
.
add
(
"ygc"
,
youngArray
);
MultiGetRequestBuilder
oldPrepareMultiGet
=
getClient
().
prepareMultiGet
();
timeBucket
=
startTimeBucket
;
do
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
String
oldId
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
+
Const
.
ID_SPLIT
+
GCPhrase
.
OLD_VALUE
;
oldPrepareMultiGet
.
add
(
GCMetricTable
.
TABLE
,
GCMetricTable
.
TABLE_TYPE
,
oldId
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
oldArray
=
new
JsonArray
();
multiGetResponse
=
oldPrepareMultiGet
.
get
();
for
(
MultiGetItemResponse
itemResponse
:
multiGetResponse
.
getResponses
())
{
if
(
itemResponse
.
getResponse
().
isExists
())
{
oldArray
.
add
(((
Number
)
itemResponse
.
getResponse
().
getSource
().
get
(
GCMetricTable
.
COLUMN_COUNT
)).
intValue
());
}
else
{
oldArray
.
add
(
0
);
}
}
response
.
add
(
"ogc"
,
oldArray
);
return
response
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GlobalTraceEsDAO.java
浏览文件 @
24a03753
...
...
@@ -24,7 +24,7 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.core.UnexpectedException
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.dao.IGlobalTraceDAO
;
import
org.skywalking.apm.collector.storage.dao.IGlobalTrace
Stream
DAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.global.GlobalTrace
;
import
org.skywalking.apm.collector.storage.table.global.GlobalTraceTable
;
...
...
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public
class
GlobalTraceEsDAO
extends
EsDAO
implements
IGlobalTraceDAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
,
GlobalTrace
>
{
public
class
GlobalTraceEsDAO
extends
EsDAO
implements
IGlobalTrace
Stream
DAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
,
GlobalTrace
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalTraceEsDAO
.
class
);
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.SearchHit
;
import
org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.global.GlobalTraceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
GlobalTraceEsUIDAO
extends
EsDAO
implements
IGlobalTraceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalTraceEsUIDAO
.
class
);
@Override
public
List
<
String
>
getGlobalTraceId
(
String
segmentId
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
GlobalTraceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
GlobalTraceTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
GlobalTraceTable
.
COLUMN_SEGMENT_ID
,
segmentId
));
searchRequestBuilder
.
setSize
(
10
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
List
<
String
>
globalTraceIds
=
new
ArrayList
<>();
SearchHit
[]
searchHits
=
searchResponse
.
getHits
().
getHits
();
for
(
SearchHit
searchHit
:
searchHits
)
{
String
globalTraceId
=
(
String
)
searchHit
.
getSource
().
get
(
GlobalTraceTable
.
COLUMN_GLOBAL_TRACE_ID
);
logger
.
debug
(
"segmentId: {}, global trace id: {}"
,
segmentId
,
globalTraceId
);
globalTraceIds
.
add
(
globalTraceId
);
}
return
globalTraceIds
;
}
@Override
public
List
<
String
>
getSegmentIds
(
String
globalTraceId
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
GlobalTraceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
GlobalTraceTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
GlobalTraceTable
.
COLUMN_GLOBAL_TRACE_ID
,
globalTraceId
));
searchRequestBuilder
.
setSize
(
10
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
List
<
String
>
segmentIds
=
new
ArrayList
<>();
SearchHit
[]
searchHits
=
searchResponse
.
getHits
().
getHits
();
for
(
SearchHit
searchHit
:
searchHits
)
{
String
segmentId
=
(
String
)
searchHit
.
getSource
().
get
(
GlobalTraceTable
.
COLUMN_SEGMENT_ID
);
logger
.
debug
(
"segmentId: {}, global trace id: {}"
,
segmentId
,
globalTraceId
);
segmentIds
.
add
(
segmentId
);
}
return
segmentIds
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstPerformanceEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.get.MultiGetItemResponse
;
import
org.elasticsearch.action.get.MultiGetRequestBuilder
;
import
org.elasticsearch.action.get.MultiGetResponse
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.metrics.sum.Sum
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.instance.InstPerformanceTable
;
/**
* @author peng-yongsheng
*/
public
class
InstPerformanceEsUIDAO
extends
EsDAO
implements
IInstPerformanceUIDAO
{
@Override
public
InstPerformance
get
(
long
[]
timeBuckets
,
int
instanceId
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
InstPerformanceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
InstPerformanceTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
InstPerformanceTable
.
COLUMN_INSTANCE_ID
,
instanceId
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termsQuery
(
InstPerformanceTable
.
COLUMN_TIME_BUCKET
,
timeBuckets
));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
0
);
searchRequestBuilder
.
addSort
(
InstPerformanceTable
.
COLUMN_INSTANCE_ID
,
SortOrder
.
ASC
);
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
sum
(
InstPerformanceTable
.
COLUMN_CALLS
).
field
(
InstPerformanceTable
.
COLUMN_CALLS
));
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
sum
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
).
field
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
Sum
sumCalls
=
searchResponse
.
getAggregations
().
get
(
InstPerformanceTable
.
COLUMN_CALLS
);
Sum
sumCostTotal
=
searchResponse
.
getAggregations
().
get
(
InstPerformanceTable
.
COLUMN_CALLS
);
return
new
InstPerformance
(
instanceId
,
(
int
)
sumCalls
.
getValue
(),
(
long
)
sumCostTotal
.
getValue
());
}
@Override
public
int
getTpsMetric
(
int
instanceId
,
long
timeBucket
)
{
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
GetResponse
getResponse
=
getClient
().
prepareGet
(
InstPerformanceTable
.
TABLE
,
id
).
get
();
if
(
getResponse
.
isExists
())
{
return
((
Number
)
getResponse
.
getSource
().
get
(
InstPerformanceTable
.
COLUMN_CALLS
)).
intValue
();
}
return
0
;
}
@Override
public
JsonArray
getTpsMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
)
{
MultiGetRequestBuilder
prepareMultiGet
=
getClient
().
prepareMultiGet
();
long
timeBucket
=
startTimeBucket
;
do
{
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
prepareMultiGet
.
add
(
InstPerformanceTable
.
TABLE
,
InstPerformanceTable
.
TABLE_TYPE
,
id
);
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
metrics
=
new
JsonArray
();
MultiGetResponse
multiGetResponse
=
prepareMultiGet
.
get
();
for
(
MultiGetItemResponse
response
:
multiGetResponse
.
getResponses
())
{
if
(
response
.
getResponse
().
isExists
())
{
metrics
.
add
(((
Number
)
response
.
getResponse
().
getSource
().
get
(
InstPerformanceTable
.
COLUMN_CALLS
)).
intValue
());
}
else
{
metrics
.
add
(
0
);
}
}
return
metrics
;
}
@Override
public
int
getRespTimeMetric
(
int
instanceId
,
long
timeBucket
)
{
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
GetResponse
getResponse
=
getClient
().
prepareGet
(
InstPerformanceTable
.
TABLE
,
id
).
get
();
if
(
getResponse
.
isExists
())
{
int
callTimes
=
((
Number
)
getResponse
.
getSource
().
get
(
InstPerformanceTable
.
COLUMN_CALLS
)).
intValue
();
int
costTotal
=
((
Number
)
getResponse
.
getSource
().
get
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
)).
intValue
();
return
costTotal
/
callTimes
;
}
return
0
;
}
@Override
public
JsonArray
getRespTimeMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
)
{
MultiGetRequestBuilder
prepareMultiGet
=
getClient
().
prepareMultiGet
();
int
i
=
0
;
long
timeBucket
;
do
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
startTimeBucket
,
i
);
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
prepareMultiGet
.
add
(
InstPerformanceTable
.
TABLE
,
InstPerformanceTable
.
TABLE_TYPE
,
id
);
i
++;
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
metrics
=
new
JsonArray
();
MultiGetResponse
multiGetResponse
=
prepareMultiGet
.
get
();
for
(
MultiGetItemResponse
response
:
multiGetResponse
.
getResponses
())
{
if
(
response
.
getResponse
().
isExists
())
{
int
callTimes
=
((
Number
)
response
.
getResponse
().
getSource
().
get
(
InstPerformanceTable
.
COLUMN_CALLS
)).
intValue
();
int
costTotal
=
((
Number
)
response
.
getResponse
().
getSource
().
get
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
)).
intValue
();
metrics
.
add
(
costTotal
/
callTimes
);
}
else
{
metrics
.
add
(
0
);
}
}
return
metrics
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceEsDAO.java
→
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceEs
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -30,7 +30,7 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.SearchHit
;
import
org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.skywalking.apm.collector.storage.dao.IInstanceDAO
;
import
org.skywalking.apm.collector.storage.dao.IInstance
Stream
DAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.register.Instance
;
import
org.skywalking.apm.collector.storage.table.register.InstanceTable
;
...
...
@@ -40,9 +40,9 @@ import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public
class
InstanceEs
DAO
extends
EsDAO
implements
IInstance
DAO
{
public
class
InstanceEs
StreamDAO
extends
EsDAO
implements
IInstanceStream
DAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceEsDAO
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceEs
Stream
DAO
.
class
);
@Override
public
int
getInstanceId
(
int
applicationId
,
String
agentUUID
)
{
ElasticSearchClient
client
=
getClient
();
...
...
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.elasticsearch.action.get.GetRequestBuilder
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.AbstractQueryBuilder
;
import
org.elasticsearch.index.query.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.index.query.RangeQueryBuilder
;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount
;
import
org.elasticsearch.search.sort.SortBuilders
;
import
org.elasticsearch.search.sort.SortMode
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.dao.IInstanceUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.register.Instance
;
import
org.skywalking.apm.collector.storage.table.register.InstanceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceEsUIDAO
extends
EsDAO
implements
IInstanceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceEsUIDAO
.
class
);
@Override
public
Long
lastHeartBeatTime
()
{
long
fiveMinuteBefore
=
System
.
currentTimeMillis
()
-
5
*
60
*
1000
;
fiveMinuteBefore
=
TimeBucketUtils
.
INSTANCE
.
getSecondTimeBucket
(
fiveMinuteBefore
);
RangeQueryBuilder
rangeQueryBuilder
=
QueryBuilders
.
rangeQuery
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
).
gt
(
fiveMinuteBefore
);
return
heartBeatTime
(
rangeQueryBuilder
);
}
@Override
public
Long
instanceLastHeartBeatTime
(
long
applicationInstanceId
)
{
long
fiveMinuteBefore
=
System
.
currentTimeMillis
()
-
5
*
60
*
1000
;
fiveMinuteBefore
=
TimeBucketUtils
.
INSTANCE
.
getSecondTimeBucket
(
fiveMinuteBefore
);
BoolQueryBuilder
boolQueryBuilder
=
new
BoolQueryBuilder
();
boolQueryBuilder
.
must
(
QueryBuilders
.
rangeQuery
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
).
gt
(
fiveMinuteBefore
));
boolQueryBuilder
.
must
(
QueryBuilders
.
termQuery
(
InstanceTable
.
COLUMN_INSTANCE_ID
,
applicationInstanceId
));
return
heartBeatTime
(
boolQueryBuilder
);
}
private
Long
heartBeatTime
(
AbstractQueryBuilder
queryBuilder
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
InstanceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
InstanceTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
queryBuilder
);
searchRequestBuilder
.
setSize
(
1
);
searchRequestBuilder
.
setFetchSource
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
null
);
searchRequestBuilder
.
addSort
(
SortBuilders
.
fieldSort
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
).
sortMode
(
SortMode
.
MAX
));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
SearchHit
[]
searchHits
=
searchResponse
.
getHits
().
getHits
();
Long
heartBeatTime
=
0L
;
for
(
SearchHit
searchHit
:
searchHits
)
{
heartBeatTime
=
(
Long
)
searchHit
.
getSource
().
get
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
);
logger
.
debug
(
"heartBeatTime: {}"
,
heartBeatTime
);
heartBeatTime
=
heartBeatTime
-
5
;
}
return
heartBeatTime
;
}
@Override
public
JsonArray
getApplications
(
long
startTime
,
long
endTime
)
{
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
));
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
)));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
Terms
genders
=
searchResponse
.
getAggregations
().
get
(
InstanceTable
.
COLUMN_APPLICATION_ID
);
JsonArray
applications
=
new
JsonArray
();
for
(
Terms
.
Bucket
applicationsBucket
:
genders
.
getBuckets
())
{
Integer
applicationId
=
applicationsBucket
.
getKeyAsNumber
().
intValue
();
logger
.
debug
(
"applicationId: {}"
,
applicationId
);
ValueCount
instanceCount
=
applicationsBucket
.
getAggregations
().
get
(
InstanceTable
.
COLUMN_INSTANCE_ID
);
JsonObject
application
=
new
JsonObject
();
application
.
addProperty
(
"applicationId"
,
applicationId
);
application
.
addProperty
(
"instanceCount"
,
instanceCount
.
getValue
());
applications
.
add
(
application
);
}
return
applications
;
}
@Override
public
Instance
getInstance
(
int
instanceId
)
{
logger
.
debug
(
"get instance info, instance id: {}"
,
instanceId
);
GetRequestBuilder
requestBuilder
=
getClient
().
prepareGet
(
InstanceTable
.
TABLE
,
String
.
valueOf
(
instanceId
));
GetResponse
getResponse
=
requestBuilder
.
get
();
if
(
getResponse
.
isExists
())
{
Instance
instance
=
new
Instance
(
getResponse
.
getId
());
instance
.
setApplicationId
(((
Number
)
getResponse
.
getSource
().
get
(
InstanceTable
.
COLUMN_APPLICATION_ID
)).
intValue
());
instance
.
setAgentUUID
((
String
)
getResponse
.
getSource
().
get
(
InstanceTable
.
COLUMN_AGENT_UUID
));
instance
.
setRegisterTime
(((
Number
)
getResponse
.
getSource
().
get
(
InstanceTable
.
COLUMN_REGISTER_TIME
)).
longValue
());
instance
.
setHeartBeatTime
(((
Number
)
getResponse
.
getSource
().
get
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
)).
longValue
());
instance
.
setOsInfo
((
String
)
getResponse
.
getSource
().
get
(
InstanceTable
.
COLUMN_OS_INFO
));
return
instance
;
}
return
null
;
}
@Override
public
List
<
Instance
>
getInstances
(
int
applicationId
,
long
timeBucket
)
{
logger
.
debug
(
"get instances info, application id: {}, timeBucket: {}"
,
applicationId
,
timeBucket
);
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
InstanceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
InstanceTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setSize
(
1000
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
).
gte
(
timeBucket
));
boolQuery
.
must
().
add
(
QueryBuilders
.
termQuery
(
InstanceTable
.
COLUMN_APPLICATION_ID
,
applicationId
));
searchRequestBuilder
.
setQuery
(
boolQuery
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
SearchHit
[]
searchHits
=
searchResponse
.
getHits
().
getHits
();
List
<
Instance
>
instanceList
=
new
LinkedList
<>();
for
(
SearchHit
searchHit
:
searchHits
)
{
Instance
instance
=
new
Instance
(
searchHit
.
getId
());
instance
.
setApplicationId
(((
Number
)
searchHit
.
getSource
().
get
(
InstanceTable
.
COLUMN_APPLICATION_ID
)).
intValue
());
instance
.
setHeartBeatTime
(((
Number
)
searchHit
.
getSource
().
get
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
)).
longValue
());
instance
.
setInstanceId
(((
Number
)
searchHit
.
getSource
().
get
(
InstanceTable
.
COLUMN_INSTANCE_ID
)).
intValue
());
instanceList
.
add
(
instance
);
}
return
instanceList
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.get.MultiGetItemResponse
;
import
org.elasticsearch.action.get.MultiGetRequestBuilder
;
import
org.elasticsearch.action.get.MultiGetResponse
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable
;
/**
* @author peng-yongsheng
*/
public
class
MemoryMetricEsUIDAO
extends
EsDAO
implements
IMemoryMetricUIDAO
{
@Override
public
JsonObject
getMetric
(
int
instanceId
,
long
timeBucket
,
boolean
isHeap
)
{
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
+
Const
.
ID_SPLIT
+
isHeap
;
GetResponse
getResponse
=
getClient
().
prepareGet
(
MemoryMetricTable
.
TABLE
,
id
).
get
();
JsonObject
metric
=
new
JsonObject
();
if
(
getResponse
.
isExists
())
{
metric
.
addProperty
(
"max"
,
((
Number
)
getResponse
.
getSource
().
get
(
MemoryMetricTable
.
COLUMN_MAX
)).
intValue
());
metric
.
addProperty
(
"init"
,
((
Number
)
getResponse
.
getSource
().
get
(
MemoryMetricTable
.
COLUMN_INIT
)).
intValue
());
metric
.
addProperty
(
"used"
,
((
Number
)
getResponse
.
getSource
().
get
(
MemoryMetricTable
.
COLUMN_USED
)).
intValue
());
}
else
{
metric
.
addProperty
(
"max"
,
0
);
metric
.
addProperty
(
"init"
,
0
);
metric
.
addProperty
(
"used"
,
0
);
}
return
metric
;
}
@Override
public
JsonObject
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
,
boolean
isHeap
)
{
MultiGetRequestBuilder
prepareMultiGet
=
getClient
().
prepareMultiGet
();
int
i
=
0
;
long
timeBucket
=
startTimeBucket
;
do
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
+
Const
.
ID_SPLIT
+
isHeap
;
prepareMultiGet
.
add
(
MemoryMetricTable
.
TABLE
,
MemoryMetricTable
.
TABLE_TYPE
,
id
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonObject
metric
=
new
JsonObject
();
JsonArray
usedMetric
=
new
JsonArray
();
MultiGetResponse
multiGetResponse
=
prepareMultiGet
.
get
();
for
(
MultiGetItemResponse
response
:
multiGetResponse
.
getResponses
())
{
if
(
response
.
getResponse
().
isExists
())
{
metric
.
addProperty
(
"max"
,
((
Number
)
response
.
getResponse
().
getSource
().
get
(
MemoryMetricTable
.
COLUMN_MAX
)).
longValue
());
metric
.
addProperty
(
"init"
,
((
Number
)
response
.
getResponse
().
getSource
().
get
(
MemoryMetricTable
.
COLUMN_INIT
)).
longValue
());
usedMetric
.
add
(((
Number
)
response
.
getResponse
().
getSource
().
get
(
MemoryMetricTable
.
COLUMN_USED
)).
longValue
());
}
else
{
metric
.
addProperty
(
"max"
,
0
);
metric
.
addProperty
(
"init"
,
0
);
usedMetric
.
add
(
0
);
}
}
metric
.
add
(
"used"
,
usedMetric
);
return
metric
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeComponentEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.dao.INodeComponentUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.node.NodeComponentTable
;
import
org.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
NodeComponentEsUIDAO
extends
EsDAO
implements
INodeComponentUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NodeComponentEsDAO
.
class
);
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
logger
.
debug
(
"node component load, start time: {}, end time: {}"
,
startTime
,
endTime
);
JsonArray
nodeComponentArray
=
new
JsonArray
();
nodeComponentArray
.
addAll
(
aggregationByComponentId
(
startTime
,
endTime
));
nodeComponentArray
.
addAll
(
aggregationByComponentName
(
startTime
,
endTime
));
return
nodeComponentArray
;
}
private
JsonArray
aggregationByComponentId
(
long
startTime
,
long
endTime
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
NodeComponentTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
NodeComponentTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
rangeQuery
(
NodeComponentTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
searchRequestBuilder
.
setSize
(
0
);
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
terms
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
).
field
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
terms
(
NodeComponentTable
.
COLUMN_PEER
).
field
(
NodeComponentTable
.
COLUMN_PEER
).
size
(
100
))
.
subAggregation
(
AggregationBuilders
.
terms
(
NodeComponentTable
.
COLUMN_PEER_ID
).
field
(
NodeComponentTable
.
COLUMN_PEER_ID
).
size
(
100
)));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
Terms
componentIdTerms
=
searchResponse
.
getAggregations
().
get
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
);
JsonArray
nodeComponentArray
=
new
JsonArray
();
for
(
Terms
.
Bucket
componentIdBucket
:
componentIdTerms
.
getBuckets
())
{
int
componentId
=
componentIdBucket
.
getKeyAsNumber
().
intValue
();
String
componentName
=
ComponentsDefine
.
getInstance
().
getComponentName
(
componentId
);
if
(
componentId
!=
0
)
{
buildComponentArray
(
componentIdBucket
,
componentName
,
nodeComponentArray
);
}
}
return
nodeComponentArray
;
}
private
JsonArray
aggregationByComponentName
(
long
startTime
,
long
endTime
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
NodeComponentTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
NodeComponentTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
rangeQuery
(
NodeComponentTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
searchRequestBuilder
.
setSize
(
0
);
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
terms
(
NodeComponentTable
.
COLUMN_COMPONENT_NAME
).
field
(
NodeComponentTable
.
COLUMN_COMPONENT_NAME
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
terms
(
NodeComponentTable
.
COLUMN_PEER
).
field
(
NodeComponentTable
.
COLUMN_PEER
).
size
(
100
))
.
subAggregation
(
AggregationBuilders
.
terms
(
NodeComponentTable
.
COLUMN_PEER_ID
).
field
(
NodeComponentTable
.
COLUMN_PEER_ID
).
size
(
100
)));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
Terms
componentNameTerms
=
searchResponse
.
getAggregations
().
get
(
NodeComponentTable
.
COLUMN_COMPONENT_NAME
);
JsonArray
nodeComponentArray
=
new
JsonArray
();
for
(
Terms
.
Bucket
componentNameBucket
:
componentNameTerms
.
getBuckets
())
{
String
componentName
=
componentNameBucket
.
getKeyAsString
();
if
(
StringUtils
.
isNotEmpty
(
componentName
))
{
buildComponentArray
(
componentNameBucket
,
componentName
,
nodeComponentArray
);
}
}
return
nodeComponentArray
;
}
private
void
buildComponentArray
(
Terms
.
Bucket
componentBucket
,
String
componentName
,
JsonArray
nodeComponentArray
)
{
Terms
peerIdTerms
=
componentBucket
.
getAggregations
().
get
(
NodeComponentTable
.
COLUMN_PEER_ID
);
for
(
Terms
.
Bucket
peerIdBucket
:
peerIdTerms
.
getBuckets
())
{
int
peerId
=
peerIdBucket
.
getKeyAsNumber
().
intValue
();
if
(
peerId
!=
0
)
{
//TODO ApplicationCache
// String peer = ApplicationCache.get(peerId);
JsonObject
nodeComponentObj
=
new
JsonObject
();
nodeComponentObj
.
addProperty
(
"componentName"
,
componentName
);
// nodeComponentObj.addProperty("peer", peer);
nodeComponentArray
.
add
(
nodeComponentObj
);
}
}
Terms
peerTerms
=
componentBucket
.
getAggregations
().
get
(
NodeComponentTable
.
COLUMN_PEER
);
for
(
Terms
.
Bucket
peerBucket
:
peerTerms
.
getBuckets
())
{
String
peer
=
peerBucket
.
getKeyAsString
();
if
(
StringUtils
.
isNotEmpty
(
peer
))
{
JsonObject
nodeComponentObj
=
new
JsonObject
();
nodeComponentObj
.
addProperty
(
"componentName"
,
componentName
);
nodeComponentObj
.
addProperty
(
"peer"
,
peer
);
nodeComponentArray
.
add
(
nodeComponentObj
);
}
}
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeMappingEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.dao.INodeMappingUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.node.NodeMappingTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
NodeMappingEsUIDAO
extends
EsDAO
implements
INodeMappingUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NodeMappingEsUIDAO
.
class
);
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
NodeMappingTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
NodeMappingTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
rangeQuery
(
NodeMappingTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
searchRequestBuilder
.
setSize
(
0
);
searchRequestBuilder
.
addAggregation
(
AggregationBuilders
.
terms
(
NodeMappingTable
.
COLUMN_APPLICATION_ID
).
field
(
NodeMappingTable
.
COLUMN_APPLICATION_ID
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
terms
(
NodeMappingTable
.
COLUMN_ADDRESS_ID
).
field
(
NodeMappingTable
.
COLUMN_ADDRESS_ID
).
size
(
100
))
.
subAggregation
(
AggregationBuilders
.
terms
(
NodeMappingTable
.
COLUMN_ADDRESS
).
field
(
NodeMappingTable
.
COLUMN_ADDRESS
).
size
(
100
)));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
Terms
applicationIdTerms
=
searchResponse
.
getAggregations
().
get
(
NodeMappingTable
.
COLUMN_APPLICATION_ID
);
JsonArray
nodeMappingArray
=
new
JsonArray
();
for
(
Terms
.
Bucket
applicationIdBucket
:
applicationIdTerms
.
getBuckets
())
{
int
applicationId
=
applicationIdBucket
.
getKeyAsNumber
().
intValue
();
//TODO ApplicationCache
// String applicationCode = ApplicationCache.get(applicationId);
Terms
addressIdTerms
=
applicationIdBucket
.
getAggregations
().
get
(
NodeMappingTable
.
COLUMN_ADDRESS_ID
);
for
(
Terms
.
Bucket
addressIdBucket
:
addressIdTerms
.
getBuckets
())
{
int
addressId
=
addressIdBucket
.
getKeyAsNumber
().
intValue
();
//TODO ApplicationCache
// String address = ApplicationCache.get(addressId);
if
(
addressId
!=
0
)
{
JsonObject
nodeMappingObj
=
new
JsonObject
();
// nodeMappingObj.addProperty("applicationCode", applicationCode);
// nodeMappingObj.addProperty("address", address);
nodeMappingArray
.
add
(
nodeMappingObj
);
}
}
Terms
addressTerms
=
applicationIdBucket
.
getAggregations
().
get
(
NodeMappingTable
.
COLUMN_ADDRESS
);
for
(
Terms
.
Bucket
addressBucket
:
addressTerms
.
getBuckets
())
{
String
address
=
addressBucket
.
getKeyAsString
();
if
(
StringUtils
.
isNotEmpty
(
address
))
{
JsonObject
nodeMappingObj
=
new
JsonObject
();
// nodeMappingObj.addProperty("applicationCode", applicationCode);
nodeMappingObj
.
addProperty
(
"address"
,
address
);
nodeMappingArray
.
add
(
nodeMappingObj
);
}
}
}
logger
.
debug
(
"node mapping data: {}"
,
nodeMappingArray
.
toString
());
return
nodeMappingArray
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeReferenceEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.aggregations.AggregationBuilders
;
import
org.elasticsearch.search.aggregations.bucket.terms.Terms
;
import
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder
;
import
org.elasticsearch.search.aggregations.metrics.sum.Sum
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.dao.INodeReferenceUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.noderef.NodeReferenceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
NodeReferenceEsUIDAO
extends
EsDAO
implements
INodeReferenceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NodeReferenceEsUIDAO
.
class
);
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
NodeReferenceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
NodeReferenceTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
rangeQuery
(
NodeReferenceTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
searchRequestBuilder
.
setSize
(
0
);
TermsAggregationBuilder
aggregationBuilder
=
AggregationBuilders
.
terms
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
).
field
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
).
size
(
100
);
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
terms
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
).
field
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_S1_LTE
).
field
(
NodeReferenceTable
.
COLUMN_S1_LTE
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_S3_LTE
).
field
(
NodeReferenceTable
.
COLUMN_S3_LTE
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_S5_LTE
).
field
(
NodeReferenceTable
.
COLUMN_S5_LTE
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_S5_GT
).
field
(
NodeReferenceTable
.
COLUMN_S5_GT
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_SUMMARY
).
field
(
NodeReferenceTable
.
COLUMN_SUMMARY
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_ERROR
).
field
(
NodeReferenceTable
.
COLUMN_ERROR
)));
aggregationBuilder
.
subAggregation
(
AggregationBuilders
.
terms
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
).
field
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
).
size
(
100
)
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_S1_LTE
).
field
(
NodeReferenceTable
.
COLUMN_S1_LTE
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_S3_LTE
).
field
(
NodeReferenceTable
.
COLUMN_S3_LTE
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_S5_LTE
).
field
(
NodeReferenceTable
.
COLUMN_S5_LTE
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_S5_GT
).
field
(
NodeReferenceTable
.
COLUMN_S5_GT
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_SUMMARY
).
field
(
NodeReferenceTable
.
COLUMN_SUMMARY
))
.
subAggregation
(
AggregationBuilders
.
sum
(
NodeReferenceTable
.
COLUMN_ERROR
).
field
(
NodeReferenceTable
.
COLUMN_ERROR
)));
searchRequestBuilder
.
addAggregation
(
aggregationBuilder
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
JsonArray
nodeRefResSumArray
=
new
JsonArray
();
Terms
frontApplicationIdTerms
=
searchResponse
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
);
for
(
Terms
.
Bucket
frontApplicationIdBucket
:
frontApplicationIdTerms
.
getBuckets
())
{
int
applicationId
=
frontApplicationIdBucket
.
getKeyAsNumber
().
intValue
();
//TODO ApplicationCache
// String applicationCode = ApplicationCache.get(applicationId);
Terms
behindApplicationIdTerms
=
frontApplicationIdBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
);
for
(
Terms
.
Bucket
behindApplicationIdBucket
:
behindApplicationIdTerms
.
getBuckets
())
{
int
behindApplicationId
=
behindApplicationIdBucket
.
getKeyAsNumber
().
intValue
();
if
(
behindApplicationId
!=
0
)
{
// String behindApplicationCode = ApplicationCache.get(behindApplicationId);
Sum
s1LTE
=
behindApplicationIdBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_S1_LTE
);
Sum
s3LTE
=
behindApplicationIdBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_S3_LTE
);
Sum
s5LTE
=
behindApplicationIdBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_S5_LTE
);
Sum
s5GT
=
behindApplicationIdBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_S5_GT
);
Sum
summary
=
behindApplicationIdBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_SUMMARY
);
Sum
error
=
behindApplicationIdBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_ERROR
);
logger
.
debug
(
"applicationId: {}, behindApplicationId: {}, s1LTE: {}, s3LTE: {}, s5LTE: {}, s5GT: {}, error: {}, summary: {}"
,
applicationId
,
behindApplicationId
,
s1LTE
.
getValue
(),
s3LTE
.
getValue
(),
s5LTE
.
getValue
(),
s5GT
.
getValue
(),
error
.
getValue
(),
summary
.
getValue
());
JsonObject
nodeRefResSumObj
=
new
JsonObject
();
// nodeRefResSumObj.addProperty("front", applicationCode);
// nodeRefResSumObj.addProperty("behind", behindApplicationCode);
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S1_LTE
,
s1LTE
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S3_LTE
,
s3LTE
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S5_LTE
,
s5LTE
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S5_GT
,
s5GT
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_ERROR
,
error
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_SUMMARY
,
summary
.
getValue
());
nodeRefResSumArray
.
add
(
nodeRefResSumObj
);
}
}
Terms
behindPeerTerms
=
frontApplicationIdBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
);
for
(
Terms
.
Bucket
behindPeerBucket
:
behindPeerTerms
.
getBuckets
())
{
String
behindPeer
=
behindPeerBucket
.
getKeyAsString
();
if
(
StringUtils
.
isNotEmpty
(
behindPeer
))
{
Sum
s1LTE
=
behindPeerBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_S1_LTE
);
Sum
s3LTE
=
behindPeerBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_S3_LTE
);
Sum
s5LTE
=
behindPeerBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_S5_LTE
);
Sum
s5GT
=
behindPeerBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_S5_GT
);
Sum
summary
=
behindPeerBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_SUMMARY
);
Sum
error
=
behindPeerBucket
.
getAggregations
().
get
(
NodeReferenceTable
.
COLUMN_ERROR
);
logger
.
debug
(
"applicationId: {}, behindPeer: {}, s1LTE: {}, s3LTE: {}, s5LTE: {}, s5GT: {}, error: {}, summary: {}"
,
applicationId
,
behindPeer
,
s1LTE
.
getValue
(),
s3LTE
.
getValue
(),
s5LTE
.
getValue
(),
s5GT
.
getValue
(),
error
.
getValue
(),
summary
.
getValue
());
JsonObject
nodeRefResSumObj
=
new
JsonObject
();
// nodeRefResSumObj.addProperty("front", applicationCode);
nodeRefResSumObj
.
addProperty
(
"behind"
,
behindPeer
);
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S1_LTE
,
s1LTE
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S3_LTE
,
s3LTE
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S5_LTE
,
s5LTE
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S5_GT
,
s5GT
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_ERROR
,
error
.
getValue
());
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_SUMMARY
,
summary
.
getValue
());
nodeRefResSumArray
.
add
(
nodeRefResSumObj
);
}
}
}
return
nodeRefResSumArray
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.List
;
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.QueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.index.query.RangeQueryBuilder
;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.skywalking.apm.collector.core.util.CollectionUtils
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.segment.SegmentCostTable
;
/**
* @author peng-yongsheng
*/
public
class
SegmentCostEsUIDAO
extends
EsDAO
implements
ISegmentCostUIDAO
{
@Override
public
JsonObject
loadTop
(
long
startTime
,
long
endTime
,
long
minCost
,
long
maxCost
,
String
operationName
,
Error
error
,
int
applicationId
,
List
<
String
>
segmentIds
,
int
limit
,
int
from
,
Sort
sort
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
SegmentCostTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
SegmentCostTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
searchRequestBuilder
.
setQuery
(
boolQueryBuilder
);
List
<
QueryBuilder
>
mustQueryList
=
boolQueryBuilder
.
must
();
mustQueryList
.
add
(
QueryBuilders
.
rangeQuery
(
SegmentCostTable
.
COLUMN_TIME_BUCKET
).
gte
(
startTime
).
lte
(
endTime
));
if
(
minCost
!=
-
1
||
maxCost
!=
-
1
)
{
RangeQueryBuilder
rangeQueryBuilder
=
QueryBuilders
.
rangeQuery
(
SegmentCostTable
.
COLUMN_COST
);
if
(
minCost
!=
-
1
)
{
rangeQueryBuilder
.
gte
(
minCost
);
}
if
(
maxCost
!=
-
1
)
{
rangeQueryBuilder
.
lte
(
maxCost
);
}
boolQueryBuilder
.
must
().
add
(
rangeQueryBuilder
);
}
if
(
StringUtils
.
isNotEmpty
(
operationName
))
{
mustQueryList
.
add
(
QueryBuilders
.
matchQuery
(
SegmentCostTable
.
COLUMN_SERVICE_NAME
,
operationName
));
}
if
(
CollectionUtils
.
isNotEmpty
(
segmentIds
))
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
termsQuery
(
SegmentCostTable
.
COLUMN_SEGMENT_ID
,
segmentIds
.
toArray
(
new
String
[
0
])));
}
if
(
Error
.
True
.
equals
(
error
))
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
termQuery
(
SegmentCostTable
.
COLUMN_IS_ERROR
,
true
));
}
else
if
(
Error
.
False
.
equals
(
error
))
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
termQuery
(
SegmentCostTable
.
COLUMN_IS_ERROR
,
false
));
}
if
(
applicationId
!=
0
)
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
termQuery
(
SegmentCostTable
.
COLUMN_APPLICATION_ID
,
applicationId
));
}
if
(
Sort
.
Cost
.
equals
(
sort
))
{
searchRequestBuilder
.
addSort
(
SegmentCostTable
.
COLUMN_COST
,
SortOrder
.
DESC
);
}
else
if
(
Sort
.
Time
.
equals
(
sort
))
{
searchRequestBuilder
.
addSort
(
SegmentCostTable
.
COLUMN_START_TIME
,
SortOrder
.
DESC
);
}
searchRequestBuilder
.
setSize
(
limit
);
searchRequestBuilder
.
setFrom
(
from
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
JsonObject
topSegPaging
=
new
JsonObject
();
topSegPaging
.
addProperty
(
"recordsTotal"
,
searchResponse
.
getHits
().
totalHits
);
JsonArray
topSegArray
=
new
JsonArray
();
topSegPaging
.
add
(
"data"
,
topSegArray
);
int
num
=
from
;
for
(
SearchHit
searchHit
:
searchResponse
.
getHits
().
getHits
())
{
JsonObject
topSegmentJson
=
new
JsonObject
();
topSegmentJson
.
addProperty
(
"num"
,
num
);
String
segmentId
=
(
String
)
searchHit
.
getSource
().
get
(
SegmentCostTable
.
COLUMN_SEGMENT_ID
);
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_SEGMENT_ID
,
segmentId
);
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_START_TIME
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostTable
.
COLUMN_START_TIME
));
if
(
searchHit
.
getSource
().
containsKey
(
SegmentCostTable
.
COLUMN_END_TIME
))
{
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_END_TIME
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostTable
.
COLUMN_END_TIME
));
}
//TODO IGlobalTraceUIDAO
// IGlobalTraceUIDAO globalTraceDAO = (IGlobalTraceDAO)DAOContainer.INSTANCE.get(IGlobalTraceDAO.class.getName());
// List<String> globalTraces = globalTraceDAO.getGlobalTraceId(segmentId);
// if (CollectionUtils.isNotEmpty(globalTraces)) {
// topSegmentJson.addProperty(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID, globalTraces.get(0));
// }
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_APPLICATION_ID
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostTable
.
COLUMN_APPLICATION_ID
));
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_SERVICE_NAME
,
(
String
)
searchHit
.
getSource
().
get
(
SegmentCostTable
.
COLUMN_SERVICE_NAME
));
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_COST
,
(
Number
)
searchHit
.
getSource
().
get
(
SegmentCostTable
.
COLUMN_COST
));
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_IS_ERROR
,
(
Boolean
)
searchHit
.
getSource
().
get
(
SegmentCostTable
.
COLUMN_IS_ERROR
));
num
++;
topSegArray
.
add
(
topSegmentJson
);
}
return
topSegPaging
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.protobuf.InvalidProtocolBufferException
;
import
java.util.Base64
;
import
java.util.Map
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.dao.ISegmentUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.segment.SegmentTable
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
SegmentEsUIDAO
extends
EsDAO
implements
ISegmentUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentEsUIDAO
.
class
);
@Override
public
TraceSegmentObject
load
(
String
segmentId
)
{
GetResponse
response
=
getClient
().
prepareGet
(
SegmentTable
.
TABLE
,
segmentId
).
get
();
Map
<
String
,
Object
>
source
=
response
.
getSource
();
String
dataBinaryBase64
=
(
String
)
source
.
get
(
SegmentTable
.
COLUMN_DATA_BINARY
);
if
(
StringUtils
.
isNotEmpty
(
dataBinaryBase64
))
{
byte
[]
dataBinary
=
Base64
.
getDecoder
().
decode
(
dataBinaryBase64
);
try
{
return
TraceSegmentObject
.
parseFrom
(
dataBinary
);
}
catch
(
InvalidProtocolBufferException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
return
null
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceEntryEsUIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.es.dao
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
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.SearchHit
;
import
org.elasticsearch.search.SearchHits
;
import
org.elasticsearch.search.sort.SortBuilders
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.skywalking.apm.collector.core.util.ColumnNameUtils
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.service.ServiceEntryTable
;
/**
* @author peng-yongsheng
*/
public
class
ServiceEntryEsUIDAO
extends
EsDAO
implements
IServiceEntryUIDAO
{
@Override
public
JsonObject
load
(
int
applicationId
,
String
entryServiceName
,
long
startTime
,
long
endTime
,
int
from
,
int
size
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
ServiceEntryTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
ServiceEntryTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQueryBuilder
=
QueryBuilders
.
boolQuery
();
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceEntryTable
.
COLUMN_REGISTER_TIME
).
lte
(
endTime
));
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
rangeQuery
(
ServiceEntryTable
.
COLUMN_NEWEST_TIME
).
gte
(
startTime
));
if
(
applicationId
!=
0
)
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
matchQuery
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
,
applicationId
));
}
if
(
StringUtils
.
isNotEmpty
(
entryServiceName
))
{
boolQueryBuilder
.
must
().
add
(
QueryBuilders
.
matchQuery
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
,
entryServiceName
));
}
searchRequestBuilder
.
setQuery
(
boolQueryBuilder
);
searchRequestBuilder
.
setSize
(
size
);
searchRequestBuilder
.
setFrom
(
from
);
searchRequestBuilder
.
addSort
(
SortBuilders
.
fieldSort
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
).
order
(
SortOrder
.
ASC
));
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
return
parseResponse
(
searchResponse
);
}
private
JsonObject
parseResponse
(
SearchResponse
searchResponse
)
{
SearchHits
searchHits
=
searchResponse
.
getHits
();
JsonArray
serviceArray
=
new
JsonArray
();
for
(
SearchHit
searchHit
:
searchHits
.
getHits
())
{
int
applicationId
=
((
Number
)
searchHit
.
getSource
().
get
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
)).
intValue
();
int
entryServiceId
=
((
Number
)
searchHit
.
getSource
().
get
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
)).
intValue
();
String
entryServiceName
=
(
String
)
searchHit
.
getSource
().
get
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
);
JsonObject
row
=
new
JsonObject
();
row
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
),
entryServiceId
);
row
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
),
entryServiceName
);
row
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
),
applicationId
);
serviceArray
.
add
(
row
);
}
JsonObject
response
=
new
JsonObject
();
response
.
addProperty
(
"total"
,
searchHits
.
totalHits
);
response
.
add
(
"array"
,
serviceArray
);
return
response
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/service/ElasticSearchDAOService.java
浏览文件 @
24a03753
...
...
@@ -18,7 +18,7 @@
package
org.skywalking.apm.collector.storage.es.service
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.skywalking.apm.collector.storage.base.dao.
Abstract
DAO
;
import
org.skywalking.apm.collector.storage.base.dao.DAOContainer
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
...
...
@@ -33,7 +33,7 @@ public class ElasticSearchDAOService implements DAOService {
this
.
daoContainer
=
daoContainer
;
}
@Override
public
DAO
get
(
Class
<
DAO
>
daoInterfaceClass
)
{
@Override
public
AbstractDAO
get
(
Class
<
Abstract
DAO
>
daoInterfaceClass
)
{
return
daoContainer
.
get
(
daoInterfaceClass
.
getName
());
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/base/dao/H2DAO.java
浏览文件 @
24a03753
...
...
@@ -22,14 +22,14 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.skywalking.apm.collector.storage.base.dao.
Abstract
DAO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
abstract
class
H2DAO
extends
DAO
<
H2Client
>
{
public
abstract
class
H2DAO
extends
Abstract
DAO
<
H2Client
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
H2DAO
.
class
);
protected
final
int
getMaxId
(
String
tableName
,
String
columnName
)
{
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2DAO.java
→
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -23,7 +23,7 @@ import java.util.Map;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IApplicationDAO
;
import
org.skywalking.apm.collector.storage.dao.IApplication
Stream
DAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.register.Application
;
import
org.skywalking.apm.collector.storage.table.register.ApplicationTable
;
...
...
@@ -33,8 +33,8 @@ import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public
class
ApplicationH2
DAO
extends
H2DAO
implements
IApplication
DAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationH2DAO
.
class
);
public
class
ApplicationH2
StreamDAO
extends
H2DAO
implements
IApplicationStream
DAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationH2
Stream
DAO
.
class
);
@Override
public
int
getMaxApplicationId
()
{
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/CpuMetricH2DAO.java
→
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/CpuMetricH2
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -22,7 +22,7 @@ import java.util.HashMap;
import
java.util.Map
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.ICpuMetricDAO
;
import
org.skywalking.apm.collector.storage.dao.ICpuMetric
Stream
DAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity
;
import
org.skywalking.apm.collector.storage.table.jvm.CpuMetric
;
...
...
@@ -33,8 +33,8 @@ import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public
class
CpuMetricH2
DAO
extends
H2DAO
implements
ICpuMetric
DAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
,
CpuMetric
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CpuMetricH2DAO
.
class
);
public
class
CpuMetricH2
StreamDAO
extends
H2DAO
implements
ICpuMetricStream
DAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
,
CpuMetric
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CpuMetricH2
Stream
DAO
.
class
);
@Override
public
CpuMetric
get
(
String
id
)
{
return
null
;
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.h2.dao
;
import
com.google.gson.JsonArray
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.jvm.CpuMetricTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
CpuMetricH2UIDAO
extends
H2DAO
implements
ICpuMetricUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CpuMetricH2UIDAO
.
class
);
private
static
final
String
GET_CPU_METRIC_SQL
=
"select * from {0} where {1} = ?"
;
@Override
public
int
getMetric
(
int
instanceId
,
long
timeBucket
)
{
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_CPU_METRIC_SQL
,
CpuMetricTable
.
TABLE
,
CpuMetricTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
id
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getInt
(
CpuMetricTable
.
COLUMN_USAGE_PERCENT
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
0
;
}
@Override
public
JsonArray
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_CPU_METRIC_SQL
,
CpuMetricTable
.
TABLE
,
CpuMetricTable
.
COLUMN_ID
);
long
timeBucket
=
startTimeBucket
;
List
<
String
>
idList
=
new
ArrayList
<>();
do
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
idList
.
add
(
id
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
metrics
=
new
JsonArray
();
idList
.
forEach
(
id
->
{
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
new
String
[]
{
id
}))
{
if
(
rs
.
next
())
{
double
cpuUsed
=
rs
.
getDouble
(
CpuMetricTable
.
COLUMN_USAGE_PERCENT
);
metrics
.
add
((
int
)(
cpuUsed
*
100
));
}
else
{
metrics
.
add
(
0
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
});
return
metrics
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GCMetricH2DAO.java
→
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GCMetricH2
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -22,7 +22,7 @@ import java.util.HashMap;
import
java.util.Map
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IGCMetricDAO
;
import
org.skywalking.apm.collector.storage.dao.IGCMetric
Stream
DAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity
;
import
org.skywalking.apm.collector.storage.table.jvm.GCMetric
;
...
...
@@ -31,7 +31,7 @@ import org.skywalking.apm.collector.storage.table.jvm.GCMetricTable;
/**
* @author peng-yongsheng, clevertension
*/
public
class
GCMetricH2
DAO
extends
H2DAO
implements
IGCMetric
DAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
,
GCMetric
>
{
public
class
GCMetricH2
StreamDAO
extends
H2DAO
implements
IGCMetricStream
DAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
,
GCMetric
>
{
@Override
public
GCMetric
get
(
String
id
)
{
return
null
;
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.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.ArrayList
;
import
java.util.List
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.jvm.GCMetricTable
;
import
org.skywalking.apm.network.proto.GCPhrase
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
GCMetricH2UIDAO
extends
H2DAO
implements
IGCMetricUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GCMetricH2UIDAO
.
class
);
private
static
final
String
GET_GC_COUNT_SQL
=
"select {1}, sum({0}) as cnt, {1} from {2} where {3} = ? and {4} in ("
;
private
static
final
String
GET_GC_METRIC_SQL
=
"select * from {0} where {1} = ?"
;
@Override
public
GCCount
getGCCount
(
long
[]
timeBuckets
,
int
instanceId
)
{
GCCount
gcCount
=
new
GCCount
();
H2Client
client
=
getClient
();
String
sql
=
GET_GC_COUNT_SQL
;
StringBuilder
builder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
timeBuckets
.
length
;
i
++)
{
builder
.
append
(
"?,"
);
}
builder
.
delete
(
builder
.
length
()
-
1
,
builder
.
length
());
builder
.
append
(
")"
);
sql
=
sql
+
builder
+
" group by {1}"
;
sql
=
SqlBuilder
.
buildSql
(
sql
,
GCMetricTable
.
COLUMN_COUNT
,
GCMetricTable
.
COLUMN_PHRASE
,
GCMetricTable
.
TABLE
,
GCMetricTable
.
COLUMN_INSTANCE_ID
,
GCMetricTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[
timeBuckets
.
length
+
1
];
for
(
int
i
=
0
;
i
<
timeBuckets
.
length
;
i
++)
{
params
[
i
+
1
]
=
timeBuckets
[
i
];
}
params
[
0
]
=
instanceId
;
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
int
phrase
=
rs
.
getInt
(
GCMetricTable
.
COLUMN_PHRASE
);
int
count
=
rs
.
getInt
(
"cnt"
);
if
(
phrase
==
GCPhrase
.
NEW_VALUE
)
{
gcCount
.
setYoung
(
count
);
}
else
if
(
phrase
==
GCPhrase
.
OLD_VALUE
)
{
gcCount
.
setOld
(
count
);
}
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
gcCount
;
}
@Override
public
JsonObject
getMetric
(
int
instanceId
,
long
timeBucket
)
{
JsonObject
response
=
new
JsonObject
();
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_GC_METRIC_SQL
,
GCMetricTable
.
TABLE
,
GCMetricTable
.
COLUMN_ID
);
String
youngId
=
timeBucket
+
Const
.
ID_SPLIT
+
GCPhrase
.
NEW_VALUE
+
instanceId
;
Object
[]
params
=
new
Object
[]
{
youngId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
response
.
addProperty
(
"ygc"
,
rs
.
getInt
(
GCMetricTable
.
COLUMN_COUNT
));
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
String
oldId
=
timeBucket
+
Const
.
ID_SPLIT
+
GCPhrase
.
OLD_VALUE
+
instanceId
;
Object
[]
params1
=
new
Object
[]
{
oldId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params1
))
{
if
(
rs
.
next
())
{
response
.
addProperty
(
"ogc"
,
rs
.
getInt
(
GCMetricTable
.
COLUMN_COUNT
));
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
response
;
}
@Override
public
JsonObject
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
)
{
JsonObject
response
=
new
JsonObject
();
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_GC_METRIC_SQL
,
GCMetricTable
.
TABLE
,
GCMetricTable
.
COLUMN_ID
);
long
timeBucket
=
startTimeBucket
;
List
<
String
>
youngIdsList
=
new
ArrayList
<>();
do
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
String
youngId
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
+
Const
.
ID_SPLIT
+
GCPhrase
.
NEW_VALUE
;
youngIdsList
.
add
(
youngId
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
youngArray
=
new
JsonArray
();
forEachRs
(
client
,
youngIdsList
,
sql
,
youngArray
);
response
.
add
(
"ygc"
,
youngArray
);
List
<
String
>
oldIdsList
=
new
ArrayList
<>();
timeBucket
=
startTimeBucket
;
do
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
String
oldId
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
+
Const
.
ID_SPLIT
+
GCPhrase
.
OLD_VALUE
;
oldIdsList
.
add
(
oldId
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
oldArray
=
new
JsonArray
();
forEachRs
(
client
,
oldIdsList
,
sql
,
oldArray
);
response
.
add
(
"ogc"
,
oldArray
);
return
response
;
}
private
void
forEachRs
(
H2Client
client
,
List
<
String
>
idsList
,
String
sql
,
JsonArray
metricArray
)
{
idsList
.
forEach
(
id
->
{
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
new
String
[]
{
id
}))
{
if
(
rs
.
next
())
{
metricArray
.
add
(
rs
.
getInt
(
GCMetricTable
.
COLUMN_COUNT
));
}
else
{
metricArray
.
add
(
0
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
});
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GlobalTraceH2DAO.java
浏览文件 @
24a03753
...
...
@@ -23,7 +23,7 @@ import java.util.Map;
import
org.skywalking.apm.collector.core.UnexpectedException
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IGlobalTraceDAO
;
import
org.skywalking.apm.collector.storage.dao.IGlobalTrace
Stream
DAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity
;
import
org.skywalking.apm.collector.storage.table.global.GlobalTrace
;
...
...
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public
class
GlobalTraceH2DAO
extends
H2DAO
implements
IGlobalTraceDAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
,
GlobalTrace
>
{
public
class
GlobalTraceH2DAO
extends
H2DAO
implements
IGlobalTrace
Stream
DAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
,
GlobalTrace
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalTraceH2DAO
.
class
);
@Override
public
GlobalTrace
get
(
String
id
)
{
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GlobalTraceH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.h2.dao
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.global.GlobalTraceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
GlobalTraceH2UIDAO
extends
H2DAO
implements
IGlobalTraceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalTraceH2UIDAO
.
class
);
private
static
final
String
GET_GLOBAL_TRACE_ID_SQL
=
"select {0} from {1} where {2} = ? limit 10"
;
private
static
final
String
GET_SEGMENT_IDS_SQL
=
"select {0} from {1} where {2} = ? limit 10"
;
@Override
public
List
<
String
>
getGlobalTraceId
(
String
segmentId
)
{
List
<
String
>
globalTraceIds
=
new
ArrayList
<>();
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_GLOBAL_TRACE_ID_SQL
,
GlobalTraceTable
.
COLUMN_GLOBAL_TRACE_ID
,
GlobalTraceTable
.
TABLE
,
GlobalTraceTable
.
COLUMN_SEGMENT_ID
);
Object
[]
params
=
new
Object
[]
{
segmentId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
String
globalTraceId
=
rs
.
getString
(
GlobalTraceTable
.
COLUMN_GLOBAL_TRACE_ID
);
logger
.
debug
(
"segmentId: {}, global trace id: {}"
,
segmentId
,
globalTraceId
);
globalTraceIds
.
add
(
globalTraceId
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
globalTraceIds
;
}
@Override
public
List
<
String
>
getSegmentIds
(
String
globalTraceId
)
{
List
<
String
>
segmentIds
=
new
ArrayList
<>();
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SEGMENT_IDS_SQL
,
GlobalTraceTable
.
COLUMN_SEGMENT_ID
,
GlobalTraceTable
.
TABLE
,
GlobalTraceTable
.
COLUMN_GLOBAL_TRACE_ID
);
Object
[]
params
=
new
Object
[]
{
globalTraceId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
String
segmentId
=
rs
.
getString
(
GlobalTraceTable
.
COLUMN_SEGMENT_ID
);
logger
.
debug
(
"segmentId: {}, global trace id: {}"
,
segmentId
,
globalTraceId
);
segmentIds
.
add
(
segmentId
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
segmentIds
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstPerformanceH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.h2.dao
;
import
com.google.gson.JsonArray
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.instance.InstPerformanceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
InstPerformanceH2UIDAO
extends
H2DAO
implements
IInstPerformanceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstPerformanceH2UIDAO
.
class
);
private
static
final
String
GET_INST_PERF_SQL
=
"select * from {0} where {1} = ? and {2} in ("
;
private
static
final
String
GET_TPS_METRIC_SQL
=
"select * from {0} where {1} = ?"
;
@Override
public
InstPerformance
get
(
long
[]
timeBuckets
,
int
instanceId
)
{
H2Client
client
=
getClient
();
logger
.
info
(
"the inst performance inst id = {}"
,
instanceId
);
String
sql
=
SqlBuilder
.
buildSql
(
GET_INST_PERF_SQL
,
InstPerformanceTable
.
TABLE
,
InstPerformanceTable
.
COLUMN_INSTANCE_ID
,
InstPerformanceTable
.
COLUMN_TIME_BUCKET
);
StringBuilder
builder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
timeBuckets
.
length
;
i
++)
{
builder
.
append
(
"?,"
);
}
builder
.
delete
(
builder
.
length
()
-
1
,
builder
.
length
());
builder
.
append
(
")"
);
sql
=
sql
+
builder
;
Object
[]
params
=
new
Object
[
timeBuckets
.
length
+
1
];
for
(
int
i
=
0
;
i
<
timeBuckets
.
length
;
i
++)
{
params
[
i
+
1
]
=
timeBuckets
[
i
];
}
params
[
0
]
=
instanceId
;
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
int
callTimes
=
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_CALLS
);
int
costTotal
=
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
);
return
new
InstPerformance
(
instanceId
,
callTimes
,
costTotal
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
@Override
public
int
getTpsMetric
(
int
instanceId
,
long
timeBucket
)
{
logger
.
info
(
"getTpMetric instanceId = {}, startTimeBucket = {}"
,
instanceId
,
timeBucket
);
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_TPS_METRIC_SQL
,
InstPerformanceTable
.
TABLE
,
InstPerformanceTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
instanceId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_CALLS
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
0
;
}
@Override
public
JsonArray
getTpsMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
)
{
logger
.
info
(
"getTpsMetric instanceId = {}, startTimeBucket = {}, endTimeBucket = {}"
,
instanceId
,
startTimeBucket
,
endTimeBucket
);
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_TPS_METRIC_SQL
,
InstPerformanceTable
.
TABLE
,
InstPerformanceTable
.
COLUMN_ID
);
long
timeBucket
=
startTimeBucket
;
List
<
String
>
idList
=
new
ArrayList
<>();
do
{
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
idList
.
add
(
id
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
metrics
=
new
JsonArray
();
idList
.
forEach
(
id
->
{
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
new
Object
[]
{
id
}))
{
if
(
rs
.
next
())
{
int
calls
=
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_CALLS
);
metrics
.
add
(
calls
);
}
else
{
metrics
.
add
(
0
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
});
return
metrics
;
}
@Override
public
int
getRespTimeMetric
(
int
instanceId
,
long
timeBucket
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_TPS_METRIC_SQL
,
InstPerformanceTable
.
TABLE
,
InstPerformanceTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
instanceId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
int
callTimes
=
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_CALLS
);
int
costTotal
=
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
);
return
costTotal
/
callTimes
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
0
;
}
@Override
public
JsonArray
getRespTimeMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_TPS_METRIC_SQL
,
InstPerformanceTable
.
TABLE
,
InstPerformanceTable
.
COLUMN_ID
);
long
timeBucket
=
startTimeBucket
;
List
<
String
>
idList
=
new
ArrayList
<>();
do
{
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
;
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
idList
.
add
(
id
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonArray
metrics
=
new
JsonArray
();
idList
.
forEach
(
id
->
{
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
new
Object
[]
{
id
}))
{
if
(
rs
.
next
())
{
int
callTimes
=
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_CALLS
);
int
costTotal
=
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
);
metrics
.
add
(
costTotal
/
callTimes
);
}
else
{
metrics
.
add
(
0
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
});
return
metrics
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2DAO.java
→
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2
Stream
DAO.java
浏览文件 @
24a03753
...
...
@@ -25,7 +25,7 @@ import java.util.Map;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IInstanceDAO
;
import
org.skywalking.apm.collector.storage.dao.IInstance
Stream
DAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.register.Instance
;
import
org.skywalking.apm.collector.storage.table.register.InstanceTable
;
...
...
@@ -35,8 +35,8 @@ import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public
class
InstanceH2
DAO
extends
H2DAO
implements
IInstance
DAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceH2DAO
.
class
);
public
class
InstanceH2
StreamDAO
extends
H2DAO
implements
IInstanceStream
DAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceH2
Stream
DAO
.
class
);
private
static
final
String
GET_INSTANCE_ID_SQL
=
"select {0} from {1} where {2} = ? and {3} = ?"
;
private
static
final
String
UPDATE_HEARTBEAT_TIME_SQL
=
"update {0} set {1} = ? where {2} = ?"
;
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.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.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IInstanceUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.register.Instance
;
import
org.skywalking.apm.collector.storage.table.register.InstanceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
InstanceH2UIDAO
extends
H2DAO
implements
IInstanceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceH2UIDAO
.
class
);
private
static
final
String
GET_LAST_HEARTBEAT_TIME_SQL
=
"select {0} from {1} where {2} > ? limit 1"
;
private
static
final
String
GET_INST_LAST_HEARTBEAT_TIME_SQL
=
"select {0} from {1} where {2} > ? and {3} = ? limit 1"
;
private
static
final
String
GET_INSTANCE_SQL
=
"select * from {0} where {1} = ?"
;
private
static
final
String
GET_INSTANCES_SQL
=
"select * from {0} where {1} = ? and {2} >= ?"
;
private
static
final
String
GET_APPLICATIONS_SQL
=
"select {3}, count({0}) as cnt from {1} where {2} >= ? group by {3} limit 100"
;
@Override
public
Long
lastHeartBeatTime
()
{
H2Client
client
=
getClient
();
long
fiveMinuteBefore
=
System
.
currentTimeMillis
()
-
5
*
60
*
1000
;
fiveMinuteBefore
=
TimeBucketUtils
.
INSTANCE
.
getSecondTimeBucket
(
fiveMinuteBefore
);
String
sql
=
SqlBuilder
.
buildSql
(
GET_LAST_HEARTBEAT_TIME_SQL
,
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_HEARTBEAT_TIME
);
Object
[]
params
=
new
Object
[]
{
fiveMinuteBefore
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getLong
(
1
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
0L
;
}
@Override
public
Long
instanceLastHeartBeatTime
(
long
applicationInstanceId
)
{
H2Client
client
=
getClient
();
long
fiveMinuteBefore
=
System
.
currentTimeMillis
()
-
5
*
60
*
1000
;
fiveMinuteBefore
=
TimeBucketUtils
.
INSTANCE
.
getSecondTimeBucket
(
fiveMinuteBefore
);
String
sql
=
SqlBuilder
.
buildSql
(
GET_INST_LAST_HEARTBEAT_TIME_SQL
,
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
InstanceTable
.
COLUMN_INSTANCE_ID
);
Object
[]
params
=
new
Object
[]
{
fiveMinuteBefore
,
applicationInstanceId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getLong
(
1
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
0L
;
}
@Override
public
JsonArray
getApplications
(
long
startTime
,
long
endTime
)
{
H2Client
client
=
getClient
();
JsonArray
applications
=
new
JsonArray
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_APPLICATIONS_SQL
,
InstanceTable
.
COLUMN_INSTANCE_ID
,
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
InstanceTable
.
COLUMN_APPLICATION_ID
);
Object
[]
params
=
new
Object
[]
{
startTime
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
Integer
applicationId
=
rs
.
getInt
(
InstanceTable
.
COLUMN_APPLICATION_ID
);
logger
.
debug
(
"applicationId: {}"
,
applicationId
);
JsonObject
application
=
new
JsonObject
();
application
.
addProperty
(
"applicationId"
,
applicationId
);
application
.
addProperty
(
"applicationCode"
,
ApplicationCache
.
get
(
applicationId
));
application
.
addProperty
(
"instanceCount"
,
rs
.
getInt
(
"cnt"
));
applications
.
add
(
application
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
applications
;
}
@Override
public
Instance
getInstance
(
int
instanceId
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_INSTANCE_SQL
,
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_INSTANCE_ID
);
Object
[]
params
=
new
Object
[]
{
instanceId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
Instance
instance
=
new
Instance
(
rs
.
getString
(
InstanceTable
.
COLUMN_ID
));
instance
.
setApplicationId
(
rs
.
getInt
(
InstanceTable
.
COLUMN_APPLICATION_ID
));
instance
.
setAgentUUID
(
rs
.
getString
(
InstanceTable
.
COLUMN_AGENT_UUID
));
instance
.
setRegisterTime
(
rs
.
getLong
(
InstanceTable
.
COLUMN_REGISTER_TIME
));
instance
.
setHeartBeatTime
(
rs
.
getLong
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
));
instance
.
setOsInfo
(
rs
.
getString
(
InstanceTable
.
COLUMN_OS_INFO
));
return
instance
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
@Override
public
List
<
Instance
>
getInstances
(
int
applicationId
,
long
timeBucket
)
{
logger
.
debug
(
"get instances info, application id: {}, timeBucket: {}"
,
applicationId
,
timeBucket
);
List
<
Instance
>
instanceList
=
new
LinkedList
<>();
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_INSTANCES_SQL
,
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_APPLICATION_ID
,
InstanceTable
.
COLUMN_HEARTBEAT_TIME
);
Object
[]
params
=
new
Object
[]
{
applicationId
,
timeBucket
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
Instance
instance
=
new
Instance
(
rs
.
getString
(
InstanceTable
.
COLUMN_ID
));
instance
.
setApplicationId
(
rs
.
getInt
(
InstanceTable
.
COLUMN_APPLICATION_ID
));
instance
.
setHeartBeatTime
(
rs
.
getLong
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
));
instance
.
setInstanceId
(
rs
.
getInt
(
InstanceTable
.
COLUMN_INSTANCE_ID
));
instanceList
.
add
(
instance
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
instanceList
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.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.ArrayList
;
import
java.util.List
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author clevertension
*/
public
class
MemoryMetricH2UIDAO
extends
H2DAO
implements
IMemoryMetricUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MemoryMetricH2UIDAO
.
class
);
private
static
final
String
GET_MEMORY_METRIC_SQL
=
"select * from {0} where {1} =?"
;
@Override
public
JsonObject
getMetric
(
int
instanceId
,
long
timeBucket
,
boolean
isHeap
)
{
H2Client
client
=
getClient
();
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
+
Const
.
ID_SPLIT
+
isHeap
;
String
sql
=
SqlBuilder
.
buildSql
(
GET_MEMORY_METRIC_SQL
,
MemoryMetricTable
.
TABLE
,
MemoryMetricTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
id
};
JsonObject
metric
=
new
JsonObject
();
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
metric
.
addProperty
(
"max"
,
rs
.
getInt
(
MemoryMetricTable
.
COLUMN_MAX
));
metric
.
addProperty
(
"init"
,
rs
.
getInt
(
MemoryMetricTable
.
COLUMN_INIT
));
metric
.
addProperty
(
"used"
,
rs
.
getInt
(
MemoryMetricTable
.
COLUMN_USED
));
}
else
{
metric
.
addProperty
(
"max"
,
0
);
metric
.
addProperty
(
"init"
,
0
);
metric
.
addProperty
(
"used"
,
0
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
metric
;
}
@Override
public
JsonObject
getMetric
(
int
instanceId
,
long
startTimeBucket
,
long
endTimeBucket
,
boolean
isHeap
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_MEMORY_METRIC_SQL
,
MemoryMetricTable
.
TABLE
,
MemoryMetricTable
.
COLUMN_ID
);
List
<
String
>
idList
=
new
ArrayList
<>();
long
timeBucket
=
startTimeBucket
;
do
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
1
);
String
id
=
timeBucket
+
Const
.
ID_SPLIT
+
instanceId
+
Const
.
ID_SPLIT
+
isHeap
;
idList
.
add
(
id
);
}
while
(
timeBucket
<=
endTimeBucket
);
JsonObject
metric
=
new
JsonObject
();
JsonArray
usedMetric
=
new
JsonArray
();
idList
.
forEach
(
id
->
{
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
new
String
[]
{
id
}))
{
if
(
rs
.
next
())
{
metric
.
addProperty
(
"max"
,
rs
.
getLong
(
MemoryMetricTable
.
COLUMN_MAX
));
metric
.
addProperty
(
"init"
,
rs
.
getLong
(
MemoryMetricTable
.
COLUMN_INIT
));
usedMetric
.
add
(
rs
.
getLong
(
MemoryMetricTable
.
COLUMN_USED
));
}
else
{
metric
.
addProperty
(
"max"
,
0
);
metric
.
addProperty
(
"init"
,
0
);
usedMetric
.
add
(
0
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
});
metric
.
add
(
"used"
,
usedMetric
);
return
metric
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeComponentH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.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
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.INodeComponentUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.node.NodeComponentTable
;
import
org.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
NodeComponentH2UIDAO
extends
H2DAO
implements
INodeComponentUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NodeComponentH2UIDAO
.
class
);
private
static
final
String
AGGREGATE_COMPONENT_SQL
=
"select {0}, {1}, {2} from {3} where {4} >= ? and {4} <= ? group by {0}, {1}, {2} limit 100"
;
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
JsonArray
nodeComponentArray
=
new
JsonArray
();
nodeComponentArray
.
addAll
(
aggregationComponent
(
startTime
,
endTime
));
return
nodeComponentArray
;
}
private
JsonArray
aggregationComponent
(
long
startTime
,
long
endTime
)
{
H2Client
client
=
getClient
();
JsonArray
nodeComponentArray
=
new
JsonArray
();
String
sql
=
SqlBuilder
.
buildSql
(
AGGREGATE_COMPONENT_SQL
,
NodeComponentTable
.
COLUMN_COMPONENT_ID
,
NodeComponentTable
.
COLUMN_PEER
,
NodeComponentTable
.
COLUMN_PEER_ID
,
NodeComponentTable
.
TABLE
,
NodeComponentTable
.
COLUMN_TIME_BUCKET
);
Object
[]
params
=
new
Object
[]
{
startTime
,
endTime
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
int
peerId
=
rs
.
getInt
(
NodeComponentTable
.
COLUMN_PEER_ID
);
int
componentId
=
rs
.
getInt
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
);
String
componentName
=
ComponentsDefine
.
getInstance
().
getComponentName
(
componentId
);
if
(
peerId
!=
0
)
{
//TODO ApplicationCache
// String peer = ApplicationCache.get(peerId);
// nodeComponentArray.add(buildNodeComponent(peer, componentName));
}
String
peer
=
rs
.
getString
(
NodeComponentTable
.
COLUMN_PEER
);
if
(
StringUtils
.
isNotEmpty
(
peer
))
{
nodeComponentArray
.
add
(
buildNodeComponent
(
peer
,
componentName
));
}
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
nodeComponentArray
;
}
private
JsonObject
buildNodeComponent
(
String
peer
,
String
componentName
)
{
JsonObject
nodeComponentObj
=
new
JsonObject
();
nodeComponentObj
.
addProperty
(
"componentName"
,
componentName
);
nodeComponentObj
.
addProperty
(
"peer"
,
peer
);
return
nodeComponentObj
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeMappingH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.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
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.INodeMappingUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.node.NodeMappingTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
NodeMappingH2UIDAO
extends
H2DAO
implements
INodeMappingUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NodeMappingH2UIDAO
.
class
);
private
static
final
String
NODE_MAPPING_SQL
=
"select {0}, {1}, {2} from {3} where {4} >= ? and {4} <= ? group by {0}, {1}, {2} limit 100"
;
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
H2Client
client
=
getClient
();
JsonArray
nodeMappingArray
=
new
JsonArray
();
String
sql
=
SqlBuilder
.
buildSql
(
NODE_MAPPING_SQL
,
NodeMappingTable
.
COLUMN_APPLICATION_ID
,
NodeMappingTable
.
COLUMN_ADDRESS_ID
,
NodeMappingTable
.
COLUMN_ADDRESS
,
NodeMappingTable
.
TABLE
,
NodeMappingTable
.
COLUMN_TIME_BUCKET
);
Object
[]
params
=
new
Object
[]
{
startTime
,
endTime
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
int
applicationId
=
rs
.
getInt
(
NodeMappingTable
.
COLUMN_APPLICATION_ID
);
//TODO ApplicationCache
// String applicationCode = ApplicationCache.get(applicationId);
int
addressId
=
rs
.
getInt
(
NodeMappingTable
.
COLUMN_ADDRESS_ID
);
if
(
addressId
!=
0
)
{
// String address = ApplicationCache.get(addressId);
JsonObject
nodeMappingObj
=
new
JsonObject
();
// nodeMappingObj.addProperty("applicationCode", applicationCode);
// nodeMappingObj.addProperty("address", address);
nodeMappingArray
.
add
(
nodeMappingObj
);
}
String
address
=
rs
.
getString
(
NodeMappingTable
.
COLUMN_ADDRESS
);
if
(
StringUtils
.
isNotEmpty
(
address
))
{
JsonObject
nodeMappingObj
=
new
JsonObject
();
// nodeMappingObj.addProperty("applicationCode", applicationCode);
nodeMappingObj
.
addProperty
(
"address"
,
address
);
nodeMappingArray
.
add
(
nodeMappingObj
);
}
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
logger
.
debug
(
"node mapping data: {}"
,
nodeMappingArray
.
toString
());
return
nodeMappingArray
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeReferenceH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.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
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.INodeReferenceUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.noderef.NodeReferenceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
NodeReferenceH2UIDAO
extends
H2DAO
implements
INodeReferenceUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NodeReferenceH2UIDAO
.
class
);
private
static
final
String
NODE_REFERENCE_SQL
=
"select {8}, {9}, {10}, sum({0}) as {0}, sum({1}) as {1}, sum({2}) as {2}, "
+
"sum({3}) as {3}, sum({4}) as {4}, sum({5}) as {5} from {6} where {7} >= ? and {7} <= ? group by {8}, {9}, {10} limit 100"
;
@Override
public
JsonArray
load
(
long
startTime
,
long
endTime
)
{
H2Client
client
=
getClient
();
JsonArray
nodeRefResSumArray
=
new
JsonArray
();
String
sql
=
SqlBuilder
.
buildSql
(
NODE_REFERENCE_SQL
,
NodeReferenceTable
.
COLUMN_S1_LTE
,
NodeReferenceTable
.
COLUMN_S3_LTE
,
NodeReferenceTable
.
COLUMN_S5_LTE
,
NodeReferenceTable
.
COLUMN_S5_GT
,
NodeReferenceTable
.
COLUMN_SUMMARY
,
NodeReferenceTable
.
COLUMN_ERROR
,
NodeReferenceTable
.
TABLE
,
NodeReferenceTable
.
COLUMN_TIME_BUCKET
,
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
,
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
,
NodeReferenceTable
.
COLUMN_BEHIND_PEER
);
Object
[]
params
=
new
Object
[]
{
startTime
,
endTime
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
while
(
rs
.
next
())
{
int
applicationId
=
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
);
//TODO ApplicationCache
// String applicationCode = ApplicationCache.get(applicationId);
int
behindApplicationId
=
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
);
if
(
behindApplicationId
!=
0
)
{
// String behindApplicationCode = ApplicationCache.get(behindApplicationId);
JsonObject
nodeRefResSumObj
=
new
JsonObject
();
// nodeRefResSumObj.addProperty("front", applicationCode);
// nodeRefResSumObj.addProperty("behind", behindApplicationCode);
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S1_LTE
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_S1_LTE
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S3_LTE
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_S3_LTE
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S5_LTE
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_S5_LTE
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S5_GT
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_S5_GT
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_ERROR
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_ERROR
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_SUMMARY
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_SUMMARY
));
nodeRefResSumArray
.
add
(
nodeRefResSumObj
);
}
String
behindPeer
=
rs
.
getString
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
);
if
(
StringUtils
.
isNotEmpty
(
behindPeer
))
{
JsonObject
nodeRefResSumObj
=
new
JsonObject
();
// nodeRefResSumObj.addProperty("front", applicationCode);
nodeRefResSumObj
.
addProperty
(
"behind"
,
behindPeer
);
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S1_LTE
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_S1_LTE
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S3_LTE
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_S3_LTE
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S5_LTE
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_S5_LTE
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_S5_GT
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_S5_GT
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_ERROR
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_ERROR
));
nodeRefResSumObj
.
addProperty
(
NodeReferenceTable
.
COLUMN_SUMMARY
,
rs
.
getDouble
(
NodeReferenceTable
.
COLUMN_SUMMARY
));
nodeRefResSumArray
.
add
(
nodeRefResSumObj
);
}
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
nodeRefResSumArray
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/SegmentCostH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.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.ArrayList
;
import
java.util.List
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.CollectionUtils
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.segment.SegmentCostTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
SegmentCostH2UIDAO
extends
H2DAO
implements
ISegmentCostUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentCostH2UIDAO
.
class
);
private
static
final
String
GET_SEGMENT_COST_SQL
=
"select * from {0} where {1} >= ? and {1} <= ?"
;
@Override
public
JsonObject
loadTop
(
long
startTime
,
long
endTime
,
long
minCost
,
long
maxCost
,
String
operationName
,
Error
error
,
int
applicationId
,
List
<
String
>
segmentIds
,
int
limit
,
int
from
,
Sort
sort
)
{
H2Client
client
=
getClient
();
String
sql
=
GET_SEGMENT_COST_SQL
;
List
<
Object
>
params
=
new
ArrayList
<>();
List
<
Object
>
columns
=
new
ArrayList
<>();
columns
.
add
(
SegmentCostTable
.
TABLE
);
columns
.
add
(
SegmentCostTable
.
COLUMN_TIME_BUCKET
);
params
.
add
(
startTime
);
params
.
add
(
endTime
);
int
paramIndex
=
1
;
if
(
minCost
!=
-
1
||
maxCost
!=
-
1
)
{
if
(
minCost
!=
-
1
)
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} >= ?"
;
params
.
add
(
minCost
);
columns
.
add
(
SegmentCostTable
.
COLUMN_COST
);
}
if
(
maxCost
!=
-
1
)
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} <= ?"
;
params
.
add
(
maxCost
);
columns
.
add
(
SegmentCostTable
.
COLUMN_COST
);
}
}
if
(
StringUtils
.
isNotEmpty
(
operationName
))
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} = ?"
;
params
.
add
(
operationName
);
columns
.
add
(
SegmentCostTable
.
COLUMN_SERVICE_NAME
);
}
if
(
CollectionUtils
.
isNotEmpty
(
segmentIds
))
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} in ("
;
columns
.
add
(
SegmentCostTable
.
COLUMN_SEGMENT_ID
);
StringBuilder
builder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
segmentIds
.
size
();
i
++)
{
builder
.
append
(
"?,"
);
}
builder
.
delete
(
builder
.
length
()
-
1
,
builder
.
length
());
builder
.
append
(
")"
);
sql
=
sql
+
builder
;
for
(
String
segmentId
:
segmentIds
)
{
params
.
add
(
segmentId
);
}
}
if
(
Error
.
True
.
equals
(
error
))
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} = ?"
;
params
.
add
(
true
);
columns
.
add
(
SegmentCostTable
.
COLUMN_IS_ERROR
);
}
else
if
(
Error
.
False
.
equals
(
error
))
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} = ?"
;
params
.
add
(
false
);
columns
.
add
(
SegmentCostTable
.
COLUMN_IS_ERROR
);
}
if
(
applicationId
!=
0
)
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} = ?"
;
params
.
add
(
applicationId
);
columns
.
add
(
SegmentCostTable
.
COLUMN_APPLICATION_ID
);
}
if
(
Sort
.
Cost
.
equals
(
sort
))
{
sql
=
sql
+
" order by "
+
SegmentCostTable
.
COLUMN_COST
+
" "
+
SortOrder
.
DESC
;
}
else
if
(
Sort
.
Time
.
equals
(
sort
))
{
sql
=
sql
+
" order by "
+
SegmentCostTable
.
COLUMN_START_TIME
+
" "
+
SortOrder
.
DESC
;
}
sql
=
sql
+
" limit "
+
from
+
","
+
limit
;
sql
=
SqlBuilder
.
buildSql
(
sql
,
columns
);
Object
[]
p
=
params
.
toArray
(
new
Object
[
0
]);
JsonObject
topSegPaging
=
new
JsonObject
();
JsonArray
topSegArray
=
new
JsonArray
();
topSegPaging
.
add
(
"data"
,
topSegArray
);
int
cnt
=
0
;
int
num
=
from
;
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
p
))
{
while
(
rs
.
next
())
{
JsonObject
topSegmentJson
=
new
JsonObject
();
topSegmentJson
.
addProperty
(
"num"
,
num
);
String
segmentId
=
rs
.
getString
(
SegmentCostTable
.
COLUMN_SEGMENT_ID
);
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_SEGMENT_ID
,
segmentId
);
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_START_TIME
,
rs
.
getLong
(
SegmentCostTable
.
COLUMN_START_TIME
));
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_END_TIME
,
rs
.
getLong
(
SegmentCostTable
.
COLUMN_END_TIME
));
//TODO IGlobalTraceDAO
// IGlobalTraceDAO globalTraceDAO = (IGlobalTraceDAO)DAOContainer.INSTANCE.get(IGlobalTraceDAO.class.getName());
// List<String> globalTraces = globalTraceDAO.getGlobalTraceId(segmentId);
// if (CollectionUtils.isNotEmpty(globalTraces)) {
// topSegmentJson.addProperty(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID, globalTraces.get(0));
// }
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_APPLICATION_ID
,
rs
.
getInt
(
SegmentCostTable
.
COLUMN_APPLICATION_ID
));
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_SERVICE_NAME
,
rs
.
getString
(
SegmentCostTable
.
COLUMN_SERVICE_NAME
));
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_COST
,
rs
.
getLong
(
SegmentCostTable
.
COLUMN_COST
));
topSegmentJson
.
addProperty
(
SegmentCostTable
.
COLUMN_IS_ERROR
,
rs
.
getBoolean
(
SegmentCostTable
.
COLUMN_IS_ERROR
));
num
++;
topSegArray
.
add
(
topSegmentJson
);
cnt
++;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
topSegPaging
.
addProperty
(
"recordsTotal"
,
cnt
);
return
topSegPaging
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/SegmentH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.storage.h2.dao
;
import
com.google.protobuf.InvalidProtocolBufferException
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.ISegmentUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.segment.SegmentTable
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
SegmentH2UIDAO
extends
H2DAO
implements
ISegmentUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentH2UIDAO
.
class
);
private
static
final
String
GET_SEGMENT_SQL
=
"select {0} from {1} where {2} = ?"
;
@Override
public
TraceSegmentObject
load
(
String
segmentId
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SEGMENT_SQL
,
SegmentTable
.
COLUMN_DATA_BINARY
,
SegmentTable
.
TABLE
,
SegmentTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
segmentId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
byte
[]
dataBinary
=
rs
.
getBytes
(
SegmentTable
.
COLUMN_DATA_BINARY
);
try
{
return
TraceSegmentObject
.
parseFrom
(
dataBinary
);
}
catch
(
InvalidProtocolBufferException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2UIDAO.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.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.ArrayList
;
import
java.util.List
;
import
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.core.util.ColumnNameUtils
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.base.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.dao.IServiceEntryUIDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.table.service.ServiceEntryTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ServiceEntryH2UIDAO
extends
H2DAO
implements
IServiceEntryUIDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceEntryH2UIDAO
.
class
);
private
static
final
String
GET_SERVICE_ENTRY_SQL
=
"select * from {0} where {1} >= ? and {2} <= ?"
;
@Override
public
JsonObject
load
(
int
applicationId
,
String
entryServiceName
,
long
startTime
,
long
endTime
,
int
from
,
int
size
)
{
H2Client
client
=
getClient
();
String
sql
=
GET_SERVICE_ENTRY_SQL
;
List
<
Object
>
params
=
new
ArrayList
<>();
List
<
Object
>
columns
=
new
ArrayList
<>();
columns
.
add
(
ServiceEntryTable
.
TABLE
);
columns
.
add
(
ServiceEntryTable
.
COLUMN_NEWEST_TIME
);
columns
.
add
(
ServiceEntryTable
.
COLUMN_REGISTER_TIME
);
params
.
add
(
startTime
);
params
.
add
(
endTime
);
int
paramIndex
=
2
;
if
(
applicationId
!=
0
)
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} = ?"
;
params
.
add
(
applicationId
);
columns
.
add
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
);
}
if
(
StringUtils
.
isNotEmpty
(
entryServiceName
))
{
paramIndex
++;
sql
=
sql
+
" and {"
+
paramIndex
+
"} = ?"
;
params
.
add
(
entryServiceName
);
columns
.
add
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
);
}
sql
=
sql
+
" limit "
+
from
+
","
+
size
;
sql
=
SqlBuilder
.
buildSql
(
sql
,
columns
);
Object
[]
p
=
params
.
toArray
(
new
Object
[
0
]);
JsonArray
serviceArray
=
new
JsonArray
();
JsonObject
response
=
new
JsonObject
();
int
index
=
0
;
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
p
))
{
while
(
rs
.
next
())
{
int
appId
=
rs
.
getInt
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
);
int
entryServiceId
=
rs
.
getInt
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
);
String
entryServiceName1
=
rs
.
getString
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
);
JsonObject
row
=
new
JsonObject
();
row
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
),
entryServiceId
);
row
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
),
entryServiceName1
);
row
.
addProperty
(
ColumnNameUtils
.
INSTANCE
.
rename
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
),
appId
);
serviceArray
.
add
(
row
);
index
++;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
response
.
addProperty
(
"total"
,
index
);
response
.
add
(
"array"
,
serviceArray
);
return
response
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/service/H2DAOService.java
浏览文件 @
24a03753
...
...
@@ -18,7 +18,7 @@
package
org.skywalking.apm.collector.storage.h2.service
;
import
org.skywalking.apm.collector.storage.base.dao.DAO
;
import
org.skywalking.apm.collector.storage.base.dao.
Abstract
DAO
;
import
org.skywalking.apm.collector.storage.base.dao.DAOContainer
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
...
...
@@ -33,7 +33,7 @@ public class H2DAOService implements DAOService {
this
.
daoContainer
=
daoContainer
;
}
@Override
public
DAO
get
(
Class
<
DAO
>
daoInterfaceClass
)
{
@Override
public
AbstractDAO
get
(
Class
<
Abstract
DAO
>
daoInterfaceClass
)
{
return
daoContainer
.
get
(
daoInterfaceClass
.
getName
());
}
}
apm-collector/apm-collector-stream/collector-stream-provider/src/main/java/org/skywalking/apm/collector/stream/StreamModuleProvider.java
浏览文件 @
24a03753
...
...
@@ -26,7 +26,7 @@ import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
import
org.skywalking.apm.collector.queue.QueueModule
;
import
org.skywalking.apm.collector.queue.service.QueueCreatorService
;
import
org.skywalking.apm.collector.remote.RemoteModule
;
import
org.skywalking.apm.collector.remote.service.Remote
Client
Service
;
import
org.skywalking.apm.collector.remote.service.Remote
Sender
Service
;
import
org.skywalking.apm.collector.storage.StorageModule
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.stream.timer.PersistenceTimer
;
...
...
@@ -51,7 +51,7 @@ public class StreamModuleProvider extends ModuleProvider {
PersistenceTimer
persistenceTimer
=
new
PersistenceTimer
();
try
{
QueueCreatorService
queueCreatorService
=
getManager
().
find
(
QueueModule
.
NAME
).
getService
(
QueueCreatorService
.
class
);
Remote
ClientService
remoteClientService
=
getManager
().
find
(
RemoteModule
.
NAME
).
getService
(
RemoteClient
Service
.
class
);
Remote
SenderService
remoteSenderService
=
getManager
().
find
(
RemoteModule
.
NAME
).
getService
(
RemoteSender
Service
.
class
);
DAOService
daoService
=
getManager
().
find
(
StorageModule
.
NAME
).
getService
(
DAOService
.
class
);
persistenceTimer
.
start
(
daoService
);
}
catch
(
ModuleNotFoundException
e
)
{
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml
浏览文件 @
24a03753
...
...
@@ -51,5 +51,10 @@
<artifactId>
collector-naming-define
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
collector-storage-define
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java
浏览文件 @
24a03753
...
...
@@ -31,10 +31,24 @@ import org.skywalking.apm.collector.jetty.manager.service.JettyManagerService;
import
org.skywalking.apm.collector.naming.NamingModule
;
import
org.skywalking.apm.collector.naming.service.NamingHandlerRegisterService
;
import
org.skywalking.apm.collector.server.Server
;
import
org.skywalking.apm.collector.storage.StorageModule
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.UIModule
;
import
org.skywalking.apm.collector.ui.jetty.handler.SegmentTopGetHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.SpanGetHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.TraceDagGetHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.TraceStackGetHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.application.ApplicationsGetHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.instancehealth.InstanceHealthGetHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.instancemetric.InstanceMetricGetOneTimeBucketHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.instancemetric.InstanceMetricGetRangeTimeBucketHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.instancemetric.InstanceOsInfoGetHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.naming.UIJettyNamingHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.naming.UIJettyNamingListener
;
import
org.skywalking.apm.collector.ui.jetty.handler.servicetree.EntryServiceGetHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.servicetree.ServiceTreeGetByIdHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.time.AllInstanceLastTimeGetHandler
;
import
org.skywalking.apm.collector.ui.jetty.handler.time.OneInstanceLastTimeGetHandler
;
/**
* @author peng-yongsheng
...
...
@@ -62,10 +76,6 @@ public class UIModuleJettyProvider extends ModuleProvider {
Integer
port
=
(
Integer
)
config
.
get
(
PORT
);
String
contextPath
=
config
.
getProperty
(
CONTEXT_PATH
);
try
{
JettyManagerService
managerService
=
getManager
().
find
(
JettyManagerModule
.
NAME
).
getService
(
JettyManagerService
.
class
);
Server
jettyServer
=
managerService
.
getOrCreateIfAbsent
(
host
,
port
,
contextPath
);
jettyServer
.
addHandler
(
new
ApplicationsGetHandler
());
ModuleRegisterService
moduleRegisterService
=
getManager
().
find
(
ClusterModule
.
NAME
).
getService
(
ModuleRegisterService
.
class
);
moduleRegisterService
.
register
(
UIModule
.
NAME
,
this
.
name
(),
new
UIModuleJettyRegistration
(
host
,
port
,
contextPath
));
...
...
@@ -75,6 +85,12 @@ public class UIModuleJettyProvider extends ModuleProvider {
NamingHandlerRegisterService
namingHandlerRegisterService
=
getManager
().
find
(
NamingModule
.
NAME
).
getService
(
NamingHandlerRegisterService
.
class
);
namingHandlerRegisterService
.
register
(
new
UIJettyNamingHandler
(
namingListener
));
DAOService
daoService
=
getManager
().
find
(
StorageModule
.
NAME
).
getService
(
DAOService
.
class
);
JettyManagerService
managerService
=
getManager
().
find
(
JettyManagerModule
.
NAME
).
getService
(
JettyManagerService
.
class
);
Server
jettyServer
=
managerService
.
getOrCreateIfAbsent
(
host
,
port
,
contextPath
);
addHandlers
(
daoService
,
jettyServer
);
}
catch
(
ModuleNotFoundException
e
)
{
throw
new
ServiceNotProvidedException
(
e
.
getMessage
());
}
...
...
@@ -87,4 +103,20 @@ public class UIModuleJettyProvider extends ModuleProvider {
@Override
public
String
[]
requiredModules
()
{
return
new
String
[]
{
ClusterModule
.
NAME
,
JettyManagerModule
.
NAME
,
NamingModule
.
NAME
};
}
private
void
addHandlers
(
DAOService
daoService
,
Server
jettyServer
)
{
jettyServer
.
addHandler
(
new
ApplicationsGetHandler
(
daoService
));
jettyServer
.
addHandler
(
new
InstanceHealthGetHandler
(
daoService
));
jettyServer
.
addHandler
(
new
InstanceMetricGetOneTimeBucketHandler
(
daoService
));
jettyServer
.
addHandler
(
new
InstanceMetricGetRangeTimeBucketHandler
(
daoService
));
jettyServer
.
addHandler
(
new
InstanceOsInfoGetHandler
(
daoService
));
jettyServer
.
addHandler
(
new
EntryServiceGetHandler
(
daoService
));
jettyServer
.
addHandler
(
new
ServiceTreeGetByIdHandler
(
daoService
));
jettyServer
.
addHandler
(
new
AllInstanceLastTimeGetHandler
(
daoService
));
jettyServer
.
addHandler
(
new
OneInstanceLastTimeGetHandler
(
daoService
));
jettyServer
.
addHandler
(
new
SegmentTopGetHandler
(
daoService
));
jettyServer
.
addHandler
(
new
SpanGetHandler
(
daoService
));
jettyServer
.
addHandler
(
new
TraceDagGetHandler
(
daoService
));
jettyServer
.
addHandler
(
new
TraceStackGetHandler
(
daoService
));
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/SegmentTopGetHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler
;
import
com.google.gson.JsonElement
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.SegmentTopService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
SegmentTopGetHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentTopGetHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/segment/top"
;
}
private
final
SegmentTopService
service
;
public
SegmentTopGetHandler
(
DAOService
daoService
)
{
this
.
service
=
new
SegmentTopService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
if
(!
req
.
getParameterMap
().
containsKey
(
"startTime"
)
||
!
req
.
getParameterMap
().
containsKey
(
"endTime"
)
||
!
req
.
getParameterMap
().
containsKey
(
"from"
)
||
!
req
.
getParameterMap
().
containsKey
(
"limit"
))
{
throw
new
ArgumentsParseException
(
"the request parameter must contains startTime, endTime, from, limit"
);
}
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"startTime: {}, endTime: {}, from: {}"
,
req
.
getParameter
(
"startTime"
),
req
.
getParameter
(
"endTime"
),
req
.
getParameter
(
"from"
));
}
long
startTime
;
try
{
startTime
=
Long
.
valueOf
(
req
.
getParameter
(
"startTime"
));
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"the request parameter startTime must be a long"
);
}
long
endTime
;
try
{
endTime
=
Long
.
valueOf
(
req
.
getParameter
(
"endTime"
));
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"the request parameter endTime must be a long"
);
}
int
from
;
try
{
from
=
Integer
.
valueOf
(
req
.
getParameter
(
"from"
));
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"the request parameter from must be an integer"
);
}
int
limit
;
try
{
limit
=
Integer
.
valueOf
(
req
.
getParameter
(
"limit"
));
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"the request parameter from must be an integer"
);
}
int
minCost
=
-
1
;
if
(
req
.
getParameterMap
().
containsKey
(
"minCost"
))
{
minCost
=
Integer
.
valueOf
(
req
.
getParameter
(
"minCost"
));
}
int
maxCost
=
-
1
;
if
(
req
.
getParameterMap
().
containsKey
(
"maxCost"
))
{
maxCost
=
Integer
.
valueOf
(
req
.
getParameter
(
"maxCost"
));
}
String
globalTraceId
=
null
;
if
(
req
.
getParameterMap
().
containsKey
(
"globalTraceId"
))
{
globalTraceId
=
req
.
getParameter
(
"globalTraceId"
);
}
String
operationName
=
null
;
if
(
req
.
getParameterMap
().
containsKey
(
"operationName"
))
{
operationName
=
req
.
getParameter
(
"operationName"
);
}
int
applicationId
;
try
{
applicationId
=
Integer
.
valueOf
(
req
.
getParameter
(
"applicationId"
));
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"the request parameter applicationId must be a int"
);
}
ISegmentCostUIDAO
.
Error
error
;
String
errorStr
=
req
.
getParameter
(
"error"
);
if
(
StringUtils
.
isNotEmpty
(
errorStr
))
{
if
(
"true"
.
equals
(
errorStr
))
{
error
=
ISegmentCostUIDAO
.
Error
.
True
;
}
else
if
(
"false"
.
equals
(
errorStr
))
{
error
=
ISegmentCostUIDAO
.
Error
.
False
;
}
else
{
error
=
ISegmentCostUIDAO
.
Error
.
All
;
}
}
else
{
error
=
ISegmentCostUIDAO
.
Error
.
All
;
}
ISegmentCostUIDAO
.
Sort
sort
=
ISegmentCostUIDAO
.
Sort
.
Cost
;
if
(
req
.
getParameterMap
().
containsKey
(
"sort"
))
{
String
sortStr
=
req
.
getParameter
(
"sort"
);
if
(
sortStr
.
toLowerCase
().
equals
(
ISegmentCostUIDAO
.
Sort
.
Time
.
name
().
toLowerCase
()))
{
sort
=
ISegmentCostUIDAO
.
Sort
.
Time
;
}
}
return
service
.
loadTop
(
startTime
,
endTime
,
minCost
,
maxCost
,
operationName
,
globalTraceId
,
error
,
applicationId
,
limit
,
from
,
sort
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/SpanGetHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler
;
import
com.google.gson.JsonElement
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.SpanService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
SpanGetHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SpanGetHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/span/spanId"
;
}
private
final
SpanService
service
;
public
SpanGetHandler
(
DAOService
daoService
)
{
this
.
service
=
new
SpanService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
String
segmentId
=
req
.
getParameter
(
"segmentId"
);
String
spanIdStr
=
req
.
getParameter
(
"spanId"
);
logger
.
debug
(
"segmentSpanId: {}, spanIdStr: {}"
,
segmentId
,
spanIdStr
);
int
spanId
;
try
{
spanId
=
Integer
.
parseInt
(
spanIdStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"span id must be integer"
);
}
return
service
.
load
(
segmentId
,
spanId
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/TraceDagGetHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler
;
import
com.google.gson.JsonElement
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.TraceDagService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
TraceDagGetHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TraceDagGetHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/traceDag"
;
}
private
final
TraceDagService
service
;
public
TraceDagGetHandler
(
DAOService
daoService
)
{
this
.
service
=
new
TraceDagService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
if
(!
req
.
getParameterMap
().
containsKey
(
"startTime"
)
||
!
req
.
getParameterMap
().
containsKey
(
"endTime"
))
{
throw
new
ArgumentsParseException
(
"the request parameter must contains startTime, endTime"
);
}
String
startTimeStr
=
req
.
getParameter
(
"startTime"
);
String
endTimeStr
=
req
.
getParameter
(
"endTime"
);
logger
.
debug
(
"startTime: {}, endTimeStr: {}"
,
startTimeStr
,
endTimeStr
);
long
startTime
;
try
{
startTime
=
Long
.
valueOf
(
req
.
getParameter
(
"startTime"
));
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"the request parameter startTime must be a long"
);
}
long
endTime
;
try
{
endTime
=
Long
.
valueOf
(
req
.
getParameter
(
"endTime"
));
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"the request parameter endTime must be a long"
);
}
return
service
.
load
(
startTime
,
endTime
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/TraceStackGetHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler
;
import
com.google.gson.JsonElement
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.TraceStackService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
TraceStackGetHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TraceStackGetHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/traceStack/globalTraceId"
;
}
private
final
TraceStackService
service
;
public
TraceStackGetHandler
(
DAOService
daoService
)
{
this
.
service
=
new
TraceStackService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
String
globalTraceId
=
req
.
getParameter
(
"globalTraceId"
);
logger
.
debug
(
"globalTraceId: {}"
,
globalTraceId
);
return
service
.
load
(
globalTraceId
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java
浏览文件 @
24a03753
...
...
@@ -19,10 +19,11 @@
package
org.skywalking.apm.collector.ui.jetty.handler.application
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.ApplicationService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -37,7 +38,11 @@ public class ApplicationsGetHandler extends JettyHandler {
return
"/applications"
;
}
// private ApplicationService service = new ApplicationService();
private
final
ApplicationService
applicationService
;
public
ApplicationsGetHandler
(
DAOService
daoService
)
{
this
.
applicationService
=
new
ApplicationService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
if
(!
req
.
getParameterMap
().
containsKey
(
"startTime"
)
||
!
req
.
getParameterMap
().
containsKey
(
"endTime"
))
{
...
...
@@ -62,11 +67,7 @@ public class ApplicationsGetHandler extends JettyHandler {
throw
new
ArgumentsParseException
(
"end time must be long"
);
}
// return service.getApplications(startTime, endTime);
JsonObject
result
=
new
JsonObject
();
result
.
addProperty
(
"result"
,
"Yes"
);
return
result
;
return
applicationService
.
getApplications
(
startTime
,
endTime
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
...
...
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler.instancehealth
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.InstanceHealthService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceHealthGetHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceHealthGetHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/instance/health/applicationId"
;
}
private
final
InstanceHealthService
service
;
public
InstanceHealthGetHandler
(
DAOService
daoService
)
{
this
.
service
=
new
InstanceHealthService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
String
timeBucketStr
=
req
.
getParameter
(
"timeBucket"
);
String
[]
applicationIdsStr
=
req
.
getParameterValues
(
"applicationIds"
);
logger
.
debug
(
"instance health get timeBucket: {}, applicationIdsStr: {}"
,
timeBucketStr
,
applicationIdsStr
);
long
timeBucket
;
try
{
timeBucket
=
Long
.
parseLong
(
timeBucketStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"timestamp must be long"
);
}
int
[]
applicationIds
=
new
int
[
applicationIdsStr
.
length
];
for
(
int
i
=
0
;
i
<
applicationIdsStr
.
length
;
i
++)
{
try
{
applicationIds
[
i
]
=
Integer
.
parseInt
(
applicationIdsStr
[
i
]);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"application id must be integer"
);
}
}
JsonObject
response
=
new
JsonObject
();
response
.
addProperty
(
"timeBucket"
,
timeBucket
);
JsonArray
appInstances
=
new
JsonArray
();
response
.
add
(
"appInstances"
,
appInstances
);
for
(
int
applicationId
:
applicationIds
)
{
appInstances
.
add
(
service
.
getInstances
(
timeBucket
,
applicationId
));
}
return
response
;
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler.instancemetric
;
import
com.google.gson.JsonElement
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.InstanceJVMService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceMetricGetOneTimeBucketHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceMetricGetOneTimeBucketHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/instance/jvm/instanceId/oneBucket"
;
}
private
final
InstanceJVMService
service
;
public
InstanceMetricGetOneTimeBucketHandler
(
DAOService
daoService
)
{
this
.
service
=
new
InstanceJVMService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
String
timeBucketStr
=
req
.
getParameter
(
"timeBucket"
);
String
instanceIdStr
=
req
.
getParameter
(
"instanceId"
);
String
[]
metricTypes
=
req
.
getParameterValues
(
"metricTypes"
);
logger
.
debug
(
"instance jvm metric get timeBucket: {}, instance id: {}, metric types: {}"
,
timeBucketStr
,
instanceIdStr
,
metricTypes
);
long
timeBucket
;
try
{
timeBucket
=
Long
.
parseLong
(
timeBucketStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"timeBucket must be long"
);
}
int
instanceId
;
try
{
instanceId
=
Integer
.
parseInt
(
instanceIdStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"instance id must be integer"
);
}
if
(
metricTypes
.
length
==
0
)
{
throw
new
ArgumentsParseException
(
"at least one metric type"
);
}
Set
<
String
>
metricTypeSet
=
new
LinkedHashSet
<>();
for
(
String
metricType
:
metricTypes
)
{
metricTypeSet
.
add
(
metricType
);
}
return
service
.
getInstanceJvmMetric
(
instanceId
,
metricTypeSet
,
timeBucket
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler.instancemetric
;
import
com.google.gson.JsonElement
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.InstanceJVMService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceMetricGetRangeTimeBucketHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceMetricGetRangeTimeBucketHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/instance/jvm/instanceId/rangeBucket"
;
}
private
final
InstanceJVMService
service
;
public
InstanceMetricGetRangeTimeBucketHandler
(
DAOService
daoService
)
{
this
.
service
=
new
InstanceJVMService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
String
startTimeBucketStr
=
req
.
getParameter
(
"startTimeBucket"
);
String
endTimeBucketStr
=
req
.
getParameter
(
"endTimeBucket"
);
String
instanceIdStr
=
req
.
getParameter
(
"instanceId"
);
String
[]
metricTypes
=
req
.
getParameterValues
(
"metricTypes"
);
logger
.
debug
(
"instance jvm metric get start timeBucket: {}, end timeBucket:{} , instance id: {}, metric types: {}"
,
startTimeBucketStr
,
endTimeBucketStr
,
instanceIdStr
,
metricTypes
);
long
startTimeBucket
;
try
{
startTimeBucket
=
Long
.
parseLong
(
startTimeBucketStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"start timeBucket must be long"
);
}
long
endTimeBucket
;
try
{
endTimeBucket
=
Long
.
parseLong
(
endTimeBucketStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"end timeBucket must be long"
);
}
int
instanceId
;
try
{
instanceId
=
Integer
.
parseInt
(
instanceIdStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"instance id must be integer"
);
}
if
(
metricTypes
.
length
==
0
)
{
throw
new
ArgumentsParseException
(
"at least one metric type"
);
}
Set
<
String
>
metricTypeSet
=
new
LinkedHashSet
<>();
for
(
String
metricType
:
metricTypes
)
{
metricTypeSet
.
add
(
metricType
);
}
return
service
.
getInstanceJvmMetrics
(
instanceId
,
metricTypeSet
,
startTimeBucket
,
endTimeBucket
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler.instancemetric
;
import
com.google.gson.JsonElement
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.InstanceJVMService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceOsInfoGetHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceOsInfoGetHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/instance/os/instanceId"
;
}
private
final
InstanceJVMService
service
;
public
InstanceOsInfoGetHandler
(
DAOService
daoService
)
{
this
.
service
=
new
InstanceJVMService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
String
instanceIdStr
=
req
.
getParameter
(
"instanceId"
);
logger
.
debug
(
"instance os info get, instance id: {}"
,
instanceIdStr
);
int
instanceId
;
try
{
instanceId
=
Integer
.
parseInt
(
instanceIdStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"instance id must be integer"
);
}
return
service
.
getInstanceOsInfo
(
instanceId
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/servicetree/EntryServiceGetHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler.servicetree
;
import
com.google.gson.JsonElement
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.ServiceTreeService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
EntryServiceGetHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EntryServiceGetHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/service/entry"
;
}
private
final
ServiceTreeService
service
;
public
EntryServiceGetHandler
(
DAOService
daoService
)
{
this
.
service
=
new
ServiceTreeService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
if
(!
req
.
getParameterMap
().
containsKey
(
"applicationId"
)
||
!
req
.
getParameterMap
().
containsKey
(
"entryServiceName"
)
||
!
req
.
getParameterMap
().
containsKey
(
"startTime"
)
||
!
req
.
getParameterMap
().
containsKey
(
"endTime"
)
||
!
req
.
getParameterMap
().
containsKey
(
"from"
)
||
!
req
.
getParameterMap
().
containsKey
(
"size"
))
{
throw
new
ArgumentsParseException
(
"must contains parameters: applicationId, entryServiceName, startTime, endTime, from, size"
);
}
String
applicationIdStr
=
req
.
getParameter
(
"applicationId"
);
String
entryServiceName
=
req
.
getParameter
(
"entryServiceName"
);
String
startTimeStr
=
req
.
getParameter
(
"startTime"
);
String
endTimeStr
=
req
.
getParameter
(
"endTime"
);
String
fromStr
=
req
.
getParameter
(
"from"
);
String
sizeStr
=
req
.
getParameter
(
"size"
);
logger
.
debug
(
"service entry get applicationId: {}, entryServiceName: {}, startTime: {}, endTime: {}, from: {}, size: {}"
,
applicationIdStr
,
entryServiceName
,
startTimeStr
,
endTimeStr
,
fromStr
,
sizeStr
);
int
applicationId
;
try
{
applicationId
=
Integer
.
parseInt
(
applicationIdStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"application id must be integer"
);
}
long
startTime
;
try
{
startTime
=
Long
.
parseLong
(
startTimeStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"start time must be long"
);
}
long
endTime
;
try
{
endTime
=
Long
.
parseLong
(
endTimeStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"end time must be long"
);
}
int
from
;
try
{
from
=
Integer
.
parseInt
(
fromStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"from must be integer"
);
}
int
size
;
try
{
size
=
Integer
.
parseInt
(
sizeStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"size must be integer"
);
}
return
service
.
loadEntryService
(
applicationId
,
entryServiceName
,
startTime
,
endTime
,
from
,
size
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler.servicetree
;
import
com.google.gson.JsonElement
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.ServiceTreeService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ServiceTreeGetByIdHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceTreeGetByIdHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/service/tree/entryServiceId"
;
}
private
final
ServiceTreeService
service
;
public
ServiceTreeGetByIdHandler
(
DAOService
daoService
)
{
this
.
service
=
new
ServiceTreeService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
if
(!
req
.
getParameterMap
().
containsKey
(
"entryServiceId"
)
||
!
req
.
getParameterMap
().
containsKey
(
"startTime"
)
||
!
req
.
getParameterMap
().
containsKey
(
"endTime"
))
{
throw
new
ArgumentsParseException
(
"must contains parameters: entryServiceId, startTime, endTime"
);
}
String
entryServiceIdStr
=
req
.
getParameter
(
"entryServiceId"
);
String
startTimeStr
=
req
.
getParameter
(
"startTime"
);
String
endTimeStr
=
req
.
getParameter
(
"endTime"
);
logger
.
debug
(
"service entry get entryServiceId: {}, startTime: {}, endTime: {}"
,
entryServiceIdStr
,
startTimeStr
,
endTimeStr
);
int
entryServiceId
;
try
{
entryServiceId
=
Integer
.
parseInt
(
entryServiceIdStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"entry service id must be integer"
);
}
long
startTime
;
try
{
startTime
=
Long
.
parseLong
(
startTimeStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"start time must be long"
);
}
long
endTime
;
try
{
endTime
=
Long
.
parseLong
(
endTimeStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"end time must be long"
);
}
return
service
.
loadServiceTree
(
entryServiceId
,
startTime
,
endTime
);
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/time/AllInstanceLastTimeGetHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler.time
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
java.util.Calendar
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.TimeSynchronousService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
AllInstanceLastTimeGetHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AllInstanceLastTimeGetHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/time/allInstance"
;
}
private
final
TimeSynchronousService
service
;
public
AllInstanceLastTimeGetHandler
(
DAOService
daoService
)
{
this
.
service
=
new
TimeSynchronousService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
Long
timeBucket
=
service
.
allInstanceLastTime
();
logger
.
debug
(
"all instance last time: {}"
,
timeBucket
);
if
(
timeBucket
==
0
)
{
timeBucket
=
TimeBucketUtils
.
INSTANCE
.
getSecondTimeBucket
(
System
.
currentTimeMillis
());
}
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTimeInMillis
(
TimeBucketUtils
.
INSTANCE
.
changeTimeBucket2TimeStamp
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
));
calendar
.
add
(
Calendar
.
SECOND
,
-
5
);
timeBucket
=
calendar
.
getTimeInMillis
();
JsonObject
timeJson
=
new
JsonObject
();
timeJson
.
addProperty
(
"timeBucket"
,
TimeBucketUtils
.
INSTANCE
.
getSecondTimeBucket
(
timeBucket
));
return
timeJson
;
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/jetty/handler/time/OneInstanceLastTimeGetHandler.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.jetty.handler.time
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
javax.servlet.http.HttpServletRequest
;
import
org.skywalking.apm.collector.server.jetty.ArgumentsParseException
;
import
org.skywalking.apm.collector.server.jetty.JettyHandler
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.ui.service.TimeSynchronousService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
OneInstanceLastTimeGetHandler
extends
JettyHandler
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OneInstanceLastTimeGetHandler
.
class
);
@Override
public
String
pathSpec
()
{
return
"/time/oneInstance"
;
}
private
final
TimeSynchronousService
service
;
public
OneInstanceLastTimeGetHandler
(
DAOService
daoService
)
{
this
.
service
=
new
TimeSynchronousService
(
daoService
);
}
@Override
protected
JsonElement
doGet
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
String
instanceIdStr
=
req
.
getParameter
(
"instanceId"
);
logger
.
debug
(
"instanceId: {}"
,
instanceIdStr
);
int
instanceId
;
try
{
instanceId
=
Integer
.
parseInt
(
instanceIdStr
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ArgumentsParseException
(
"application instance id must be integer"
);
}
Long
time
=
service
.
instanceLastTime
(
instanceId
);
logger
.
debug
(
"application instance id: {}, instance last time: {}"
,
instanceId
,
time
);
JsonObject
timeJson
=
new
JsonObject
();
timeJson
.
addProperty
(
"timeBucket"
,
time
);
return
timeJson
;
}
@Override
protected
JsonElement
doPost
(
HttpServletRequest
req
)
throws
ArgumentsParseException
{
throw
new
UnsupportedOperationException
();
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/ApplicationService.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.service
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
org.skywalking.apm.collector.cache.ApplicationCache
;
import
org.skywalking.apm.collector.storage.dao.IInstanceUIDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
/**
* @author peng-yongsheng
*/
public
class
ApplicationService
{
private
final
DAOService
daoService
;
public
ApplicationService
(
DAOService
daoService
)
{
this
.
daoService
=
daoService
;
}
public
JsonArray
getApplications
(
long
startTime
,
long
endTime
)
{
IInstanceUIDAO
instanceDAO
=
(
IInstanceUIDAO
)
daoService
.
get
(
IInstanceUIDAO
.
class
);
JsonArray
applications
=
instanceDAO
.
getApplications
(
startTime
,
endTime
);
applications
.
forEach
(
jsonElement
->
{
JsonObject
application
=
jsonElement
.
getAsJsonObject
();
int
applicationId
=
application
.
get
(
"applicationId"
).
getAsInt
();
String
applicationCode
=
ApplicationCache
.
get
(
applicationId
);
application
.
addProperty
(
"applicationCode"
,
applicationCode
);
});
return
applications
;
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/InstanceHealthService.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.service
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
java.util.List
;
import
org.skywalking.apm.collector.cache.ApplicationCache
;
import
org.skywalking.apm.collector.core.util.TimeBucketUtils
;
import
org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO
;
import
org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO
;
import
org.skywalking.apm.collector.storage.dao.IInstanceUIDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.skywalking.apm.collector.storage.table.register.Instance
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceHealthService
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceHealthService
.
class
);
private
final
DAOService
daoService
;
public
InstanceHealthService
(
DAOService
daoService
)
{
this
.
daoService
=
daoService
;
}
public
JsonObject
getInstances
(
long
timeBucket
,
int
applicationId
)
{
JsonObject
response
=
new
JsonObject
();
long
[]
timeBuckets
=
TimeBucketUtils
.
INSTANCE
.
getFiveSecondTimeBuckets
(
timeBucket
);
long
halfHourBeforeTimeBucket
=
TimeBucketUtils
.
INSTANCE
.
addSecondForSecondTimeBucket
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
,
-
60
*
30
);
IInstanceUIDAO
instanceDAO
=
(
IInstanceUIDAO
)
daoService
.
get
(
IInstanceUIDAO
.
class
);
List
<
Instance
>
instanceList
=
instanceDAO
.
getInstances
(
applicationId
,
halfHourBeforeTimeBucket
);
JsonArray
instances
=
new
JsonArray
();
response
.
add
(
"instances"
,
instances
);
instanceList
.
forEach
(
instance
->
{
response
.
addProperty
(
"applicationCode"
,
ApplicationCache
.
get
(
applicationId
));
response
.
addProperty
(
"applicationId"
,
applicationId
);
IInstPerformanceUIDAO
instPerformanceDAO
=
(
IInstPerformanceUIDAO
)
daoService
.
get
(
IInstPerformanceUIDAO
.
class
);
IInstPerformanceUIDAO
.
InstPerformance
performance
=
instPerformanceDAO
.
get
(
timeBuckets
,
instance
.
getInstanceId
());
IGCMetricUIDAO
gcMetricDAO
=
(
IGCMetricUIDAO
)
daoService
.
get
(
IGCMetricUIDAO
.
class
);
JsonObject
instanceJson
=
new
JsonObject
();
instanceJson
.
addProperty
(
"id"
,
instance
.
getInstanceId
());
if
(
performance
!=
null
)
{
instanceJson
.
addProperty
(
"tps"
,
performance
.
getCalls
());
}
else
{
instanceJson
.
addProperty
(
"tps"
,
0
);
}
int
avg
=
0
;
if
(
performance
!=
null
&&
performance
.
getCalls
()
!=
0
)
{
avg
=
(
int
)(
performance
.
getCostTotal
()
/
performance
.
getCalls
());
}
instanceJson
.
addProperty
(
"avg"
,
avg
);
if
(
avg
>
5000
)
{
instanceJson
.
addProperty
(
"healthLevel"
,
0
);
}
else
if
(
avg
>
3000
&&
avg
<=
5000
)
{
instanceJson
.
addProperty
(
"healthLevel"
,
1
);
}
else
if
(
avg
>
1000
&&
avg
<=
3000
)
{
instanceJson
.
addProperty
(
"healthLevel"
,
2
);
}
else
{
instanceJson
.
addProperty
(
"healthLevel"
,
3
);
}
long
heartBeatTime
=
TimeBucketUtils
.
INSTANCE
.
changeTimeBucket2TimeStamp
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
instance
.
getHeartBeatTime
());
long
currentTime
=
TimeBucketUtils
.
INSTANCE
.
changeTimeBucket2TimeStamp
(
TimeBucketUtils
.
TimeBucketType
.
SECOND
.
name
(),
timeBucket
);
if
(
currentTime
-
heartBeatTime
<
1000
*
60
*
2
)
{
instanceJson
.
addProperty
(
"status"
,
0
);
}
else
{
instanceJson
.
addProperty
(
"status"
,
1
);
}
IGCMetricUIDAO
.
GCCount
gcCount
=
gcMetricDAO
.
getGCCount
(
timeBuckets
,
instance
.
getInstanceId
());
instanceJson
.
addProperty
(
"ygc"
,
gcCount
.
getYoung
());
instanceJson
.
addProperty
(
"ogc"
,
gcCount
.
getOld
());
instances
.
add
(
instanceJson
);
});
return
response
;
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/InstanceJVMService.java
0 → 100644
浏览文件 @
24a03753
此差异已折叠。
点击以展开。
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/SegmentTopService.java
0 → 100644
浏览文件 @
24a03753
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.collector.ui.service
;
import
com.google.gson.JsonObject
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.collector.core.util.StringUtils
;
import
org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO
;
import
org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO
;
import
org.skywalking.apm.collector.storage.service.DAOService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
SegmentTopService
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentTopService
.
class
);
private
final
DAOService
daoService
;
public
SegmentTopService
(
DAOService
daoService
)
{
this
.
daoService
=
daoService
;
}
public
JsonObject
loadTop
(
long
startTime
,
long
endTime
,
long
minCost
,
long
maxCost
,
String
operationName
,
String
globalTraceId
,
ISegmentCostUIDAO
.
Error
error
,
int
applicationId
,
int
limit
,
int
from
,
ISegmentCostUIDAO
.
Sort
sort
)
{
logger
.
debug
(
"startTime: {}, endTime: {}, minCost: {}, maxCost: {}, operationName: {}, globalTraceId: {}, error: {}, applicationId: {}, limit: {}, from: {}"
,
startTime
,
endTime
,
minCost
,
maxCost
,
operationName
,
globalTraceId
,
error
,
applicationId
,
limit
,
from
);
List
<
String
>
segmentIds
=
new
LinkedList
<>();
if
(
StringUtils
.
isNotEmpty
(
globalTraceId
))
{
IGlobalTraceUIDAO
globalTraceDAO
=
(
IGlobalTraceUIDAO
)
daoService
.
get
(
IGlobalTraceUIDAO
.
class
);
segmentIds
=
globalTraceDAO
.
getSegmentIds
(
globalTraceId
);
}
ISegmentCostUIDAO
segmentCostDAO
=
(
ISegmentCostUIDAO
)
daoService
.
get
(
ISegmentCostUIDAO
.
class
);
return
segmentCostDAO
.
loadTop
(
startTime
,
endTime
,
minCost
,
maxCost
,
operationName
,
error
,
applicationId
,
segmentIds
,
limit
,
from
,
sort
);
}
}
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/ServiceTreeService.java
0 → 100644
浏览文件 @
24a03753
此差异已折叠。
点击以展开。
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/SpanService.java
0 → 100644
浏览文件 @
24a03753
此差异已折叠。
点击以展开。
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TimeSynchronousService.java
0 → 100644
浏览文件 @
24a03753
此差异已折叠。
点击以展开。
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java
0 → 100644
浏览文件 @
24a03753
此差异已折叠。
点击以展开。
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceDagService.java
0 → 100644
浏览文件 @
24a03753
此差异已折叠。
点击以展开。
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/skywalking/apm/collector/ui/service/TraceStackService.java
0 → 100644
浏览文件 @
24a03753
此差异已折叠。
点击以展开。
apm-collector/apm-collector-ui/pom.xml
浏览文件 @
24a03753
...
...
@@ -22,5 +22,10 @@
<artifactId>
apm-collector-core
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
apm-collector-cache
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录