use of org.apache.zeppelin.interpreter.remote.AppendOutputRunner in project zeppelin by apache.
the class RemoteInterpreterEventServer method start.
public void start() throws IOException {
Thread startingThread = new Thread() {
@Override
public void run() {
try (TServerSocket tSocket = new TServerSocket(RemoteInterpreterUtils.findAvailablePort(portRange))) {
port = tSocket.getServerSocket().getLocalPort();
host = RemoteInterpreterUtils.findAvailableHostAddress();
LOGGER.info("InterpreterEventServer is starting at {}:{}", host, port);
RemoteInterpreterEventService.Processor<RemoteInterpreterEventServer> processor = new RemoteInterpreterEventService.Processor<>(RemoteInterpreterEventServer.this);
thriftServer = new TThreadPoolServer(new TThreadPoolServer.Args(tSocket).processor(processor));
thriftServer.serve();
} catch (IOException | TTransportException e) {
throw new RuntimeException("Fail to create TServerSocket", e);
}
LOGGER.info("ThriftServer-Thread finished");
}
};
startingThread.start();
long start = System.currentTimeMillis();
while ((System.currentTimeMillis() - start) < 30 * 1000) {
if (thriftServer != null && thriftServer.isServing()) {
break;
}
try {
Thread.sleep(500);
} catch (InterruptedException e) {
throw new IOException(e);
}
}
if (thriftServer != null && !thriftServer.isServing()) {
throw new IOException("Fail to start InterpreterEventServer in 30 seconds.");
}
LOGGER.info("RemoteInterpreterEventServer is started");
runner = new AppendOutputRunner(listener);
appendFuture = appendService.scheduleWithFixedDelay(runner, 0, AppendOutputRunner.BUFFER_TIME_MS, TimeUnit.MILLISECONDS);
}
Aggregations