@Bean public CuratorFramework curatorFramework() { ZKConfig config = config(); if (config.useZooKeeperWaitTimePolicy()) { return new RedirectorCuratorFramework(config); } CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(config.getZooKeeperConnection()) .connectionTimeoutMs(config.getZooKeeperConnectionTimeout()) .sessionTimeoutMs(config.getZooKeeperSessionTimeout()) .retryPolicy(new RetryNTimes(config.getZooKeeperRetryAttempts(), config.getZooKeeperRetryInterval())) .compressionProvider(new GzipCompressionProvider()); return builder.build(); }
public static void init() throws Exception { try { Config.CuratorConfig zkConfig = Config.config.zookeeper; curator = CuratorFrameworkFactory .builder() .connectString(zkConfig.addrs) .retryPolicy(new ExponentialBackoffRetry(zkConfig.baseSleepTimeMs, zkConfig.maxRetries, zkConfig.maxSleepMs)) .compressionProvider(new GzipCompressionProvider()) .build(); curator.start(); kafkaInfos = new KafkaInfos(new ZkClient(zkConfig.addrs, 30000, zkConfig.connectionTimeout, zkSerializer)); druidInfos = Config.config.druidInfos; zkHosts = new ZookeeperHosts(Config.config.zookeeper.addrs); druidInfos.init(); notify = new Notify(Config.config.notify.url); fetchers = Config.config.fetchers; Prometheus.defaultInitialize(); prometheusQuery = new PrometheusQuery(Config.config.prometheus.serverUrl); } catch (Exception e) { log.error(e, "error while initialyzing resourses"); throw e; } }
private CuratorFramework createCurator(ZKConfig config) { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(config.getZooKeeperConnection()) .connectionTimeoutMs(config.getZooKeeperConnectionTimeout()) .sessionTimeoutMs(config.getZooKeeperSessionTimeout()) .retryPolicy(new RetryNTimes(config.getZooKeeperRetryAttempts(), config.getZooKeeperRetryInterval())); builder.compressionProvider(new GzipCompressionProvider()); return builder.build(); }
private synchronized CuratorFramework buildCuratorFramework(final ZKConfig config) { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(config.getZooKeeperConnection()) .connectionTimeoutMs(config.getZooKeeperConnectionTimeout()) .sessionTimeoutMs(config.getZooKeeperSessionTimeout()) .retryPolicy(new RetryNTimes(config.getZooKeeperRetryAttempts(), config.getZooKeeperRetryInterval())) .compressionProvider(new GzipCompressionProvider()); CuratorFramework framework = builder.build(); listenerStateProxy.updateCurator(framework); listenerProxy.updateCurator(framework); return framework; }