Search in sources :

Example 16 with ServerConfig

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());
}
Also used : Quote(com.questdb.model.Quote) Trade(com.questdb.model.Trade) ServerConfig(com.questdb.net.ha.config.ServerConfig) InetSocketAddress(java.net.InetSocketAddress) HugeBufferConsumer(com.questdb.net.ha.comsumer.HugeBufferConsumer)

Example 17 with ServerConfig

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();
}
Also used : ServerConfig(com.questdb.net.ha.config.ServerConfig) AbstractOnDemandSender(com.questdb.net.ha.mcast.AbstractOnDemandSender) OnDemandAddressSender(com.questdb.net.ha.mcast.OnDemandAddressSender) OnDemandAddressPoller(com.questdb.net.ha.mcast.OnDemandAddressPoller) ClientConfig(com.questdb.net.ha.config.ClientConfig) ServerNode(com.questdb.net.ha.config.ServerNode)

Example 18 with ServerConfig

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();
}
Also used : ServerConfig(com.questdb.net.ha.config.ServerConfig) ServerNode(com.questdb.net.ha.config.ServerNode) CountDownLatch(java.util.concurrent.CountDownLatch) ClientConfig(com.questdb.net.ha.config.ClientConfig) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 19 with ServerConfig

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();
        }
    }
}
Also used : Quote(com.questdb.model.Quote) ServerConfig(com.questdb.net.ha.config.ServerConfig) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InputStream(java.io.InputStream) CountDownLatch(java.util.concurrent.CountDownLatch) ClientConfig(com.questdb.net.ha.config.ClientConfig)

Example 20 with ServerConfig

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();
        }
    }
}
Also used : Quote(com.questdb.model.Quote) ServerConfig(com.questdb.net.ha.config.ServerConfig) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InputStream(java.io.InputStream) CountDownLatch(java.util.concurrent.CountDownLatch) ClientConfig(com.questdb.net.ha.config.ClientConfig)

Aggregations

ServerConfig (com.questdb.net.ha.config.ServerConfig)20 ClientConfig (com.questdb.net.ha.config.ClientConfig)13 CountDownLatch (java.util.concurrent.CountDownLatch)11 Quote (com.questdb.model.Quote)10 AbstractTest (com.questdb.test.tools.AbstractTest)10 Test (org.junit.Test)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 ServerNode (com.questdb.net.ha.config.ServerNode)7 InputStream (java.io.InputStream)7 JournalWriter (com.questdb.store.JournalWriter)4 JournalListener (com.questdb.store.JournalListener)3 RecordSource (com.questdb.ql.RecordSource)2 RecordSourcePrinter (com.questdb.ql.RecordSourcePrinter)2 StringSink (com.questdb.std.str.StringSink)2 JournalKey (com.questdb.store.JournalKey)2 Factory (com.questdb.store.factory.Factory)2 Price (org.questdb.examples.support.Price)2 Trade (com.questdb.model.Trade)1 ClusterController (com.questdb.net.ha.ClusterController)1 JournalServer (com.questdb.net.ha.JournalServer)1