當前位置: 首頁>>代碼示例>>Java>>正文


Java Disruptor.handleExceptionsWith方法代碼示例

本文整理匯總了Java中com.lmax.disruptor.dsl.Disruptor.handleExceptionsWith方法的典型用法代碼示例。如果您正苦於以下問題:Java Disruptor.handleExceptionsWith方法的具體用法?Java Disruptor.handleExceptionsWith怎麽用?Java Disruptor.handleExceptionsWith使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.lmax.disruptor.dsl.Disruptor的用法示例。


在下文中一共展示了Disruptor.handleExceptionsWith方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: inputDisruptor

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
@Provides
@Singleton
@Named("disruptor")
@SuppressWarnings("Unchecked")
protected Disruptor<TwoPhaseEvent<T>> inputDisruptor(Provider<WorkHandler<TwoPhaseEvent<T>>> workHandlerProvider,
                                                     Provider<EventHandler<TwoPhaseEvent<T>>> evenHandlerProvider) {
    Disruptor<TwoPhaseEvent<T>> disruptor = new Disruptor<>(
            TwoPhaseEvent.factory(outputEventFactory()),
            options.ringSize(), threadsProvider,
            ProducerType.SINGLE, new SleepingWaitStrategy());
    WorkHandler<TwoPhaseEvent<T>>[] parsers = new WorkHandler[options.threads()];
    for (int i = 0; i < options.threads(); i++) {
        parsers[i] = workHandlerProvider.get();
    }
    disruptor.handleExceptionsWith(new FatalExceptionHandler());
    disruptor.handleEventsWithWorkerPool(parsers).then(evenHandlerProvider.get());
    return disruptor;
}
 
開發者ID:scaled-ml,項目名稱:Scaled-ML,代碼行數:19,代碼來源:AbstractParallelModule.java

示例2: firstPassDisruptor

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
@Provides
@Singleton
@Named("firstPassDisruptor")
public Disruptor<TwoPhaseEvent<Void>> firstPassDisruptor(
        Provider<WorkHandler<TwoPhaseEvent<Void>>> statisticsHandlerProvider) {
    Disruptor<TwoPhaseEvent<Void>> disruptor = new Disruptor<>(
            TwoPhaseEvent.factory(() -> null),
            options.ringSize(), threadsProvider,
            ProducerType.SINGLE, new SleepingWaitStrategy());
    WorkHandler<TwoPhaseEvent<Void>>[] parsers = new WorkHandler[options.threads()];
    for (int i = 0; i < options.threads(); i++) {
        parsers[i] = statisticsHandlerProvider.get();
    }
    disruptor.handleExceptionsWith(new FatalExceptionHandler());
    disruptor.handleEventsWithWorkerPool(parsers);
    return disruptor;
}
 
開發者ID:scaled-ml,項目名稱:Scaled-ML,代碼行數:18,代碼來源:FeatureEngineeringModule.java

示例3: secondPassDisruptor

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
@Provides
@Singleton
@Named("secondPassDisruptor")
public Disruptor<TwoPhaseEvent<SparseItem>> secondPassDisruptor(
        Provider<WorkHandler<TwoPhaseEvent<SparseItem>>> binningHandlerProvider,
        Provider<EventHandler<TwoPhaseEvent<SparseItem>>> outputHandlerProvider) {
    Disruptor<TwoPhaseEvent<SparseItem>> disruptor = new Disruptor<>(
            TwoPhaseEvent.factory(SparseItem::new),
            options.ringSize(), threadsProvider,
            ProducerType.SINGLE, new SleepingWaitStrategy());
    WorkHandler<TwoPhaseEvent<SparseItem>>[] parsers = new WorkHandler[options.threads()];
    for (int i = 0; i < options.threads(); i++) {
        parsers[i] = binningHandlerProvider.get();
    }
    disruptor.handleExceptionsWith(new FatalExceptionHandler());
    disruptor.handleEventsWithWorkerPool(parsers)
            .then(outputHandlerProvider.get());
    return disruptor;
}
 
開發者ID:scaled-ml,項目名稱:Scaled-ML,代碼行數:20,代碼來源:FeatureEngineeringModule.java

