use of org.apache.curator.RetryPolicy in project metron by apache.
the class TestConfig method client.
@Bean(initMethod = "start", destroyMethod = "close")
public CuratorFramework client(ComponentRunner componentRunner) {
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
ZKServerComponent zkServerComponent = componentRunner.getComponent("zk", ZKServerComponent.class);
return CuratorFrameworkFactory.newClient(zkServerComponent.getConnectionString(), retryPolicy);
}
use of org.apache.curator.RetryPolicy in project metron by apache.
the class ZookeeperConfig method client.
@Bean(initMethod = "start", destroyMethod = "close")
public CuratorFramework client(Environment environment) {
int sleepTime = Integer.parseInt(environment.getProperty(MetronRestConstants.CURATOR_SLEEP_TIME));
int maxRetries = Integer.parseInt(environment.getProperty(MetronRestConstants.CURATOR_MAX_RETRIES));
RetryPolicy retryPolicy = new ExponentialBackoffRetry(sleepTime, maxRetries);
CuratorFramework ret = CuratorFrameworkFactory.newClient(environment.getProperty(MetronRestConstants.ZK_URL_SPRING_PROPERTY), retryPolicy);
return ret;
}
use of org.apache.curator.RetryPolicy in project tutorials by eugenp.
the class BaseTest method newClient.
protected CuratorFramework newClient() {
int sleepMsBetweenRetries = 100;
int maxRetries = 3;
RetryPolicy retryPolicy = new RetryNTimes(maxRetries, sleepMsBetweenRetries);
return CuratorFrameworkFactory.newClient("127.0.0.1:2181", retryPolicy);
}
use of org.apache.curator.RetryPolicy in project tutorials by eugenp.
the class ConnectionManagementManualTest method givenRunningZookeeper_whenOpenConnection_thenClientIsOpened.
@Test
public void givenRunningZookeeper_whenOpenConnection_thenClientIsOpened() throws Exception {
int sleepMsBetweenRetries = 100;
int maxRetries = 3;
RetryPolicy retryPolicy = new RetryNTimes(maxRetries, sleepMsBetweenRetries);
try (CuratorFramework client = CuratorFrameworkFactory.newClient("127.0.0.1:2181", retryPolicy)) {
client.start();
assertThat(client.checkExists().forPath("/")).isNotNull();
}
}
use of org.apache.curator.RetryPolicy in project tutorials by eugenp.
the class ConnectionManagementManualTest method givenRunningZookeeper_whenOpenConnectionUsingAsyncBlocking_thenClientIsOpened.
@Test
public void givenRunningZookeeper_whenOpenConnectionUsingAsyncBlocking_thenClientIsOpened() throws InterruptedException {
int sleepMsBetweenRetries = 100;
int maxRetries = 3;
RetryPolicy retryPolicy = new RetryNTimes(maxRetries, sleepMsBetweenRetries);
try (CuratorFramework client = CuratorFrameworkFactory.newClient("127.0.0.1:2181", retryPolicy)) {
client.start();
AsyncCuratorFramework async = AsyncCuratorFramework.wrap(client);
AtomicBoolean exists = new AtomicBoolean(false);
async.checkExists().forPath("/").thenAccept(s -> exists.set(s != null));
await().until(() -> assertThat(exists.get()).isTrue());
}
}
Aggregations