Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
润土的好友猹
SkyWalking
提交
118485fb
S
SkyWalking
项目概览
润土的好友猹
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
9
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,发现更多精彩内容 >>
提交
118485fb
编写于
5月 10, 2019
作者:
彭
彭勇升 pengys
提交者:
wu-sheng
5月 10, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make the elasticsearch json object build to be a public method. (#2648)
上级
3a318128
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
73 deletion
+33
-73
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java
...g/oap/server/storage/plugin/elasticsearch/base/EsDAO.java
+20
-1
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java
...storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java
+2
-5
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java
...erver/storage/plugin/elasticsearch/base/MetricsEsDAO.java
+4
-31
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java
...server/storage/plugin/elasticsearch/base/RecordEsDAO.java
+3
-16
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java
...rver/storage/plugin/elasticsearch/base/RegisterEsDAO.java
+4
-20
未找到文件。
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java
浏览文件 @
118485fb
...
...
@@ -18,10 +18,14 @@
package
org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base
;
import
java.io.IOException
;
import
java.util.Map
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.Metrics
;
import
org.apache.skywalking.oap.server.core.query.sql.Where
;
import
org.apache.skywalking.oap.server.core.storage.AbstractDAO
;
import
org.apache.skywalking.oap.server.core.storage.type.StorageDataType
;
import
org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient
;
import
org.elasticsearch.common.xcontent.*
;
import
org.elasticsearch.index.query.*
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
...
...
@@ -34,7 +38,7 @@ public abstract class EsDAO extends AbstractDAO<ElasticSearchClient> {
super
(
client
);
}
p
ublic
final
void
queryBuild
(
SearchSourceBuilder
sourceBuilder
,
Where
where
,
long
startTB
,
long
endTB
)
{
p
rotected
final
void
queryBuild
(
SearchSourceBuilder
sourceBuilder
,
Where
where
,
long
startTB
,
long
endTB
)
{
RangeQueryBuilder
rangeQueryBuilder
=
QueryBuilders
.
rangeQuery
(
Metrics
.
TIME_BUCKET
).
gte
(
startTB
).
lte
(
endTB
);
if
(
where
.
getKeyValues
().
isEmpty
())
{
sourceBuilder
.
query
(
rangeQueryBuilder
);
...
...
@@ -53,4 +57,19 @@ public abstract class EsDAO extends AbstractDAO<ElasticSearchClient> {
}
sourceBuilder
.
size
(
0
);
}
XContentBuilder
map2builder
(
Map
<
String
,
Object
>
objectMap
)
throws
IOException
{
XContentBuilder
builder
=
XContentFactory
.
jsonBuilder
().
startObject
();
for
(
String
key
:
objectMap
.
keySet
())
{
Object
value
=
objectMap
.
get
(
key
);
if
(
value
instanceof
StorageDataType
)
{
builder
.
field
(
key
,
((
StorageDataType
)
value
).
toStorageData
());
}
else
{
builder
.
field
(
key
,
value
);
}
}
builder
.
endObject
();
return
builder
;
}
}
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java
浏览文件 @
118485fb
...
...
@@ -18,13 +18,10 @@
package
org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base
;
import
java.io.IOException
;
import
org.apache.skywalking.oap.server.core.storage.IHistoryDeleteDAO
;
import
org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
org.slf4j.*
;
/**
* @author peng-yongsheng
...
...
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java
浏览文件 @
118485fb
...
...
@@ -19,27 +19,22 @@
package
org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base
;
import
java.io.IOException
;
import
java.util.Map
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.Metrics
;
import
org.apache.skywalking.oap.server.core.storage.*
;
import
org.apache.skywalking.oap.server.core.storage.type.StorageDataType
;
import
org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.action.index.IndexRequest
;
import
org.elasticsearch.action.update.UpdateRequest
;
import
org.elasticsearch.common.xcontent.*
;
import
org.slf4j.*
;
import
org.elasticsearch.common.xcontent.XContentBuilder
;
/**
* @author peng-yongsheng
*/
public
class
MetricsEsDAO
extends
EsDAO
implements
IMetricsDAO
<
IndexRequest
,
UpdateRequest
>
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MetricsEsDAO
.
class
);
private
final
StorageBuilder
<
Metrics
>
storageBuilder
;
public
MetricsEsDAO
(
ElasticSearchClient
client
,
StorageBuilder
<
Metrics
>
storageBuilder
)
{
MetricsEsDAO
(
ElasticSearchClient
client
,
StorageBuilder
<
Metrics
>
storageBuilder
)
{
super
(
client
);
this
.
storageBuilder
=
storageBuilder
;
}
...
...
@@ -54,34 +49,12 @@ public class MetricsEsDAO extends EsDAO implements IMetricsDAO<IndexRequest, Upd
}
@Override
public
IndexRequest
prepareBatchInsert
(
String
modelName
,
Metrics
metrics
)
throws
IOException
{
Map
<
String
,
Object
>
objectMap
=
storageBuilder
.
data2Map
(
metrics
);
XContentBuilder
builder
=
XContentFactory
.
jsonBuilder
().
startObject
();
for
(
String
key
:
objectMap
.
keySet
())
{
Object
value
=
objectMap
.
get
(
key
);
if
(
value
instanceof
StorageDataType
)
{
builder
.
field
(
key
,
((
StorageDataType
)
value
).
toStorageData
());
}
else
{
builder
.
field
(
key
,
value
);
}
}
builder
.
endObject
();
XContentBuilder
builder
=
map2builder
(
storageBuilder
.
data2Map
(
metrics
));
return
getClient
().
prepareInsert
(
modelName
,
metrics
.
id
(),
builder
);
}
@Override
public
UpdateRequest
prepareBatchUpdate
(
String
modelName
,
Metrics
metrics
)
throws
IOException
{
Map
<
String
,
Object
>
objectMap
=
storageBuilder
.
data2Map
(
metrics
);
XContentBuilder
builder
=
XContentFactory
.
jsonBuilder
().
startObject
();
for
(
String
key
:
objectMap
.
keySet
())
{
Object
value
=
objectMap
.
get
(
key
);
if
(
value
instanceof
StorageDataType
)
{
builder
.
field
(
key
,
((
StorageDataType
)
value
).
toStorageData
());
}
else
{
builder
.
field
(
key
,
value
);
}
}
builder
.
endObject
();
XContentBuilder
builder
=
map2builder
(
storageBuilder
.
data2Map
(
metrics
));
return
getClient
().
prepareUpdate
(
modelName
,
metrics
.
id
(),
builder
);
}
}
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java
浏览文件 @
118485fb
...
...
@@ -19,13 +19,11 @@
package
org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base
;
import
java.io.IOException
;
import
java.util.Map
;
import
org.apache.skywalking.oap.server.core.analysis.record.Record
;
import
org.apache.skywalking.oap.server.core.storage.*
;
import
org.apache.skywalking.oap.server.core.storage.type.StorageDataType
;
import
org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient
;
import
org.elasticsearch.action.index.IndexRequest
;
import
org.elasticsearch.common.xcontent.
*
;
import
org.elasticsearch.common.xcontent.
XContentBuilder
;
/**
* @author peng-yongsheng
...
...
@@ -34,24 +32,13 @@ public class RecordEsDAO extends EsDAO implements IRecordDAO<IndexRequest> {
private
final
StorageBuilder
<
Record
>
storageBuilder
;
public
RecordEsDAO
(
ElasticSearchClient
client
,
StorageBuilder
<
Record
>
storageBuilder
)
{
RecordEsDAO
(
ElasticSearchClient
client
,
StorageBuilder
<
Record
>
storageBuilder
)
{
super
(
client
);
this
.
storageBuilder
=
storageBuilder
;
}
@Override
public
IndexRequest
prepareBatchInsert
(
String
modelName
,
Record
record
)
throws
IOException
{
Map
<
String
,
Object
>
objectMap
=
storageBuilder
.
data2Map
(
record
);
XContentBuilder
builder
=
XContentFactory
.
jsonBuilder
().
startObject
();
for
(
String
key
:
objectMap
.
keySet
())
{
Object
value
=
objectMap
.
get
(
key
);
if
(
value
instanceof
StorageDataType
)
{
builder
.
field
(
key
,
((
StorageDataType
)
value
).
toStorageData
());
}
else
{
builder
.
field
(
key
,
value
);
}
}
builder
.
endObject
();
XContentBuilder
builder
=
map2builder
(
storageBuilder
.
data2Map
(
record
));
return
getClient
().
prepareInsert
(
modelName
,
record
.
id
(),
builder
);
}
}
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java
浏览文件 @
118485fb
...
...
@@ -19,24 +19,20 @@
package
org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base
;
import
java.io.IOException
;
import
java.util.Map
;
import
org.apache.skywalking.oap.server.core.register.RegisterSource
;
import
org.apache.skywalking.oap.server.core.storage.*
;
import
org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient
;
import
org.elasticsearch.action.get.GetResponse
;
import
org.elasticsearch.common.xcontent.*
;
import
org.slf4j.*
;
import
org.elasticsearch.common.xcontent.XContentBuilder
;
/**
* @author peng-yongsheng
*/
public
class
RegisterEsDAO
extends
EsDAO
implements
IRegisterDAO
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RegisterEsDAO
.
class
);
private
final
StorageBuilder
<
RegisterSource
>
storageBuilder
;
public
RegisterEsDAO
(
ElasticSearchClient
client
,
StorageBuilder
<
RegisterSource
>
storageBuilder
)
{
RegisterEsDAO
(
ElasticSearchClient
client
,
StorageBuilder
<
RegisterSource
>
storageBuilder
)
{
super
(
client
);
this
.
storageBuilder
=
storageBuilder
;
}
...
...
@@ -51,24 +47,12 @@ public class RegisterEsDAO extends EsDAO implements IRegisterDAO {
}
@Override
public
void
forceInsert
(
String
modelName
,
RegisterSource
source
)
throws
IOException
{
XContentBuilder
builder
=
build
(
source
);
XContentBuilder
builder
=
map2builder
(
storageBuilder
.
data2Map
(
source
)
);
getClient
().
forceInsert
(
modelName
,
source
.
id
(),
builder
);
}
@Override
public
void
forceUpdate
(
String
modelName
,
RegisterSource
source
)
throws
IOException
{
XContentBuilder
builder
=
build
(
source
);
XContentBuilder
builder
=
map2builder
(
storageBuilder
.
data2Map
(
source
)
);
getClient
().
forceUpdate
(
modelName
,
source
.
id
(),
builder
);
}
private
XContentBuilder
build
(
RegisterSource
source
)
throws
IOException
{
Map
<
String
,
Object
>
objectMap
=
storageBuilder
.
data2Map
(
source
);
XContentBuilder
builder
=
XContentFactory
.
jsonBuilder
().
startObject
();
for
(
String
key
:
objectMap
.
keySet
())
{
builder
.
field
(
key
,
objectMap
.
get
(
key
));
}
builder
.
endObject
();
return
builder
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录