use of org.apache.curator.framework.CuratorFramework in project pravega by pravega.
the class BookKeeperAdapter method shutDown.
@Override
protected void shutDown() {
this.logs.values().forEach(DurableDataLog::close);
this.logs.clear();
BookKeeperLogFactory lf = this.logFactory;
if (lf != null) {
lf.close();
this.logFactory = null;
}
stopBookKeeper();
CuratorFramework zkClient = this.zkClient;
if (zkClient != null) {
zkClient.close();
this.zkClient = null;
}
Runtime.getRuntime().removeShutdownHook(this.stopBookKeeperProcess);
}
use of org.apache.curator.framework.CuratorFramework in project pravega by pravega.
the class ClusterZKTest method deregisterNode.
@Test(timeout = TEST_TIMEOUT)
public void deregisterNode() throws Exception {
LinkedBlockingQueue<String> nodeAddedQueue = new LinkedBlockingQueue<>();
LinkedBlockingQueue<String> nodeRemovedQueue = new LinkedBlockingQueue<>();
LinkedBlockingQueue<Exception> exceptionsQueue = new LinkedBlockingQueue<>();
CuratorFramework client2 = CuratorFrameworkFactory.builder().connectString(zkUrl).retryPolicy(new ExponentialBackoffRetry(RETRY_SLEEP_MS, MAX_RETRY)).namespace(CLUSTER_NAME_2).build();
@Cleanup Cluster clusterListener = new ClusterZKImpl(client2, ClusterType.HOST);
clusterListener.addListener((eventType, host) -> {
switch(eventType) {
case HOST_ADDED:
nodeAddedQueue.offer(host.getIpAddr());
break;
case HOST_REMOVED:
nodeRemovedQueue.offer(host.getIpAddr());
break;
case ERROR:
exceptionsQueue.offer(new RuntimeException("Encountered error"));
break;
default:
exceptionsQueue.offer(new RuntimeException("Unhandled case"));
break;
}
});
CuratorFramework client = CuratorFrameworkFactory.builder().connectString(zkUrl).retryPolicy(new ExponentialBackoffRetry(RETRY_SLEEP_MS, MAX_RETRY)).namespace(CLUSTER_NAME_2).build();
// Create Add a node to the cluster.
@Cleanup Cluster clusterZKInstance1 = new ClusterZKImpl(client, ClusterType.HOST);
clusterZKInstance1.registerHost(new Host(HOST_1, PORT, null));
assertEquals(HOST_1, nodeAddedQueue.poll(5, TimeUnit.SECONDS));
clusterZKInstance1.deregisterHost(new Host(HOST_1, PORT, null));
assertEquals(HOST_1, nodeRemovedQueue.poll(5, TimeUnit.SECONDS));
Exception exception = exceptionsQueue.poll();
if (exception != null) {
throw exception;
}
}
use of org.apache.curator.framework.CuratorFramework in project pravega by pravega.
the class ZookeeperTest method zkTest.
/**
* Invoke the zookeeper test, ensure zookeeper can be accessed.
* The test fails incase zookeeper cannot be accessed
*/
@Test(timeout = 5 * 60 * 1000)
public void zkTest() {
log.info("Start execution of ZkTest");
Service zk = Utils.createZookeeperService();
URI zkUri = zk.getServiceDetails().get(0);
CuratorFramework curatorFrameworkClient = CuratorFrameworkFactory.newClient(zkUri.getHost() + ":2181", new RetryOneTime(5000));
curatorFrameworkClient.start();
log.info("CuratorFramework status {} ", curatorFrameworkClient.getState());
assertEquals("Connection to zk client ", STARTED, curatorFrameworkClient.getState());
log.info("Zookeeper Service URI : {} ", zkUri);
log.info("ZkTest execution completed");
}
use of org.apache.curator.framework.CuratorFramework in project eventuate-local by eventuate-local.
the class EventTableChangesToAggregateTopicRelayConfiguration method makeStartedCuratorClient.
static CuratorFramework makeStartedCuratorClient(String connectionString) {
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
CuratorFramework client = CuratorFrameworkFactory.builder().retryPolicy(retryPolicy).connectString(connectionString).build();
client.start();
return client;
}
use of org.apache.curator.framework.CuratorFramework in project eventuate-local by eventuate-local.
the class EventTableChangesToAggregateTopicTranslatorConfiguration method makeStartedCuratorClient.
static CuratorFramework makeStartedCuratorClient(String connectionString) {
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
CuratorFramework client = CuratorFrameworkFactory.builder().retryPolicy(retryPolicy).connectString(connectionString).build();
client.start();
return client;
}
Aggregations