Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从突然发生的java.lang.IllegalStateException中获取此错误:无法执行请求;I/O反应器状态:停止_Java_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Nio_Apache Httpasyncclient - Fatal编程技术网 elasticsearch,nio,apache-httpasyncclient,Java,elasticsearch,Nio,Apache Httpasyncclient" /> elasticsearch,nio,apache-httpasyncclient,Java,elasticsearch,Nio,Apache Httpasyncclient" />

从突然发生的java.lang.IllegalStateException中获取此错误:无法执行请求;I/O反应器状态:停止

从突然发生的java.lang.IllegalStateException中获取此错误:无法执行请求;I/O反应器状态:停止,java,elasticsearch,nio,apache-httpasyncclient,Java,elasticsearch,Nio,Apache Httpasyncclient,我正在使用httpcore-nio-4.4.5.jar。我正在使用elasticsearch RestHighLevelClient与我们的elasticsearch服务器交互。这一切工作正常,除了有一段时间我们突然发现I/O反应堆停止错误 一切似乎都很好。没有奇怪的行为 这就是我初始化ES客户端的方式 public synchronized RestHighLevelClient getHighLevelClient() throws ManagerException { if

我正在使用httpcore-nio-4.4.5.jar。我正在使用elasticsearch RestHighLevelClient与我们的elasticsearch服务器交互。这一切工作正常,除了有一段时间我们突然发现I/O反应堆停止错误

一切似乎都很好。没有奇怪的行为

这就是我初始化ES客户端的方式

public synchronized RestHighLevelClient getHighLevelClient() throws ManagerException {
        if (highLevelClient != null) {
            return highLevelClient;
        }

        Map<String, Integer> map = getEsServers(esAddresses);

        HttpHost[] hosts = new HttpHost[map.size()];

        int i = 0;

        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            hosts[i++] = new HttpHost(entry.getKey(), entry.getValue(), "http");
            LOGGER.info(entry.getKey() + " " + entry.getValue());
        }

        RestClientBuilder restClientBuilder = RestClient.builder(hosts);
        highLevelClient = customizeHttpClient(restClientBuilder);
        return highLevelClient;
    }
所以基本上首先我得到了下面的stacktrace

java.lang.IllegalStateException: I/O reactor has been shut down
        at org.apache.http.util.Asserts.check(Asserts.java:34) 
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.connect(DefaultConnectingIOReactor.java:224) 
        at org.apache.http.nio.pool.AbstractNIOConnPool.processPendingRequest(AbstractNIOConnPool.java:434) 
        at org.apache.http.nio.pool.AbstractNIOConnPool.lease(AbstractNIOConnPool.java:276) 
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.requestConnection(PoolingNHttpClientConnectionManager.java:266) 
        at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.requestConnection(AbstractClientExchangeHandler.java:363) 
        at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.start(DefaultClientExchangeHandlerImpl.java:125) 
        at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:141) 
        at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:346) 
        at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:328) 
        at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:271) 
        at org.elasticsearch.client.RestHighLevelClient.performRequestAsync(RestHighLevelClient.java:537) 
        at org.elasticsearch.client.RestHighLevelClient.performRequestAsyncAndParseEntity(RestHighLevelClient.java:515) 
        at org.elasticsearch.client.RestHighLevelClient.searchAsync(RestHighLevelClient.java:400) 
在这之后,没有超时,只会持续出现以下异常,直到我重新启动服务器

java.lang.IllegalStateException: Request cannot be executed; I/O reactor status: STOPPED
    at org.apache.http.util.Asserts.check(Asserts.java:46)  
    at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.ensureRunning(CloseableHttpAsyncClientBase.java:90)  
    at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:123)  
    at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:346)  
    at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:328)  
    at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:271)  
    at org.elasticsearch.client.RestHighLevelClient.performRequestAsync(RestHighLevelClient.java:537)  
    at org.elasticsearch.client.RestHighLevelClient.performRequestAsyncAndParseEntity(RestHighLevelClient.java:515)  
    at org.elasticsearch.client.RestHighLevelClient.searchAsync(RestHighLevelClient.java:400)  ```

我也面临同样的问题,结果证明我并没有关闭HighLevelRestClient

参考亨宁安徒生的回答:

这听起来像141。该问题中的问题是由在客户端应用程序代码中的onFailure方法中引发异常引起的。这将导致连接关闭,后续请求将失败,并在此处报告错误

我相信,如果使用通过ActionListener报告响应/失败的任何方法,这也会影响高级客户机(我认为所有这些方法的方法名称中都有后缀Async)

解决方法是确保您的onFailure方法不会抛出异常


你的客户在哪里运行?如何运行?可能重复@KalpeshSoni我已经尝试过了,在那里找不到任何东西。我更改了答案,我在pcf中遇到了相同的问题
java.lang.IllegalStateException: Request cannot be executed; I/O reactor status: STOPPED
    at org.apache.http.util.Asserts.check(Asserts.java:46)  
    at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.ensureRunning(CloseableHttpAsyncClientBase.java:90)  
    at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:123)  
    at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:346)  
    at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:328)  
    at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:271)  
    at org.elasticsearch.client.RestHighLevelClient.performRequestAsync(RestHighLevelClient.java:537)  
    at org.elasticsearch.client.RestHighLevelClient.performRequestAsyncAndParseEntity(RestHighLevelClient.java:515)  
    at org.elasticsearch.client.RestHighLevelClient.searchAsync(RestHighLevelClient.java:400)  ```