use of com.questdb.model.Quote 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());
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class JournalSymbolTableTest method setUp.
@Before
public void setUp() throws Exception {
origin = getFactory().writer(Quote.class, "origin");
master = getFactory().writer(Quote.class, "master");
slave = getFactory().writer(Quote.class, "slave");
channel = new MockByteChannel();
journalSymbolTableProducer = new JournalSymbolTableProducer(master);
journalSymbolTableConsumer = new JournalSymbolTableConsumer(slave);
origin.append(new Quote().setSym("AB").setEx("EX1").setMode("M1"));
origin.append(new Quote().setSym("CD").setEx("EX2").setMode("M2"));
origin.append(new Quote().setSym("EF").setEx("EX3").setMode("M2"));
origin.append(new Quote().setSym("GH").setEx("EX3").setMode("M3"));
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class SSLTest method testAuthBothCertsMissing.
@Test
@Ignore
public void testAuthBothCertsMissing() throws Exception {
try (JournalWriter<Quote> remote = getFactory().writer(Quote.class, "remote")) {
JournalServer server = new JournalServer(new ServerConfig() {
{
setHeartbeatFrequency(TimeUnit.MILLISECONDS.toMillis(500));
getSslConfig().setSecure(true);
getSslConfig().setRequireClientAuth(true);
try (InputStream is = this.getClass().getResourceAsStream("/keystore/singlekey.ks")) {
getSslConfig().setKeyStore(is, "changeit");
}
setEnableMultiCast(false);
setHeartbeatFrequency(50);
}
}, getFactory());
try {
final AtomicInteger serverErrorCount = new AtomicInteger();
final CountDownLatch terminated = new CountDownLatch(1);
JournalClient client = new JournalClient(new ClientConfig("localhost") {
{
getSslConfig().setSecure(true);
try (InputStream is = this.getClass().getResourceAsStream("/keystore/singlekey.ks")) {
getSslConfig().setTrustStore(is, "changeit");
}
}
}, getFactory(), null, evt -> {
switch(evt) {
case JournalClientEvents.EVT_SERVER_ERROR:
serverErrorCount.incrementAndGet();
break;
case JournalClientEvents.EVT_TERMINATED:
terminated.countDown();
break;
default:
break;
}
});
server.publish(remote);
server.start();
client.subscribe(Quote.class, "remote", "local");
client.start();
Assert.assertTrue(terminated.await(5, TimeUnit.SECONDS));
Assert.assertEquals(0, server.getConnectedClients());
Assert.assertFalse(client.isRunning());
Assert.assertEquals(1, serverErrorCount.get());
} finally {
server.halt();
}
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class SSLTest method testNonAuthClientTrustMissing.
@Test
public void testNonAuthClientTrustMissing() throws Exception {
try (JournalWriter<Quote> remote = getFactory().writer(Quote.class, "remote")) {
JournalServer server = new JournalServer(new ServerConfig() {
{
setHeartbeatFrequency(TimeUnit.MILLISECONDS.toMillis(500));
getSslConfig().setSecure(true);
try (InputStream is = this.getClass().getResourceAsStream("/keystore/singlekey.ks")) {
getSslConfig().setKeyStore(is, "changeit");
}
setEnableMultiCast(false);
setHeartbeatFrequency(50);
}
}, getFactory());
try {
final AtomicInteger serverErrorCount = new AtomicInteger();
final CountDownLatch terminated = new CountDownLatch(1);
JournalClient client = new JournalClient(new ClientConfig("localhost") {
{
getSslConfig().setSecure(true);
}
}, getFactory(), null, evt -> {
switch(evt) {
case JournalClientEvents.EVT_SERVER_ERROR:
serverErrorCount.incrementAndGet();
break;
case JournalClientEvents.EVT_TERMINATED:
terminated.countDown();
break;
default:
break;
}
});
server.publish(remote);
server.start();
client.subscribe(Quote.class, "remote", "local");
client.subscribe(Quote.class, "remote", "local");
client.start();
Assert.assertTrue(terminated.await(5, TimeUnit.SECONDS));
// Assert.assertEquals(0, server.getConnectedClients());
Assert.assertFalse(client.isRunning());
Assert.assertEquals(1, serverErrorCount.get());
client.halt();
} finally {
server.halt();
}
}
}
use of com.questdb.model.Quote in project questdb by bluestreak01.
the class PrinterTest method testDateConversion.
@Test
public void testDateConversion() throws Exception {
long millis = DateFormatUtils.parseDateTime("2013-10-11T10:00:00.000Z");
Quote position1 = new Quote().setBidSize(10).setTimestamp(millis);
Quote position2 = new Quote().setTimestamp(millis);
try (JournalPrinter printer = new JournalPrinter()) {
printer.types(Quote.class, int.class);
printer.setAppender(testAppender);
printer.f("timestamp").i(0).h("TimeStamp").c(new DateConverter(printer)).f("bidSize").f("askSize").v(1).h("test");
printer.header();
printer.out(position1, 0);
printer.out(position2, 1);
testAppender.assertLine("TimeStamp\tbidSize\taskSize\ttest", 0);
testAppender.assertLine("2013-10-11T10:00:00.000Z\t10\t0\t0", 1);
testAppender.assertLine("2013-10-11T10:00:00.000Z\t0\t0\t1", 2);
}
}
Aggregations