Search in sources :

Example 1 with IndexedJournal

use of com.questdb.net.ha.model.IndexedJournal in project questdb by bluestreak01.

the class PartitionTest method syncSymbolTables.

private void syncSymbolTables() throws JournalNetworkException {
    JournalClientStateProducer sp = new JournalClientStateProducer();
    JournalClientStateConsumer sc = new JournalClientStateConsumer();
    sp.write(channel, new IndexedJournal(0, slave));
    sc.read(channel);
    JournalSymbolTableProducer p = new JournalSymbolTableProducer(master);
    JournalSymbolTableConsumer c = new JournalSymbolTableConsumer(slave);
    p.configure(master.find(sc.getValue().getTxn(), sc.getValue().getTxPin()));
    p.write(channel);
    c.read(channel);
}
Also used : JournalClientStateProducer(com.questdb.net.ha.producer.JournalClientStateProducer) JournalClientStateConsumer(com.questdb.net.ha.comsumer.JournalClientStateConsumer) IndexedJournal(com.questdb.net.ha.model.IndexedJournal) JournalSymbolTableProducer(com.questdb.net.ha.producer.JournalSymbolTableProducer) JournalSymbolTableConsumer(com.questdb.net.ha.comsumer.JournalSymbolTableConsumer)

Example 2 with IndexedJournal

use of com.questdb.net.ha.model.IndexedJournal in project questdb by bluestreak01.

the class AbstractJournalTest method executeSequence.

void executeSequence(boolean expectContent) throws JournalNetworkException, JournalException {
    slave.refresh();
    journalClientStateProducer.write(channel, new IndexedJournal(0, slave));
    journalClientStateConsumer.read(channel);
    journalDeltaProducer.configure(journalClientStateConsumer.getValue().getTxn(), journalClientStateConsumer.getValue().getTxPin());
    Assert.assertEquals(expectContent, journalDeltaProducer.hasContent());
    if (expectContent) {
        journalDeltaProducer.write(channel);
        journalDeltaConsumer.read(channel);
        TestUtils.assertEquals(master, slave);
    }
}
Also used : IndexedJournal(com.questdb.net.ha.model.IndexedJournal)

Example 3 with IndexedJournal

use of com.questdb.net.ha.model.IndexedJournal in project questdb by bluestreak01.

the class JournalServerAgentTest method testIncrementalInteraction.

@Test
public void testIncrementalInteraction() throws Exception {
    try (JournalWriter<Quote> origin = getFactory().writer(Quote.class, "origin")) {
        TestUtils.generateQuoteData(origin, 200);
        server.start();
        try (JournalWriter<Quote> quoteClientWriter = getFactory().writer(Quote.class, "client")) {
            JournalDeltaConsumer quoteDeltaConsumer = new JournalDeltaConsumer(quoteClientWriter);
            // send quote journal key
            commandProducer.write(channel, Command.ADD_KEY_CMD);
            setKeyRequestProducer.write(channel, new IndexedJournalKey(0, quoteWriter.getMetadata().getKey()));
            agent.process(channel);
            charSequenceResponseConsumer.read(channel);
            TestUtils.assertEquals("OK", charSequenceResponseConsumer.getValue());
            hugeBufferConsumer.read(channel);
            // send quote state
            commandProducer.write(channel, Command.DELTA_REQUEST_CMD);
            journalClientStateProducer.write(channel, new IndexedJournal(0, quoteClientWriter));
            agent.process(channel);
            charSequenceResponseConsumer.read(channel);
            TestUtils.assertEquals("OK", charSequenceResponseConsumer.getValue());
            quoteWriter.append(origin.query().all().asResultSet().subset(0, 100));
            quoteWriter.commit();
            commandProducer.write(channel, Command.CLIENT_READY_CMD);
            agent.process(channel);
            commandConsumer.read(channel);
            Assert.assertEquals(Command.JOURNAL_DELTA_CMD, commandConsumer.getCommand());
            Assert.assertEquals(0, intResponseConsumer.getValue(channel));
            quoteDeltaConsumer.read(channel);
            Assert.assertEquals(100, quoteClientWriter.size());
            commandConsumer.read(channel);
            Assert.assertEquals(Command.SERVER_READY_CMD, commandConsumer.getCommand());
            quoteWriter.append(origin.query().all().asResultSet().subset(100, 200));
            quoteWriter.commit();
            // send quote state
            commandProducer.write(channel, Command.DELTA_REQUEST_CMD);
            journalClientStateProducer.write(channel, new IndexedJournal(0, quoteClientWriter));
            agent.process(channel);
            charSequenceResponseConsumer.read(channel);
            TestUtils.assertEquals("OK", charSequenceResponseConsumer.getValue());
            commandProducer.write(channel, Command.CLIENT_READY_CMD);
            agent.process(channel);
            commandConsumer.read(channel);
            Assert.assertEquals(Command.JOURNAL_DELTA_CMD, commandConsumer.getCommand());
            Assert.assertEquals(0, intResponseConsumer.getValue(channel));
            quoteDeltaConsumer.read(channel);
            Assert.assertEquals(200, quoteClientWriter.size());
            commandConsumer.read(channel);
            Assert.assertEquals(Command.SERVER_READY_CMD, commandConsumer.getCommand());
        }
    }
}
Also used : Quote(com.questdb.model.Quote) JournalDeltaConsumer(com.questdb.net.ha.comsumer.JournalDeltaConsumer) IndexedJournalKey(com.questdb.net.ha.model.IndexedJournalKey) IndexedJournal(com.questdb.net.ha.model.IndexedJournal) AbstractTest(com.questdb.test.tools.AbstractTest)

