Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
7abec320
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7abec320
编写于
11月 01, 2017
作者:
P
peng-yongsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
All Daos are add in.
上级
4e524de1
变更
46
隐藏空白更改
内联
并排
Showing
46 changed file
with
2551 addition
and
15 deletion
+2551
-15
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
+28
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGlobalTraceDAO.java
...skywalking/apm/collector/storage/dao/IGlobalTraceDAO.java
+25
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstPerformanceDAO.java
...alking/apm/collector/storage/dao/IInstPerformanceDAO.java
+25
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceCacheDAO.java
...ywalking/apm/collector/storage/dao/IInstanceCacheDAO.java
+26
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceDAO.java
...rg/skywalking/apm/collector/storage/dao/IInstanceDAO.java
+36
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeComponentDAO.java
...ywalking/apm/collector/storage/dao/INodeComponentDAO.java
+25
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeReferenceDAO.java
...ywalking/apm/collector/storage/dao/INodeReferenceDAO.java
+25
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ISegmentCostDAO.java
...skywalking/apm/collector/storage/dao/ISegmentCostDAO.java
+25
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ISegmentDAO.java
...org/skywalking/apm/collector/storage/dao/ISegmentDAO.java
+25
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceEntryDAO.java
...kywalking/apm/collector/storage/dao/IServiceEntryDAO.java
+25
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceNameCacheDAO.java
...lking/apm/collector/storage/dao/IServiceNameCacheDAO.java
+28
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceNameDAO.java
...skywalking/apm/collector/storage/dao/IServiceNameDAO.java
+32
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceReferenceDAO.java
...lking/apm/collector/storage/dao/IServiceReferenceDAO.java
+25
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ApplicationDataDefine.java
...llector/storage/table/register/ApplicationDataDefine.java
+17
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/InstanceDataDefine.java
.../collector/storage/table/register/InstanceDataDefine.java
+33
-0
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ServiceNameDataDefine.java
...llector/storage/table/register/ServiceNameDataDefine.java
+21
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEsCacheDAO.java
...g/apm/collector/storage/es/dao/ApplicationEsCacheDAO.java
+71
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEsDAO.java
...alking/apm/collector/storage/es/dao/ApplicationEsDAO.java
+9
-5
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
+58
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstPerformanceEsDAO.java
...ng/apm/collector/storage/es/dao/InstPerformanceEsDAO.java
+80
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceEsCacheDAO.java
...king/apm/collector/storage/es/dao/InstanceEsCacheDAO.java
+43
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceEsDAO.java
...kywalking/apm/collector/storage/es/dao/InstanceEsDAO.java
+113
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeComponentEsDAO.java
...king/apm/collector/storage/es/dao/NodeComponentEsDAO.java
+75
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeReferenceEsDAO.java
...king/apm/collector/storage/es/dao/NodeReferenceEsDAO.java
+90
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/SegmentCostEsDAO.java
...alking/apm/collector/storage/es/dao/SegmentCostEsDAO.java
+63
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/SegmentEsDAO.java
...skywalking/apm/collector/storage/es/dao/SegmentEsDAO.java
+56
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceEntryEsDAO.java
...lking/apm/collector/storage/es/dao/ServiceEntryEsDAO.java
+74
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceNameEsCacheDAO.java
...g/apm/collector/storage/es/dao/ServiceNameEsCacheDAO.java
+69
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceNameEsDAO.java
...alking/apm/collector/storage/es/dao/ServiceNameEsDAO.java
+65
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsDAO.java
...g/apm/collector/storage/es/dao/ServiceReferenceEsDAO.java
+106
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/es_dao.define
...rovider/src/main/resources/META-INF/defines/es_dao.define
+15
-1
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2CacheDAO.java
...g/apm/collector/storage/h2/dao/ApplicationH2CacheDAO.java
+72
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2DAO.java
...alking/apm/collector/storage/h2/dao/ApplicationH2DAO.java
+13
-8
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
+63
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstPerformanceH2DAO.java
...ng/apm/collector/storage/h2/dao/InstPerformanceH2DAO.java
+99
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2CacheDAO.java
...king/apm/collector/storage/h2/dao/InstanceH2CacheDAO.java
+55
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2DAO.java
...kywalking/apm/collector/storage/h2/dao/InstanceH2DAO.java
+107
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeComponentH2DAO.java
...king/apm/collector/storage/h2/dao/NodeComponentH2DAO.java
+102
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeReferenceH2DAO.java
...king/apm/collector/storage/h2/dao/NodeReferenceH2DAO.java
+114
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/SegmentCostH2DAO.java
...alking/apm/collector/storage/h2/dao/SegmentCostH2DAO.java
+68
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/SegmentH2DAO.java
...skywalking/apm/collector/storage/h2/dao/SegmentH2DAO.java
+60
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2DAO.java
...lking/apm/collector/storage/h2/dao/ServiceEntryH2DAO.java
+98
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ServiceNameH2CacheDAO.java
...g/apm/collector/storage/h2/dao/ServiceNameH2CacheDAO.java
+74
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ServiceNameH2DAO.java
...alking/apm/collector/storage/h2/dao/ServiceNameH2DAO.java
+73
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ServiceReferenceH2DAO.java
...g/apm/collector/storage/h2/dao/ServiceReferenceH2DAO.java
+130
-0
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/h2_dao.define
...rovider/src/main/resources/META-INF/defines/h2_dao.define
+15
-1
未找到文件。
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IApplicationCacheDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
IApplicationCacheDAO
{
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/IGlobalTraceDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
IGlobalTraceDAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstPerformanceDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
IInstPerformanceDAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceCacheDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
IInstanceCacheDAO
{
int
getApplicationId
(
int
applicationInstanceId
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.core.data.Data
;
/**
* @author peng-yongsheng
*/
public
interface
IInstanceDAO
{
int
getInstanceId
(
int
applicationId
,
String
agentUUID
);
int
getMaxInstanceId
();
int
getMinInstanceId
();
void
save
(
Data
data
);
void
updateHeartbeatTime
(
int
instanceId
,
long
heartbeatTime
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeComponentDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
INodeComponentDAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/INodeReferenceDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
INodeReferenceDAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ISegmentCostDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
ISegmentCostDAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ISegmentDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
ISegmentDAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceEntryDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
IServiceEntryDAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceNameCacheDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
IServiceNameCacheDAO
{
String
getServiceName
(
int
serviceId
);
int
getServiceId
(
int
applicationId
,
String
serviceName
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceNameDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.core.data.Data
;
/**
* @author peng-yongsheng
*/
public
interface
IServiceNameDAO
{
int
getMaxServiceId
();
int
getMinServiceId
();
void
save
(
Data
data
);
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IServiceReferenceDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
;
/**
* @author peng-yongsheng
*/
public
interface
IServiceReferenceDAO
{
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ApplicationDataDefine.java
浏览文件 @
7abec320
...
...
@@ -18,6 +18,7 @@
package
org.skywalking.apm.collector.storage.table.register
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.define.Attribute
;
import
org.skywalking.apm.collector.storage.base.define.AttributeType
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
...
...
@@ -38,4 +39,20 @@ public class ApplicationDataDefine extends DataDefine {
addAttribute
(
1
,
new
Attribute
(
ApplicationTable
.
COLUMN_APPLICATION_CODE
,
AttributeType
.
STRING
,
new
CoverOperation
()));
addAttribute
(
2
,
new
Attribute
(
ApplicationTable
.
COLUMN_APPLICATION_ID
,
AttributeType
.
INTEGER
,
new
CoverOperation
()));
}
public
enum
Application
{
INSTANCE
;
public
String
getId
(
Data
data
)
{
return
data
.
getDataString
(
0
);
}
public
String
getApplicationCode
(
Data
data
)
{
return
data
.
getDataString
(
1
);
}
public
int
getApplicationId
(
Data
data
)
{
return
data
.
getDataInteger
(
1
);
}
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/InstanceDataDefine.java
浏览文件 @
7abec320
...
...
@@ -18,6 +18,7 @@
package
org.skywalking.apm.collector.storage.table.register
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.define.Attribute
;
import
org.skywalking.apm.collector.storage.base.define.AttributeType
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
...
...
@@ -42,4 +43,36 @@ public class InstanceDataDefine extends DataDefine {
addAttribute
(
5
,
new
Attribute
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
AttributeType
.
LONG
,
new
CoverOperation
()));
addAttribute
(
6
,
new
Attribute
(
InstanceTable
.
COLUMN_OS_INFO
,
AttributeType
.
STRING
,
new
CoverOperation
()));
}
public
enum
Instance
{
INSTANCE
;
public
String
getId
(
Data
data
)
{
return
data
.
getDataString
(
0
);
}
public
int
getApplicationId
(
Data
data
)
{
return
data
.
getDataInteger
(
0
);
}
public
String
getAgentUUID
(
Data
data
)
{
return
data
.
getDataString
(
1
);
}
public
long
getRegisterTime
(
Data
data
)
{
return
data
.
getDataLong
(
0
);
}
public
int
getInstanceId
(
Data
data
)
{
return
data
.
getDataInteger
(
1
);
}
public
long
getHeartBeatTime
(
Data
data
)
{
return
data
.
getDataLong
(
1
);
}
public
String
getOsInfo
(
Data
data
)
{
return
data
.
getDataString
(
2
);
}
}
}
apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/table/register/ServiceNameDataDefine.java
浏览文件 @
7abec320
...
...
@@ -18,6 +18,7 @@
package
org.skywalking.apm.collector.storage.table.register
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.define.Attribute
;
import
org.skywalking.apm.collector.storage.base.define.AttributeType
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
...
...
@@ -39,4 +40,24 @@ public class ServiceNameDataDefine extends DataDefine {
addAttribute
(
2
,
new
Attribute
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
,
AttributeType
.
INTEGER
,
new
CoverOperation
()));
addAttribute
(
3
,
new
Attribute
(
ServiceNameTable
.
COLUMN_SERVICE_ID
,
AttributeType
.
INTEGER
,
new
CoverOperation
()));
}
public
enum
ServiceName
{
INSTANCE
;
public
String
getId
(
Data
data
)
{
return
data
.
getDataString
(
0
);
}
public
String
getServiceName
(
Data
data
)
{
return
data
.
getDataString
(
1
);
}
public
int
getApplicationId
(
Data
data
)
{
return
data
.
getDataInteger
(
0
);
}
public
int
getServiceId
(
Data
data
)
{
return
data
.
getDataInteger
(
1
);
}
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEsCacheDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
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.QueryBuilders
;
import
org.elasticsearch.search.SearchHit
;
import
org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.register.ApplicationTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ApplicationEsCacheDAO
extends
EsDAO
implements
IApplicationCacheDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationEsCacheDAO
.
class
);
@Override
public
int
getApplicationId
(
String
applicationCode
)
{
ElasticSearchClient
client
=
getClient
();
SearchRequestBuilder
searchRequestBuilder
=
client
.
prepareSearch
(
ApplicationTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
"type"
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
QUERY_THEN_FETCH
);
searchRequestBuilder
.
setQuery
(
QueryBuilders
.
termQuery
(
ApplicationTable
.
COLUMN_APPLICATION_CODE
,
applicationCode
));
searchRequestBuilder
.
setSize
(
1
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
if
(
searchResponse
.
getHits
().
totalHits
>
0
)
{
SearchHit
searchHit
=
searchResponse
.
getHits
().
iterator
().
next
();
return
(
int
)
searchHit
.
getSource
().
get
(
ApplicationTable
.
COLUMN_APPLICATION_ID
);
}
return
0
;
}
@Override
public
String
getApplicationCode
(
int
applicationId
)
{
logger
.
debug
(
"get application code, applicationId: {}"
,
applicationId
);
ElasticSearchClient
client
=
getClient
();
GetRequestBuilder
getRequestBuilder
=
client
.
prepareGet
(
ApplicationTable
.
TABLE
,
String
.
valueOf
(
applicationId
));
GetResponse
getResponse
=
getRequestBuilder
.
get
();
if
(
getResponse
.
isExists
())
{
return
(
String
)
getResponse
.
getSource
().
get
(
ApplicationTable
.
COLUMN_APPLICATION_CODE
);
}
return
Const
.
EMPTY_STRING
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEsDAO.java
浏览文件 @
7abec320
...
...
@@ -26,6 +26,7 @@ import org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.dao.IApplicationDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.register.ApplicationDataDefine
;
import
org.skywalking.apm.collector.storage.table.register.ApplicationTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -46,13 +47,16 @@ public class ApplicationEsDAO extends EsDAO implements IApplicationDAO {
}
@Override
public
void
save
(
Data
data
)
{
logger
.
debug
(
"save application register info, application id: {}, application code: {}"
,
application
.
getApplicationId
(),
application
.
getApplicationCode
());
String
id
=
ApplicationDataDefine
.
Application
.
INSTANCE
.
getId
(
data
);
int
applicationId
=
ApplicationDataDefine
.
Application
.
INSTANCE
.
getApplicationId
(
data
);
String
applicationCode
=
ApplicationDataDefine
.
Application
.
INSTANCE
.
getApplicationCode
(
data
);
logger
.
debug
(
"save application register info, application id: {}, application code: {}"
,
applicationId
,
applicationCode
);
ElasticSearchClient
client
=
getClient
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ApplicationTable
.
COLUMN_APPLICATION_CODE
,
application
.
getApplicationCode
()
);
source
.
put
(
ApplicationTable
.
COLUMN_APPLICATION_ID
,
application
.
getApplicationId
()
);
source
.
put
(
ApplicationTable
.
COLUMN_APPLICATION_CODE
,
application
Code
);
source
.
put
(
ApplicationTable
.
COLUMN_APPLICATION_ID
,
application
Id
);
IndexResponse
response
=
client
.
prepareIndex
(
ApplicationTable
.
TABLE
,
application
.
getId
()
).
setSource
(
source
).
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
IMMEDIATE
).
get
();
logger
.
debug
(
"save application register info, application id: {}, application code: {}, status: {}"
,
application
.
getApplicationId
(),
application
.
getApplicationCode
()
,
response
.
status
().
name
());
IndexResponse
response
=
client
.
prepareIndex
(
ApplicationTable
.
TABLE
,
id
).
setSource
(
source
).
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
IMMEDIATE
).
get
();
logger
.
debug
(
"save application register info, application id: {}, application code: {}, status: {}"
,
application
Id
,
applicationCode
,
response
.
status
().
name
());
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GlobalTraceEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.core.UnexpectedException
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.IGlobalTraceDAO
;
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
GlobalTraceEsDAO
extends
EsDAO
implements
IGlobalTraceDAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalTraceEsDAO
.
class
);
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
throw
new
UnexpectedException
(
"There is no need to merge stream data with database data."
);
}
@Override
public
UpdateRequestBuilder
prepareBatchUpdate
(
Data
data
)
{
throw
new
UnexpectedException
(
"There is no need to merge stream data with database data."
);
}
@Override
public
IndexRequestBuilder
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
GlobalTraceTable
.
COLUMN_SEGMENT_ID
,
data
.
getDataString
(
1
));
source
.
put
(
GlobalTraceTable
.
COLUMN_GLOBAL_TRACE_ID
,
data
.
getDataString
(
2
));
source
.
put
(
GlobalTraceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
logger
.
debug
(
"global trace source: {}"
,
source
.
toString
());
return
getClient
().
prepareIndex
(
GlobalTraceTable
.
TABLE
,
data
.
getDataString
(
0
)).
setSource
(
source
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstPerformanceEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.IInstPerformanceDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.instance.InstPerformanceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstPerformanceEsDAO
extends
EsDAO
implements
IInstPerformanceDAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstPerformanceEsDAO
.
class
);
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
GetResponse
getResponse
=
getClient
().
prepareGet
(
InstPerformanceTable
.
TABLE
,
id
).
get
();
if
(
getResponse
.
isExists
())
{
logger
.
debug
(
"id: {} is exist"
,
id
);
Data
data
=
dataDefine
.
build
(
id
);
Map
<
String
,
Object
>
source
=
getResponse
.
getSource
();
data
.
setDataInteger
(
0
,
(
Integer
)
source
.
get
(
InstPerformanceTable
.
COLUMN_APPLICATION_ID
));
data
.
setDataInteger
(
1
,
(
Integer
)
source
.
get
(
InstPerformanceTable
.
COLUMN_INSTANCE_ID
));
data
.
setDataInteger
(
2
,
(
Integer
)
source
.
get
(
InstPerformanceTable
.
COLUMN_CALLS
));
data
.
setDataLong
(
0
,
((
Number
)
source
.
get
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
)).
longValue
());
data
.
setDataLong
(
1
,
((
Number
)
source
.
get
(
InstPerformanceTable
.
COLUMN_TIME_BUCKET
)).
longValue
());
return
data
;
}
else
{
return
null
;
}
}
@Override
public
IndexRequestBuilder
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
InstPerformanceTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
InstPerformanceTable
.
COLUMN_INSTANCE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
InstPerformanceTable
.
COLUMN_CALLS
,
data
.
getDataInteger
(
2
));
source
.
put
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
,
data
.
getDataLong
(
0
));
source
.
put
(
InstPerformanceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
1
));
return
getClient
().
prepareIndex
(
InstPerformanceTable
.
TABLE
,
data
.
getDataString
(
0
)).
setSource
(
source
);
}
@Override
public
UpdateRequestBuilder
prepareBatchUpdate
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
InstPerformanceTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
InstPerformanceTable
.
COLUMN_INSTANCE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
InstPerformanceTable
.
COLUMN_CALLS
,
data
.
getDataInteger
(
2
));
source
.
put
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
,
data
.
getDataLong
(
0
));
source
.
put
(
InstPerformanceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
1
));
return
getClient
().
prepareUpdate
(
InstPerformanceTable
.
TABLE
,
data
.
getDataString
(
0
)).
setDoc
(
source
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceEsCacheDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
org.elasticsearch.action.get.GetResponse
;
import
org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.register.InstanceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceEsCacheDAO
extends
EsDAO
implements
IInstanceCacheDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceEsCacheDAO
.
class
);
@Override
public
int
getApplicationId
(
int
applicationInstanceId
)
{
GetResponse
response
=
getClient
().
prepareGet
(
InstanceTable
.
TABLE
,
String
.
valueOf
(
applicationInstanceId
)).
get
();
if
(
response
.
isExists
())
{
return
(
int
)
response
.
getSource
().
get
(
InstanceTable
.
COLUMN_APPLICATION_ID
);
}
else
{
return
0
;
}
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.index.IndexResponse
;
import
org.elasticsearch.action.search.SearchRequestBuilder
;
import
org.elasticsearch.action.search.SearchResponse
;
import
org.elasticsearch.action.search.SearchType
;
import
org.elasticsearch.action.support.WriteRequest
;
import
org.elasticsearch.action.update.UpdateRequest
;
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.core.data.Data
;
import
org.skywalking.apm.collector.storage.dao.IInstanceDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.register.InstanceDataDefine
;
import
org.skywalking.apm.collector.storage.table.register.InstanceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceEsDAO
extends
EsDAO
implements
IInstanceDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceEsDAO
.
class
);
@Override
public
int
getInstanceId
(
int
applicationId
,
String
agentUUID
)
{
ElasticSearchClient
client
=
getClient
();
SearchRequestBuilder
searchRequestBuilder
=
client
.
prepareSearch
(
InstanceTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
"type"
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
QUERY_THEN_FETCH
);
BoolQueryBuilder
builder
=
QueryBuilders
.
boolQuery
();
builder
.
must
().
add
(
QueryBuilders
.
termQuery
(
InstanceTable
.
COLUMN_APPLICATION_ID
,
applicationId
));
builder
.
must
().
add
(
QueryBuilders
.
termQuery
(
InstanceTable
.
COLUMN_AGENT_UUID
,
agentUUID
));
searchRequestBuilder
.
setQuery
(
builder
);
searchRequestBuilder
.
setSize
(
1
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
execute
().
actionGet
();
if
(
searchResponse
.
getHits
().
totalHits
>
0
)
{
SearchHit
searchHit
=
searchResponse
.
getHits
().
iterator
().
next
();
return
(
int
)
searchHit
.
getSource
().
get
(
InstanceTable
.
COLUMN_INSTANCE_ID
);
}
return
0
;
}
@Override
public
int
getMaxInstanceId
()
{
return
getMaxId
(
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_INSTANCE_ID
);
}
@Override
public
int
getMinInstanceId
()
{
return
getMinId
(
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_INSTANCE_ID
);
}
@Override
public
void
save
(
Data
data
)
{
String
id
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getId
(
data
);
int
instanceId
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getInstanceId
(
data
);
int
applicationId
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getApplicationId
(
data
);
String
agentUUID
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getAgentUUID
(
data
);
long
registerTime
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getRegisterTime
(
data
);
long
heartBeatTime
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getHeartBeatTime
(
data
);
String
osInfo
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getOsInfo
(
data
);
logger
.
debug
(
"save instance register info, application id: {}, agentUUID: {}"
,
applicationId
,
agentUUID
);
ElasticSearchClient
client
=
getClient
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
InstanceTable
.
COLUMN_INSTANCE_ID
,
instanceId
);
source
.
put
(
InstanceTable
.
COLUMN_APPLICATION_ID
,
applicationId
);
source
.
put
(
InstanceTable
.
COLUMN_AGENT_UUID
,
agentUUID
);
source
.
put
(
InstanceTable
.
COLUMN_REGISTER_TIME
,
registerTime
);
source
.
put
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
heartBeatTime
);
source
.
put
(
InstanceTable
.
COLUMN_OS_INFO
,
osInfo
);
IndexResponse
response
=
client
.
prepareIndex
(
InstanceTable
.
TABLE
,
id
).
setSource
(
source
).
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
IMMEDIATE
).
get
();
logger
.
debug
(
"save instance register info, application id: {}, agentUUID: {}, status: {}"
,
applicationId
,
agentUUID
,
response
.
status
().
name
());
}
@Override
public
void
updateHeartbeatTime
(
int
instanceId
,
long
heartbeatTime
)
{
ElasticSearchClient
client
=
getClient
();
UpdateRequest
updateRequest
=
new
UpdateRequest
();
updateRequest
.
index
(
InstanceTable
.
TABLE
);
updateRequest
.
type
(
"type"
);
updateRequest
.
id
(
String
.
valueOf
(
instanceId
));
updateRequest
.
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
IMMEDIATE
);
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
heartbeatTime
);
updateRequest
.
doc
(
source
);
client
.
update
(
updateRequest
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeComponentEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.INodeComponentDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.node.NodeComponentTable
;
/**
* @author peng-yongsheng
*/
public
class
NodeComponentEsDAO
extends
EsDAO
implements
INodeComponentDAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
>
{
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
GetResponse
getResponse
=
getClient
().
prepareGet
(
NodeComponentTable
.
TABLE
,
id
).
get
();
if
(
getResponse
.
isExists
())
{
Data
data
=
dataDefine
.
build
(
id
);
Map
<
String
,
Object
>
source
=
getResponse
.
getSource
();
data
.
setDataInteger
(
0
,
((
Number
)
source
.
get
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
)).
intValue
());
data
.
setDataString
(
1
,
(
String
)
source
.
get
(
NodeComponentTable
.
COLUMN_COMPONENT_NAME
));
data
.
setDataInteger
(
1
,
((
Number
)
source
.
get
(
NodeComponentTable
.
COLUMN_PEER_ID
)).
intValue
());
data
.
setDataString
(
2
,
(
String
)
source
.
get
(
NodeComponentTable
.
COLUMN_PEER
));
data
.
setDataLong
(
0
,
(
Long
)
source
.
get
(
NodeComponentTable
.
COLUMN_TIME_BUCKET
));
return
data
;
}
else
{
return
null
;
}
}
@Override
public
IndexRequestBuilder
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
NodeComponentTable
.
COLUMN_COMPONENT_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
NodeComponentTable
.
COLUMN_PEER_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
NodeComponentTable
.
COLUMN_PEER
,
data
.
getDataString
(
2
));
source
.
put
(
NodeComponentTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
return
getClient
().
prepareIndex
(
NodeComponentTable
.
TABLE
,
data
.
getDataString
(
0
)).
setSource
(
source
);
}
@Override
public
UpdateRequestBuilder
prepareBatchUpdate
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
NodeComponentTable
.
COLUMN_COMPONENT_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
NodeComponentTable
.
COLUMN_PEER_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
NodeComponentTable
.
COLUMN_PEER
,
data
.
getDataString
(
2
));
source
.
put
(
NodeComponentTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
return
getClient
().
prepareUpdate
(
NodeComponentTable
.
TABLE
,
data
.
getDataString
(
0
)).
setDoc
(
source
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/NodeReferenceEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.INodeReferenceDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.noderef.NodeReferenceTable
;
/**
* @author peng-yongsheng
*/
public
class
NodeReferenceEsDAO
extends
EsDAO
implements
INodeReferenceDAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
>
{
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
GetResponse
getResponse
=
getClient
().
prepareGet
(
NodeReferenceTable
.
TABLE
,
id
).
get
();
if
(
getResponse
.
isExists
())
{
Data
data
=
dataDefine
.
build
(
id
);
Map
<
String
,
Object
>
source
=
getResponse
.
getSource
();
data
.
setDataInteger
(
0
,
((
Number
)
source
.
get
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
)).
intValue
());
data
.
setDataInteger
(
1
,
((
Number
)
source
.
get
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
)).
intValue
());
data
.
setDataString
(
1
,
(
String
)
source
.
get
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
));
data
.
setDataInteger
(
2
,
((
Number
)
source
.
get
(
NodeReferenceTable
.
COLUMN_S1_LTE
)).
intValue
());
data
.
setDataInteger
(
3
,
((
Number
)
source
.
get
(
NodeReferenceTable
.
COLUMN_S3_LTE
)).
intValue
());
data
.
setDataInteger
(
4
,
((
Number
)
source
.
get
(
NodeReferenceTable
.
COLUMN_S5_LTE
)).
intValue
());
data
.
setDataInteger
(
5
,
((
Number
)
source
.
get
(
NodeReferenceTable
.
COLUMN_S5_GT
)).
intValue
());
data
.
setDataInteger
(
6
,
((
Number
)
source
.
get
(
NodeReferenceTable
.
COLUMN_SUMMARY
)).
intValue
());
data
.
setDataInteger
(
7
,
((
Number
)
source
.
get
(
NodeReferenceTable
.
COLUMN_ERROR
)).
intValue
());
data
.
setDataLong
(
0
,
((
Number
)
source
.
get
(
NodeReferenceTable
.
COLUMN_TIME_BUCKET
)).
longValue
());
return
data
;
}
else
{
return
null
;
}
}
@Override
public
IndexRequestBuilder
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
,
data
.
getDataString
(
1
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S1_LTE
,
data
.
getDataInteger
(
2
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S3_LTE
,
data
.
getDataInteger
(
3
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S5_LTE
,
data
.
getDataInteger
(
4
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S5_GT
,
data
.
getDataInteger
(
5
));
source
.
put
(
NodeReferenceTable
.
COLUMN_SUMMARY
,
data
.
getDataInteger
(
6
));
source
.
put
(
NodeReferenceTable
.
COLUMN_ERROR
,
data
.
getDataInteger
(
7
));
source
.
put
(
NodeReferenceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
return
getClient
().
prepareIndex
(
NodeReferenceTable
.
TABLE
,
data
.
getDataString
(
0
)).
setSource
(
source
);
}
@Override
public
UpdateRequestBuilder
prepareBatchUpdate
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
,
data
.
getDataString
(
1
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S1_LTE
,
data
.
getDataInteger
(
2
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S3_LTE
,
data
.
getDataInteger
(
3
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S5_LTE
,
data
.
getDataInteger
(
4
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S5_GT
,
data
.
getDataInteger
(
5
));
source
.
put
(
NodeReferenceTable
.
COLUMN_SUMMARY
,
data
.
getDataInteger
(
6
));
source
.
put
(
NodeReferenceTable
.
COLUMN_ERROR
,
data
.
getDataInteger
(
7
));
source
.
put
(
NodeReferenceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
return
getClient
().
prepareUpdate
(
NodeReferenceTable
.
TABLE
,
data
.
getDataString
(
0
)).
setDoc
(
source
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/SegmentCostEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.ISegmentCostDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.segment.SegmentCostTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
SegmentCostEsDAO
extends
EsDAO
implements
ISegmentCostDAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentCostEsDAO
.
class
);
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
return
null
;
}
@Override
public
UpdateRequestBuilder
prepareBatchUpdate
(
Data
data
)
{
return
null
;
}
@Override
public
IndexRequestBuilder
prepareBatchInsert
(
Data
data
)
{
logger
.
debug
(
"segment cost prepareBatchInsert, id: {}"
,
data
.
getDataString
(
0
));
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
SegmentCostTable
.
COLUMN_SEGMENT_ID
,
data
.
getDataString
(
1
));
source
.
put
(
SegmentCostTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
SegmentCostTable
.
COLUMN_SERVICE_NAME
,
data
.
getDataString
(
2
));
source
.
put
(
SegmentCostTable
.
COLUMN_COST
,
data
.
getDataLong
(
0
));
source
.
put
(
SegmentCostTable
.
COLUMN_START_TIME
,
data
.
getDataLong
(
1
));
source
.
put
(
SegmentCostTable
.
COLUMN_END_TIME
,
data
.
getDataLong
(
2
));
source
.
put
(
SegmentCostTable
.
COLUMN_IS_ERROR
,
data
.
getDataBoolean
(
0
));
source
.
put
(
SegmentCostTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
3
));
logger
.
debug
(
"segment cost source: {}"
,
source
.
toString
());
return
getClient
().
prepareIndex
(
SegmentCostTable
.
TABLE
,
data
.
getDataString
(
0
)).
setSource
(
source
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/SegmentEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.Base64
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.ISegmentDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.segment.SegmentTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
SegmentEsDAO
extends
EsDAO
implements
ISegmentDAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentEsDAO
.
class
);
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
return
null
;
}
@Override
public
UpdateRequestBuilder
prepareBatchUpdate
(
Data
data
)
{
return
null
;
}
@Override
public
IndexRequestBuilder
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
SegmentTable
.
COLUMN_DATA_BINARY
,
new
String
(
Base64
.
getEncoder
().
encode
(
data
.
getDataBytes
(
0
))));
logger
.
debug
(
"segment source: {}"
,
source
.
toString
());
return
getClient
().
prepareIndex
(
SegmentTable
.
TABLE
,
data
.
getDataString
(
0
)).
setSource
(
source
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceEntryEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.IServiceEntryDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.service.ServiceEntryTable
;
/**
* @author peng-yongsheng
*/
public
class
ServiceEntryEsDAO
extends
EsDAO
implements
IServiceEntryDAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
>
{
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
GetResponse
getResponse
=
getClient
().
prepareGet
(
ServiceEntryTable
.
TABLE
,
id
).
get
();
if
(
getResponse
.
isExists
())
{
Data
data
=
dataDefine
.
build
(
id
);
Map
<
String
,
Object
>
source
=
getResponse
.
getSource
();
data
.
setDataInteger
(
0
,
((
Number
)
source
.
get
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
)).
intValue
());
data
.
setDataInteger
(
1
,
((
Number
)
source
.
get
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
)).
intValue
());
data
.
setDataString
(
1
,
(
String
)
source
.
get
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
));
data
.
setDataLong
(
0
,
((
Number
)
source
.
get
(
ServiceEntryTable
.
COLUMN_REGISTER_TIME
)).
longValue
());
data
.
setDataLong
(
1
,
((
Number
)
source
.
get
(
ServiceEntryTable
.
COLUMN_NEWEST_TIME
)).
longValue
());
return
data
;
}
else
{
return
null
;
}
}
@Override
public
IndexRequestBuilder
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
ServiceEntryTable
.
COLUMN_REGISTER_TIME
,
data
.
getDataLong
(
0
));
source
.
put
(
ServiceEntryTable
.
COLUMN_NEWEST_TIME
,
data
.
getDataLong
(
1
));
return
getClient
().
prepareIndex
(
ServiceEntryTable
.
TABLE
,
data
.
getDataString
(
0
)).
setSource
(
source
);
}
@Override
public
UpdateRequestBuilder
prepareBatchUpdate
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
ServiceEntryTable
.
COLUMN_REGISTER_TIME
,
data
.
getDataLong
(
0
));
source
.
put
(
ServiceEntryTable
.
COLUMN_NEWEST_TIME
,
data
.
getDataLong
(
1
));
return
getClient
().
prepareUpdate
(
ServiceEntryTable
.
TABLE
,
data
.
getDataString
(
0
)).
setDoc
(
source
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceNameEsCacheDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
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.BoolQueryBuilder
;
import
org.elasticsearch.index.query.QueryBuilders
;
import
org.elasticsearch.search.SearchHit
;
import
org.skywalking.apm.collector.core.util.Const
;
import
org.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.register.ServiceNameTable
;
/**
* @author peng-yongsheng
*/
public
class
ServiceNameEsCacheDAO
extends
EsDAO
implements
IServiceNameCacheDAO
{
@Override
public
String
getServiceName
(
int
serviceId
)
{
GetRequestBuilder
getRequestBuilder
=
getClient
().
prepareGet
(
ServiceNameTable
.
TABLE
,
String
.
valueOf
(
serviceId
));
GetResponse
getResponse
=
getRequestBuilder
.
get
();
if
(
getResponse
.
isExists
())
{
String
serviceName
=
(
String
)
getResponse
.
getSource
().
get
(
ServiceNameTable
.
COLUMN_SERVICE_NAME
);
int
applicationId
=
((
Number
)
getResponse
.
getSource
().
get
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
)).
intValue
();
return
applicationId
+
Const
.
ID_SPLIT
+
serviceName
;
}
return
Const
.
EMPTY_STRING
;
}
@Override
public
int
getServiceId
(
int
applicationId
,
String
serviceName
)
{
SearchRequestBuilder
searchRequestBuilder
=
getClient
().
prepareSearch
(
ServiceNameTable
.
TABLE
);
searchRequestBuilder
.
setTypes
(
ServiceNameTable
.
TABLE_TYPE
);
searchRequestBuilder
.
setSearchType
(
SearchType
.
DFS_QUERY_THEN_FETCH
);
BoolQueryBuilder
boolQuery
=
QueryBuilders
.
boolQuery
();
boolQuery
.
must
().
add
(
QueryBuilders
.
matchQuery
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
,
applicationId
));
boolQuery
.
must
().
add
(
QueryBuilders
.
matchQuery
(
ServiceNameTable
.
COLUMN_SERVICE_NAME
,
serviceName
));
searchRequestBuilder
.
setQuery
(
boolQuery
);
searchRequestBuilder
.
setSize
(
1
);
SearchResponse
searchResponse
=
searchRequestBuilder
.
get
();
if
(
searchResponse
.
getHits
().
totalHits
>
0
)
{
SearchHit
searchHit
=
searchResponse
.
getHits
().
iterator
().
next
();
return
(
int
)
searchHit
.
getSource
().
get
(
ServiceNameTable
.
COLUMN_SERVICE_ID
);
}
return
0
;
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceNameEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
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.core.data.Data
;
import
org.skywalking.apm.collector.storage.dao.IServiceNameDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.register.ServiceNameDataDefine
;
import
org.skywalking.apm.collector.storage.table.register.ServiceNameTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ServiceNameEsDAO
extends
EsDAO
implements
IServiceNameDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceNameEsDAO
.
class
);
@Override
public
int
getMaxServiceId
()
{
return
getMaxId
(
ServiceNameTable
.
TABLE
,
ServiceNameTable
.
COLUMN_SERVICE_ID
);
}
@Override
public
int
getMinServiceId
()
{
return
getMinId
(
ServiceNameTable
.
TABLE
,
ServiceNameTable
.
COLUMN_SERVICE_ID
);
}
@Override
public
void
save
(
Data
data
)
{
String
id
=
ServiceNameDataDefine
.
ServiceName
.
INSTANCE
.
getId
(
data
);
int
applicationId
=
ServiceNameDataDefine
.
ServiceName
.
INSTANCE
.
getApplicationId
(
data
);
int
serviceId
=
ServiceNameDataDefine
.
ServiceName
.
INSTANCE
.
getServiceId
(
data
);
String
serviceName
=
ServiceNameDataDefine
.
ServiceName
.
INSTANCE
.
getServiceName
(
data
);
logger
.
debug
(
"save service name register info, application id: {}, service name: {}"
,
applicationId
,
serviceName
);
ElasticSearchClient
client
=
getClient
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceNameTable
.
COLUMN_SERVICE_ID
,
serviceId
);
source
.
put
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
,
applicationId
);
source
.
put
(
ServiceNameTable
.
COLUMN_SERVICE_NAME
,
serviceName
);
IndexResponse
response
=
client
.
prepareIndex
(
ServiceNameTable
.
TABLE
,
id
).
setSource
(
source
).
setRefreshPolicy
(
WriteRequest
.
RefreshPolicy
.
IMMEDIATE
).
get
();
logger
.
debug
(
"save service name register info, application id: {}, service name: {}, status: {}"
,
applicationId
,
serviceName
,
response
.
status
().
name
());
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.Map
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.index.IndexRequestBuilder
;
import
org.elasticsearch.action.update.UpdateRequestBuilder
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.IServiceReferenceDAO
;
import
org.skywalking.apm.collector.storage.es.base.dao.EsDAO
;
import
org.skywalking.apm.collector.storage.table.serviceref.ServiceReferenceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
ServiceReferenceEsDAO
extends
EsDAO
implements
IServiceReferenceDAO
,
IPersistenceDAO
<
IndexRequestBuilder
,
UpdateRequestBuilder
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceReferenceEsDAO
.
class
);
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
GetResponse
getResponse
=
getClient
().
prepareGet
(
ServiceReferenceTable
.
TABLE
,
id
).
get
();
if
(
getResponse
.
isExists
())
{
Data
data
=
dataDefine
.
build
(
id
);
Map
<
String
,
Object
>
source
=
getResponse
.
getSource
();
data
.
setDataInteger
(
0
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_ID
)).
intValue
());
data
.
setDataString
(
1
,
(
String
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_NAME
));
data
.
setDataInteger
(
1
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_ID
)).
intValue
());
data
.
setDataString
(
2
,
(
String
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_NAME
));
data
.
setDataInteger
(
2
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_ID
)).
intValue
());
data
.
setDataString
(
3
,
(
String
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_NAME
));
data
.
setDataLong
(
0
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_S1_LTE
)).
longValue
());
data
.
setDataLong
(
1
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_S3_LTE
)).
longValue
());
data
.
setDataLong
(
2
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_S5_LTE
)).
longValue
());
data
.
setDataLong
(
3
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_S5_GT
)).
longValue
());
data
.
setDataLong
(
4
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_SUMMARY
)).
longValue
());
data
.
setDataLong
(
5
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_ERROR
)).
longValue
());
data
.
setDataLong
(
6
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_COST_SUMMARY
)).
longValue
());
data
.
setDataLong
(
7
,
((
Number
)
source
.
get
(
ServiceReferenceTable
.
COLUMN_TIME_BUCKET
)).
longValue
());
return
data
;
}
else
{
return
null
;
}
}
@Override
public
IndexRequestBuilder
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_NAME
,
data
.
getDataString
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_ID
,
data
.
getDataInteger
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_NAME
,
data
.
getDataString
(
3
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S1_LTE
,
data
.
getDataLong
(
0
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S3_LTE
,
data
.
getDataLong
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S5_LTE
,
data
.
getDataLong
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S5_GT
,
data
.
getDataLong
(
3
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_SUMMARY
,
data
.
getDataLong
(
4
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_ERROR
,
data
.
getDataLong
(
5
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_COST_SUMMARY
,
data
.
getDataLong
(
6
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
7
));
return
getClient
().
prepareIndex
(
ServiceReferenceTable
.
TABLE
,
data
.
getDataString
(
0
)).
setSource
(
source
);
}
@Override
public
UpdateRequestBuilder
prepareBatchUpdate
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_NAME
,
data
.
getDataString
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_ID
,
data
.
getDataInteger
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_NAME
,
data
.
getDataString
(
3
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S1_LTE
,
data
.
getDataLong
(
0
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S3_LTE
,
data
.
getDataLong
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S5_LTE
,
data
.
getDataLong
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S5_GT
,
data
.
getDataLong
(
3
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_SUMMARY
,
data
.
getDataLong
(
4
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_ERROR
,
data
.
getDataLong
(
5
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_COST_SUMMARY
,
data
.
getDataLong
(
6
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
7
));
return
getClient
().
prepareUpdate
(
ServiceReferenceTable
.
TABLE
,
data
.
getDataString
(
0
)).
setDoc
(
source
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/es_dao.define
浏览文件 @
7abec320
...
...
@@ -2,4 +2,18 @@ org.skywalking.apm.collector.storage.es.dao.CpuMetricEsDAO
org.skywalking.apm.collector.storage.es.dao.GCMetricEsDAO
org.skywalking.apm.collector.storage.es.dao.InstanceHeartBeatEsDAO
org.skywalking.apm.collector.storage.es.dao.MemoryMetricEsDAO
org.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsDAO
\ No newline at end of file
org.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsDAO
org.skywalking.apm.collector.storage.es.dao.ApplicationEsDAO
org.skywalking.apm.collector.storage.es.dao.InstanceEsDAO
org.skywalking.apm.collector.storage.es.dao.ServiceNameEsDAO
org.skywalking.apm.collector.storage.es.dao.GlobalTraceEsDAO
org.skywalking.apm.collector.storage.es.dao.InstPerformanceEsDAO
org.skywalking.apm.collector.storage.es.dao.NodeComponentEsDAO
org.skywalking.apm.collector.storage.es.dao.NodeReferenceEsDAO
org.skywalking.apm.collector.storage.es.dao.SegmentCostEsDAO
org.skywalking.apm.collector.storage.es.dao.SegmentEsDAO
org.skywalking.apm.collector.storage.es.dao.ServiceEntryEsDAO
org.skywalking.apm.collector.storage.es.dao.ServiceReferenceEsDAO
org.skywalking.apm.collector.storage.es.dao.ApplicationEsCacheDAO
org.skywalking.apm.collector.storage.es.dao.InstanceEsCacheDAO
org.skywalking.apm.collector.storage.es.dao.ServiceNameEsCacheDAO
\ No newline at end of file
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2CacheDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
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.storage.dao.IApplicationCacheDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.register.ApplicationTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
ApplicationH2CacheDAO
extends
H2DAO
implements
IApplicationCacheDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApplicationH2CacheDAO
.
class
);
private
static
final
String
GET_APPLICATION_ID_OR_CODE_SQL
=
"select {0} from {1} where {2} = ?"
;
@Override
public
int
getApplicationId
(
String
applicationCode
)
{
logger
.
info
(
"get the application id with application code = {}"
,
applicationCode
);
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_APPLICATION_ID_OR_CODE_SQL
,
ApplicationTable
.
COLUMN_APPLICATION_ID
,
ApplicationTable
.
TABLE
,
ApplicationTable
.
COLUMN_APPLICATION_CODE
);
Object
[]
params
=
new
Object
[]
{
applicationCode
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getInt
(
1
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
0
;
}
@Override
public
String
getApplicationCode
(
int
applicationId
)
{
logger
.
debug
(
"get application code, applicationId: {}"
,
applicationId
);
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_APPLICATION_ID_OR_CODE_SQL
,
ApplicationTable
.
COLUMN_APPLICATION_CODE
,
ApplicationTable
.
TABLE
,
ApplicationTable
.
COLUMN_APPLICATION_ID
);
Object
[]
params
=
new
Object
[]
{
applicationId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getString
(
1
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
Const
.
EMPTY_STRING
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2DAO.java
浏览文件 @
7abec320
...
...
@@ -22,10 +22,12 @@ import java.util.HashMap;
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.define.register.ApplicationDataDefine
;
import
org.skywalking.apm.collector.storage.define.register.ApplicationTable
;
import
org.skywalking.apm.collector.storage.h2.SqlBuilder
;
import
org.skywalking.apm.collector.storage.h2.dao.H2DAO
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.dao.IApplicationDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.register.ApplicationDataDefine
;
import
org.skywalking.apm.collector.storage.table.register.ApplicationTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -46,13 +48,16 @@ public class ApplicationH2DAO extends H2DAO implements IApplicationDAO {
}
@Override
public
void
save
(
ApplicationDataDefine
.
Application
application
)
{
public
void
save
(
Data
data
)
{
String
id
=
ApplicationDataDefine
.
Application
.
INSTANCE
.
getId
(
data
);
int
applicationId
=
ApplicationDataDefine
.
Application
.
INSTANCE
.
getApplicationId
(
data
);
String
applicationCode
=
ApplicationDataDefine
.
Application
.
INSTANCE
.
getApplicationCode
(
data
);
H2Client
client
=
getClient
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ApplicationTable
.
COLUMN_ID
,
application
.
getApplicationId
()
);
source
.
put
(
ApplicationTable
.
COLUMN_APPLICATION_CODE
,
application
.
getApplicationCode
()
);
source
.
put
(
ApplicationTable
.
COLUMN_APPLICATION_ID
,
application
.
getApplicationId
()
);
source
.
put
(
ApplicationTable
.
COLUMN_ID
,
id
);
source
.
put
(
ApplicationTable
.
COLUMN_APPLICATION_CODE
,
application
Code
);
source
.
put
(
ApplicationTable
.
COLUMN_APPLICATION_ID
,
application
Id
);
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
ApplicationTable
.
TABLE
,
source
.
keySet
());
Object
[]
params
=
source
.
values
().
toArray
(
new
Object
[
0
]);
...
...
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GlobalTraceH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.util.HashMap
;
import
java.util.Map
;
import
org.skywalking.apm.collector.core.UnexpectedException
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.IGlobalTraceDAO
;
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.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.global.GlobalTraceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
GlobalTraceH2DAO
extends
H2DAO
implements
IGlobalTraceDAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalTraceH2DAO
.
class
);
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
throw
new
UnexpectedException
(
"There is no need to merge stream data with database data."
);
}
@Override
public
H2SqlEntity
prepareBatchUpdate
(
Data
data
)
{
throw
new
UnexpectedException
(
"There is no need to merge stream data with database data."
);
}
@Override
public
H2SqlEntity
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
GlobalTraceTable
.
COLUMN_ID
,
data
.
getDataString
(
0
));
source
.
put
(
GlobalTraceTable
.
COLUMN_SEGMENT_ID
,
data
.
getDataString
(
1
));
source
.
put
(
GlobalTraceTable
.
COLUMN_GLOBAL_TRACE_ID
,
data
.
getDataString
(
2
));
source
.
put
(
GlobalTraceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
logger
.
debug
(
"global trace source: {}"
,
source
.
toString
());
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
GlobalTraceTable
.
TABLE
,
source
.
keySet
());
entity
.
setSql
(
sql
);
entity
.
setParams
(
source
.
values
().
toArray
(
new
Object
[
0
]));
return
entity
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstPerformanceH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.List
;
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.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.IInstPerformanceDAO
;
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.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.instance.InstPerformanceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
InstPerformanceH2DAO
extends
H2DAO
implements
IInstPerformanceDAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstPerformanceH2DAO
.
class
);
private
static
final
String
GET_SQL
=
"select * from {0} where {1} = ?"
;
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SQL
,
InstPerformanceTable
.
TABLE
,
InstPerformanceTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
id
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
Data
data
=
dataDefine
.
build
(
id
);
data
.
setDataInteger
(
0
,
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_APPLICATION_ID
));
data
.
setDataInteger
(
1
,
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_INSTANCE_ID
));
data
.
setDataInteger
(
2
,
rs
.
getInt
(
InstPerformanceTable
.
COLUMN_CALLS
));
data
.
setDataLong
(
0
,
rs
.
getLong
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
));
data
.
setDataLong
(
1
,
rs
.
getLong
(
InstPerformanceTable
.
COLUMN_TIME_BUCKET
));
return
data
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
@Override
public
H2SqlEntity
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
InstPerformanceTable
.
COLUMN_ID
,
data
.
getDataString
(
0
));
source
.
put
(
InstPerformanceTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
InstPerformanceTable
.
COLUMN_INSTANCE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
InstPerformanceTable
.
COLUMN_CALLS
,
data
.
getDataInteger
(
2
));
source
.
put
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
,
data
.
getDataLong
(
0
));
source
.
put
(
InstPerformanceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
1
));
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
InstPerformanceTable
.
TABLE
,
source
.
keySet
());
entity
.
setSql
(
sql
);
entity
.
setParams
(
source
.
values
().
toArray
(
new
Object
[
0
]));
return
entity
;
}
@Override
public
H2SqlEntity
prepareBatchUpdate
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
InstPerformanceTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
InstPerformanceTable
.
COLUMN_INSTANCE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
InstPerformanceTable
.
COLUMN_CALLS
,
data
.
getDataInteger
(
2
));
source
.
put
(
InstPerformanceTable
.
COLUMN_COST_TOTAL
,
data
.
getDataLong
(
0
));
source
.
put
(
InstPerformanceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
1
));
String
id
=
data
.
getDataString
(
0
);
String
sql
=
SqlBuilder
.
buildBatchUpdateSql
(
InstPerformanceTable
.
TABLE
,
source
.
keySet
(),
InstPerformanceTable
.
COLUMN_ID
);
entity
.
setSql
(
sql
);
List
<
Object
>
values
=
new
ArrayList
<>(
source
.
values
());
values
.
add
(
id
);
entity
.
setParams
(
values
.
toArray
(
new
Object
[
0
]));
return
entity
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2CacheDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
org.skywalking.apm.collector.client.h2.H2Client
;
import
org.skywalking.apm.collector.client.h2.H2ClientException
;
import
org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.register.InstanceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng
*/
public
class
InstanceH2CacheDAO
extends
H2DAO
implements
IInstanceCacheDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceH2CacheDAO
.
class
);
private
static
final
String
GET_APPLICATION_ID_SQL
=
"select {0} from {1} where {2} = ?"
;
@Override
public
int
getApplicationId
(
int
applicationInstanceId
)
{
logger
.
info
(
"get the application id with application id = {}"
,
applicationInstanceId
);
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_APPLICATION_ID_SQL
,
InstanceTable
.
COLUMN_APPLICATION_ID
,
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_INSTANCE_ID
);
Object
[]
params
=
new
Object
[]
{
applicationInstanceId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getInt
(
InstanceTable
.
COLUMN_APPLICATION_ID
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
0
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
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.core.data.Data
;
import
org.skywalking.apm.collector.storage.dao.IInstanceDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.register.InstanceDataDefine
;
import
org.skywalking.apm.collector.storage.table.register.InstanceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
InstanceH2DAO
extends
H2DAO
implements
IInstanceDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstanceH2DAO
.
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} = ?"
;
@Override
public
int
getInstanceId
(
int
applicationId
,
String
agentUUID
)
{
logger
.
info
(
"get the application id with application id = {}, agentUUID = {}"
,
applicationId
,
agentUUID
);
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_INSTANCE_ID_SQL
,
InstanceTable
.
COLUMN_INSTANCE_ID
,
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_APPLICATION_ID
,
InstanceTable
.
COLUMN_AGENT_UUID
);
Object
[]
params
=
new
Object
[]
{
applicationId
,
agentUUID
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getInt
(
InstanceTable
.
COLUMN_INSTANCE_ID
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
0
;
}
@Override
public
int
getMaxInstanceId
()
{
return
getMaxId
(
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_INSTANCE_ID
);
}
@Override
public
int
getMinInstanceId
()
{
return
getMinId
(
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_INSTANCE_ID
);
}
@Override
public
void
save
(
Data
data
)
{
String
id
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getId
(
data
);
int
instanceId
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getInstanceId
(
data
);
int
applicationId
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getApplicationId
(
data
);
String
agentUUID
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getAgentUUID
(
data
);
long
registerTime
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getRegisterTime
(
data
);
long
heartBeatTime
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getHeartBeatTime
(
data
);
String
osInfo
=
InstanceDataDefine
.
Instance
.
INSTANCE
.
getOsInfo
(
data
);
H2Client
client
=
getClient
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
InstanceTable
.
COLUMN_ID
,
id
);
source
.
put
(
InstanceTable
.
COLUMN_INSTANCE_ID
,
instanceId
);
source
.
put
(
InstanceTable
.
COLUMN_APPLICATION_ID
,
applicationId
);
source
.
put
(
InstanceTable
.
COLUMN_AGENT_UUID
,
agentUUID
);
source
.
put
(
InstanceTable
.
COLUMN_REGISTER_TIME
,
registerTime
);
source
.
put
(
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
heartBeatTime
);
source
.
put
(
InstanceTable
.
COLUMN_OS_INFO
,
osInfo
);
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
InstanceTable
.
TABLE
,
source
.
keySet
());
Object
[]
params
=
source
.
values
().
toArray
(
new
Object
[
0
]);
try
{
client
.
execute
(
sql
,
params
);
}
catch
(
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
@Override
public
void
updateHeartbeatTime
(
int
instanceId
,
long
heartbeatTime
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
UPDATE_HEARTBEAT_TIME_SQL
,
InstanceTable
.
TABLE
,
InstanceTable
.
COLUMN_HEARTBEAT_TIME
,
InstanceTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
heartbeatTime
,
instanceId
};
try
{
client
.
execute
(
sql
,
params
);
}
catch
(
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/NodeComponentH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.List
;
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.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.INodeComponentDAO
;
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.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.node.NodeComponentTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
NodeComponentH2DAO
extends
H2DAO
implements
INodeComponentDAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NodeComponentH2DAO
.
class
);
private
static
final
String
GET_SQL
=
"select * from {0} where {1} = ?"
;
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SQL
,
NodeComponentTable
.
TABLE
,
NodeComponentTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
id
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
Data
data
=
dataDefine
.
build
(
id
);
data
.
setDataInteger
(
0
,
rs
.
getInt
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
));
data
.
setDataString
(
1
,
rs
.
getString
(
NodeComponentTable
.
COLUMN_COMPONENT_NAME
));
data
.
setDataInteger
(
1
,
rs
.
getInt
(
NodeComponentTable
.
COLUMN_PEER_ID
));
data
.
setDataString
(
2
,
rs
.
getString
(
NodeComponentTable
.
COLUMN_PEER
));
data
.
setDataLong
(
0
,
rs
.
getLong
(
NodeComponentTable
.
COLUMN_TIME_BUCKET
));
return
data
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
@Override
public
H2SqlEntity
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
NodeComponentTable
.
COLUMN_ID
,
data
.
getDataString
(
0
));
source
.
put
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
NodeComponentTable
.
COLUMN_COMPONENT_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
NodeComponentTable
.
COLUMN_PEER_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
NodeComponentTable
.
COLUMN_PEER
,
data
.
getDataString
(
2
));
source
.
put
(
NodeComponentTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
NodeComponentTable
.
TABLE
,
source
.
keySet
());
entity
.
setSql
(
sql
);
entity
.
setParams
(
source
.
values
().
toArray
(
new
Object
[
0
]));
return
entity
;
}
@Override
public
H2SqlEntity
prepareBatchUpdate
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
NodeComponentTable
.
COLUMN_COMPONENT_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
NodeComponentTable
.
COLUMN_COMPONENT_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
NodeComponentTable
.
COLUMN_PEER_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
NodeComponentTable
.
COLUMN_PEER
,
data
.
getDataString
(
2
));
source
.
put
(
NodeComponentTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
String
id
=
data
.
getDataString
(
0
);
String
sql
=
SqlBuilder
.
buildBatchUpdateSql
(
NodeComponentTable
.
TABLE
,
source
.
keySet
(),
NodeComponentTable
.
COLUMN_ID
);
entity
.
setSql
(
sql
);
List
<
Object
>
values
=
new
ArrayList
<>(
source
.
values
());
values
.
add
(
id
);
entity
.
setParams
(
values
.
toArray
(
new
Object
[
0
]));
return
entity
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/NodeReferenceH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.List
;
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.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.INodeReferenceDAO
;
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.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.noderef.NodeReferenceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
NodeReferenceH2DAO
extends
H2DAO
implements
INodeReferenceDAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
NodeReferenceH2DAO
.
class
);
private
static
final
String
GET_SQL
=
"select * from {0} where {1} = ?"
;
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SQL
,
NodeReferenceTable
.
TABLE
,
NodeReferenceTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
id
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
Data
data
=
dataDefine
.
build
(
id
);
data
.
setDataInteger
(
0
,
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
));
data
.
setDataInteger
(
1
,
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
));
data
.
setDataString
(
1
,
rs
.
getString
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
));
data
.
setDataInteger
(
2
,
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_S1_LTE
));
data
.
setDataInteger
(
3
,
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_S3_LTE
));
data
.
setDataInteger
(
4
,
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_S5_LTE
));
data
.
setDataInteger
(
5
,
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_S5_GT
));
data
.
setDataInteger
(
6
,
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_SUMMARY
));
data
.
setDataInteger
(
7
,
rs
.
getInt
(
NodeReferenceTable
.
COLUMN_ERROR
));
data
.
setDataLong
(
0
,
rs
.
getLong
(
NodeReferenceTable
.
COLUMN_TIME_BUCKET
));
return
data
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
@Override
public
H2SqlEntity
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
NodeReferenceTable
.
COLUMN_ID
,
data
.
getDataString
(
0
));
source
.
put
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
,
data
.
getDataString
(
1
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S1_LTE
,
data
.
getDataInteger
(
2
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S3_LTE
,
data
.
getDataInteger
(
3
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S5_LTE
,
data
.
getDataInteger
(
4
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S5_GT
,
data
.
getDataInteger
(
5
));
source
.
put
(
NodeReferenceTable
.
COLUMN_SUMMARY
,
data
.
getDataInteger
(
6
));
source
.
put
(
NodeReferenceTable
.
COLUMN_ERROR
,
data
.
getDataInteger
(
7
));
source
.
put
(
NodeReferenceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
NodeReferenceTable
.
TABLE
,
source
.
keySet
());
entity
.
setSql
(
sql
);
entity
.
setParams
(
source
.
values
().
toArray
(
new
Object
[
0
]));
return
entity
;
}
@Override
public
H2SqlEntity
prepareBatchUpdate
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
NodeReferenceTable
.
COLUMN_FRONT_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
NodeReferenceTable
.
COLUMN_BEHIND_APPLICATION_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
NodeReferenceTable
.
COLUMN_BEHIND_PEER
,
data
.
getDataString
(
1
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S1_LTE
,
data
.
getDataInteger
(
2
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S3_LTE
,
data
.
getDataInteger
(
3
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S5_LTE
,
data
.
getDataInteger
(
4
));
source
.
put
(
NodeReferenceTable
.
COLUMN_S5_GT
,
data
.
getDataInteger
(
5
));
source
.
put
(
NodeReferenceTable
.
COLUMN_SUMMARY
,
data
.
getDataInteger
(
6
));
source
.
put
(
NodeReferenceTable
.
COLUMN_ERROR
,
data
.
getDataInteger
(
7
));
source
.
put
(
NodeReferenceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
0
));
String
id
=
data
.
getDataString
(
0
);
String
sql
=
SqlBuilder
.
buildBatchUpdateSql
(
NodeReferenceTable
.
TABLE
,
source
.
keySet
(),
NodeReferenceTable
.
COLUMN_ID
);
entity
.
setSql
(
sql
);
List
<
Object
>
values
=
new
ArrayList
<>(
source
.
values
());
values
.
add
(
id
);
entity
.
setParams
(
values
.
toArray
(
new
Object
[
0
]));
return
entity
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/SegmentCostH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.util.HashMap
;
import
java.util.Map
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.ISegmentCostDAO
;
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.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.segment.SegmentCostTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
SegmentCostH2DAO
extends
H2DAO
implements
ISegmentCostDAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentCostH2DAO
.
class
);
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
return
null
;
}
@Override
public
H2SqlEntity
prepareBatchInsert
(
Data
data
)
{
logger
.
debug
(
"segment cost prepareBatchInsert, id: {}"
,
data
.
getDataString
(
0
));
H2SqlEntity
entity
=
new
H2SqlEntity
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
SegmentCostTable
.
COLUMN_ID
,
data
.
getDataString
(
0
));
source
.
put
(
SegmentCostTable
.
COLUMN_SEGMENT_ID
,
data
.
getDataString
(
1
));
source
.
put
(
SegmentCostTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
SegmentCostTable
.
COLUMN_SERVICE_NAME
,
data
.
getDataString
(
2
));
source
.
put
(
SegmentCostTable
.
COLUMN_COST
,
data
.
getDataLong
(
0
));
source
.
put
(
SegmentCostTable
.
COLUMN_START_TIME
,
data
.
getDataLong
(
1
));
source
.
put
(
SegmentCostTable
.
COLUMN_END_TIME
,
data
.
getDataLong
(
2
));
source
.
put
(
SegmentCostTable
.
COLUMN_IS_ERROR
,
data
.
getDataBoolean
(
0
));
source
.
put
(
SegmentCostTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
3
));
logger
.
debug
(
"segment cost source: {}"
,
source
.
toString
());
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
SegmentCostTable
.
TABLE
,
source
.
keySet
());
entity
.
setSql
(
sql
);
entity
.
setParams
(
source
.
values
().
toArray
(
new
Object
[
0
]));
return
entity
;
}
@Override
public
H2SqlEntity
prepareBatchUpdate
(
Data
data
)
{
return
null
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/SegmentH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.util.HashMap
;
import
java.util.Map
;
import
org.skywalking.apm.collector.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.ISegmentDAO
;
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.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.segment.SegmentTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
SegmentH2DAO
extends
H2DAO
implements
ISegmentDAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SegmentH2DAO
.
class
);
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
return
null
;
}
@Override
public
H2SqlEntity
prepareBatchInsert
(
Data
data
)
{
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
H2SqlEntity
entity
=
new
H2SqlEntity
();
source
.
put
(
SegmentTable
.
COLUMN_ID
,
data
.
getDataString
(
0
));
source
.
put
(
SegmentTable
.
COLUMN_DATA_BINARY
,
data
.
getDataBytes
(
0
));
logger
.
debug
(
"segment source: {}"
,
source
.
toString
());
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
SegmentTable
.
TABLE
,
source
.
keySet
());
entity
.
setSql
(
sql
);
entity
.
setParams
(
source
.
values
().
toArray
(
new
Object
[
0
]));
return
entity
;
}
@Override
public
H2SqlEntity
prepareBatchUpdate
(
Data
data
)
{
return
null
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ServiceEntryH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.List
;
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.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.IServiceEntryDAO
;
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.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.service.ServiceEntryTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
ServiceEntryH2DAO
extends
H2DAO
implements
IServiceEntryDAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceEntryH2DAO
.
class
);
private
static
final
String
GET_SERVICE_ENTRY_SQL
=
"select * from {0} where {1} = ?"
;
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SERVICE_ENTRY_SQL
,
ServiceEntryTable
.
TABLE
,
ServiceEntryTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
id
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
Data
data
=
dataDefine
.
build
(
id
);
data
.
setDataInteger
(
0
,
rs
.
getInt
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
));
data
.
setDataInteger
(
1
,
rs
.
getInt
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
));
data
.
setDataString
(
1
,
rs
.
getString
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
));
data
.
setDataLong
(
0
,
rs
.
getLong
(
ServiceEntryTable
.
COLUMN_REGISTER_TIME
));
data
.
setDataLong
(
1
,
rs
.
getLong
(
ServiceEntryTable
.
COLUMN_NEWEST_TIME
));
return
data
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
@Override
public
H2SqlEntity
prepareBatchInsert
(
Data
data
)
{
H2SqlEntity
entity
=
new
H2SqlEntity
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceEntryTable
.
COLUMN_ID
,
data
.
getDataString
(
0
));
source
.
put
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
ServiceEntryTable
.
COLUMN_REGISTER_TIME
,
data
.
getDataLong
(
0
));
source
.
put
(
ServiceEntryTable
.
COLUMN_NEWEST_TIME
,
data
.
getDataLong
(
1
));
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
ServiceEntryTable
.
TABLE
,
source
.
keySet
());
entity
.
setSql
(
sql
);
entity
.
setParams
(
source
.
values
().
toArray
(
new
Object
[
0
]));
return
entity
;
}
@Override
public
H2SqlEntity
prepareBatchUpdate
(
Data
data
)
{
H2SqlEntity
entity
=
new
H2SqlEntity
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceEntryTable
.
COLUMN_APPLICATION_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
ServiceEntryTable
.
COLUMN_ENTRY_SERVICE_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
ServiceEntryTable
.
COLUMN_REGISTER_TIME
,
data
.
getDataLong
(
0
));
source
.
put
(
ServiceEntryTable
.
COLUMN_NEWEST_TIME
,
data
.
getDataLong
(
1
));
String
id
=
data
.
getDataString
(
0
);
String
sql
=
SqlBuilder
.
buildBatchUpdateSql
(
ServiceEntryTable
.
TABLE
,
source
.
keySet
(),
ServiceEntryTable
.
COLUMN_ID
);
entity
.
setSql
(
sql
);
List
<
Object
>
values
=
new
ArrayList
<>(
source
.
values
());
values
.
add
(
id
);
entity
.
setParams
(
values
.
toArray
(
new
Object
[
0
]));
return
entity
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ServiceNameH2CacheDAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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
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.storage.dao.IServiceNameCacheDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.register.ServiceNameTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
ServiceNameH2CacheDAO
extends
H2DAO
implements
IServiceNameCacheDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceNameH2CacheDAO
.
class
);
private
static
final
String
GET_SERVICE_NAME_SQL
=
"select {0},{1} from {2} where {3} = ?"
;
private
static
final
String
GET_SERVICE_ID_SQL
=
"select {0} from {1} where {2} = ? and {3} = ? limit 1"
;
@Override
public
String
getServiceName
(
int
serviceId
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SERVICE_NAME_SQL
,
ServiceNameTable
.
COLUMN_APPLICATION_ID
,
ServiceNameTable
.
COLUMN_SERVICE_NAME
,
ServiceNameTable
.
TABLE
,
ServiceNameTable
.
COLUMN_SERVICE_ID
);
Object
[]
params
=
new
Object
[]
{
serviceId
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
String
serviceName
=
rs
.
getString
(
ServiceNameTable
.
COLUMN_SERVICE_NAME
);
int
applicationId
=
rs
.
getInt
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
);
return
applicationId
+
Const
.
ID_SPLIT
+
serviceName
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
Const
.
EMPTY_STRING
;
}
@Override
public
int
getServiceId
(
int
applicationId
,
String
serviceName
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SERVICE_ID_SQL
,
ServiceNameTable
.
COLUMN_SERVICE_ID
,
ServiceNameTable
.
TABLE
,
ServiceNameTable
.
COLUMN_APPLICATION_ID
,
ServiceNameTable
.
COLUMN_SERVICE_NAME
);
Object
[]
params
=
new
Object
[]
{
applicationId
,
serviceName
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
return
rs
.
getInt
(
ServiceNameTable
.
COLUMN_SERVICE_ID
);
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
0
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ServiceNameH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.util.HashMap
;
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.core.data.Data
;
import
org.skywalking.apm.collector.storage.dao.IServiceNameDAO
;
import
org.skywalking.apm.collector.storage.h2.base.dao.H2DAO
;
import
org.skywalking.apm.collector.storage.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.register.ServiceNameDataDefine
;
import
org.skywalking.apm.collector.storage.table.register.ServiceNameTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
ServiceNameH2DAO
extends
H2DAO
implements
IServiceNameDAO
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceNameH2DAO
.
class
);
@Override
public
int
getMaxServiceId
()
{
return
getMaxId
(
ServiceNameTable
.
TABLE
,
ServiceNameTable
.
COLUMN_SERVICE_ID
);
}
@Override
public
int
getMinServiceId
()
{
return
getMinId
(
ServiceNameTable
.
TABLE
,
ServiceNameTable
.
COLUMN_SERVICE_ID
);
}
@Override
public
void
save
(
Data
data
)
{
String
id
=
ServiceNameDataDefine
.
ServiceName
.
INSTANCE
.
getId
(
data
);
int
applicationId
=
ServiceNameDataDefine
.
ServiceName
.
INSTANCE
.
getApplicationId
(
data
);
int
serviceId
=
ServiceNameDataDefine
.
ServiceName
.
INSTANCE
.
getServiceId
(
data
);
String
serviceName
=
ServiceNameDataDefine
.
ServiceName
.
INSTANCE
.
getServiceName
(
data
);
logger
.
debug
(
"save service name register info, application id: {}, service name: {}"
,
applicationId
,
serviceName
);
H2Client
client
=
getClient
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceNameTable
.
COLUMN_ID
,
id
);
source
.
put
(
ServiceNameTable
.
COLUMN_SERVICE_ID
,
serviceId
);
source
.
put
(
ServiceNameTable
.
COLUMN_APPLICATION_ID
,
applicationId
);
source
.
put
(
ServiceNameTable
.
COLUMN_SERVICE_NAME
,
serviceName
);
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
ServiceNameTable
.
TABLE
,
source
.
keySet
());
Object
[]
params
=
source
.
values
().
toArray
(
new
Object
[
0
]);
try
{
client
.
execute
(
sql
,
params
);
}
catch
(
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/ServiceReferenceH2DAO.java
0 → 100644
浏览文件 @
7abec320
/*
* 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.HashMap
;
import
java.util.List
;
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.core.data.Data
;
import
org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO
;
import
org.skywalking.apm.collector.storage.base.define.DataDefine
;
import
org.skywalking.apm.collector.storage.dao.IServiceReferenceDAO
;
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.sql.SqlBuilder
;
import
org.skywalking.apm.collector.storage.table.serviceref.ServiceReferenceTable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author peng-yongsheng, clevertension
*/
public
class
ServiceReferenceH2DAO
extends
H2DAO
implements
IServiceReferenceDAO
,
IPersistenceDAO
<
H2SqlEntity
,
H2SqlEntity
>
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServiceReferenceH2DAO
.
class
);
private
static
final
String
GET_SQL
=
"select * from {0} where {1} = ?"
;
@Override
public
Data
get
(
String
id
,
DataDefine
dataDefine
)
{
H2Client
client
=
getClient
();
String
sql
=
SqlBuilder
.
buildSql
(
GET_SQL
,
ServiceReferenceTable
.
TABLE
,
ServiceReferenceTable
.
COLUMN_ID
);
Object
[]
params
=
new
Object
[]
{
id
};
try
(
ResultSet
rs
=
client
.
executeQuery
(
sql
,
params
))
{
if
(
rs
.
next
())
{
Data
data
=
dataDefine
.
build
(
id
);
data
.
setDataInteger
(
0
,
rs
.
getInt
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_ID
));
data
.
setDataString
(
1
,
rs
.
getString
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_NAME
));
data
.
setDataInteger
(
1
,
rs
.
getInt
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_ID
));
data
.
setDataString
(
2
,
rs
.
getString
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_NAME
));
data
.
setDataInteger
(
2
,
rs
.
getInt
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_ID
));
data
.
setDataString
(
3
,
rs
.
getString
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_NAME
));
data
.
setDataLong
(
0
,
rs
.
getLong
(
ServiceReferenceTable
.
COLUMN_S1_LTE
));
data
.
setDataLong
(
1
,
rs
.
getLong
(
ServiceReferenceTable
.
COLUMN_S3_LTE
));
data
.
setDataLong
(
2
,
rs
.
getLong
(
ServiceReferenceTable
.
COLUMN_S5_LTE
));
data
.
setDataLong
(
3
,
rs
.
getLong
(
ServiceReferenceTable
.
COLUMN_S5_GT
));
data
.
setDataLong
(
4
,
rs
.
getLong
(
ServiceReferenceTable
.
COLUMN_SUMMARY
));
data
.
setDataLong
(
5
,
rs
.
getLong
(
ServiceReferenceTable
.
COLUMN_ERROR
));
data
.
setDataLong
(
6
,
rs
.
getLong
(
ServiceReferenceTable
.
COLUMN_COST_SUMMARY
));
data
.
setDataLong
(
7
,
rs
.
getLong
(
ServiceReferenceTable
.
COLUMN_TIME_BUCKET
));
return
data
;
}
}
catch
(
SQLException
|
H2ClientException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
@Override
public
H2SqlEntity
prepareBatchInsert
(
Data
data
)
{
H2SqlEntity
entity
=
new
H2SqlEntity
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceReferenceTable
.
COLUMN_ID
,
data
.
getDataString
(
0
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_NAME
,
data
.
getDataString
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_ID
,
data
.
getDataInteger
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_NAME
,
data
.
getDataString
(
3
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S1_LTE
,
data
.
getDataLong
(
0
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S3_LTE
,
data
.
getDataLong
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S5_LTE
,
data
.
getDataLong
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S5_GT
,
data
.
getDataLong
(
3
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_SUMMARY
,
data
.
getDataLong
(
4
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_ERROR
,
data
.
getDataLong
(
5
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_COST_SUMMARY
,
data
.
getDataLong
(
6
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
7
));
String
sql
=
SqlBuilder
.
buildBatchInsertSql
(
ServiceReferenceTable
.
TABLE
,
source
.
keySet
());
entity
.
setSql
(
sql
);
entity
.
setParams
(
source
.
values
().
toArray
(
new
Object
[
0
]));
return
entity
;
}
@Override
public
H2SqlEntity
prepareBatchUpdate
(
Data
data
)
{
H2SqlEntity
entity
=
new
H2SqlEntity
();
Map
<
String
,
Object
>
source
=
new
HashMap
<>();
source
.
put
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_ID
,
data
.
getDataInteger
(
0
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_ENTRY_SERVICE_NAME
,
data
.
getDataString
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_ID
,
data
.
getDataInteger
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_FRONT_SERVICE_NAME
,
data
.
getDataString
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_ID
,
data
.
getDataInteger
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_BEHIND_SERVICE_NAME
,
data
.
getDataString
(
3
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S1_LTE
,
data
.
getDataLong
(
0
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S3_LTE
,
data
.
getDataLong
(
1
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S5_LTE
,
data
.
getDataLong
(
2
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_S5_GT
,
data
.
getDataLong
(
3
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_SUMMARY
,
data
.
getDataLong
(
4
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_ERROR
,
data
.
getDataLong
(
5
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_COST_SUMMARY
,
data
.
getDataLong
(
6
));
source
.
put
(
ServiceReferenceTable
.
COLUMN_TIME_BUCKET
,
data
.
getDataLong
(
7
));
String
id
=
data
.
getDataString
(
0
);
String
sql
=
SqlBuilder
.
buildBatchUpdateSql
(
ServiceReferenceTable
.
TABLE
,
source
.
keySet
(),
ServiceReferenceTable
.
COLUMN_ID
);
entity
.
setSql
(
sql
);
List
<
Object
>
values
=
new
ArrayList
<>(
source
.
values
());
values
.
add
(
id
);
entity
.
setParams
(
values
.
toArray
(
new
Object
[
0
]));
return
entity
;
}
}
apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/h2_dao.define
浏览文件 @
7abec320
...
...
@@ -2,4 +2,18 @@ org.skywalking.apm.collector.storage.h2.dao.CpuMetricH2DAO
org.skywalking.apm.collector.storage.h2.dao.GCMetricH2DAO
org.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2DAO
org.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2DAO
org.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2DAO
\ No newline at end of file
org.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2DAO
org.skywalking.apm.collector.storage.h2.dao.ApplicationH2DAO
org.skywalking.apm.collector.storage.h2.dao.InstanceH2DAO
org.skywalking.apm.collector.storage.h2.dao.ServiceNameH2DAO
org.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2DAO
org.skywalking.apm.collector.storage.h2.dao.InstPerformanceH2DAO
org.skywalking.apm.collector.storage.h2.dao.NodeComponentH2DAO
org.skywalking.apm.collector.storage.h2.dao.NodeReferenceH2DAO
org.skywalking.apm.collector.storage.h2.dao.SegmentCostH2DAO
org.skywalking.apm.collector.storage.h2.dao.SegmentH2DAO
org.skywalking.apm.collector.storage.h2.dao.ServiceEntryH2DAO
org.skywalking.apm.collector.storage.h2.dao.ServiceReferenceH2DAO
org.skywalking.apm.collector.storage.h2.dao.ApplicationH2CacheDAO
org.skywalking.apm.collector.storage.h2.dao.InstanceH2CacheDAO
org.skywalking.apm.collector.storage.h2.dao.ServiceNameH2CacheDAO
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录