本文整理汇总了Java中com.lmax.disruptor.TimeoutException类的典型用法代码示例。如果您正苦于以下问题:Java TimeoutException类的具体用法?Java TimeoutException怎么用?Java TimeoutException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeoutException类属于com.lmax.disruptor包,在下文中一共展示了TimeoutException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replay
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
private boolean replay(final boolean unbounded) {
Sequence replayedSequence;
MutableSignal<T> signal;
while ((replayedSequence = processor.cancelledSequences.poll()) != null) {
signal = processor.ringBuffer.get(replayedSequence.get() + 1L);
try {
if (signal.value == null) {
barrier.waitFor(replayedSequence.get() + 1L);
}
readNextEvent(signal, unbounded);
RingBufferSubscriberUtils.routeOnce(signal, subscriber);
processor.ringBuffer.removeGatingSequence(replayedSequence);
} catch (TimeoutException | InterruptedException | AlertException | CancelException ce) {
processor.ringBuffer.removeGatingSequence(sequence);
processor.cancelledSequences.add(replayedSequence);
return true;
}
}
return false;
}
示例2: doShutdown
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
@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;
}
}
示例3: getConsumeBatch
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
private synchronized List<Object> getConsumeBatch() throws AlertException, InterruptedException, TimeoutException {
long endCursor = getAvailableConsumeCursor();
long currCursor = _consumer.get();
long eventNumber = endCursor - currCursor;
List<Object> batch = new ArrayList<>((int) eventNumber);
for (long curr = currCursor + 1; curr <= endCursor; curr++) {
try {
MutableObject mo = _buffer.get(curr);
Object o = mo.o;
mo.setObject(null);
batch.add(o);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
_consumer.set(endCursor);
return batch;
}
示例4: close
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
@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();
}
}
示例5: shutdown
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
/**
* <p>Waits until all events currently in the disruptor have been processed by all event processors
* and then halts the processors.</p>
* <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
*/
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();
}
示例6: shouldThrowTimeoutExceptionIfShutdownDoesNotCompleteNormally
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
@Test(expected = TimeoutException.class, timeout = 2000)
public void shouldThrowTimeoutExceptionIfShutdownDoesNotCompleteNormally() throws Exception
{
//Given
final DelayedEventHandler delayedEventHandler = createDelayedEventHandler();
disruptor.handleEventsWith(delayedEventHandler);
publishEvent();
//When
disruptor.shutdown(1, SECONDS);
//Then
}
示例7: waitFor
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
public long waitFor(
long sequence,
Sequence cursor,
Sequence dependentSequence,
SequenceBarrier barrier
) throws AlertException, InterruptedException, TimeoutException {
long availableSequence;
if ((availableSequence = cursor.get()) < sequence) {
flush();
synchronized (lock) {
++numWaiters;
while ((availableSequence = cursor.get()) < sequence) {
if (state == State.STOPPED) {
disruptor.halt();
throw AlertException.INSTANCE;
}
barrier.checkAlert();
//*/
lock.wait();
/*/
Thread.sleep(1);
//*/
}
--numWaiters;
}
}
while ((availableSequence = dependentSequence.get()) < sequence) {
barrier.checkAlert();
}
return availableSequence;
}
示例8: waitFor
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
@Override
public long waitFor(long sequence,
Sequence cursor,
Sequence dependentSequence,
SequenceBarrier barrier) throws AlertException,
InterruptedException,
TimeoutException {
long availableSequence;
while ((availableSequence = dependentSequence.get()) < sequence) {
barrier.checkAlert();
LockSupport.parkNanos(parkFor);
}
return availableSequence;
}
示例9: awaitAndShutdown
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
@Override
public void awaitAndShutdown(long time) {
try {
LOG.debug("Disruptor {} is going to shutdown in {} {}", getThreadName(), time, TimeUnit.SECONDS);
disruptor.shutdown(time, TimeUnit.SECONDS);
LOG.info("Disruptor {} has shutdown after {} {}.", getThreadName(), time, TimeUnit.SECONDS);
} catch (TimeoutException e) {
LOG.error(e.getMessage(),e);
}
}
示例10: test_awaitAndShutdown
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
@Test
public void test_awaitAndShutdown() throws TimeoutException, InterruptedException {
mockDisruptor.shutdown(1, TimeUnit.SECONDS);
replay(mockDisruptor);
disruptorLifecycleManager.awaitAndShutdown(1);
verify(mockDisruptor);
}
开发者ID:anair-it,项目名称:disruptor-spring-manager,代码行数:10,代码来源:AbstractDisruptorLifecycleManagerTest.java
示例11: test_awaitAndShutdown_InterruptedException
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
@Test
public void test_awaitAndShutdown_InterruptedException() throws TimeoutException, InterruptedException {
mockDisruptor.shutdown(1, TimeUnit.SECONDS);
replay(mockDisruptor);
disruptorLifecycleManager.awaitAndShutdown(1);
verify(mockDisruptor);
}
开发者ID:anair-it,项目名称:disruptor-spring-manager,代码行数:10,代码来源:AbstractDisruptorLifecycleManagerTest.java
示例12: test_awaitAndShutdown_TimeoutException
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
@Test
public void test_awaitAndShutdown_TimeoutException() throws TimeoutException, InterruptedException {
mockDisruptor.shutdown(1, TimeUnit.SECONDS);
expectLastCall().andThrow(TimeoutException.INSTANCE);
replay(mockDisruptor);
disruptorLifecycleManager.awaitAndShutdown(1);
verify(mockDisruptor);
}
开发者ID:anair-it,项目名称:disruptor-spring-manager,代码行数:10,代码来源:AbstractDisruptorLifecycleManagerTest.java
示例13: stop
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
/**
* Waits until all events currently in the disruptor have been processed by all event processors
* and then halts the processors. It is critical that publishing to the ring buffer has stopped
* before calling this method, otherwise it may never return.
*/
public void stop() {
try {
disruptor.shutdown(OUTBOUND_DISRUPTOR_SHUTDOWN_WAIT_TIME, TimeUnit.SECONDS);
} catch (TimeoutException e) {
log.error("Outbound disruptor did not shut down properly.");
}
}
示例14: waitFor
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public long waitFor(final long sequence, final Sequence cursor,
final Sequence dependentSequence, final SequenceBarrier barrier)
throws AlertException, InterruptedException, TimeoutException {
return cursor.get();
}
示例15: shutdownGracefully
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
public void shutdownGracefully() throws IllegalStateException {
if (disruptor == null) {
throw new IllegalStateException("disruptor == null, call init");
}
for (ExchangeEventProducer<T> producer : producers) {
producer.stop();
}
try {
disruptor.shutdown(shutdownTimeout, TimeUnit.MINUTES);
} catch (TimeoutException ex) {
LOG.error(ex.getMessage());
}
}