Package com.higherfrequencytrading.chronicle.impl

Examples of com.higherfrequencytrading.chronicle.impl.IndexedChronicle


        String basePath = args[0];
        int port = Integer.parseInt(args[1]);
        int delayNS = 5 * 1000 * 1000;
        if (args.length > 2)
            delayNS = Integer.parseInt(args[2]);
        IndexedChronicle ic = new IndexedChronicle(basePath, dataBitsHintSize, byteOrder);
        new ChronicleSource<IndexedChronicle>(ic, port, delayNS);
    }
View Full Code Here


        String inboundPath = args[1];
        String hostname = args[2];
        int port = Integer.parseInt(args[3]);
        WaitingThread thread = new WaitingThread(1, "SocketGateway " + hostname + ":" + port, false);
        new SocketGateway(new InetSocketAddress(hostname, port),
                new IndexedChronicle(outboundPath), new IndexedChronicle(inboundPath), thread);
    }
View Full Code Here

        String def = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN ? "Big" : "Little";
        ByteOrder byteOrder = System.getProperty("byteOrder", def).equalsIgnoreCase("Big") ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
        String basePath = args[0];
        String hostname = args[1];
        int port = Integer.parseInt(args[2]);
        IndexedChronicle ic = new IndexedChronicle(basePath, dataBitsHintSize, byteOrder);
        new ChronicleSink(ic, hostname, port);
    }
View Full Code Here

        AffinitySupport.setAffinity(1 << 3);
        String tmp = System.getProperty("java.io.tmpdir");
//        String tmp = System.getProperty("user.home");

        String pePath = tmp + "/demo/pe";
        IndexedChronicle pe2gw = new IndexedChronicle(pePath);
        pe2gw.useUnsafe(true);
        Excerpt excerpt = pe2gw.createExcerpt();
        final Pe2GwWriter pe2GwWriter = new Pe2GwWriter(excerpt);

        Gw2PeEvents listener = new PEEvents(pe2GwWriter);
        Gw2PeReader[] readers = new Gw2PeReader[2];
        IndexedChronicle[] gw2pe = new IndexedChronicle[readers.length];
        for (int i = 0; i < readers.length; i++) {
            int sourceId = i + 1;
            String gw2pePath = tmp + "/demo/gw2pe" + sourceId;
            gw2pe[i] = new IndexedChronicle(gw2pePath);
            gw2pe[i].useUnsafe(true);
            readers[i] = new Gw2PeReader(sourceId, gw2pe[i].createExcerpt(), listener);
        }

        long prevProcessed = 0, count = 0;
