@Override public void leader() { // if the txManager fails, we should stop the server txManager = txManagerProvider.get(); txManager.addListener(new ServiceListenerAdapter() { @Override public void failed(State from, Throwable failure) { LOG.error("Transaction manager aborted, stopping transaction service"); TransactionService.this.abort(failure); } }, MoreExecutors.sameThreadExecutor()); pruningService = createPruningService(conf, txManager); server = ThriftRPCServer.builder(TTransactionServer.class) .setHost(address) .setPort(port) .setWorkerThreads(threads) .setMaxReadBufferBytes(maxReadBufferBytes) .setIOThreads(ioThreads) .build(new TransactionServiceThriftHandler(txManager, pruningService)); try { server.startAndWait(); pruningService.startAndWait(); doRegister(); LOG.info("Transaction Thrift Service started successfully on " + getAddress()); } catch (Throwable t) { LOG.info("Transaction Thrift Service didn't start on " + server.getBindAddress()); leaderElection.stop(); notifyFailed(t); } }