创建 elasticsearch 客户端抛出一个 netty IllegalStateException

Ash*_*her 4 java netty elasticsearch

弹性搜索版本 5.4.3

我使用单例来创建一个客户端,这里是主要代码

TransportClient tclient = null;
    if (clusterName != null) {
            Settings settings = Settings.builder()
                    .put("cluster.name",clusterName)
                    .put("client.transport.sniff", true)
                    .build();
            tclient = new PreBuiltTransportClient(settings);//here will throw the exception
    } else {
        tclient = new  PreBuiltTransportClient(Settings.EMPTY);
    }
Run Code Online (Sandbox Code Playgroud)

第一次运行到代码“tclient = new PreBuiltTransportClient(settings);”时,抛出异常

IllegalStateException:availableProcessors 已设置为 [4]

但是第二次调用它会成功,并且客户端将被终止,有人知道如何解决它吗?

Ash*_*her 6

在启动时设置以下系统属性: System.setProperty("es.set.netty.runtime.available.processors", "false");

https://discuss.elastic.co/t/elasticsearch-5-4-1-availableprocessors-is-already-set/88036/8