• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExcerptAppender类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.openhft.chronicle.queue.ExcerptAppender的典型用法代码示例。如果您正苦于以下问题:Java ExcerptAppender类的具体用法?Java ExcerptAppender怎么用?Java ExcerptAppender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExcerptAppender类属于net.openhft.chronicle.queue包,在下文中一共展示了ExcerptAppender类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeNonSerial

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
public static void writeNonSerial() {
    //for(int t=0; t<5; t++) {
    //    new Thread(() -> {
    try (ChronicleQueue queue = SingleChronicleQueueBuilder.binary(file).bufferCapacity(1000).build()) {
        final ExcerptAppender appender = queue.acquireAppender();
        for (int i = 0; i < 10; i++) {
            final int f = i;
            appender.writeDocument(w -> {
                w.getValueOut().int64(System.currentTimeMillis());
                w.getValueOut().object(new MarketData());
            });
            DSUtil.sleep(100);
        }

    }
    //    }).start();
    // }
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:19,代码来源:QueuePlayGround.java


示例2: writeToQueue

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
public static void writeToQueue() {
    //for(int t=0; t<5; t++) {
    //    new Thread(() -> {
    try (ChronicleQueue queue = SingleChronicleQueueBuilder.binary(file).build()) {
        final ExcerptAppender appender = queue.acquireAppender();
        for (int i = 0; i < 10; i++) {
            final int f = i;
            appender.writeDocument(w -> {
                w.getValueOut().int64(System.currentTimeMillis());
                w.getValueOut().object(new MarketData());
            });
            DSUtil.sleep(100);
        }

    }
    //    }).start();
    // }
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:19,代码来源:QueuePlayGround.java


示例3: record

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
public void record(Publisher<?> publisher, String filter) {
    ChronicleQueue queue = reactiveJournal.createQueue();
    ExcerptAppender appender = queue.acquireAppender();

    TriConsumer<ExcerptAppender, String, Object> onNextConsumer = getOnNextConsumerRecorder();
    BiConsumer<ExcerptAppender, String> onCompleteConsumer = getOnCompleteRecorder();
    TriConsumer<ExcerptAppender, String, Throwable> onErrorConsumer = getOnErrorRecorder();

    publisher.subscribe(new Subscriber<Object>() {
        @Override
        public void onSubscribe(Subscription subscription) {
            subscription.request(Long.MAX_VALUE);
        }

        @Override
        public void onNext(Object o) {
            onNextConsumer.accept(appender, filter, o);
        }

        @Override
        public void onError(Throwable throwable) {
            onErrorConsumer.accept(appender, filter, throwable);
        }

        @Override
        public void onComplete() {
            onCompleteConsumer.accept(appender, filter);
        }
    });
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:31,代码来源:ReactiveRecorder.java


示例4: start

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
public void start() {
	for(int i = 0; i < threadCount; i++) {
		final int ID = i;
		threadPool.execute(new Runnable(){				
			public void run() {
				final Thread thread = Thread.currentThread();
				final ExcerptAppender ae = queue.acquireAppender();
				ae.padToCacheAlign(Padding.SMART);
				final HashMap<String, String> map = new HashMap<String, String>(4);
				final boolean pause = pauseTime > 0L;
				log.info("Starting writer thread #{}", ID);
				while(true) {
					if(!running.get()) break;
					try {
						final ElapsedTime et = SystemClock.startClock();
						for(int i = 0; i < batchSize; i++) {
							final DataPoint dp = randomDataPoint();
							//pendingDataPoints.put(dp.longHashCode(), dp.clone());
							ae.writeBytes(dp);								
							sendCounter.increment();
						}
						log.info("Sender: {}", et.printAvg("MessagesSent", batchSize));
						if(pause) thread.join(pauseTime);
					} catch (InterruptedException iex) {
						log.info("Stopped writer thread #{}", ID);
						break;
					} catch (Exception ex) {
						if(running.get()) {
							log.error("Processing error in writer", ex);
						}
					}
				}
			}
		});
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:37,代码来源:MessageGenerator.java


示例5: main

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
public static void main(String[] args) {
    String path = "queue";
    SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(path).build();
    ExcerptAppender appender = queue.acquireAppender();
    Scanner read = new Scanner(System.in);
    while (true) {
        System.out.println("type something");
        String line = read.nextLine();
        if (line.isEmpty())
            break;
        appender.writeText(line);
    }
    System.out.println("... bye.");
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Queue-Sample,代码行数:15,代码来源:InputMain.java


示例6: getOnNextConsumerRecorder

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
private TriConsumer<ExcerptAppender, String, Object> getOnNextConsumerRecorder(){
    return (a, f, v) -> a.writeDocument(w -> {
        writeObject(w, f, v, ReactiveStatus.VALID);
    });
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:6,代码来源:ReactiveRecorder.java


示例7: getOnCompleteRecorder

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
private BiConsumer<ExcerptAppender, String> getOnCompleteRecorder(){
    return (a,f) -> a.writeDocument(w -> {
        writeObject(w, f, new EndOfStream(), ReactiveStatus.COMPLETE);
        LOG.debug("Adding end of stream token");
    });
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:7,代码来源:ReactiveRecorder.java


示例8: getOnErrorRecorder

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
private TriConsumer<ExcerptAppender, String, Throwable> getOnErrorRecorder(){
    return (a, f, t) -> a.writeDocument(w -> {
        writeObject(w, f, t, ReactiveStatus.ERROR);
    });
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:6,代码来源:ReactiveRecorder.java


示例9: run

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
private void run() {
    // start a timer to monitor events / second
    AtomicLong numEvents = new AtomicLong(0L);
    timeline.getScheduler().schedule(() -> {
        LOG.info("processed " + (numEvents.get() / 15) + " events / second");
        numEvents.set(0L);
    }).repeatIndefinitely(Duration.ofSeconds(15L))
            .start();

    // start the marketdata subscription
    String[] productCodes = {
            "BTC/USD",
            "ETH/USD",
            "LTC/USD",
            "ETH/BTC",
            "LTC/BTC"
    };
    for (String productCode : productCodes) {
        ProductId product = new ProductId("urn:gsid:product:" + productCode);
        mdClientFuture.thenAccept(mdClient -> {
            try {
                Signal<OrderBookEvent> events = mdClient.subscribeOrderBookEvents(product);
                timeline.onSignal(events)
                        .map(event -> numEvents.incrementAndGet())
                        .bind();

                RecordContext ctx = new InMemoryRecordContext();
                String queuePath = "orderEvents" + File.separator + productCode.replace('/', '-');
                try (ChronicleQueue queue = SingleChronicleQueueBuilder.binary(queuePath).build()) {
                   timeline.bind(events, event -> {
                       OrderBookEvent orderEvent = events.getValue();
                       ExcerptAppender appender = queue.acquireAppender();
                       appender.writeDocument(w -> w.write("orderEvent")
                               .marshallable(m -> m.write("eventTypeCode")
                                       .int8(orderEvent.getEventType().getCode())
                               .write("product").text(product.getCode())
                               .write("eventData").bytes(orderEvent.encodeRecord(ctx))));
                   });
                }
            } catch (GeneralSecurityException | IOException | URISyntaxException e) {
                LOG.error("failed to subscribe to OrderBookEvents", e);
            }
        });
    }
}
 
开发者ID:cloudwall,项目名称:libcwfincore,代码行数:46,代码来源:MarketdataCaptureTool.java


示例10: getAppender

import net.openhft.chronicle.queue.ExcerptAppender; //导入依赖的package包/类
public ExcerptAppender getAppender() {
    return appender;
}
 
开发者ID:terzerm,项目名称:fx-highway,代码行数:4,代码来源:ChronicleQueue4x.java



注:本文中的net.openhft.chronicle.queue.ExcerptAppender类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CommandPermission类代码示例发布时间:2022-05-23
下一篇:
Java BaseMod类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap