Cluster name not specified in java client and it is failing to communicate with cluster, no node available exceptio

Hi,

I am not setting any cluster name in elasticsearch java client. it use to work with ES1.x. In 5.x yml file i am specifying path.data=/../data/{clustername} [path.data: /home/vagrant/elasticsearch-5.5.1/data/qa-elasticsearch]. it is creating a directory with cluster name and nodes directory in it.

My java client unable to identify this cluster. I am setting only port and host to client. This code use to work with ES1.x.

Below is my elasticsearch.yml

cluster.name: 'qa-elasticsearch'
node.name:    'localhost'


#################################### Paths ####################################

path.data: /home/vagrant/elasticsearch-5.5.1/data/qa-elasticsearch
path.logs: /home/vagrant/elasticsearch-5.5.1/logs
#path.conf: /usr/local/etc/elasticsearch


transport.host: localhost
network.host: 0.0.0.0
network.bind_host: '0.0.0.0'
transport.bind_host: 0.0.0.0
transport.tcp.port: 9300
http.port: 9200

bootstrap.system_call_filter: false
indices.query.bool.max_clause_count: 10240

client code:

@Autowired
    public CreateElasticSearchClient(@Qualifier("transportClient") Client client, SearchConfig searchConfig) {
        this.client = client;
        if (client instanceof TransportClient) {
            for (String hostName : searchConfig.searchServerHosts().split(",")) {
                try {
                    ((TransportClient) this.client).addTransportAddress(
                            new InetSocketTransportAddress(InetAddress.getByName(hostName), searchConfig.searchTransportPort()));
                } catch (UnknownHostException e) {
                    LOGGER.error(e.getMessage(),e);
                }
            }
        }
    }

getting No node available exception.

Thanks

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

I edited your post.

What do you have in searchConfig object?
What are elasticsearch server logs please?

Hi,

SearchConfig is my custom object which holds the host and port number of cluster.

Below exception i am getting in my java client console. Not seeing anything in cluster logs.

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{P4AAYjiKTq6PRgZePPMo3g}{localhost}{127.0.0.1:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:363)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:397)
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1250)
at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.putMapping(AbstractClient.java:1497)
at

I understand what SearchConfig is. I'd like to know what are the values you passed in it.

For logs, I'd like to see the logs when elasticsearch starts.

And please don't forget to format the code (or logs).

I understand what SearchConfig is. I'd like to know what are the values you passed in it.

For logs, I'd like to see the logs when elasticsearch starts.

And please don't forget to format the code (or logs).

SerchConfig has two values set in it.

search.server.hosts=localhost
search.server.transport.port=9300

below is my log from ES5.4.1 logs:

[2017-11-08T14:42:10,253][INFO ][o.e.n.Node               ] [localhost] initializing ...
[2017-11-08T14:42:10,407][INFO ][o.e.e.NodeEnvironment    ] [localhost] using [1] data paths, mounts [[/ (/dev/mapper/VolGroup-lv_root)]], net usable_space [451.6gb], net total_space [489.2gb], spins? [possibly], types [ext4]
[2017-11-08T14:42:10,408][INFO ][o.e.e.NodeEnvironment    ] [localhost] heap size [1.9gb], compressed ordinary object pointers [true]
[2017-11-08T14:42:10,466][INFO ][o.e.n.Node               ] [localhost] node name [localhost], node ID [CwCsYqDaSHSeU8OQdBJMqw]
[2017-11-08T14:42:10,466][INFO ][o.e.n.Node               ] [localhost] version[5.5.1], pid[4608], build[19c13d0/2017-07-18T20:44:24.823Z], OS[Linux/2.6.32-358.el6.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_112/25.112-b15]
[2017-11-08T14:42:10,472][INFO ][o.e.n.Node               ] [localhost] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/media/sf_KC/elasticsearch5.x/elasticsearch-5.5.1]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [aggs-matrix-stats]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [ingest-common]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [lang-expression]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [lang-groovy]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [lang-mustache]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [lang-painless]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [parent-join]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [percolator]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [reindex]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [transport-netty3]
[2017-11-08T14:42:13,021][INFO ][o.e.p.PluginsService     ] [localhost] loaded module [transport-netty4]
[2017-11-08T14:42:13,023][INFO ][o.e.p.PluginsService     ] [localhost] no plugins loaded
[2017-11-08T14:42:16,504][INFO ][o.e.d.DiscoveryModule    ] [localhost] using discovery type [zen]
[2017-11-08T14:42:17,659][INFO ][o.e.n.Node               ] [localhost] initialized
[2017-11-08T14:42:17,660][INFO ][o.e.n.Node               ] [localhost] starting ...
[2017-11-08T14:42:17,944][INFO ][o.e.t.TransportService   ] [localhost] publish_address {127.0.0.1:9300}, bound_addresses {[::]:9300}
[2017-11-08T14:42:17,964][INFO ][o.e.b.BootstrapChecks    ] [localhost] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-11-08T14:42:21,154][INFO ][o.e.c.s.ClusterService   ] [localhost] new_master {localhost}{CwCsYqDaSHSeU8OQdBJMqw}{FcTm9pKzT6CtDCha--RwcA}{localhost}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-11-08T14:42:21,222][INFO ][o.e.h.n.Netty4HttpServerTransport] [localhost] publish_address {10.0.2.15:9200}, bound_addresses {[::]:9200}
[2017-11-08T14:42:21,222][INFO ][o.e.n.Node               ] [localhost] started
[2017-11-08T14:42:21,840][INFO ][o.e.g.GatewayService     ] [localhost] recovered [6] indices into cluster_state
[2017-11-08T14:42:22,898][INFO ][o.e.c.r.a.AllocationService] [localhost] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[default.tenant.com-30715f972f4194d07e25d8f15a91dd14-b2b-kc-resources][1], [default.tenant.com-30715f972f4194d07e25d8f15a91dd14-b2b-kc-resources][4], [default.tenant.com-30715f972f4194d07e25d8f15a91dd14-b2b-kc-resources][0], [default.tenant.com-30715f972f4194d07e25d8f15a91dd14-b2b-kc-resources][3]] ...]).

Thanks

Could you try with 127.0.0.1 as the address instead of localhost?

Hi,

It was working with host as "locahost" and clustername in yml file as "elasticsearch".
The only change i made here is, changed cluster name to "qa-elasticsearch" in yml file.

No where i am setting cluster name in java. previously and now also.

We are migrating from 1.x to 5.x. In 1.x also we were not setting the cluster name in java client. It is working (cluster name "qa-cluster").

As per your suggestion i changed it to 127.0.0.1. Getting same exception.


"nodes" initialized in else block, but code not entering that else block. hence i am getting exception.

Further anylysis,

if (!ignoreClusterName && !clusterName.equals(livenessResponse.getClusterName())) {
                        logger.warn("node {} not part of the cluster {}, ignoring...", listedNode, clusterName);
                        newFilteredNodes.add(listedNode);
                    }

My code entering this if loop meaning it is not ignoring elastic cluster name(ignoreClusterName =false).
below is my code to create client object.

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY);

I solved the issue..

setting this property in Settings.
"client.transport.ignore_cluster_name","true"

Thanks David Pilato for your support. Thank you so much.. :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.