Search in sources :

Example 1 with ClusterController

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

the class ClusteredProducerMain method main.

public static void main(String[] args) throws JournalException, IOException, JournalNetworkException, NumericException {
    final String pathToDatabase = args[0];
    final int instance = Numbers.parseInt(args[1]);
    final JournalConfiguration configuration = new JournalConfigurationBuilder() {

        {
            $(Price.class).$ts();
        }
    }.build(pathToDatabase);
    final Factory factory = new Factory(configuration, 1000, 1, 0);
    final JournalWriter<Price> writer = factory.writer(new JournalKey<>(Price.class, null, PartitionBy.DEFAULT, 1000000000));
    final WorkerController wc = new WorkerController(writer);
    final ClusterController cc = new ClusterController(new ServerConfig() {

        {
            addNode(new ServerNode(1, "127.0.0.1:7080"));
            addNode(new ServerNode(2, "127.0.0.1:7090"));
        }
    }, new ClientConfig(), factory, instance, new ArrayList<JournalWriter>() {

        {
            add(writer);
        }
    }, wc);
    cc.start();
    Runtime.getRuntime().addShutdownHook(new Thread(cc::halt));
}
Also used : JournalWriter(com.questdb.store.JournalWriter) Factory(com.questdb.store.factory.Factory) JournalConfigurationBuilder(com.questdb.store.factory.configuration.JournalConfigurationBuilder) ServerConfig(com.questdb.net.ha.config.ServerConfig) JournalConfiguration(com.questdb.store.factory.configuration.JournalConfiguration) ClusterController(com.questdb.net.ha.ClusterController) Price(org.questdb.examples.support.Price) ServerNode(com.questdb.net.ha.config.ServerNode) ClientConfig(com.questdb.net.ha.config.ClientConfig)

Aggregations

ClusterController (com.questdb.net.ha.ClusterController)1 ClientConfig (com.questdb.net.ha.config.ClientConfig)1 ServerConfig (com.questdb.net.ha.config.ServerConfig)1 ServerNode (com.questdb.net.ha.config.ServerNode)1 JournalWriter (com.questdb.store.JournalWriter)1 Factory (com.questdb.store.factory.Factory)1 JournalConfiguration (com.questdb.store.factory.configuration.JournalConfiguration)1 JournalConfigurationBuilder (com.questdb.store.factory.configuration.JournalConfigurationBuilder)1 Price (org.questdb.examples.support.Price)1