Example 4 with IndexedJournal

use of com.questdb.net.ha.model.IndexedJournal in project questdb by bluestreak01.

the class LinkedJournalSymbolTableTest method executeSequence.

private void executeSequence(boolean expectContent) throws JournalNetworkException {
    journalClientStateProducer.write(channel, new IndexedJournal(0, slave));
    journalClientStateConsumer.read(channel);
    // journalSymbolTableProducer.configure(journalClientStateConsumer.getValue());
    journalSymbolTableProducer.configure(master.find(journalClientStateConsumer.getValue().getTxn(), journalClientStateConsumer.getValue().getTxPin()));
    Assert.assertEquals(expectContent, journalSymbolTableProducer.hasContent());
    if (expectContent) {
        journalSymbolTableProducer.write(channel);
        journalSymbolTableConsumer.read(channel);
        TestUtils.compareSymbolTables(master, slave);
    }
}
Also used : IndexedJournal(com.questdb.net.ha.model.IndexedJournal)

Example 5 with IndexedJournal

use of com.questdb.net.ha.model.IndexedJournal in project questdb by bluestreak01.

the class JournalServerAgentTest method testJournalIndexCorrectness.

@Test
public void testJournalIndexCorrectness() throws Exception {
    server.publish(tradeWriter);
    server.start();
    try (Journal<Quote> quoteClientWriter = getFactory().writer(Quote.class, "client")) {
        // send quote journal key
        // commandProducer.write(channel, Command.ADD_KEY_CMD);
        // setKeyRequestProducer.write(channel, new IndexedJournalKey(3, quoteWriter.getKey()));
        // agent.process(channel);
        // charSequenceResponseConsumer.reset();
        // charSequenceResponseConsumer.read(channel);
        // Assert.assertTrue(charSequenceResponseConsumer.isComplete());
        // Assert.assertEquals("Journal index is too large. Max 1", charSequenceResponseConsumer.getValue());
        commandProducer.write(channel, Command.ADD_KEY_CMD);
        setKeyRequestProducer.write(channel, new IndexedJournalKey(0, quoteWriter.getMetadata().getKey()));
        agent.process(channel);
        charSequenceResponseConsumer.read(channel);
        TestUtils.assertEquals("OK", charSequenceResponseConsumer.getValue());
        hugeBufferConsumer.read(channel);
        commandProducer.write(channel, Command.DELTA_REQUEST_CMD);
        journalClientStateProducer.write(channel, new IndexedJournal(1, quoteClientWriter));
        agent.process(channel);
        charSequenceResponseConsumer.read(channel);
        TestUtils.assertEquals("Journal index does not match key request", charSequenceResponseConsumer.getValue());
        commandProducer.write(channel, Command.DELTA_REQUEST_CMD);
        journalClientStateProducer.write(channel, new IndexedJournal(0, quoteClientWriter));
        agent.process(channel);
        charSequenceResponseConsumer.read(channel);
        TestUtils.assertEquals("OK", charSequenceResponseConsumer.getValue());
    }
}
Also used : Quote(com.questdb.model.Quote) IndexedJournalKey(com.questdb.net.ha.model.IndexedJournalKey) IndexedJournal(com.questdb.net.ha.model.IndexedJournal) AbstractTest(com.questdb.test.tools.AbstractTest)

Aggregations

IndexedJournal (com.questdb.net.ha.model.IndexedJournal)8 IndexedJournalKey (com.questdb.net.ha.model.IndexedJournalKey)3 Quote (com.questdb.model.Quote)2 JournalDeltaConsumer (com.questdb.net.ha.comsumer.JournalDeltaConsumer)2 AbstractTest (com.questdb.test.tools.AbstractTest)2 IncompatibleJournalException (com.questdb.ex.IncompatibleJournalException)1 HugeBufferConsumer (com.questdb.net.ha.comsumer.HugeBufferConsumer)1 JournalClientStateConsumer (com.questdb.net.ha.comsumer.JournalClientStateConsumer)1 JournalSymbolTableConsumer (com.questdb.net.ha.comsumer.JournalSymbolTableConsumer)1 JournalClientStateProducer (com.questdb.net.ha.producer.JournalClientStateProducer)1 JournalSymbolTableProducer (com.questdb.net.ha.producer.JournalSymbolTableProducer)1 JournalException (com.questdb.std.ex.JournalException)1 JournalNetworkException (com.questdb.std.ex.JournalNetworkException)1 JournalMetadata (com.questdb.store.factory.configuration.JournalMetadata)1 File (java.io.File)1