com.lmax.disruptor.LiteBlockingWaitStrategy Java Examples
The following examples show how to use
com.lmax.disruptor.LiteBlockingWaitStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Dispatcher.java From Electrons with MIT License | 5 votes |
/** * 初始化正常管道,任何情况下都会有 * * @param pool 线程池 */ private void initNormalChannel(ExecutorService pool) { Disruptor<ElectronsHolder> normalDis = new Disruptor<>(ElectronsHolder::new, conf.getCircuitLen(), pool, ProducerType.MULTI, new LiteBlockingWaitStrategy()); WorkHandler[] workHandlers = new WorkHandler[conf.getCircuitNum()]; Arrays.fill(workHandlers, (WorkHandler<ElectronsHolder>) electronsHolder -> electronsHolder.handle()); normalDis.handleEventsWithWorkerPool(workHandlers); normalDis.handleExceptionsWith(new ElecExceptionHandler("Normal Disruptor")); //初始化channel Channel normalChannel = new NormalChannel(normalDis); //配置限流相关 normalChannel.confLimitRate(conf.isLimitRate(), conf.getPermitsPerSecond(), conf.isWarmup(), conf.getWarmupPeriod(), conf.getWarmPeriodUnit()); channelMap.put(NORMAL_CHANNEL_KEY, normalChannel); }
Example #2
Source File: WaitStrategyTypeTest.java From disruptor-spring-manager with MIT License | 5 votes |
@Test public void test_All_WaitStrategies() { assertTrue(WaitStrategyType.BLOCKING.instance() instanceof BlockingWaitStrategy); assertTrue(WaitStrategyType.BUSY_SPIN.instance() instanceof BusySpinWaitStrategy); assertTrue(WaitStrategyType.LITE_BLOCKING.instance() instanceof LiteBlockingWaitStrategy); assertTrue(WaitStrategyType.SLEEPING_WAIT.instance() instanceof SleepingWaitStrategy); assertTrue(WaitStrategyType.YIELDING.instance() instanceof YieldingWaitStrategy); }
Example #3
Source File: BenchmarkHandler.java From Okra with Apache License 2.0 | 5 votes |
@Override protected Disruptor<ConcurrentEvent> initialValue() { Disruptor<ConcurrentEvent> disruptor = new Disruptor<>( ConcurrentEventFactory.DEFAULT, DEFAULT_RING_BUFFER_SIZE, CACHED_THREAD_POOL, ProducerType.SINGLE, new LiteBlockingWaitStrategy()); disruptor.handleEventsWith(new ConcurrentHandler()); // disruptor.handleExceptionsWith(); disruptor.start(); return disruptor; }
Example #4
Source File: DisruptorAdapterBy41xHandler.java From Okra with Apache License 2.0 | 5 votes |
@Override protected Disruptor<ConcurrentEvent> initialValue() { Disruptor<ConcurrentEvent> disruptor = new Disruptor<>( ConcurrentEventFactory.DEFAULT, DEFAULT_RING_BUFFER_SIZE, CACHED_THREAD_POOL, ProducerType.SINGLE, new LiteBlockingWaitStrategy()); disruptor.handleEventsWith(new ConcurrentHandler()); // disruptor.handleExceptionsWith(); disruptor.start(); return disruptor; }
Example #5
Source File: Dispatcher.java From Electrons with MIT License | 5 votes |
/** * 根据config初始化特殊通道 * * @param symbol 事件 * @param listeners 对应的监听器集合 */ private void initSpecDisruptor(String symbol, List<ElectronsListener> listeners) { ExecutorService specPool = Executors.newFixedThreadPool(conf.getSpecCircuitNum(), new ThreadFactory() { final AtomicInteger cursor = new AtomicInteger(0); @Override public Thread newThread(Runnable r) { return new Thread(r, "Electrons Thread (from spec channel) : thread" + cursor.incrementAndGet()); } }); pools.add(specPool); Disruptor<ElectronsHolder> disruptor = new Disruptor<>(ElectronsHolder::new, conf.getSpecCircuitLen(), specPool, ProducerType.MULTI, new LiteBlockingWaitStrategy()); disruptor.handleExceptionsWith(new ElecExceptionHandler("Spec Disruptor {" + symbol + "}")); //初始化管道并放入集合中 SpecChannel specChannel = new SpecChannel(disruptor); if (conf.isBreaker()) { EventCountCircuitBreaker breaker = new EventCountCircuitBreaker(conf.getErrorNum(), conf.getPerUnit(), conf.getUnit(), conf.getCloseThreshold(), conf.getRest(), conf.getRestUnit()); specChannel.setBreaker(breaker); } //构建listener顺序 ListenerChainBuilderNew.buildChain(specChannel, listeners); channelMap.put(SPEC_CHANNEL_PREFIX + symbol, specChannel); }
Example #6
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and the passed auto-cancel setting. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> create(ExecutorService service, boolean autoCancel) { return create(service, SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), autoCancel); }
Example #7
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and auto-cancel. * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> create(ExecutorService service) { return create(service, SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), true); }
Example #8
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using the passed buffer size, blockingWait Strategy * and auto-cancel. * <p> * A new Cached ThreadExecutorPool will be implicitely created and will use the passed name to qualify * the created threads. * * @param name Use a new Cached ExecutorService and assign this name to the created threads * @param bufferSize A Backlog Size to mitigate slow subscribers * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> create(String name, int bufferSize) { return create(name, bufferSize, new LiteBlockingWaitStrategy(), true); }
Example #9
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using the passed buffer size, blockingWait Strategy * and the passed auto-cancel setting. * <p> * A new Cached ThreadExecutorPool will be implicitely created and will use the passed name to qualify * the created threads. * * @param name Use a new Cached ExecutorService and assign this name to the created threads * @param bufferSize A Backlog Size to mitigate slow subscribers * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> create(String name, int bufferSize, boolean autoCancel) { return create(name, bufferSize, new LiteBlockingWaitStrategy(), autoCancel); }
Example #10
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using the passed buffer size, blockingWait Strategy * and auto-cancel. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param bufferSize A Backlog Size to mitigate slow subscribers * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> create(ExecutorService service, int bufferSize) { return create(service, bufferSize, new LiteBlockingWaitStrategy(), true); }
Example #11
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using the passed buffer size, blockingWait Strategy * and auto-cancel. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param bufferSize A Backlog Size to mitigate slow subscribers * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> create(ExecutorService service, int bufferSize, boolean autoCancel) { return create(service, bufferSize, new LiteBlockingWaitStrategy(), autoCancel); }
Example #12
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and auto-cancel. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * A new Cached ThreadExecutorPool will be implicitely created. * * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> share() { return share(RingBufferWorkProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), true); }
Example #13
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and the passed auto-cancel setting. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * A new Cached ThreadExecutorPool will be implicitely created. * * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> share(boolean autoCancel) { return share(RingBufferWorkProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), autoCancel); }
Example #14
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and auto-cancel. * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> share(ExecutorService service) { return share(service, SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), true); }
Example #15
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and the passed auto-cancel setting. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> share(ExecutorService service, boolean autoCancel) { return share(service, SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), autoCancel); }
Example #16
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using the passed buffer size, blockingWait Strategy * and auto-cancel. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * A new Cached ThreadExecutorPool will be implicitely created and will use the passed name to qualify * the created threads. * * @param name Use a new Cached ExecutorService and assign this name to the created threads * @param bufferSize A Backlog Size to mitigate slow subscribers * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> share(String name, int bufferSize) { return share(name, bufferSize, new LiteBlockingWaitStrategy(), true); }
Example #17
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using the passed buffer size, blockingWait Strategy * and the passed auto-cancel setting. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * A new Cached ThreadExecutorPool will be implicitely created and will use the passed name to qualify * the created threads. * * @param name Use a new Cached ExecutorService and assign this name to the created threads * @param bufferSize A Backlog Size to mitigate slow subscribers * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> share(String name, int bufferSize, boolean autoCancel) { return share(name, bufferSize, new LiteBlockingWaitStrategy(), autoCancel); }
Example #18
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using the passed buffer size, blockingWait Strategy * and auto-cancel. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param bufferSize A Backlog Size to mitigate slow subscribers * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> share(ExecutorService service, int bufferSize) { return share(service, bufferSize, new LiteBlockingWaitStrategy(), true); }
Example #19
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using the passed buffer size, blockingWait Strategy * and auto-cancel. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param bufferSize A Backlog Size to mitigate slow subscribers * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> share(ExecutorService service, int bufferSize, boolean autoCancel) { return share(service, bufferSize, new LiteBlockingWaitStrategy(), autoCancel); }
Example #20
Source File: RingBufferProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and the passed auto-cancel setting. * <p> * A new Cached ThreadExecutorPool will be implicitely created. * * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferProcessor<E> create(boolean autoCancel) { return create(RingBufferProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), autoCancel); }
Example #21
Source File: RingBufferProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and auto-cancel. * <p> * A new Cached ThreadExecutorPool will be implicitely created. * * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferProcessor<E> create() { return create(RingBufferProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), true); }
Example #22
Source File: RingBufferProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and auto-cancel. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferProcessor<E> create(ExecutorService service) { return create(service, SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), true); }
Example #23
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and the passed auto-cancel setting. * <p> * A new Cached ThreadExecutorPool will be implicitely created. * * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> create(boolean autoCancel) { return create(RingBufferWorkProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), autoCancel); }
Example #24
Source File: RingBufferWorkProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferWorkProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and auto-cancel. * <p> * A new Cached ThreadExecutorPool will be implicitely created. * * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferWorkProcessor<E> create() { return create(RingBufferWorkProcessor.class.getSimpleName(), SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), true); }
Example #25
Source File: RingBufferProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using passed backlog size, blockingWait Strategy * and the auto-cancel argument. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param bufferSize A Backlog Size to mitigate slow subscribers * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferProcessor<E> share(ExecutorService service, int bufferSize, boolean autoCancel) { return share(service, bufferSize, new LiteBlockingWaitStrategy(), autoCancel); }
Example #26
Source File: RingBufferProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using passed backlog size, blockingWait Strategy * and will auto-cancel. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param bufferSize A Backlog Size to mitigate slow subscribers * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferProcessor<E> share(ExecutorService service, int bufferSize) { return share(service, bufferSize, new LiteBlockingWaitStrategy(), true); }
Example #27
Source File: RingBufferProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using the blockingWait Strategy, passed backlog size, * and auto-cancel settings. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param name Use a new Cached ExecutorService and assign this name to the created threads * @param bufferSize A Backlog Size to mitigate slow subscribers * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferProcessor<E> share(String name, int bufferSize, boolean autoCancel) { return share(name, bufferSize, new LiteBlockingWaitStrategy(), autoCancel); }
Example #28
Source File: RingBufferProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and the passed auto-cancel setting. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * A new Cached ThreadExecutorPool will be implicitely created and will use the passed name to qualify * the created threads. * * @param name Use a new Cached ExecutorService and assign this name to the created threads * @param bufferSize A Backlog Size to mitigate slow subscribers * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferProcessor<E> share(String name, int bufferSize) { return share(name, bufferSize, new LiteBlockingWaitStrategy(), true); }
Example #29
Source File: RingBufferProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and the passed auto-cancel setting. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param autoCancel Should this propagate cancellation when unregistered by all subscribers ? * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferProcessor<E> share(ExecutorService service, boolean autoCancel) { return share(service, SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), autoCancel); }
Example #30
Source File: RingBufferProcessor.java From camunda-bpm-reactor with Apache License 2.0 | 2 votes |
/** * Create a new RingBufferProcessor using {@link #SMALL_BUFFER_SIZE} backlog size, blockingWait Strategy * and auto-cancel. * <p> * A Shared Processor authorizes concurrent onNext calls and is suited for multi-threaded publisher that * will fan-in data. * <p> * The passed {@link java.util.concurrent.ExecutorService} will execute as many event-loop * consuming the ringbuffer as subscribers. * * @param service A provided ExecutorService to manage threading infrastructure * @param <E> Type of processed signals * @return a fresh processor */ public static <E> RingBufferProcessor<E> share(ExecutorService service) { return share(service, SMALL_BUFFER_SIZE, new LiteBlockingWaitStrategy(), true); }