use of com.questdb.net.ha.config.ServerConfig in project questdb by bluestreak01.
the class JournalServerAgentTest method setUp.
@Before
public void setUp() throws Exception {
channel = new MockByteChannel();
quoteWriter = getFactory().writer(Quote.class);
tradeWriter = getFactory().writer(Trade.class);
ServerConfig config = new ServerConfig() {
{
setHeartbeatFrequency(100);
setEnableMultiCast(false);
}
};
server = new JournalServer(config, getFactory());
server.publish(quoteWriter);
agent = new JournalServerAgent(server, new InetSocketAddress(NetworkConfig.DEFAULT_DATA_PORT), null);
hugeBufferConsumer = new HugeBufferConsumer(temp.newFile());
}
use of com.questdb.net.ha.config.ServerConfig in project questdb by bluestreak01.
the class MulticastTest method assertMulticast.
private void assertMulticast() throws JournalNetworkException, InterruptedException {
AbstractOnDemandSender sender = new OnDemandAddressSender(new ServerConfig(), 120, 150, 0);
sender.start();
Thread.sleep(1000L);
OnDemandAddressPoller poller = new OnDemandAddressPoller(new ClientConfig(), 150, 120);
ServerNode address = poller.poll(2, 500, TimeUnit.MILLISECONDS);
Assert.assertNotNull(address);
sender.halt();
}
use of com.questdb.net.ha.config.ServerConfig in project questdb by bluestreak01.
the class MulticastTest method testIPv6.
@Test
public void testIPv6() throws Exception {
if (multicastDisabled || !hasIPv6()) {
return;
}
JournalServer server = new JournalServer(new ServerConfig() {
{
addNode(new ServerNode(0, "[0:0:0:0:0:0:0:0]"));
setHeartbeatFrequency(100);
}
}, getFactory(), null, 0);
final CountDownLatch connected = new CountDownLatch(1);
JournalClient client = new JournalClient(new ClientConfig(), getFactory(), null, evt -> {
if (evt == JournalClientEvents.EVT_CONNECTED) {
connected.countDown();
}
});
server.start();
client.start();
connected.await(3, TimeUnit.SECONDS);
client.halt();
server.halt();
}
use of com.questdb.net.ha.config.ServerConfig 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.net.ha.config.ServerConfig 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();
}
}
}
Aggregations