Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用hashmap lmax中断器中的数据实现ringbuffer_Java_Disruptor Pattern_Lmax - Fatal编程技术网

Java 如何使用hashmap lmax中断器中的数据实现ringbuffer

Java 如何使用hashmap lmax中断器中的数据实现ringbuffer,java,disruptor-pattern,lmax,Java,Disruptor Pattern,Lmax,实际上,在阅读并使用了一个简单的破坏性示例之后,我找不到如何使用hashmap中的数据实现环缓冲区,而hashmap中的数据已经使用eventHandler中的数据实现了,translator或从哪个组件获得帮助?u应该在bean中或包含业务流程的地方进行测试最简单的方法是在主类中进行测试 public static void main () { // Executor that will be used to construct new threads for consumers

实际上,在阅读并使用了一个简单的破坏性示例之后,我找不到如何使用hashmap中的数据实现环缓冲区,而hashmap中的数据已经使用eventHandler中的数据实现了,translator或从哪个组件获得帮助?

u应该在bean中或包含业务流程的地方进行测试最简单的方法是在主类中进行测试

 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());

        }**
publicstaticvoidmain(){
//将用于为使用者构造新线程的执行器
Executor Executor=Executors.newCachedThreadPool();
//活动的工厂
LogEventFactory=新的LogEventFactory();
//指定环形缓冲区的大小,必须是2的幂。
int bufferSize=262144;
//构造破坏者
干扰物干扰物=新干扰物(工厂、缓冲区大小、执行器);
//连接处理程序
disruptor.handleEventsWith(新的LogEventHandler());
//启动中断器,启动所有线程运行
disruptor.start();
//从中断器获取用于发布的环形缓冲区。
RingBuffer-RingBuffer=disruptor.getRingBuffer();
LongEventProducerWithTranslator producer=新的LongEventProducerWithTranslator(环形缓冲区);
**for(字符串名称:cache.keySet()){
String key=name.toString();
字符串值=cache.get(name.toString();
producer.onData(cache.get(name));
//《睡眠》(2000年);
//System.out.println(“key:+key++++”//value:+cache.get(name.getTags());
}**
遍历它,您的translator类应该获取通过循环的对象