public ZookeeperStateStore(String connectionString, int retries, int retryInterval) { if (connectionString == null) { zookeeperConnectionString = "localhost:2181"; } else { zookeeperConnectionString = connectionString; } RetryPolicy retryPolicy = new RetryNTimes(retries, retryInterval); curatorFramework = CuratorFrameworkFactory.newClient(zookeeperConnectionString, retryPolicy); }
private static CuratorFramework newCurator(Configuration config) throws Exception { return CuratorFrameworkFactory.newClient(config.zkHosts, config.zkSessionTimeoutMs, config.zkConnectionTimeoutMs, new RetryNTimes(config.zkRetryTimes, config.zkRetryIntervalMs)); }
private static CuratorFramework newCurator(Configuration config) throws Exception { return CuratorFrameworkFactory.newClient(config.zkHosts, config.zkSessionTimeoutMs, config.zkConnectionTimeoutMs, new RetryNTimes(config.zkRetryTimes, config.zkRetryIntervalMs)); }
public CuratorZookeeperClient(URL url) { super(url); try { int timeout = url.getParameter(Constants.TIMEOUT_KEY, 5000); CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(url.getBackupAddress()) .retryPolicy(new RetryNTimes(1, 1000)) .connectionTimeoutMs(timeout); String authority = url.getAuthority(); if (authority != null && authority.length() > 0) { builder = builder.authorization("digest", authority.getBytes()); } client = builder.build(); client.getConnectionStateListenable().addListener(new ConnectionStateListener() { @Override public void stateChanged(CuratorFramework client, ConnectionState state) { if (state == ConnectionState.LOST) { CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED); } else if (state == ConnectionState.CONNECTED) { CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED); } else if (state == ConnectionState.RECONNECTED) { CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED); } } }); client.start(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
public CuratorZookeeperClient(URL url) { super(url); try { int timeout = url.getParameter(Constants.TIMEOUT_KEY, 5000); CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(url.getBackupAddress()) .retryPolicy(new RetryNTimes(1, 1000)) .connectionTimeoutMs(timeout); String authority = url.getAuthority(); if (authority != null && authority.length() > 0) { builder = builder.authorization("digest", authority.getBytes()); } client = builder.build(); client.getConnectionStateListenable().addListener(new ConnectionStateListener() { @Override public void stateChanged(CuratorFramework client, ConnectionState state) { if (state == ConnectionState.LOST) { CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED); } else if (state == ConnectionState.CONNECTED) { CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED); } else if (state == ConnectionState.RECONNECTED) { CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED); } } }); client.start(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
private CuratorFramework newCurator(Map conf, KafkaSpoutConfig config) throws Exception { String serverPorts = ""; List<Host> zkServers = config.zkServers; for (Host server : zkServers) { serverPorts = serverPorts + server.getHost() + ":" + server.getPort() + ","; } return CuratorFrameworkFactory.newClient(serverPorts, Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_SESSION_TIMEOUT)), 15000, new RetryNTimes( Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_TIMES)), Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_INTERVAL)))); }
void initialize () { curatorFramework = CuratorFrameworkFactory.newClient(zkInfo.getZkUrl(), zkInfo.getSessionTimeoutMs(), zkInfo.getConnectionTimeoutMs(), new RetryNTimes(zkInfo.getRetryAttempts(), zkInfo.getRetryIntervalMs())); curatorFramework.start(); }
CommonConfigurationKeys.ZK_RETRY_INTERVAL_MS, CommonConfigurationKeys.ZK_RETRY_INTERVAL_MS_DEFAULT); RetryNTimes retryPolicy = new RetryNTimes(numRetries, zkRetryInterval);
public CuratorZkClient(Config config) { String registryAddress = NodeRegistryUtils.getRealRegistryAddress(config.getRegistryAddress()); CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(registryAddress) .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000)) .connectionTimeoutMs(5000); client = builder.build(); client.getConnectionStateListenable().addListener(new ConnectionStateListener() { public void stateChanged(CuratorFramework client, ConnectionState state) { if (state == ConnectionState.LOST) { CuratorZkClient.this.stateChanged(StateListener.DISCONNECTED); } else if (state == ConnectionState.CONNECTED) { CuratorZkClient.this.stateChanged(StateListener.CONNECTED); } else if (state == ConnectionState.RECONNECTED) { CuratorZkClient.this.stateChanged(StateListener.RECONNECTED); } else if (state == ConnectionState.SUSPENDED) { CuratorZkClient.this.stateChanged(StateListener.DISCONNECTED); } } }); zkSerializer = new SerializableSerializer(); client.start(); }
public CuratorZkClient(Config config) { String registryAddress = NodeRegistryUtils.getRealRegistryAddress(config.getRegistryAddress()); CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(registryAddress) .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000)) .connectionTimeoutMs(5000); client = builder.build(); client.getConnectionStateListenable().addListener(new ConnectionStateListener() { public void stateChanged(CuratorFramework client, ConnectionState state) { if (state == ConnectionState.LOST) { CuratorZkClient.this.stateChanged(StateListener.DISCONNECTED); } else if (state == ConnectionState.CONNECTED) { CuratorZkClient.this.stateChanged(StateListener.CONNECTED); } else if (state == ConnectionState.RECONNECTED) { CuratorZkClient.this.stateChanged(StateListener.RECONNECTED); } else if (state == ConnectionState.SUSPENDED) { CuratorZkClient.this.stateChanged(StateListener.DISCONNECTED); } } }); zkSerializer = new SerializableSerializer(); client.start(); }
public ZKClusterCoordinator(String connect, String zkRoot, String clusterId, int retryCount, int retryDelayMs, int connectTimeoutMs) throws IOException { logger.debug("ZK connect: " + connect + ", zkRoot: " + zkRoot + ", clusterId: " + clusterId); this.serviceName = clusterId; RetryPolicy rp = new RetryNTimes(retryCount, retryDelayMs); curator = CuratorFrameworkFactory.builder().namespace(zkRoot) .connectionTimeoutMs(connectTimeoutMs).retryPolicy(rp) .connectString(connect).build(); curator.getConnectionStateListenable() .addListener(new InitialConnectionListener()); curator.start(); discovery = newDiscovery(); factory = CachingTransientStoreFactory .of(new ZkTransientStoreFactory(curator)); }
/** * Connect to the test ZK for the simulated Drillbit side of the test. (The AM * side of the test uses the actual AM code, which is what we're testing * here...) * * @param connectString * @return */ public static CuratorFramework connectToZk(String connectString) { CuratorFramework client = CuratorFrameworkFactory.builder() .namespace(ZK_ROOT + "/" + CLUSTER_ID).connectString(connectString) .retryPolicy(new RetryNTimes(3, 1000)).build(); client.start(); return client; }
new RetryNTimes(numRetries, sessionT / numRetries)); } catch (Exception ex) { throw new RuntimeException("Could not Load ZK acls or auth");
private CuratorFramework createClient() { // Create a new client because we don't want to try indefinitely for this to occur. final RetryPolicy retryPolicy = new RetryNTimes(1, 100); final CuratorACLProviderFactory aclProviderFactory = new CuratorACLProviderFactory(); final CuratorFramework client = CuratorFrameworkFactory.builder() .connectString(zkConfig.getConnectString()) .sessionTimeoutMs(zkConfig.getSessionTimeoutMillis()) .connectionTimeoutMs(zkConfig.getConnectionTimeoutMillis()) .retryPolicy(retryPolicy) .aclProvider(aclProviderFactory.create(zkConfig)) .defaultData(new byte[0]) .build(); client.start(); return client; }
final RetryPolicy retryPolicy = new RetryNTimes(0, 0); final CuratorFramework curatorClient = CuratorFrameworkFactory.newClient(zkConfig.getConnectString(), zkConfig.getSessionTimeoutMillis(), zkConfig.getConnectionTimeoutMillis(), retryPolicy);
/** * Before test. * * @throws Exception */ @Override public void beforeTest() throws Exception { super.beforeTest(); // remove stale system properties System.getProperties().remove(TcpDiscoveryZookeeperIpFinder.PROP_ZK_CONNECTION_STRING); // disable JMX for tests System.setProperty("zookeeper.jmx.log4j.disable", "true"); // start the ZK cluster zkCluster = new TestingCluster(ZK_CLUSTER_SIZE); zkCluster.start(); // start the Curator client so we can perform assertions on the ZK state later zkCurator = CuratorFrameworkFactory.newClient(zkCluster.getConnectString(), new RetryNTimes(10, 1000)); zkCurator.start(); }
public CuratorZookeeperClient(URL url) { super(url); try { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder() .connectString(url.getBackupAddress()) .retryPolicy(new RetryNTimes(1, 1000)) .connectionTimeoutMs(5000); String authority = url.getAuthority(); if (authority != null && authority.length() > 0) { builder = builder.authorization("digest", authority.getBytes()); } client = builder.build(); client.getConnectionStateListenable().addListener(new ConnectionStateListener() { @Override public void stateChanged(CuratorFramework client, ConnectionState state) { if (state == ConnectionState.LOST) { CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED); } else if (state == ConnectionState.CONNECTED) { CuratorZookeeperClient.this.stateChanged(StateListener.CONNECTED); } else if (state == ConnectionState.RECONNECTED) { CuratorZookeeperClient.this.stateChanged(StateListener.RECONNECTED); } } }); client.start(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
.retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000)).build(); client.start(); return client;
/** * Retries 25 times with delay of 200ms * * @return RetryNTimes */ private static RetryPolicy getRetryPolicy() { return new RetryNTimes(25, 200); }
private CuratorFramework curatorFramework(KafkaProperties kafkaProperties) { CuratorFramework curator = CuratorFrameworkFactory.newClient( kafkaProperties.getConnectionString(), new RetryNTimes(kafkaProperties.getRetryTimes(), kafkaProperties.getRetrySleepMillis())); curator.start(); curators.add(curator); return curator; }