I am trying to create transport client for our remote 2 node es cluster
(version 1.3) in java. When I use "hardcoded" cluster details all works
just fine as code follows:
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",
"elasticsearch").build();
final Client client = new TransportClient(settings)
.addTransportAddress(new
InetSocketTransportAddress("bd-es1", 9300))
.addTransportAddress(new
InetSocketTransportAddress("bd-es2", 9300));
But when I try to use setting file elasticsearch.yml located in resources
with content like following:
INFO: [Bandit] loaded [], sites []
Exception in thread "main"
org.elasticsearch.client.transport.NoNodeAvailableException: None of the
configured nodes are available: []
at
org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:278)
at
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:197)
at
org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)
at
org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)
at
org.elasticsearch.client.transport.TransportClient.get(TransportClient.java:384)
at
org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
at com.ncr.bigdata.es.HelloElasticSearch.main(HelloElasticSearch.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Settings beginning with "es.*" are new to me in config files. They are only
for command line.
So I think es.nodes and es.port are ignored.
Beside that, the settings for the TransportClient do not set the host(s) to
connect to, they set the node of the TransportClient itself (which is quite
menaningless with regard to the connection settings).
I am trying to create transport client for our remote 2 node es cluster
(version 1.3) in java. When I use "hardcoded" cluster details all works
just fine as code follows:
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",
"elasticsearch").build();
final Client client = new TransportClient(settings)
.addTransportAddress(new
InetSocketTransportAddress("bd-es1", 9300))
.addTransportAddress(new
InetSocketTransportAddress("bd-es2", 9300));
But when I try to use setting file elasticsearch.yml located in resources
with content like following:
INFO: [Bandit] loaded , sites
Exception in thread "main"
org.elasticsearch.client.transport.NoNodeAvailableException: None of the
configured nodes are available:
at
org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:278)
at
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:197)
at
org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)
at
org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:193)
at
org.elasticsearch.client.transport.TransportClient.get(TransportClient.java:384)
at
org.elasticsearch.action.get.GetRequestBuilder.doExecute(GetRequestBuilder.java:201)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
at com.ncr.bigdata.es.HelloElasticSearch.main(HelloElasticSearch.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
I use this mechanism, e.g., to first locate the services in question in a
Zookeeper-based directory, and then fill in the necessary data as an
Elasticsearch node/client starts up.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.