popgis
(Chunrong Liu)
August 25, 2016, 4:22am
1
Hi, everyone.
I have installed and configured the three ElasticSearch hosts with cluster.
It's OK when I use the HTTP API, but excepted when I use transport mode by Java client API.
The ElasticSearch server version is 2.3.4.
The exception happen like the following:
injector = {org.elasticsearch.common.inject.InjectorImpl@3026} Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate org.elasticsearch.common.inject.InjectorImpl.toString()
state = {org.elasticsearch.common.inject.InheritingState@3088}
parent = null
readOnly = true
bindingsMultimap = {org.elasticsearch.common.inject.InjectorImpl$BindingsMultimap@3089}
initializer = {org.elasticsearch.common.inject.Initializer@3090}
jitBindings = {java.util.HashMap@3091} size = 0
lookups = {org.elasticsearch.common.inject.InjectorImpl@3026} Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate org.elasticsearch.common.inject.InjectorImpl.toString()
constructors = {org.elasticsearch.common.inject.ConstructorInjectorStore@3092}
membersInjectorStore = {org.elasticsearch.common.inject.MembersInjectorStore@3093}
localContext = {org.elasticsearch.common.inject.InjectorImpl$1@3094}
My hosts is:
hosts = {java.lang.String@3022} "10.144.153.10:9300,10.163.250.111:9300,10.144.188.13:9300"
cluster = {java.lang.String@3023} "multway"
The client settings is:
settings = {com.google.common.collect.RegularImmutableSortedMap@3058} size = 7
0 = {com.google.common.collect.ImmutableEntry@3064} "client.transport.sniff=false"
1 = {com.google.common.collect.ImmutableEntry@3065} "client.type" -> "transport"
2 = {com.google.common.collect.ImmutableEntry@3066} "cluster.name " -> "multway"
3 = {com.google.common.collect.ImmutableEntry@3067} "name" -> "Gravity"
4 = {com.google.common.collect.ImmutableEntry@3068} "network.server" -> "false"
5 = {com.google.common.collect.ImmutableEntry@3069} "node.client" -> "true"
6 = {com.google.common.collect.ImmutableEntry@3070} "transport.ping_schedule" -> "5s"
forcedUnderscoreSettings = {com.google.common.collect.EmptyImmutableBiMap@3059} size = 0
The cluster health status is green.
{
cluster_name: "multway",
status: "green",
timed_out: false,
number_of_nodes: 3,
number_of_data_nodes: 3,
active_primary_shards: 10,
active_shards: 20,
relocating_shards: 0,
initializing_shards: 0,
unassigned_shards: 0,
delayed_unassigned_shards: 0,
number_of_pending_tasks: 0,
number_of_in_flight_fetch: 0,
task_max_waiting_in_queue_millis: 0,
active_shards_percent_as_number: 100
}
Please give me some suggestions.
Thanks.
popgis
(Chunrong Liu)
August 25, 2016, 4:28am
2
The elasticsearch.yaml content of the els1 node:
cluster.name : multway
node.name : els1
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["10.144.153.10:9300", "10.163.250.111:9300", "10.144.188.13:9300"]
discovery.zen.minimum_master_nodes: 2
The others node's elasticsearch.yaml file content is similar except for the node name.
popgis
(Chunrong Liu)
August 25, 2016, 5:24am
3
The following content is the source codes of the client side.
private Client createClient(String hosts, String cluster) {
logger.info ("the elasticsearch host: " + hosts + ", cluster is " + cluster);
Client client = null;
try {
TransportClient build = null;
if(null != cluster && !cluster.trim().isEmpty()) {
Settings settings = Settings.settingsBuilder()
.put("client.transport.sniff", false)
.put("cluster.name", cluster).build();
build = TransportClient.builder().settings(settings).build();
logger.info("initialized the cluster elasticsearch client settings!");
} else {
build = TransportClient.builder().build();
}
String[] hostArr = hosts.split(",");
for(String item : hostArr) {
String[] hps = item.split(":");
String host = "127.0.0.1";
Integer port = 9300;
if(hps.length > 0) {
host = hps[0];
}
if(hps.length > 1) {
port = Integer.parseInt(hps[1]);
}
logger.info("the elasticsearch host is " + host + ", port is " + port);
InetAddress address = null;
String ipExp = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";
Pattern pat = Pattern.compile(ipExp);
Matcher matcher = pat.matcher(host);
if (matcher.matches()) {
String[] segs = host.split("\\.");
byte[] bs = new byte[]{Short.valueOf(segs[0]).byteValue(),
Short.valueOf(segs[1]).byteValue(),
Short.valueOf(segs[2]).byteValue(),
Short.valueOf(segs[3]).byteValue()};
address = InetAddress.getByAddress(bs);
} else {
address = InetAddress.getByName(host);
}
build.addTransportAddress(new InetSocketTransportAddress(address, port));
}
client = build;
} catch (UnknownHostException e) {
logger.error("failed to initialize the elasticsearch client with the unknown host!", e);
} catch (Exception e) {
logger.error("failed to initialize the elasticsearch client!", e);
}
return client;
}
jprante
(Jörg Prante)
August 25, 2016, 7:09am
4
popgis:
"node.client" -> "true"
This setting is for a node client, not for a transport client .
popgis
(Chunrong Liu)
August 25, 2016, 3:01pm
5
You means that I should create settings like this:
Settings settings = Settings.settingsBuilder()
.put("client.node", true)
.put("client.transport.sniff", false)
.put("cluster.name ", cluster).build();
But It's not work still.
The 'java.lang.StackOverflowError' exception exists.
kusid
(Kusid)
December 29, 2016, 6:12pm
6
Were you able to solve this?
skyfall
(dingx)
February 21, 2017, 12:52am
7
我也遇到一样的问题了..你解决没?我es-2.4.4,配置也都差不多
popgis
(Chunrong Liu)
February 21, 2017, 4:51am
8
popgis
(Chunrong Liu)
February 21, 2017, 4:52am
9
please read the official document about it.
popgis
(Chunrong Liu)
February 21, 2017, 4:59am
10
jprante:
node.client
还有一个客户端设置需要注意:
Settings settings = Settings.settingsBuilder()
.put("client.transport.sniff", true)
popgis
(Chunrong Liu)
February 21, 2017, 5:00am
11
skyfall
(dingx)
February 21, 2017, 6:16am
12
谢谢哥们啊 设置我没改动 忽略这个问题 继续跑下去 就能获取结果 这个溢出放着了