@Override public void cancel() { election.stop(); registry.remove(name, election); } }
/** * Stops all active {@link LeaderElection} processes. */ public void shutdown() { for (LeaderElection election : registry.values()) { election.stop(); } }
@Override public void cancel() { election.stop(); registry.remove(name, election); } }
/** * Stops all active {@link LeaderElection} processes. */ public void shutdown() { for (LeaderElection election : registry.values()) { election.stop(); } }
private void becomeFollower() { state = State.FOLLOWER; LOG.debug("Become follower for {}", zkNodePath); try { handler.follower(); } catch (Throwable t) { LOG.warn("Exception thrown when calling follower() method. Withdraw from the leader election process.", t); stop(); } }
private void becomeFollower() { state = State.FOLLOWER; LOG.debug("Become follower for {}", zkNodePath); try { handler.follower(); } catch (Throwable t) { LOG.warn("Exception thrown when calling follower() method. Withdraw from the leader election process.", t); stop(); } }
private void becomeLeader() { state = State.LEADER; LOG.debug("Become leader for {}.", zkNodePath); try { handler.leader(); } catch (Throwable t) { LOG.warn("Exception thrown when calling leader() method. Withdraw from the leader election process.", t); stop(); } }
protected void internalStop() { if (leaderElection != null) { // NOTE: if was a leader this will cause loosing of leadership which in callback above will // de-register service in discovery service and stop the service if needed try { Uninterruptibles.getUninterruptibly(leaderElection.stop(), 5, TimeUnit.SECONDS); } catch (TimeoutException te) { LOG.warn("Timed out waiting for leader election cancellation to complete"); } catch (ExecutionException e) { LOG.error("Exception when cancelling leader election.", e); } } }
private void becomeLeader() { state = State.LEADER; LOG.debug("Become leader for {}.", zkNodePath); try { handler.leader(); } catch (Throwable t) { LOG.warn("Exception thrown when calling leader() method. Withdraw from the leader election process.", t); stop(); } }
protected void internalStop() { if (leaderElection != null) { // NOTE: if was a leader this will cause loosing of leadership which in callback above will // de-register service in discovery service and stop the service if needed try { Uninterruptibles.getUninterruptibly(leaderElection.stop(), 5, TimeUnit.SECONDS); } catch (TimeoutException te) { LOG.warn("Timed out waiting for leader election cancellation to complete"); } catch (ExecutionException e) { LOG.error("Exception when cancelling leader election.", e); } } } }
protected void internalStop() { if (leaderElection != null) { // NOTE: if was a leader this will cause loosing of leadership which in callback above will // de-register service in discovery service and stop the service if needed try { Uninterruptibles.getUninterruptibly(leaderElection.stop(), 5, TimeUnit.SECONDS); } catch (TimeoutException te) { LOG.warn("Timed out waiting for leader election cancellation to complete"); } catch (ExecutionException e) { LOG.error("Exception when cancelling leader election.", e); } } } }
@Override protected void doShutdown() throws Exception { for (StreamSizeAggregator aggregator : aggregators.values()) { aggregator.cancel(); } if (leaderListenerCancellable != null) { leaderListenerCancellable.cancel(); } if (heartbeatsSubscription != null) { heartbeatsSubscription.cancel(); } if (heartbeatsSubscriptionExecutor != null) { heartbeatsSubscriptionExecutor.shutdownNow(); } heartbeatPublisher.stopAndWait(); if (leaderElection != null) { Uninterruptibles.getUninterruptibly(leaderElection.stop(), 5, TimeUnit.SECONDS); } if (coordinationSubscription != null) { coordinationSubscription.cancel(); } if (resourceCoordinatorClient != null) { resourceCoordinatorClient.stopAndWait(); } }
@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()); server = ThriftRPCServer.builder(TTransactionServer.class) .setHost(address) .setPort(port) .setWorkerThreads(threads) .setMaxReadBufferBytes(maxReadBufferBytes) .setIOThreads(ioThreads) .build(new TransactionServiceThriftHandler(txManager)); try { server.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); } }
@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()); server = ThriftRPCServer.builder(TTransactionServer.class) .setHost(address) .setPort(port) .setWorkerThreads(threads) .setMaxReadBufferBytes(maxReadBufferBytes) .setIOThreads(ioThreads) .build(new TransactionServiceThriftHandler(txManager)); try { server.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); } }
@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); } }