本文整理汇总了Java中com.lmax.disruptor.TimeoutException类的典型用法代码示例。如果您正苦于以下问题:Java TimeoutException类的具体用法?Java TimeoutException怎么用?Java TimeoutException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeoutException类属于com.lmax.disruptor包,在下文中一共展示了TimeoutException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:21,代码来源:RingBufferWorkProcessor.java
示例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;
}
}
开发者ID:apache,项目名称:hbase,代码行数:26,代码来源:FSHLog.java
示例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;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:21,代码来源:DisruptorQueueImpl.java
示例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();
}
}
开发者ID:sip3io,项目名称:tapir,代码行数:12,代码来源:Receiver.java
示例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();
}
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:21,代码来源:Disruptor.java
示例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
}
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:14,代码来源:DisruptorTest.java
示例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;
}
开发者ID:vladimirdolzhenko,项目名称:gflogger,代码行数:33,代码来源:LoggerServiceImpl.java
示例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;
}
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:15,代码来源:ParkWaitStrategy.java
示例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);
}
}
开发者ID:anair-it,项目名称:disruptor-spring-manager,代码行数:11,代码来源:AbstractDisruptorLifecycleManager.java
示例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.");
}
}
开发者ID:wso2,项目名称:andes,代码行数:13,代码来源:DisruptorBasedFlusher.java
示例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();
}
开发者ID:ricardopadilha,项目名称:dsys-snio,代码行数:10,代码来源:WakeupWaitStrategy.java
示例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());
}
}
开发者ID:garethahealy,项目名称:jboss-fuse-examples,代码行数:16,代码来源:DisruptorService.java
示例16: shutdown
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.
*
* <p>This method will not shutdown the executor, nor will it await the final termination of the
* processor threads.</p>
*/
public void shutdown()
{
try
{
shutdown(-1, TimeUnit.MILLISECONDS);
}
catch (TimeoutException e)
{
exceptionHandler.handleOnShutdownException(e);
}
}
开发者ID:wen866595,项目名称:annotated-src,代码行数:20,代码来源:Disruptor.java
示例17: asyncConsumeBatchToCursor
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
public void asyncConsumeBatchToCursor(EventHandler<Object> handler) throws AlertException, InterruptedException, TimeoutException {
List<Object> batch = getConsumeBatch();
if (batch == null)
return;
for (int i = 0; i < batch.size(); i++) {
try {
handler.onEvent(batch.get(i), 0, i == (batch.size() - 1));
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
}
开发者ID:alibaba,项目名称:jstorm,代码行数:15,代码来源:DisruptorQueueImpl.java
示例18: waitRequestOrTerminalEvent
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
public static <T> boolean waitRequestOrTerminalEvent(
Sequence pendingRequest,
RingBuffer<MutableSignal<T>> ringBuffer,
SequenceBarrier barrier,
Subscriber<? super T> subscriber,
AtomicBoolean isRunning
) {
final long waitedSequence = ringBuffer.getCursor() + 1L;
try {
MutableSignal<T> event = null;
while (pendingRequest.get() < 0l) {
//pause until first request
if (event == null) {
barrier.waitFor(waitedSequence);
event = ringBuffer.get(waitedSequence);
if (event.type == MutableSignal.Type.COMPLETE) {
try {
subscriber.onComplete();
return false;
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
subscriber.onError(t);
return false;
}
} else if (event.type == MutableSignal.Type.ERROR) {
subscriber.onError(event.error);
return false;
}
} else {
barrier.checkAlert();
}
LockSupport.parkNanos(1l);
}
} catch (TimeoutException te) {
//ignore
} catch (AlertException ae) {
if (!isRunning.get()) {
return false;
}
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
return true;
}
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:47,代码来源:RingBufferSubscriberUtils.java
示例19: waitFor
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
@Override
public long waitFor(long sequence, Sequence cursor, Sequence dependentSequence, SequenceBarrier barrier)
throws AlertException, InterruptedException, TimeoutException {
return currentStrategy.waitFor(sequence, cursor, dependentSequence, barrier);
}
开发者ID:camunda,项目名称:camunda-bpm-reactor,代码行数:6,代码来源:AgileWaitingStrategy.java
示例20: main
import com.lmax.disruptor.TimeoutException; //导入依赖的package包/类
public static void main(final String[] args) throws Exception
{
final CommandLineArgs commandLineArgs = new CommandLineArgs();
new JCommander(commandLineArgs).parse(args);
final Disruptor<Packet> packetDisruptor =
new Disruptor<>(new Packet.Factory(commandLineArgs.getRecordLength()), commandLineArgs.getBufferSize(),
newCachedThreadPool(DAEMON_THREAD_FACTORY), ProducerType.SINGLE, new SpinLoopHintBusySpinWaitStrategy());
final Overrides overrides = new Overrides(commandLineArgs);
overrides.init();
final Journaller journaller = new Journaller(SYSTEM_NANO_TIMER, commandLineArgs, overrides.enableJournaller());
journaller.init();
final Histogram[] messageTransitTimeHistograms = new Histogram[commandLineArgs.getNumberOfIterations()];
setAll(messageTransitTimeHistograms, HISTOGRAMS::createHistogramForArray);
final Histogram[] interMessageTimeHistograms = new Histogram[commandLineArgs.getNumberOfIterations()];
setAll(interMessageTimeHistograms, HISTOGRAMS::createHistogramForArray);
packetDisruptor.handleEventsWith(
runOnCpus(wrap(new Accumulator(messageTransitTimeHistograms, interMessageTimeHistograms, SYSTEM_NANO_TIMER, commandLineArgs)::process),
"Accumulator", overrides.getAccumulatorThreadAffinity()),
runOnCpus(wrap(journaller::process), "Journaller", overrides.getJournallerThreadAffinity()));
packetDisruptor.start();
final InputReader inputReader = new InputReader(packetDisruptor.getRingBuffer(), SYSTEM_NANO_TIMER, commandLineArgs);
if(commandLineArgs.runSpinners())
{
System.out.println("Starting spinner threads to perturb the system");
Spinners.SPINNERS.start();
}
System.out.println("Starting replay at " + new Date());
final Thread thread = DAEMON_THREAD_FACTORY.newThread(THREADS.runOnCpu(inputReader::processFiles,
overrides.getProducerThreadAffinity()));
thread.start();
try
{
thread.join();
System.out.println("Finished replay at " + new Date());
packetDisruptor.shutdown(1, TimeUnit.MINUTES);
}
catch (TimeoutException e)
{
throw new RuntimeException("Consumers did not process remaining events within timeout", e);
}
finally
{
Spinners.SPINNERS.stop();
packetDisruptor.halt();
}
System.out.println("Pausing for 10 seconds...");
THREADS.sleep(10L, TimeUnit.SECONDS);
}
开发者ID:epickrram,项目名称:perf-workshop,代码行数:61,代码来源:AppMain.java
注:本文中的com.lmax.disruptor.TimeoutException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论