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);
}
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);
}
}
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());
}
}
}
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);
}
}
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());
}
}
Aggregations