/** * <p>Waits until all events currently in the disruptor have been processed by all event processors * and then halts the processors.</p> * * <p>This method will not shutdown the executor, nor will it await the final termination of the * processor threads.</p> * * @param timeout the amount of time to wait for all events to be processed. <code>-1</code> will give an infinite timeout * @param timeUnit the unit the timeOut is specified in * @throws TimeoutException if a timeout occurs before shutdown completes. */ public void shutdown(final long timeout, final TimeUnit timeUnit) throws TimeoutException { final long timeOutAt = System.currentTimeMillis() + timeUnit.toMillis(timeout); while (hasBacklog()) { if (timeout >= 0 && System.currentTimeMillis() > timeOutAt) { throw TimeoutException.INSTANCE; } // Busy spin } halt(); }
@Override protected void doShutdown() throws IOException { // Shutdown the disruptor. Will stop after all entries have been processed. Make sure we // have stopped incoming appends before calling this else it will not shutdown. We are // conservative below waiting a long time and if not elapsed, then halting. if (this.disruptor != null) { long timeoutms = conf.getLong("hbase.wal.disruptor.shutdown.timeout.ms", 60000); try { this.disruptor.shutdown(timeoutms, TimeUnit.MILLISECONDS); } catch (TimeoutException e) { LOG.warn("Timed out bringing down disruptor after " + timeoutms + "ms; forcing halt " + "(It is a problem if this is NOT an ABORT! -- DATALOSS!!!!)"); this.disruptor.halt(); this.disruptor.shutdown(); } } if (LOG.isDebugEnabled()) { LOG.debug("Closing WAL writer in " + FSUtils.getPath(walDir)); } if (this.writer != null) { this.writer.close(); this.writer = null; } }
@After public void tearDown() throws Exception { for (DelayedEventHandler delayedEventHandler : delayedEventHandlers) { delayedEventHandler.stopWaiting(); } for (TestWorkHandler testWorkHandler : testWorkHandlers) { testWorkHandler.stopWaiting(); } disruptor.halt(); executor.joinAllThreads(); }
private void stopDisruptor() { Map<String, Disruptor> mydisruptors = new HashMap(topicDisruptors); topicDisruptors.clear(); try { Thread.sleep(10000);// wait a while until all disruptor is done; } catch (InterruptedException e1) { e1.printStackTrace(); } for (String topic : mydisruptors.keySet()) { Disruptor disruptor = (Disruptor) mydisruptors.get(topic); try { disruptor.halt(); } catch (Exception e) { } } mydisruptors.clear(); }
private void stopDisruptor() { Map<String, Disruptor> mydisruptors = new HashMap(topicDisruptors); topicDisruptors.clear(); try { Thread.sleep(10000);// wait a while until all disruptor is done; } catch (InterruptedException e1) { e1.printStackTrace(); } for (String topic : mydisruptors.keySet()) { Disruptor disruptor = (Disruptor) mydisruptors.get(topic); try { disruptor.halt(); } catch (Exception e) { } } mydisruptors.clear(); }
/** * <p>Waits until all events currently in the disruptor have been processed by all event processors * and then halts the processors.</p> * * <p>This method will not shutdown the executor, nor will it await the final termination of the * processor threads.</p> * * @param timeout the amount of time to wait for all events to be processed. <code>-1</code> will give an infinite timeout * @param timeUnit the unit the timeOut is specified in * @throws TimeoutException if a timeout occurs before shutdown completes. */ public void shutdown(final long timeout, final TimeUnit timeUnit) throws TimeoutException { final long timeOutAt = System.currentTimeMillis() + timeUnit.toMillis(timeout); while (hasBacklog()) { if (timeout >= 0 && System.currentTimeMillis() > timeOutAt) { throw TimeoutException.INSTANCE; } // Busy spin } halt(); }
@Override public void stop() { disruptor.halt(); } }
private void doHalt() { disruptor.halt(); }
private void doHalt() { disruptor.halt(); }
public void terminate() { disruptor.halt(); }
private void doHalt() { disruptor.halt(); }
public void halt() { if(shutdownExecutor) { executor.shutdownNow(); } disruptor.halt(); }
@Override public void halt() { executor.shutdownNow(); disruptor.halt(); super.halt(); }
private void halt() { disruptor.halt(); disruptor.shutdown(); } }
@Override public void halt() { executor.shutdownNow(); disruptor.halt(); super.halt(); }
@Override public void forceShutdown() { executor.shutdownNow(); disruptor.halt(); super.forceShutdown(); }
@Override public void forceShutdown() { executor.shutdownNow(); disruptor.halt(); super.forceShutdown(); }
@Override public void close() throws Exception { handle.breakLoop(); disruptor.halt(); } }
@Override public void close() throws IOException { LOG.info("Terminating Request Processor..."); disruptor.halt(); disruptor.shutdown(); LOG.info("\tRequest Processor Disruptor shutdown"); disruptorExec.shutdownNow(); try { disruptorExec.awaitTermination(3, SECONDS); LOG.info("\tRequest Processor Disruptor executor shutdown"); } catch (InterruptedException e) { LOG.error("Interrupted whilst finishing Request Processor Disruptor executor"); Thread.currentThread().interrupt(); } LOG.info("Request Processor terminated"); }
@Override public void close() throws Exception { isAlive = false; ringBuffer.tryPublishEvent((container, sequence) -> container.clear()); try { disruptor.shutdown(5, TimeUnit.SECONDS); } catch (TimeoutException e) { logger.warn("Disruptor shutdown timeout....", e); disruptor.halt(); } } }