create elasticsearch client throws a netty IllegalStateException

Viewed 2903

elasticsearch version 5.4.3

I use singleton to create a client , here is the main code

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

when the first time run to the code "tclient = new PreBuiltTransportClient(settings);",it throws a exception

IllegalStateException: availableProcessors is already set to [4]

but invoke that for the second it will success,and client will be ceated, anyone knows how to fix it?

1 Answers
Related