@Override protected void doStart() throws ElasticSearchException {
InetAddress bindAddrX;
try {
bindAddrX = networkService.resolveBindHostAddress(bindHost);
} catch (IOException e) {
throw new BindTransportException("Failed to resolve host [" + bindHost + "]", e);
}
final InetAddress bindAddr = bindAddrX;
PortsRange portsRange = new PortsRange(port);
final AtomicReference<Exception> lastException = new AtomicReference<Exception>();
boolean success = portsRange.iterate(new PortsRange.PortCallback() {
@Override public boolean onPortNumber(int portNumber) {
ThriftServer.this.portNumber = portNumber;
try {
Rest.Processor processor = new Rest.Processor(client);
// Bind and start to accept incoming connections.
TServerSocket serverSocket = new TServerSocket(new InetSocketAddress(bindAddr, portNumber));
TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverSocket)
.minWorkerThreads(16)
.maxWorkerThreads(Integer.MAX_VALUE)
.inputProtocolFactory(protocolFactory)
.outputProtocolFactory(protocolFactory)
.processor(processor);
if (frame <= 0) {
args.inputTransportFactory(new TTransportFactory());
args.outputTransportFactory(new TTransportFactory());
} else {
args.inputTransportFactory(new TFramedTransport.Factory(frame));
args.outputTransportFactory(new TFramedTransport.Factory(frame));
}
server = new TThreadPoolServer(args);
} catch (Exception e) {
lastException.set(e);
return false;
}
return true;
}
});
if (!success) {
throw new BindTransportException("Failed to bind to [" + port + "]", lastException.get());
}
logger.info("bound on port [{}]", portNumber);
try {
nodesInfoAction.putNodeAttribute("thrift_address", new InetSocketAddress(networkService.resolvePublishHostAddress(publishHost), portNumber).toString());
} catch (Exception e) {