Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
5624417c
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,发现更多精彩内容 >>
提交
5624417c
编写于
3月 26, 2018
作者:
X
Xin,Zhang
提交者:
wu-sheng
3月 26, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Collector] fix the collector cannot started (#987)
上级
061a4d4c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
14 deletion
+89
-14
apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java
...m/collector/client/elasticsearch/ElasticSearchClient.java
+56
-12
apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/elasticsearch/ElasticSearchClientNotReadyException.java
...t/elasticsearch/ElasticSearchClientNotReadyException.java
+29
-0
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java
...ing/apm/collector/storage/es/StorageModuleEsProvider.java
+4
-2
未找到文件。
apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java
浏览文件 @
5624417c
...
@@ -16,9 +16,13 @@
...
@@ -16,9 +16,13 @@
*
*
*/
*/
package
org.apache.skywalking.apm.collector.client.elasticsearch
;
package
org.apache.skywalking.apm.collector.client.elasticsearch
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.function.Consumer
;
import
org.apache.skywalking.apm.collector.client.Client
;
import
org.apache.skywalking.apm.collector.client.Client
;
import
org.apache.skywalking.apm.collector.client.ClientException
;
import
org.apache.skywalking.apm.collector.client.ClientException
;
import
org.apache.skywalking.apm.collector.core.util.StringUtils
;
import
org.apache.skywalking.apm.collector.core.util.StringUtils
;
...
@@ -43,12 +47,6 @@ import org.elasticsearch.transport.client.PreBuiltTransportClient;
...
@@ -43,12 +47,6 @@ import org.elasticsearch.transport.client.PreBuiltTransportClient;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.function.Consumer
;
/**
/**
* @author peng-yongsheng
* @author peng-yongsheng
*/
*/
...
@@ -58,16 +56,17 @@ public class ElasticSearchClient implements Client {
...
@@ -58,16 +56,17 @@ public class ElasticSearchClient implements Client {
private
org
.
elasticsearch
.
client
.
Client
client
;
private
org
.
elasticsearch
.
client
.
Client
client
;
private
final
String
namespace
;
private
final
String
clusterName
;
private
final
String
clusterName
;
private
final
Boolean
clusterTransportSniffer
;
private
final
Boolean
clusterTransportSniffer
;
private
final
String
clusterNodes
;
private
final
String
clusterNodes
;
public
ElasticSearchClient
(
String
namespace
,
String
clusterName
,
Boolean
clusterTransportSniffer
,
String
clusterNodes
)
{
private
boolean
ready
=
false
;
this
.
namespace
=
namespace
;
private
String
namespace
;
public
ElasticSearchClient
(
String
clusterName
,
Boolean
clusterTransportSniffer
,
String
clusterNodes
)
{
this
.
clusterName
=
clusterName
;
this
.
clusterName
=
clusterName
;
this
.
clusterTransportSniffer
=
clusterTransportSniffer
;
this
.
clusterTransportSniffer
=
clusterTransportSniffer
;
this
.
clusterNodes
=
clusterNodes
;
this
.
clusterNodes
=
clusterNodes
;
...
@@ -90,6 +89,8 @@ public class ElasticSearchClient implements Client {
...
@@ -90,6 +89,8 @@ public class ElasticSearchClient implements Client {
throw
new
ElasticSearchClientException
(
e
.
getMessage
(),
e
);
throw
new
ElasticSearchClientException
(
e
.
getMessage
(),
e
);
}
}
}
}
this
.
ready
=
true
;
}
}
@Override
@Override
...
@@ -110,6 +111,14 @@ public class ElasticSearchClient implements Client {
...
@@ -110,6 +111,14 @@ public class ElasticSearchClient implements Client {
return
pairsList
;
return
pairsList
;
}
}
public
void
setNamespace
(
String
namespace
)
throws
ElasticSearchClientException
{
if
(!
ready
)
{
this
.
namespace
=
namespace
;
}
else
{
throw
new
ElasticSearchClientException
(
"The namespace cannot be set after ElasticSearchClient is ready."
);
}
}
class
AddressPairs
{
class
AddressPairs
{
private
String
host
;
private
String
host
;
private
Integer
port
;
private
Integer
port
;
...
@@ -121,6 +130,10 @@ public class ElasticSearchClient implements Client {
...
@@ -121,6 +130,10 @@ public class ElasticSearchClient implements Client {
}
}
public
boolean
createIndex
(
String
indexName
,
String
indexType
,
Settings
settings
,
XContentBuilder
mappingBuilder
)
{
public
boolean
createIndex
(
String
indexName
,
String
indexType
,
Settings
settings
,
XContentBuilder
mappingBuilder
)
{
if
(!
ready
)
{
throw
new
ElasticSearchClientNotReadyException
();
}
IndicesAdminClient
adminClient
=
client
.
admin
().
indices
();
IndicesAdminClient
adminClient
=
client
.
admin
().
indices
();
indexName
=
formatIndexName
(
indexName
);
indexName
=
formatIndexName
(
indexName
);
CreateIndexResponse
response
=
adminClient
.
prepareCreate
(
indexName
).
setSettings
(
settings
).
addMapping
(
indexType
,
mappingBuilder
).
get
();
CreateIndexResponse
response
=
adminClient
.
prepareCreate
(
indexName
).
setSettings
(
settings
).
addMapping
(
indexType
,
mappingBuilder
).
get
();
...
@@ -129,6 +142,10 @@ public class ElasticSearchClient implements Client {
...
@@ -129,6 +142,10 @@ public class ElasticSearchClient implements Client {
}
}
public
boolean
deleteIndex
(
String
indexName
)
{
public
boolean
deleteIndex
(
String
indexName
)
{
if
(!
ready
)
{
throw
new
ElasticSearchClientNotReadyException
();
}
indexName
=
formatIndexName
(
indexName
);
indexName
=
formatIndexName
(
indexName
);
IndicesAdminClient
adminClient
=
client
.
admin
().
indices
();
IndicesAdminClient
adminClient
=
client
.
admin
().
indices
();
DeleteIndexResponse
response
=
adminClient
.
prepareDelete
(
indexName
).
get
();
DeleteIndexResponse
response
=
adminClient
.
prepareDelete
(
indexName
).
get
();
...
@@ -137,6 +154,10 @@ public class ElasticSearchClient implements Client {
...
@@ -137,6 +154,10 @@ public class ElasticSearchClient implements Client {
}
}
public
boolean
isExistsIndex
(
String
indexName
)
{
public
boolean
isExistsIndex
(
String
indexName
)
{
if
(!
ready
)
{
throw
new
ElasticSearchClientNotReadyException
();
}
indexName
=
formatIndexName
(
indexName
);
indexName
=
formatIndexName
(
indexName
);
IndicesAdminClient
adminClient
=
client
.
admin
().
indices
();
IndicesAdminClient
adminClient
=
client
.
admin
().
indices
();
IndicesExistsResponse
response
=
adminClient
.
prepareExists
(
indexName
).
get
();
IndicesExistsResponse
response
=
adminClient
.
prepareExists
(
indexName
).
get
();
...
@@ -144,31 +165,55 @@ public class ElasticSearchClient implements Client {
...
@@ -144,31 +165,55 @@ public class ElasticSearchClient implements Client {
}
}
public
SearchRequestBuilder
prepareSearch
(
String
indexName
)
{
public
SearchRequestBuilder
prepareSearch
(
String
indexName
)
{
if
(!
ready
)
{
throw
new
ElasticSearchClientNotReadyException
();
}
indexName
=
formatIndexName
(
indexName
);
indexName
=
formatIndexName
(
indexName
);
return
client
.
prepareSearch
(
indexName
);
return
client
.
prepareSearch
(
indexName
);
}
}
public
IndexRequestBuilder
prepareIndex
(
String
indexName
,
String
id
)
{
public
IndexRequestBuilder
prepareIndex
(
String
indexName
,
String
id
)
{
if
(!
ready
)
{
throw
new
ElasticSearchClientNotReadyException
();
}
indexName
=
formatIndexName
(
indexName
);
indexName
=
formatIndexName
(
indexName
);
return
client
.
prepareIndex
(
indexName
,
"type"
,
id
);
return
client
.
prepareIndex
(
indexName
,
"type"
,
id
);
}
}
public
UpdateRequestBuilder
prepareUpdate
(
String
indexName
,
String
id
)
{
public
UpdateRequestBuilder
prepareUpdate
(
String
indexName
,
String
id
)
{
if
(!
ready
)
{
throw
new
ElasticSearchClientNotReadyException
();
}
indexName
=
formatIndexName
(
indexName
);
indexName
=
formatIndexName
(
indexName
);
return
client
.
prepareUpdate
(
indexName
,
"type"
,
id
);
return
client
.
prepareUpdate
(
indexName
,
"type"
,
id
);
}
}
public
GetRequestBuilder
prepareGet
(
String
indexName
,
String
id
)
{
public
GetRequestBuilder
prepareGet
(
String
indexName
,
String
id
)
{
if
(!
ready
)
{
throw
new
ElasticSearchClientNotReadyException
();
}
indexName
=
formatIndexName
(
indexName
);
indexName
=
formatIndexName
(
indexName
);
return
client
.
prepareGet
(
indexName
,
"type"
,
id
);
return
client
.
prepareGet
(
indexName
,
"type"
,
id
);
}
}
public
DeleteByQueryRequestBuilder
prepareDelete
(
QueryBuilder
queryBuilder
,
String
indexName
)
{
public
DeleteByQueryRequestBuilder
prepareDelete
(
QueryBuilder
queryBuilder
,
String
indexName
)
{
if
(!
ready
)
{
throw
new
ElasticSearchClientNotReadyException
();
}
indexName
=
formatIndexName
(
indexName
);
indexName
=
formatIndexName
(
indexName
);
return
DeleteByQueryAction
.
INSTANCE
.
newRequestBuilder
(
client
).
filter
(
queryBuilder
).
source
(
indexName
);
return
DeleteByQueryAction
.
INSTANCE
.
newRequestBuilder
(
client
).
filter
(
queryBuilder
).
source
(
indexName
);
}
}
public
MultiGetRequestBuilder
prepareMultiGet
(
List
<?>
rows
,
MultiGetRowHandler
rowHandler
)
{
public
MultiGetRequestBuilder
prepareMultiGet
(
List
<?>
rows
,
MultiGetRowHandler
rowHandler
)
{
if
(!
ready
)
{
throw
new
ElasticSearchClientNotReadyException
();
}
MultiGetRequestBuilder
prepareMultiGet
=
client
.
prepareMultiGet
();
MultiGetRequestBuilder
prepareMultiGet
=
client
.
prepareMultiGet
();
rowHandler
.
setPrepareMultiGet
(
prepareMultiGet
);
rowHandler
.
setPrepareMultiGet
(
prepareMultiGet
);
rowHandler
.
setNamespace
(
namespace
);
rowHandler
.
setNamespace
(
namespace
);
...
@@ -202,7 +247,6 @@ public class ElasticSearchClient implements Client {
...
@@ -202,7 +247,6 @@ public class ElasticSearchClient implements Client {
}
}
}
}
public
BulkRequestBuilder
prepareBulk
()
{
public
BulkRequestBuilder
prepareBulk
()
{
return
client
.
prepareBulk
();
return
client
.
prepareBulk
();
}
}
...
...
apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/elasticsearch/ElasticSearchClientNotReadyException.java
0 → 100644
浏览文件 @
5624417c
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.collector.client.elasticsearch
;
/**
* @author zhang xin
*/
public
class
ElasticSearchClientNotReadyException
extends
RuntimeException
{
public
ElasticSearchClientNotReadyException
()
{
super
(
"ElasticSearchClient not complete the initialization, Please call initializeFinished method before operation ElasticSearchClient."
);
}
}
apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java
浏览文件 @
5624417c
...
@@ -180,8 +180,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
...
@@ -180,8 +180,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
String
clusterName
=
config
.
getProperty
(
CLUSTER_NAME
);
String
clusterName
=
config
.
getProperty
(
CLUSTER_NAME
);
Boolean
clusterTransportSniffer
=
(
Boolean
)
config
.
get
(
CLUSTER_TRANSPORT_SNIFFER
);
Boolean
clusterTransportSniffer
=
(
Boolean
)
config
.
get
(
CLUSTER_TRANSPORT_SNIFFER
);
String
clusterNodes
=
config
.
getProperty
(
CLUSTER_NODES
);
String
clusterNodes
=
config
.
getProperty
(
CLUSTER_NODES
);
String
namespace
=
getManager
().
find
(
ConfigurationModule
.
NAME
).
getService
(
ICollectorConfig
.
class
).
getNamespace
();
elasticSearchClient
=
new
ElasticSearchClient
(
clusterName
,
clusterTransportSniffer
,
clusterNodes
);
elasticSearchClient
=
new
ElasticSearchClient
(
namespace
,
clusterName
,
clusterTransportSniffer
,
clusterNodes
);
this
.
registerServiceImplementation
(
IBatchDAO
.
class
,
new
BatchEsDAO
(
elasticSearchClient
));
this
.
registerServiceImplementation
(
IBatchDAO
.
class
,
new
BatchEsDAO
(
elasticSearchClient
));
registerCacheDAO
();
registerCacheDAO
();
...
@@ -196,6 +195,9 @@ public class StorageModuleEsProvider extends ModuleProvider {
...
@@ -196,6 +195,9 @@ public class StorageModuleEsProvider extends ModuleProvider {
Integer
indexShardsNumber
=
(
Integer
)
config
.
get
(
INDEX_SHARDS_NUMBER
);
Integer
indexShardsNumber
=
(
Integer
)
config
.
get
(
INDEX_SHARDS_NUMBER
);
Integer
indexReplicasNumber
=
(
Integer
)
config
.
get
(
INDEX_REPLICAS_NUMBER
);
Integer
indexReplicasNumber
=
(
Integer
)
config
.
get
(
INDEX_REPLICAS_NUMBER
);
try
{
try
{
String
namespace
=
getManager
().
find
(
ConfigurationModule
.
NAME
).
getService
(
ICollectorConfig
.
class
).
getNamespace
();
elasticSearchClient
.
setNamespace
(
namespace
);
elasticSearchClient
.
initialize
();
elasticSearchClient
.
initialize
();
ElasticSearchStorageInstaller
installer
=
new
ElasticSearchStorageInstaller
(
indexShardsNumber
,
indexReplicasNumber
);
ElasticSearchStorageInstaller
installer
=
new
ElasticSearchStorageInstaller
(
indexShardsNumber
,
indexReplicasNumber
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录