当前位置: 首页>>代码示例>>Java>>正文


Java ExcerptTailer类代码示例

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


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

示例1: readFromQueue

import net.openhft.chronicle.queue.ExcerptTailer; //导入依赖的package包/类
public static void readFromQueue(){

        ChronicleQueue queue = SingleChronicleQueueBuilder.binary(file).build();

            final ExcerptTailer tailer = queue.createTailer();
            //System.out.println(queue.dump());
            Executors.newSingleThreadExecutor().submit(()-> {
                while (true) {
                    tailer.readDocument(w -> {
                        ValueIn in = w.getValueIn();
                        long time = in.int64();
                        String filter = in.text();
                        MarketData trade = in.object(new MarketData(), MarketData.class);
                        System.out.println(time + "->" + trade);
                    });
                }
            });

    }
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:20,代码来源:QueuePlayGround.java

示例2: nextItemFromQueue

import net.openhft.chronicle.queue.ExcerptTailer; //导入依赖的package包/类
private boolean nextItemFromQueue(ExcerptTailer tailer,
                                  PlayOptions options, DataItemProcessor dim) {
    return !tailer.readDocument(w -> {
        ValueIn in = w.getValueIn();
        dim.process(in, options.using());
    });
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:8,代码来源:ReactivePlayer.java

示例3: getNextMatchingFilter

import net.openhft.chronicle.queue.ExcerptTailer; //导入依赖的package包/类
private Object getNextMatchingFilter(ExcerptTailer tailer, String filter) {
    nextItemFromQueue(tailer, dataItemProcessor);
    if (dataItemProcessor.getFilter().equals(filter)) {
        return dataItemProcessor.getObject();
    } else {
        return getNextMatchingFilter(tailer, filter);
    }

}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:10,代码来源:ReactiveValidator.java

示例4: writeToFile

import net.openhft.chronicle.queue.ExcerptTailer; //导入依赖的package包/类
/**
 * Writes the journal in a human readable form to a file. Optionally also writes it to stdout.
 * @param fileOutput The name of the file
 * @param toStdout Whether it should be written to stdout
 * @param zoneId TimeZone to display to format the time. If null uses millis since 1970.
 */
public void writeToFile(String fileOutput, boolean toStdout, ZoneId zoneId) {
    LOG.info("Writing recording to dir [" + fileOutput + "]");
    try (ChronicleQueue queue = createQueue()) {
        ExcerptTailer tailer = queue.createTailer();
        try {
            writeQueueToFile(tailer, fileOutput, toStdout, zoneId);
        } catch (IOException e) {
            LOG.error("Error writing to file", e);
        }
    }
    LOG.info("Writing to dir complete");
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:19,代码来源:ReactiveJournal.java

示例5: writeQueueToFile

import net.openhft.chronicle.queue.ExcerptTailer; //导入依赖的package包/类
private static void writeQueueToFile(ExcerptTailer tailer, String fileName, boolean toStdout, ZoneId zoneId)
        throws IOException {
    FileWriter fileWriter = new FileWriter(fileName);
    tailer.toStart();
    DataItemProcessor dim = new DataItemProcessor();
    while(tailer.readDocument(
            w -> {
                ValueIn in = w.getValueIn();
                dim.process(in,null);
                String time = null;
                if(zoneId != null) {
                    LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(dim.getTime()), zoneId);
                    time = dateTime.toString();
                }else{
                    time = String.valueOf(dim.getTime());
                }
                try {
                    String item = ReactiveStatus.toString(dim.getStatus()) + "\t" + dim.getMessageCount() + "\t" + time + "\t"
                            + dim.getFilter() + "\t" + dim.getObject();
                    fileWriter.write(item  + "\n");
                    if(toStdout) {
                        LOG.info(item);
                    }
                } catch (IOException e) {
                    LOG.error("Problem writing to file[" + fileName + "]", e);
                }
            }));
    fileWriter.close();
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:30,代码来源:ReactiveJournal.java

示例6: main

import net.openhft.chronicle.queue.ExcerptTailer; //导入依赖的package包/类
public static void main(String[] args) {
    String path = "queue";
    SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(path).build();
    ExcerptTailer tailer = queue.createTailer();

    while (true) {
        String text = tailer.readText();
        if (text == null)
            Jvm.pause(10);
        else
            System.out.println(text);

    }
}
 
开发者ID:OpenHFT,项目名称:Chronicle-Queue-Sample,代码行数:15,代码来源:OutputMain.java

示例7: nextItemFromQueue

import net.openhft.chronicle.queue.ExcerptTailer; //导入依赖的package包/类
private boolean nextItemFromQueue(ExcerptTailer tailer,DataItemProcessor dim) {
    return !tailer.readDocument(w -> {
        ValueIn in = w.getValueIn();
        dim.process(in, null);
    });
}
 
开发者ID:danielshaya,项目名称:reactivejournal,代码行数:7,代码来源:ReactiveValidator.java

示例8: getTailer

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

示例9: run

import net.openhft.chronicle.queue.ExcerptTailer; //导入依赖的package包/类
/**
	 * {@inheritDoc}
	 * @see java.lang.Runnable#run()
	 */
	@Override
	public void run() {
		final ExcerptTailer tailer = queue.createTailer();
		final ByteBufMarshallable smm = new ByteBufMarshallable(compression); 
		startLatch.countDown();
		while(keepRunning.get()) {			
			try {
				long processed = 0L;
				long reads = 0L;
				int listenerProcessed = 0;
				final long startTime = System.currentTimeMillis();
				while(tailer.readBytes(smm)) {
					chronicleReads.inc();
					reads++;
					final ByteBuf sm = smm.getAndNullByteBuf();
					log.debug("MessageQueue Read Buffer, size: {} bytes", sm.readableBytes());
					if(sm!=null) {
						listenerProcessed += listener.onMetric(sm);
//						sm.release();
						processed++;
						if(processed==stopCheckCount) {
							processed = 0;
							if(!keepRunning.get()) break;
						}
					}
				}
				if(reads==0) {
					Jvm.pause(idlePauseTime);
				} else {
					final long elapsedTime = System.currentTimeMillis() - startTime;
					log.info("Processed [{}] in [{}] ms.", listenerProcessed, elapsedTime);
				}			
				reads = 0;
			} catch (Exception ex) {
				if(ex instanceof InterruptedException) {
					if(keepRunning.get()) {
						if(Thread.interrupted()) Thread.interrupted();
					}
					log.info("Reader Thread [{}] shutting down", Thread.currentThread());
				} else {
					log.warn("Unexpected exception in reader thread",  ex);
				}
			}
		}
	}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:50,代码来源:MessageQueue.java


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