Getting availableProcessors is already set to [1], rejecting [1] IllegalStateException exception

Hi I am using transport client to connect to the elastic search cluster and getting this exception

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalStateException: availableProcessors is already set to [1], rejecting [1] at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119) at org.eclipse.jetty.server.Server.handle(Server.java:517) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalStateException: availableProcessors is already set to [1], rejecting [1] at com.slb.index.core.IndexServiceHandler.processDataAndSchemaForElastic(IndexServiceHandler.java:1824) at com.slb.index.core.IndexServiceHandler.processClubbedList(IndexServiceHandler.java:1774) ... 28 more Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: availableProcessors is already set to [1], rejecting [1] at com.slb.index.util.TransportClientHandle.getTransportClient(TransportClientHandle.java:43) at com.slb.index.core.IndexServiceHandler.processElasticSchema(IndexServiceHandler.java:1935) at com.slb.index.core.IndexServiceHandler.processDataAndSchemaForElastic(IndexServiceHandler.java:1816) ... 29 more Caused by: java.lang.IllegalStateException: availableProcessors is already set to [1], rejecting [1] at io.netty.util.NettyRuntime$AvailableProcessorsHolder.setAvailableProcessors(NettyRuntime.java:51) at io.netty.util.NettyRuntime.setAvailableProcessors(NettyRuntime.java:87) at org.elasticsearch.transport.netty4.Netty4Utils.setAvailableProcessors(Netty4Utils.java:82) at org.elasticsearch.transport.netty4.Netty4Transport.(Netty4Transport.java:138) at org.elasticsearch.transport.Netty4Plugin.lambda$getTransports$0(Netty4Plugin.java:93) at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:174) at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:265) at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:130) at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:116) at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:106) at com.slb.index.util.TransportClientHandle.getTransportClient(TransportClientHandle.java:38) ... 31 more

I am using elastic search 5.5.0 and this is the way i connect to ES

public static TransportClient getTransportClient(){
TransportClient client = null;
try{
Settings settings = Settings.builder()
.put("client.transport.sniff",true)
.put("cluster.name", System.getenv(SharedConstant.CLUSTER))
.build();
client = new PreBuiltTransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(System.getenv(SharedConstant.HOST1)), 9300))
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(System.getenv(SharedConstant.HOST2)), 9300));
}catch (Exception e){
LOG.info(e.getMessage());
throw new RuntimeException(e);

        }
        return client;
    }

Any help in resolving this would be appreciated.
Rohit

I think that you’re using Netty elsewhere in your application, yes? If so, you have two choices:

  • force the transport client to initialize before any other component that uses Netty initializes
  • set the system property es.set.netty.runtime.available.processors to false

You should prefer the first option, the second option is an escape hatch.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.