Search in sources :

Example 6 with DiscoveryService

use of com.yahoo.pulsar.discovery.service.DiscoveryService in project pulsar by yahoo.

the class DiscoveryServiceStarter method init.

public static void init(String configFile) throws Exception {
    // setup handlers
    removeHandlersForRootLogger();
    install();
    setDefaultUncaughtExceptionHandler((thread, exception) -> {
        log.error("Uncaught exception in thread {}: {}", thread.getName(), exception.getMessage(), exception);
    });
    // load config file
    final ServiceConfig config = PulsarConfigurationLoader.create(configFile, ServiceConfig.class);
    checkArgument(!isEmpty(config.getZookeeperServers()), "zookeeperServers must be provided");
    checkArgument(!isEmpty(config.getGlobalZookeeperServers()), "global-zookeeperServers must be provided");
    // create broker service
    DiscoveryService discoveryService = new DiscoveryService(config);
    // create a web-service
    final ServerManager server = new ServerManager(config);
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            try {
                discoveryService.close();
                server.stop();
            } catch (Exception e) {
                log.warn("server couldn't stop gracefully {}", e.getMessage(), e);
            }
        }
    });
    discoveryService.start();
    startWebService(server, config);
}
Also used : DiscoveryService(com.yahoo.pulsar.discovery.service.DiscoveryService)

Aggregations

DiscoveryService (com.yahoo.pulsar.discovery.service.DiscoveryService)6 ServiceConfig (com.yahoo.pulsar.discovery.service.server.ServiceConfig)5 Test (org.testng.annotations.Test)5 IOException (java.io.IOException)3 AuthenticationTls (com.yahoo.pulsar.client.impl.auth.AuthenticationTls)1 HashMap (java.util.HashMap)1