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);
}
Aggregations