waitStrategy ); disruptor.setDefaultExceptionHandler(new LoggingExceptionHandler(LOG));
waitStrategy ); disruptor.setDefaultExceptionHandler(new LoggingExceptionHandler(LOG));
/** * disruptor start. * * @param bufferSize this is disruptor buffer size. * @param threadSize this is disruptor consumer thread size. */ private void start(final int bufferSize, final int threadSize) { disruptor = new Disruptor<>(new HmilyTransactionEventFactory(), bufferSize, runnable -> { return new Thread(new ThreadGroup("hmily-disruptor"), runnable, "disruptor-thread-" + INDEX.getAndIncrement()); }, ProducerType.MULTI, new BlockingWaitStrategy()); HmilyConsumerDataHandler[] consumers = new HmilyConsumerDataHandler[1]; List<SingletonExecutor> selects = new ArrayList<>(); for (int i = 0; i < threadSize; i++) { selects.add(new SingletonExecutor("hmily-log-disruptor" + i)); } ConsistentHashSelector selector = new ConsistentHashSelector(selects); consumers[0] = new HmilyConsumerDataHandler(selector, coordinatorService); disruptor.handleEventsWithWorkerPool(consumers); disruptor.setDefaultExceptionHandler(new IgnoreExceptionHandler()); disruptor.start(); }
/** * start disruptor. * * @param bufferSize bufferSize */ private void start(final int bufferSize, final int threadSize) { disruptor = new Disruptor<>(new MythTransactionEventFactory(), bufferSize, runnable -> { return new Thread(new ThreadGroup("hmily-disruptor"), runnable, "disruptor-thread-" + INDEX.getAndIncrement()); }, ProducerType.MULTI, new BlockingWaitStrategy()); final Executor executor = new ThreadPoolExecutor(MAX_THREAD, MAX_THREAD, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), MythTransactionThreadFactory.create("myth-log-disruptor", false), new ThreadPoolExecutor.AbortPolicy()); MythTransactionEventHandler[] consumers = new MythTransactionEventHandler[MAX_THREAD]; for (int i = 0; i < threadSize; i++) { consumers[i] = new MythTransactionEventHandler(coordinatorService, executor); } disruptor.handleEventsWithWorkerPool(consumers); disruptor.setDefaultExceptionHandler(new IgnoreExceptionHandler()); disruptor.start(); }
ProducerType.MULTI, configuration.getInputBufferWaitStrategy()); disruptor.setDefaultExceptionHandler(new LoggingExceptionHandler(LOG));
/** * disruptor start. * * @param bufferSize this is disruptor buffer size. * @param threads this is disruptor consumer thread size. */ private void start(final int bufferSize, final int threads) { disruptor = new Disruptor<>(new TxTransactionEventFactory(), bufferSize, r -> { return new Thread(null, r, "disruptor-thread-" + INDEX.getAndIncrement()); }, ProducerType.MULTI, new BlockingWaitStrategy()); final Executor executor = new ThreadPoolExecutor(threads, threads, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), TxTransactionThreadFactory.create("raincat-log-disruptor", false), new ThreadPoolExecutor.AbortPolicy()); TxTransactionEventHandler[] consumers = new TxTransactionEventHandler[threads]; for (int i = 0; i < threads; i++) { consumers[i] = new TxTransactionEventHandler(executor, txCompensationService); } disruptor.handleEventsWithWorkerPool(consumers); disruptor.setDefaultExceptionHandler(new IgnoreExceptionHandler()); disruptor.start(); }
this.ringBufferEventHandler = new RingBufferEventHandler( conf.getInt("hbase.regionserver.hlog.syncer.count", 5), maxHandlersCount); this.disruptor.setDefaultExceptionHandler(new RingBufferExceptionHandler()); this.disruptor.handleEventsWith(new RingBufferEventHandler[] { this.ringBufferEventHandler });
@Test public void shouldApplyDefaultExceptionHandlerToExistingEventProcessors() throws Exception { AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>(); ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled); RuntimeException testException = new RuntimeException(); ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException); disruptor.handleEventsWith(handler); disruptor.setDefaultExceptionHandler(exceptionHandler); publishEvent(); final Throwable actualException = waitFor(eventHandled); assertSame(testException, actualException); }
disruptor.setDefaultExceptionHandler(new ExceptionHandler()); disruptor.handleEventsWith(commandHandlerInvokers).then(publishers); disruptor.start();
@Test public void shouldSupportSpecifyingADefaultExceptionHandlerForEventProcessors() throws Exception { AtomicReference<Throwable> eventHandled = new AtomicReference<Throwable>(); ExceptionHandler exceptionHandler = new StubExceptionHandler(eventHandled); RuntimeException testException = new RuntimeException(); ExceptionThrowingEventHandler handler = new ExceptionThrowingEventHandler(testException); disruptor.setDefaultExceptionHandler(exceptionHandler); disruptor.handleEventsWith(handler); publishEvent(); final Throwable actualException = waitFor(eventHandled); assertSame(testException, actualException); }
ProducerType.MULTI, new SleepingWaitStrategy()); RingBuffer<TestEvent> ringBuffer = disruptor.getRingBuffer(); disruptor.setDefaultExceptionHandler(new FatalExceptionHandler());
ProducerType.MULTI, new BusySpinWaitStrategy()); RingBuffer<TestEvent> ringBuffer = disruptor.getRingBuffer(); disruptor.setDefaultExceptionHandler(new FatalExceptionHandler());
@SuppressWarnings("unchecked") @Before public void setUp() { disruptor = new Disruptor<byte[]>( new ByteArrayFactory(256), 1024, DaemonThreadFactory.INSTANCE, ProducerType.SINGLE, new BlockingWaitStrategy()); disruptor.handleEventsWith(eventHandler); disruptor.setDefaultExceptionHandler(new FatalExceptionHandler()); }
dr.setDefaultExceptionHandler(new LoggingExceptionHandler()); numWorkers = Math.min(Math.abs(numWorkers), MAX_NUM_WORKERS); if (numWorkers == 1) {
dr.setDefaultExceptionHandler(new LoggingExceptionHandler()); numWorkers = Math.min(Math.abs(numWorkers), MAX_NUM_WORKERS); if (numWorkers == 1) {
waitStrategy); final ExceptionHandler<RingBufferEvent> errorHandler = new QueryLoggerDefaultExceptionHandler(); disruptor.setDefaultExceptionHandler(errorHandler);
/** * disruptor start with bufferSize. */ private void start() { disruptor = new Disruptor<>(new SoulEventFactory(), bufferSize, r -> { AtomicInteger index = new AtomicInteger(1); return new Thread(null, r, "disruptor-thread-" + index.getAndIncrement()); }, ProducerType.MULTI, new BlockingWaitStrategy()); final Executor executor = new ThreadPoolExecutor(threadSize, threadSize, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), SoulThreadFactory.create("soul-log-disruptor", false), new ThreadPoolExecutor.AbortPolicy()); SoulDataHandler[] consumers = new SoulDataHandler[threadSize]; for (int i = 0; i < threadSize; i++) { consumers[i] = new SoulDataHandler(executor, influxDbService); } disruptor.handleEventsWithWorkerPool(consumers); disruptor.setDefaultExceptionHandler(new IgnoreExceptionHandler()); disruptor.start(); }
@SuppressWarnings("unchecked") SharedMessageStore(MessageDao messageDao, int bufferSize, int maxDbBatchSize) { pendingMessages = new ConcurrentHashMap<>(); ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() .setNameFormat("DisruptorMessageStoreThread-%d").build(); disruptor = new Disruptor<>(DbOperation.getFactory(), bufferSize, namedThreadFactory, ProducerType.MULTI, new SleepingBlockingWaitStrategy()); disruptor.setDefaultExceptionHandler(new LogExceptionHandler()); disruptor.handleEventsWith(new DbEventMatcher(bufferSize)) .then(new DbAccessHandler(messageDao, maxDbBatchSize)) .then(new FinalEventHandler()); disruptor.start(); this.messageDao = messageDao; }
@Bean public Disruptor disruptor(@Value("${disruptor.capacity}") int capacity, @Value("${disruptor.consumers}") int consumers) { Disruptor<PacketContainer> disruptor = new Disruptor<>(PacketContainer::new, capacity, DaemonThreadFactory.INSTANCE, ProducerType.SINGLE, new SleepingWaitStrategy()); disruptor.setDefaultExceptionHandler(new PacketExceptionHandler()); disruptor.handleEventsWith(handlers(consumers, factory::decoder)) .then(handlers(consumers, factory::defragmentator)) .then(handlers(consumers, factory::sender)); return disruptor; }
public synchronized void start() { if (this.disruptor != null) { return; } // init disruptor this.disruptor = new Disruptor<>(eventFactory, ringBufferSize, threadFactory, ProducerType.MULTI, waitStrategy); this.disruptor.handleEventsWith(this.consumer); this.disruptor.setDefaultExceptionHandler(LogConstants.DEFAULT_EXCEPTION_HANDLER); this.disruptor.start(); // init producer this.producer = new WorkingLogEntryEventProducer(this.disruptor.getRingBuffer(), this.logEntryEventStat); setStarted(); }