View Full Code Here

        ChronicleTools.deleteOnExit(basePath1);
        ChronicleTools.deleteOnExit(basePath2);
        ChronicleTools.deleteOnExit(basePath3);

        Chronicle chronicle2w = new IndexedChronicle(basePath2);
        EventsWriter writer2 = new EventsWriter(chronicle2w);

        Chronicle chronicle1 = new IndexedChronicle(basePath1);
        InProcessChronicleSink sink = new InProcessChronicleSink(chronicle1, HOST, PORT);
        final EventsReader sinkReader = new EventsReader(sink.createExcerpt(), new BrokerEvents(writer2),
                TimingStage.SourceRead, TimingStage.EngineWrite);

        Thread cbt = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("CB: Waiting to consume events");
                // first broker thread.
                while (true) {
                    if (!sinkReader.read())
                        pause();
                }
            }
        }, "central broker");
        cbt.start();

        Chronicle chronicle3 = new IndexedChronicle(basePath3);
        InProcessChronicleSource source3 = new InProcessChronicleSource(chronicle3, PORT3);
        source3.busyWaitTimeNS(2 * 1000 * 1000);
        EventsWriter writer3 = new EventsWriter(source3);

        Chronicle chronicle2r = new IndexedChronicle(basePath2);
        final EventsReader reader2 = new EventsReader(chronicle2r.createExcerpt(),
                new BrokerEvents(writer3), TimingStage.EngineRead, TimingStage.SinkWrite);

        Thread pet = new Thread(new Runnable() {
            @Override
            public void run() {
View Full Code Here

    public static void main(String... ignored) throws IOException, InterruptedException {
        String basePath = TMP + "/1-source";
        ChronicleTools.deleteOnExit(basePath);

        Chronicle chronicle = new IndexedChronicle(basePath);
        InProcessChronicleSource source = new InProcessChronicleSource(chronicle, PORT);
        source.busyWaitTimeNS(2 * 1000 * 1000);

        EventsWriter writer = new EventsWriter(source);

View Full Code Here

    public static void main(String... ignored) throws IOException, InterruptedException {
        String basePath3 = TMP + "/3-sink";

        ChronicleTools.deleteOnExit(basePath3);

        Chronicle chronicle3 = new IndexedChronicle(basePath3);
        InProcessChronicleSink sink3 = new InProcessChronicleSink(chronicle3, HOST3, PORT3);
        final EventsReader sinkReader = new EventsReader(sink3.createExcerpt(), new LatencyEvents(), TimingStage.SinkRead, TimingStage.EngineWrite);

        while (true) {
            if (!sinkReader.read())
View Full Code Here

            stringsListener.inSync();
            intListener.inSync();

            replay(stringsListener);
            replay(intListener);
            Chronicle chronicle = new IndexedChronicle(name);
            DataStore dataStore = new DataStore(chronicle, ModelMode.MASTER);
            MapWrapper<String, String> strings = new MapWrapper<String, String>(dataStore, "strings", String.class, String.class, new LinkedHashMap<String, String>(), 16);
            strings.addListener(stringsListener);
            MapWrapper<Integer, Integer> ints = new MapWrapper<Integer, Integer>(dataStore, "ints", Integer.class, Integer.class, new LinkedHashMap<Integer, Integer>(), 16);
            ints.addListener(intListener);

            dataStore.start();

            ints.put(0, 1000);
            strings.put("Hello", "hi");
            ints.put(1, 1001);
            strings.put("World", "all");
            ints.put(2, 1002);

            strings.publishEvent("bye");
            ints.publishEvent("now");

            verify(stringsListener);
            verify(intListener);

            assertEquals("{Hello=hi, World=all}", strings.toString());
            assertEquals("{0=1000, 1=1001, 2=1002}", ints.toString());

            chronicle.close();
        }
        {
            MapListener stringsListener = createMock("strings", MapListener.class);
            stringsListener.eventStart(7, "strings");
            stringsListener.add("!", "end");
            stringsListener.eventEnd(true);

            MapListener intListener = createMock("ints", MapListener.class);

            intListener.eventStart(8, "ints");
            intListener.add(3, 1003);
            intListener.eventEnd(true);

            stringsListener.inSync();
            intListener.inSync();

            replay(stringsListener);
            replay(intListener);

            Chronicle chronicle = new IndexedChronicle(name);
            DataStore dataStore = new DataStore(chronicle, ModelMode.MASTER);
            MapWrapper<String, String> strings = new MapWrapper<String, String>(dataStore, "strings", String.class, String.class, new LinkedHashMap<String, String>(), 16);
            strings.addListener(stringsListener);
            MapWrapper<Integer, Integer> ints = new MapWrapper<Integer, Integer>(dataStore, "ints", Integer.class, Integer.class, new LinkedHashMap<Integer, Integer>(), 16);
            ints.addListener(intListener);

            // assume we have  all the events written so far
            dataStore.start(chronicle.size() - 1);

            strings.put("!", "end");
            ints.put(3, 1003);

            verify(stringsListener);
            verify(intListener);

            assertEquals("{Hello=hi, World=all, !=end}", strings.toString());
            assertEquals("{0=1000, 1=1001, 2=1002, 3=1003}", ints.toString());
            chronicle.close();
        }
    }
View Full Code Here

        String name = TMP + "/map-perf";
        ChronicleTools.deleteOnExit(name);
        long start = System.nanoTime();
        int size = 0;
        {
            Chronicle chronicle = new IndexedChronicle(name);
            DataStore dataStore = new DataStore(chronicle, ModelMode.MASTER);
            MapWrapper<String, String> strings = new MapWrapper<String, String>(dataStore, "strings", String.class, String.class, new LinkedHashMap<String, String>(), 16);
            MapWrapper<Integer, Integer> ints = new MapWrapper<Integer, Integer>(dataStore, "ints", Integer.class, Integer.class, new LinkedHashMap<Integer, Integer>(), 16);
            dataStore.start();
            ints.clear();
            strings.clear();

            for (int j = 0; j < 10000; j++) {
                for (int i = 0; i < 100; i++) {
                    ints.put(i, i + j);
                    strings.put(Integer.toString(i), Integer.toString(i + j));
                }
                size += Math.min(strings.size(), ints.size());
                for (int i = 0; i < 100; i++) {
                    ints.remove(i);
                    strings.remove(Integer.toString(i));
                }
            }

            chronicle.close();
        }
        long mid = System.nanoTime();
        {
            Chronicle chronicle = new IndexedChronicle(name);
            DataStore dataStore = new DataStore(chronicle, ModelMode.MASTER);
            MapWrapper<String, String> strings = new MapWrapper<String, String>(dataStore, "strings", String.class, String.class, new LinkedHashMap<String, String>(), 16);
            MapWrapper<Integer, Integer> ints = new MapWrapper<Integer, Integer>(dataStore, "ints", Integer.class, Integer.class, new LinkedHashMap<Integer, Integer>(), 16);
            dataStore.start();
            chronicle.close();
        }
        long end = System.nanoTime();
        System.out.printf("Took %.1f seconds avg to add&remove %,d elements and %.1f seconds avg to reload them%n",
                (mid - start) / 2e9, size, (end - mid) / 2e9);
    }
View Full Code Here

        long start = System.nanoTime();
        int PORT = 12346;
        int size = 0;

        InProcessChronicleSource chronicle = new InProcessChronicleSource(new IndexedChronicle(name), PORT);
        DataStore dataStore = new DataStore(chronicle, ModelMode.MASTER);
        MapWrapper<String, String> strings = new MapWrapper<String, String>(dataStore, "strings", String.class, String.class, new LinkedHashMap<String, String>(), 16);
        MapWrapper<Integer, Integer> ints = new MapWrapper<Integer, Integer>(dataStore, "ints", Integer.class, Integer.class, new LinkedHashMap<Integer, Integer>(), 16);
        dataStore.start();
        ints.clear();
        strings.clear();

        InProcessChronicleSink chronicle2 = new InProcessChronicleSink(new IndexedChronicle(name2), "localhost", PORT);
        DataStore dataStore2 = new DataStore(chronicle2, ModelMode.READ_ONLY);
        MapWrapper<String, String> strings2 = new MapWrapper<String, String>(dataStore2, "strings", String.class, String.class, new LinkedHashMap<String, String>(), 16);
        MapWrapper<Integer, Integer> ints2 = new MapWrapper<Integer, Integer>(dataStore2, "ints", Integer.class, Integer.class, new LinkedHashMap<Integer, Integer>(), 16);

        final AtomicInteger sai = new AtomicInteger();
View Full Code Here

TOP

Related Classes of com.higherfrequencytrading.chronicle.impl.IndexedChronicle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.