Elasticsearch Transportclient在集成测试中抛出NoNodeAvailableException

时间:2014-04-01 14:44:39

标签: java elasticsearch

所以我尝试连接到本地嵌入式Elasticsearch节点进行测试,该节点通常与其他测试一起使用。嵌入式节点也是local = true。它适用于另外两个测试,一个使用HTTP Rest API,另一个使用数据少节点客户端。他们都很好。

但是当我尝试像这样使用TransportClient时:

  Settings settings = ImmutableSettings.settingsBuilder()
                .put("client.transport.ignore_cluster_name", false)
                .put("cluster.name", clusterName)
                .put("client.transport.sniff", false)
                .put("client.transport.ping_timeout", pingTimeout)
                .put("client.transport.nodes_sampler_interval", pingSamplerInterval).build();

        client = new TransportClient(settings);

        String hostPieces[] = hosts.split(",");
        for (String piece : hostPieces){
            String hostAndPort[] = piece.trim().split(":");
            if (hostAndPort.length != 2){
                throw new IllegalArgumentException("Error in hosts string: "+ piece);
            }
            String host = hostAndPort[0].trim();
            String portStr = hostAndPort[1].trim();

            InetSocketTransportAddress address = new InetSocketTransportAddress(host, Integer.valueOf(portStr));

            client.addTransportAddress(address);
        }

虽然在乞讨时它似乎连接到本地节点,然后它就死了:

[2014-04-01 15:31:21,504][DEBUG][org.elasticsearch.client.transport] [Googam] adding address [[#transport#-1][d][inet[localhost/127.0.0.1:11547]]]
[2014-04-01 15:31:21,517][DEBUG][org.elasticsearch.transport.netty] [Googam] connected to node [[#transport#-1][d][inet[localhost/127.0.0.1:11547]]]
[2014-04-01 15:31:31,316][DEBUG][org.elasticsearch.cluster.service] [Sepulchre] processing [routing-table-updater]: execute
[2014-04-01 15:31:31,317][DEBUG][org.elasticsearch.cluster.service] [Sepulchre] processing [routing-table-updater]: no change in cluster_state
[2014-04-01 15:32:16,521][INFO ][org.elasticsearch.client.transport] [Googam] failed to get node info for [#transport#-1][d][inet[localhost/127.0.0.1:11547]], disconnecting...
org.elasticsearch.transport.ReceiveTimeoutTransportException: [][inet[localhost/127.0.0.1:11547]][cluster/nodes/info] request_id [0] timed out after [55001ms]
    at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:356)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
[2014-04-01 15:32:16,525][DEBUG][org.elasticsearch.transport.netty] [Googam] disconnected from [[#transport#-1][d][inet[localhost/127.0.0.1:11547]]]
[2014-04-01 15:32:16,527][DEBUG][org.elasticsearch.transport.netty] [Googam] connected to node [[#transport#-1][d][inet[localhost/127.0.0.1:11547]]]
[2014-04-01 15:32:16,530][INFO ][org.elasticsearch.node   ] [Sepulchre] stopping ...
[2014-04-01 15:32:16,530][DEBUG][org.elasticsearch.transport.netty] [Googam] disconnected from [[#transport#-1][d][inet[localhost/127.0.0.1:11547]]], channel closed event
[2014-04-01 15:32:16,532][INFO ][org.elasticsearch.client.transport] [Googam] failed to get node info for [#transport#-1][d][inet[localhost/127.0.0.1:11547]], disconnecting...
org.elasticsearch.transport.NodeDisconnectedException: [][inet[localhost/127.0.0.1:11547]][cluster/nodes/info] disconnected
[2014-04-01 15:32:16,534][INFO ][org.elasticsearch.node   ] [Sepulchre] stopped
Exception in thread "Thread-1" org.elasticsearch.client.transport.NoNodeAvailableException: No node available

在日志中你有Googam,它是作为嵌入式节点的TransportClient和Sepulcher。

0 个答案:

没有答案