Search in sources :

Example 36 with SingleChronicleQueue

use of net.openhft.chronicle.queue.impl.single.SingleChronicleQueue in project Chronicle-Queue by OpenHFT.

the class ResultGenerator method main.

public static void main(String[] args) throws IOException {
    if (args.length != 1) {
        throw new IllegalArgumentException("Usage: <program> [resource-name]");
    }
    final ConfigParser configParser = new ConfigParser(args[0]);
    final List<StageConfig> allStageConfigs = configParser.getAllStageConfigs();
    final StageConfig lastStageConfig = allStageConfigs.get(allStageConfigs.size() - 1);
    Jvm.setExceptionHandlers((c, m, t) -> {
        System.out.println(m);
    }, (c, m, t) -> {
        System.out.println(m);
        if (t != null) {
            t.printStackTrace();
        }
    }, (c, m, t) -> System.out.println(m));
    try (final SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(lastStageConfig.getOutputPath()).build();
        final Writer resultsWriter = new FileWriter("results.txt", false)) {
        final MethodReader methodReader = queue.createTailer().methodReader(new CapturingReceiver(resultsWriter));
        while (methodReader.readOne()) {
        // report
        }
    }
}
Also used : FileWriter(java.io.FileWriter) ConfigParser(net.openhft.load.config.ConfigParser) SingleChronicleQueue(net.openhft.chronicle.queue.impl.single.SingleChronicleQueue) MethodReader(net.openhft.chronicle.bytes.MethodReader) StageConfig(net.openhft.load.config.StageConfig) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Aggregations

SingleChronicleQueue (net.openhft.chronicle.queue.impl.single.SingleChronicleQueue)36 Test (org.junit.Test)24 File (java.io.File)13 MethodReader (net.openhft.chronicle.bytes.MethodReader)10 DocumentContext (net.openhft.chronicle.wire.DocumentContext)10 ExcerptAppender (net.openhft.chronicle.queue.ExcerptAppender)7 Ignore (org.junit.Ignore)6 OS (net.openhft.chronicle.core.OS)4 IOTools (net.openhft.chronicle.core.io.IOTools)4 ExcerptTailer (net.openhft.chronicle.queue.ExcerptTailer)4 SingleChronicleQueueBuilder (net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder)4 Path (java.nio.file.Path)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 NotNull (org.jetbrains.annotations.NotNull)3 Assert (org.junit.Assert)3 Before (org.junit.Before)3 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 PrintStream (java.io.PrintStream)2