Search in sources :

Example 1 with AppendOutputRunner

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);
}
Also used : RemoteInterpreterEventService(org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEventService) TTransportException(org.apache.thrift.transport.TTransportException) IOException(java.io.IOException) TServerSocket(org.apache.thrift.transport.TServerSocket) TThreadPoolServer(org.apache.thrift.server.TThreadPoolServer) AppendOutputRunner(org.apache.zeppelin.interpreter.remote.AppendOutputRunner)

Aggregations

IOException (java.io.IOException)1 TThreadPoolServer (org.apache.thrift.server.TThreadPoolServer)1 TServerSocket (org.apache.thrift.transport.TServerSocket)1 TTransportException (org.apache.thrift.transport.TTransportException)1 AppendOutputRunner (org.apache.zeppelin.interpreter.remote.AppendOutputRunner)1 RemoteInterpreterEventService (org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEventService)1