简体   繁体   中英

how to fulfill the ringbuffer with data from my hashmap lmax disruptor

实际上,在阅读并使用一个简单的破坏性示例之后,我找不到如何将哈希映射中的数据与eventHandler,Translator或来自哪个组件的数据一起满足的哈希缓冲区中的数据实现到哪里?

u should do it in your bean or place containing your business process the easiest way to test with is in your main class

 public static void main () {

    // Executor that will be used to construct new threads for consumers
        Executor executor = Executors.newCachedThreadPool();

        // The factory for the event
        LogEventFactory factory = new LogEventFactory();

        // Specify the size of the ring buffer, must be power of 2.
        int bufferSize = 262144;

        // Construct the Disruptor
        Disruptor<LogEvent> disruptor = new Disruptor<LogEvent>(factory, bufferSize, executor);

        // Connect the handler
        disruptor.handleEventsWith(new LogEventHandler());

        // Start the Disruptor, starts all threads running
        disruptor.start();

        // Get the ring buffer from the Disruptor to be used for publishing.
        RingBuffer<LogEvent> ringBuffer = disruptor.getRingBuffer();

        LongEventProducerWithTranslator producer = new LongEventProducerWithTranslator(ringBuffer);

        **for (String name : cache.keySet()) {



            String key = name.toString();
            String value = cache.get(name).toString();

            producer.onData(cache.get(name));
            //Thread.sleep(2000);
            //System.out.println("key:" + key + " " + "//value:" + cache.get(name).getTags());

        }**

iterate through it and your translator class should take object passed through the loop

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM