本文整理汇总了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);
});
}
});
}
示例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());
});
}
示例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);
}
}
示例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");
}
示例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();
}
示例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);
}
}
示例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);
});
}
示例8: getTailer
import net.openhft.chronicle.queue.ExcerptTailer; //导入依赖的package包/类
public ExcerptTailer getTailer() {
return tailer;
}
示例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);
}
}
}
}