示例4: initSpecDisruptor

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
/**
 * 根據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);
}
 
開發者ID:carryxyh,項目名稱:Electrons,代碼行數:34,代碼來源:Dispatcher.java

示例5: initNormalChannel

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
/**
 * 初始化正常管道,任何情況下都會有
 *
 * @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);
}
 
開發者ID:carryxyh,項目名稱:Electrons,代碼行數:19,代碼來源:Dispatcher.java

示例6: buildDisruptor

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private Disruptor<AvroEvent> buildDisruptor() {
  Disruptor<AvroEvent> disruptor = new Disruptor<>(avroEventFactory,
                                                   ringBufferSize,
                                                   consumerExecutor,
                                                   producerType,
                                                   waitStrategy);
  disruptor.handleExceptionsWith(new DisruptorExceptionHandler());
  disruptor.handleEventsWith(new AvroEventConsumer(avroFilename, avroSchema, rollingPolicy));
  return disruptor;
}
 
開發者ID:aol,項目名稱:vulcan,代碼行數:12,代碼來源:AvroWriterBuilder.java

示例7: DisruptorSbeMetricsService

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
public DisruptorSbeMetricsService(
            TimeSource timeSource,
            ConcurrentErrorReporter errorReporter,
            TimeUnit timeUnit,
            long maxRuntimeDurationAsNano,
            ResultsLogWriter resultsLogWriter,
            Map<Integer,Class<? extends Operation>> operationTypeToClassMapping,
            LoggingServiceFactory loggingServiceFactory ) throws MetricsCollectionException
    {
        // Specify the size of the ring buffer, must be power of 2
        int bufferSize = 1024;

        this.executor = Executors.newSingleThreadExecutor();
        // Construct the Disruptor
        disruptor = new Disruptor(
                new MetricsCollectionEventFactory(),
                bufferSize,
                // Executor that will be used to construct new threads for consumers
                this.executor,
                ProducerType.MULTI,
                new BlockingWaitStrategy()
//                new LiteBlockingWaitStrategy()
//                new SleepingWaitStrategy()
//                new YieldingWaitStrategy()
//                new BusySpinWaitStrategy()
//                new TimeoutBlockingWaitStrategy()
//                new PhasedBackoffWaitStrategy()
        );

        // Connect the handler
        eventHandler = new DisruptorSbeMetricsEventHandler(
                errorReporter,
                resultsLogWriter,
                timeUnit,
                timeSource,
                maxRuntimeDurationAsNano,
                operationTypeToClassMapping,
                loggingServiceFactory
        );

        disruptor.handleEventsWith( eventHandler );
        DisruptorExceptionHandler exceptionHandler = new DisruptorExceptionHandler( errorReporter );
        disruptor.handleExceptionsFor( eventHandler ).with( exceptionHandler );
        disruptor.handleExceptionsWith( exceptionHandler );

        // Start the Disruptor, starts all threads running  & get the ring buffer from the Disruptor to be used for
        // publishing
        ringBuffer = disruptor.start();

        this.timeSource = timeSource;
        metricsServiceWriters = new ConcurrentLinkedQueue<>();
    }
 
開發者ID:ldbc,項目名稱:ldbc_snb_driver,代碼行數:53,代碼來源:DisruptorSbeMetricsService.java

示例8: RoundRobinRelatedItemIndexingMessageEventHandler

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
public RoundRobinRelatedItemIndexingMessageEventHandler(final Configuration configuration,
                                                        RelatedItemIndexingMessageConverter converter,
                                                        RelatedItemReferenceMessageFactory messageFactory,
                                                        RelatedItemReferenceEventHandlerFactory relatedItemIndexingEventHandlerFactory
) {
    this.configuration = configuration;
    this.converter = converter;
    int numberOfIndexingRequestProcessors = Util.ceilingNextPowerOfTwo(configuration.getNumberOfIndexingRequestProcessors());
    disruptors = new Disruptor[numberOfIndexingRequestProcessors];
    executors = new ExecutorService[numberOfIndexingRequestProcessors];
    handlers = new RelatedItemReferenceEventHandler[numberOfIndexingRequestProcessors];

    mask = numberOfIndexingRequestProcessors-1;
    final int sizeOfQueue;
    if(configuration.getSizeOfBatchIndexingRequestQueue()==-1) {
        sizeOfQueue = Util.ceilingNextPowerOfTwo(configuration.getSizeOfIncomingMessageQueue()/numberOfIndexingRequestProcessors);
    } else {
        sizeOfQueue = Util.ceilingNextPowerOfTwo(configuration.getSizeOfBatchIndexingRequestQueue());
    }
    int i = numberOfIndexingRequestProcessors;
    while(i--!=0) {
        ExecutorService executorService = getExecutorService();
        executors[i]  = executorService;
        Disruptor<RelatedItemReference> disruptor = new Disruptor<RelatedItemReference>(
                messageFactory,
                sizeOfQueue, executorService,
                ProducerType.SINGLE, configuration.getWaitStrategyFactory().createWaitStrategy());

        disruptors[i]  = disruptor;
        handlers[i] = relatedItemIndexingEventHandlerFactory.getHandler();
        disruptor.handleExceptionsWith(new IgnoreExceptionHandler());
        disruptor.handleEventsWith(handlers[i]);

        disruptor.start();

    }
    nextDisruptor[COUNTER_POS] = 1;
    batchSize = configuration.getIndexBatchSize();

    batchMessages= new ArrayList<RelatedItem>(batchSize + configuration.getMaxNumberOfRelatedItemsPerItem());
}
 
開發者ID:tootedom,項目名稱:related,代碼行數:42,代碼來源:RoundRobinRelatedItemIndexingMessageEventHandler.java

示例9: createDisruptor

import com.lmax.disruptor.dsl.Disruptor; //導入方法依賴的package包/類
private Disruptor<ProxyMethodInvocation> createDisruptor(final ExecutorService executor, final int ringBufferSize)
{
    final Disruptor<ProxyMethodInvocation> disruptor = new Disruptor<ProxyMethodInvocation>(new RingBufferProxyEventFactory(), ringBufferSize, executor);
    disruptor.handleExceptionsWith(new FatalExceptionHandler());
    return disruptor;
}
 
開發者ID:LMAX-Exchange,項目名稱:disruptor-proxy,代碼行數:7,代碼來源:AbstractRingBufferProxyGeneratorTest.java


注:本文中的com.lmax.disruptor.dsl.Disruptor.handleExceptionsWith方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。