Elastic Search的搜索操作失败,并显示“ java.io.IOException:等待[30000] ms后侦听器超时”

时间:2019-07-10 01:12:26

标签: elasticsearch

我们有一个10节点的集群,只有几个GB的数据。我们有5个索引(总共28个主要分片),每个分片都有1个副本。昨晚我们删除了2个索引,并将数据重新摄取到这些索引中。此后,当我们尝试从任何索引读取数据时,我们看到以下错误:

java.io.IOException: listener timeout after waiting for [30000] ms
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:617) ~[rest-5.2.2.jar:5.2.2]
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:212) ~[rest-5.2.2.jar:5.2.2]
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:184) ~[rest-5.2.2.jar:5.2.2]

我已经在Elastic Search论坛和SO上搜索了类似的问题,但是建议主要针对长时间运行的摄取或批量更新,这不适用于我们的情况,因为我们在搜索过程中发现了此错误。如果我尝试通过使用curl命令登录到ES节点之一来运行相同的查询,则它运行良好,没有任何错误,并返回了结果。

这是我们用于创建RestClient的代码

public RestClient getElasticServerRestClient(String sourceESServerIp, int sourceESServerPort,
        String sourceESServerProtocol, final String userName, final String password,String resource) {
    try {
        HttpHost elasticCacheHost = new HttpHost(sourceESServerIp, sourceESServerPort, sourceESServerProtocol);
        RestClientBuilder restClientBuilder = RestClient.builder(elasticCacheHost);
        restClientBuilder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
            @Override
            public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                int maxConnTotal = cacheConfigurations.getMaxTotalConnections();
                if (maxConnTotal > 0) {
                    httpClientBuilder.setMaxConnTotal(maxConnTotal);
                }
                int maxConnPerRoute = cacheConfigurations.getMaxConnectionsPerRoute();
                if (maxConnPerRoute > 0) {
                    httpClientBuilder.setMaxConnPerRoute(maxConnPerRoute);
                }

                if (userName != null && !userName.trim().isEmpty() && password != null && !password.trim().isEmpty()) {
                    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); 
                    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, 
                            password));
                    httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
                }
                return httpClientBuilder;
            }
        });


        RestClient elasticServerRestClient = restClientBuilder.build();
        return elasticServerRestClient;
    }
    catch (Throwable t) {
        log.error("Error in getElasticServerRestClient", t);
        return null;
    }
}

群集状态为绿色,日志中也没有任何其他问题的迹象。请分享有关如何确定失败原因的建议。

感谢与问候, Shobhana

0 个答案:

没有答案