ElasticSearch 2.0 Transport Client - No Node Available exception

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ElasticSearch 2.0 Transport Client - No Node Available exception

sanesearch
This post has NOT been accepted by the mailing list yet.
This post was updated on .
[Using ElasticSearch version 2.0]

In etc/hosts file  "esnode" is mapped to IP address(some other machine where ES is running) as shown

192.168.2.219   esnode

The Transport Client code is ::

public Client getClient() {
                if ((this.client == null)) {
                        try {
                                Settings settings = Settings.settingsBuilder()
                                                .put("cluster.name", "myclustername").build();
                                TransportClient tClient = TransportClient.builder().settings(settings).build();
                                String[] nodes = "esnode:9300".split(COMMA);
                                for (String node : nodes) {
                                        String[] hostPort = node.split(COLON);
                                       
                                        tClient.addTransportAddress(new InetSocketTransportAddress(
                                                        InetAddress.getByName(hostPort[0]), Integer.parseInt(hostPort[1])));
                                }
                                this.client = tClient;

                        } catch (Exception e) {
                                e.printStackTrace();
                        }
                }
                return this.client;
        }

This client code runs but when executing the below code :
              this.getClient().prepareGet(indexName, typeName, String.valueOf(id)).get();

The exception is thrown:

NoNodeAvailableException[None of the configured nodes are available: []]
        at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:280)
        at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:197)
        at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
        at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:272)
        at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
        at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
        at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)
        at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:67)
       

I have also tried using IPAddress instead of host name. The above code runs properly if

esnode is mapped to 127.0.0.1

Can somebody help...