Search in sources :

Example 1 with StageConfig

use of net.openhft.load.config.StageConfig in project Chronicle-Queue by OpenHFT.

the class StageMain method main.

public static void main(String[] args) throws IOException {
    // MlockAll.doMlockall();
    if (args.length != 2) {
        throw new IllegalArgumentException("Usage: <program> [resource-name] [stage-index]");
    }
    final ConfigParser configParser = new ConfigParser(args[0]);
    final StageConfig stageConfig = configParser.getStageConfig(Integer.parseInt(args[1]));
    final ExecutorService service = Executors.newFixedThreadPool(stageConfig.getStageIndices().size() + 1);
    service.submit(new PretoucherTask(outputQueue(stageConfig.getOutputPath(), UNSET_SOURCE), configParser.getPretouchIntervalMillis()));
    for (Integer index : stageConfig.getStageIndices()) {
        service.submit(() -> {
            final Stage stage = new Stage(createOutput(stageConfig.getOutputPath(), index + 1), index);
            final MethodReader reader = createReader(stageConfig.getInputPath(), stage);
            Thread.currentThread().setName("load.stage-consumer-" + index);
            boolean warnOnce = false;
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    reader.readOne();
                } catch (Exception e) {
                    if (!warnOnce) {
                        e.printStackTrace();
                        warnOnce = true;
                    }
                }
            }
        });
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) ConfigParser(net.openhft.load.config.ConfigParser) MethodReader(net.openhft.chronicle.bytes.MethodReader) StageConfig(net.openhft.load.config.StageConfig) IOException(java.io.IOException)

Example 2 with StageConfig

use of net.openhft.load.config.StageConfig in project Chronicle-Queue by OpenHFT.

the class PublishDeltaGenerator method main.

public static void main(String[] args) throws IOException {
    if (args.length != 1) {
        throw new IllegalArgumentException("Usage: <program> [resource-name]");
    }
    Jvm.setExceptionHandlers((c, m, t) -> {
        System.out.println(m);
    }, (c, m, t) -> {
        System.out.println(m);
        t.printStackTrace();
    }, (c, m, t) -> System.out.println(m));
    final ConfigParser configParser = new ConfigParser(args[0]);
    final List<StageConfig> allStageConfigs = configParser.getAllStageConfigs();
    final StageConfig lastStageConfig = allStageConfigs.get(allStageConfigs.size() - 1);
    try (final SingleChronicleQueue pubQueue = SingleChronicleQueueBuilder.binary(configParser.getPublisherConfig().outputDir()).build();
        final SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(lastStageConfig.getOutputPath()).build();
        final Writer resultsWriter = new FileWriter("publish-deltas.txt", false);
        final Writer s0Pub = new FileWriter("s0-deltas.txt", false);
        final Writer s1Pub = new FileWriter("s1-deltas.txt", false);
        final Writer s0s2Pub = new FileWriter("s0-s2-deltas.txt", false);
        final Writer s1s2Pub = new FileWriter("s1-s2-deltas.txt", false)) {
        final MethodReader reader = pubQueue.createTailer().methodReader(new CapturingReceiver(resultsWriter, m -> m.publishNanos));
        while (reader.readOne()) {
        // report
        }
        final MethodReader methodReader = queue.createTailer().methodReader(new DelegatingReceiver(new CapturingReceiver(s0Pub, m -> m.t0), new CapturingReceiver(s1Pub, m -> m.t1), new CapturingReceiver(s0s2Pub, m -> m.t2, 5), new CapturingReceiver(s1s2Pub, m -> m.t2, 6)));
        while (methodReader.readOne()) {
        // report
        }
    }
}
Also used : MethodReader(net.openhft.chronicle.bytes.MethodReader) FileWriter(java.io.FileWriter) LocalDateTime(java.time.LocalDateTime) IOException(java.io.IOException) EightyByteMessage(net.openhft.load.messages.EightyByteMessage) Jvm(net.openhft.chronicle.core.Jvm) TimeUnit(java.util.concurrent.TimeUnit) SingleChronicleQueueBuilder(net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder) List(java.util.List) SingleChronicleQueue(net.openhft.chronicle.queue.impl.single.SingleChronicleQueue) StageConfig(net.openhft.load.config.StageConfig) DateTimeFormatter(java.time.format.DateTimeFormatter) Writer(java.io.Writer) ZoneOffset(java.time.ZoneOffset) ToLongFunction(java.util.function.ToLongFunction) ConfigParser(net.openhft.load.config.ConfigParser) 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)

Example 3 with StageConfig

use of net.openhft.load.config.StageConfig 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

MethodReader (net.openhft.chronicle.bytes.MethodReader)3 ConfigParser (net.openhft.load.config.ConfigParser)3 StageConfig (net.openhft.load.config.StageConfig)3 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 Writer (java.io.Writer)2 SingleChronicleQueue (net.openhft.chronicle.queue.impl.single.SingleChronicleQueue)2 LocalDateTime (java.time.LocalDateTime)1 ZoneOffset (java.time.ZoneOffset)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 List (java.util.List)1 ExecutorService (java.util.concurrent.ExecutorService)1 TimeUnit (java.util.concurrent.TimeUnit)1 ToLongFunction (java.util.function.ToLongFunction)1 Jvm (net.openhft.chronicle.core.Jvm)1 SingleChronicleQueueBuilder (net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder)1 EightyByteMessage (net.openhft.load.messages.EightyByteMessage)1