Search in sources :

Example 1 with JournalServer

use of com.questdb.net.ha.JournalServer in project questdb by bluestreak01.

the class SimpleReplicationServerMain method start.

public void start() throws Exception {
    JournalConfiguration configuration = new JournalConfigurationBuilder().build(location);
    Factory factory = new Factory(configuration, 1000, 1, 0);
    JournalServer server = new JournalServer(factory);
    JournalWriter<Price> writer = factory.writer(Price.class);
    server.publish(writer);
    server.start();
    System.out.print("Publishing: ");
    for (int i = 0; i < 10; i++) {
        publishPrice(writer, i < 3 ? 1000000 : 100);
        Thread.sleep(TimeUnit.SECONDS.toMillis(2));
        System.out.print('.');
    }
    System.out.println(" [Done]");
}
Also used : JournalConfiguration(com.questdb.store.factory.configuration.JournalConfiguration) Price(org.questdb.examples.support.Price) JournalServer(com.questdb.net.ha.JournalServer) Factory(com.questdb.store.factory.Factory) JournalConfigurationBuilder(com.questdb.store.factory.configuration.JournalConfigurationBuilder)

Example 2 with JournalServer

use of com.questdb.net.ha.JournalServer in project questdb by bluestreak01.

the class SslReplicationServerMain method start.

public void start() throws Exception {
    Factory factory = new Factory(location, 1000, 1, 0);
    JournalServer server = new JournalServer(new ServerConfig() {

        {
            getSslConfig().setSecure(true);
            try (InputStream is = this.getClass().getResourceAsStream("/keystore/singlekey.ks")) {
                getSslConfig().setKeyStore(is, "changeit");
            }
        }
    }, factory);
    JournalWriter<Price> writer = factory.writer(Price.class);
    server.publish(writer);
    server.start();
    System.out.print("Publishing: ");
    for (int i = 0; i < 10; i++) {
        publishPrice(writer, i < 3 ? 1000000 : 100);
        Thread.sleep(TimeUnit.SECONDS.toMillis(2));
        System.out.print('.');
    }
    System.out.println(" [Done]");
}
Also used : ServerConfig(com.questdb.net.ha.config.ServerConfig) Price(org.questdb.examples.support.Price) InputStream(java.io.InputStream) JournalServer(com.questdb.net.ha.JournalServer) Factory(com.questdb.store.factory.Factory)

Example 3 with JournalServer

use of com.questdb.net.ha.JournalServer in project questdb by bluestreak01.

the class AuthReplicationServerMain method start.

public void start() throws Exception {
    JournalConfiguration configuration = new JournalConfigurationBuilder().build(location);
    Factory factory = new Factory(configuration, 1000, 2, 0);
    JournalServer server = new JournalServer(factory, (token, requestedKeys) -> "MY SECRET".equals(new String(token, "UTF8")));
    JournalWriter<Price> writer = factory.writer(Price.class);
    server.publish(writer);
    server.start();
    System.out.print("Publishing: ");
    for (int i = 0; i < 10; i++) {
        publishPrice(writer, i < 3 ? 1000000 : 100);
        Thread.sleep(TimeUnit.SECONDS.toMillis(2));
        System.out.print('.');
    }
    System.out.println(" [Done]");
}
Also used : JournalConfiguration(com.questdb.store.factory.configuration.JournalConfiguration) Price(org.questdb.examples.support.Price) JournalServer(com.questdb.net.ha.JournalServer) Factory(com.questdb.store.factory.Factory) JournalConfigurationBuilder(com.questdb.store.factory.configuration.JournalConfigurationBuilder)

Aggregations

JournalServer (com.questdb.net.ha.JournalServer)3 Factory (com.questdb.store.factory.Factory)3 Price (org.questdb.examples.support.Price)3 JournalConfiguration (com.questdb.store.factory.configuration.JournalConfiguration)2 JournalConfigurationBuilder (com.questdb.store.factory.configuration.JournalConfigurationBuilder)2 ServerConfig (com.questdb.net.ha.config.ServerConfig)1 InputStream (java.io.InputStream)1