create elasticsearch client抛出一个netty IllegalStateException

时间:2017-07-15 09:50:53

标签: java elasticsearch netty

elasticsearch版本5.4.3

我使用singleton创建客户端,这里是主要代码

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);
    }

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

IllegalStateException: availableProcessors is already set to [4]

但是要调用第二个它会成功,并且客户端将被终止, 谁知道如何解决它?

1 个答案:

答案 0 :(得分:1)

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

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