use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project airavata by apache.
the class Factory method getCuratorClient.
public static CuratorFramework getCuratorClient() throws ApplicationSettingsException {
if (curatorClient == null) {
synchronized (Factory.class) {
if (curatorClient == null) {
String connectionSting = ServerSettings.getZookeeperConnection();
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 5);
curatorClient = CuratorFrameworkFactory.newClient(connectionSting, retryPolicy);
}
}
}
return curatorClient;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project airavata by apache.
the class DbEventManagerZkUtils method getCuratorClient.
/**
* Get curatorFramework instance
* @return
* @throws ApplicationSettingsException
*/
public static CuratorFramework getCuratorClient() throws ApplicationSettingsException {
if (curatorClient == null) {
synchronized (DbEventManagerZkUtils.class) {
if (curatorClient == null) {
String connectionSting = ServerSettings.getZookeeperConnection();
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 5);
curatorClient = CuratorFrameworkFactory.newClient(connectionSting, retryPolicy);
}
}
}
return curatorClient;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project airavata by apache.
the class OrchestratorServerHandler method startCurator.
private void startCurator() throws ApplicationSettingsException {
String connectionSting = ServerSettings.getZookeeperConnection();
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 5);
curatorClient = CuratorFrameworkFactory.newClient(connectionSting, retryPolicy);
curatorClient.start();
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project Mycat_plus by coderczp.
the class ZKUtils method createConnection.
private static CuratorFramework createConnection() {
String url = ZkConfig.getInstance().getZkURL();
CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(url, new ExponentialBackoffRetry(100, 6));
// start connection
curatorFramework.start();
// wait 3 second to establish connect
try {
curatorFramework.blockUntilConnected(3, TimeUnit.SECONDS);
if (curatorFramework.getZookeeperClient().isConnected()) {
return curatorFramework;
}
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
// fail situation
curatorFramework.close();
throw new RuntimeException("failed to connect to zookeeper service : " + url);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project Mycat_plus by coderczp.
the class DistributedSequenceHandler method initializeZK.
public void initializeZK(String zkAddress) {
this.client = CuratorFrameworkFactory.newClient(zkAddress, new ExponentialBackoffRetry(1000, 3));
this.client.start();
try {
if (client.checkExists().forPath(PATH.concat(INSTANCE_PATH)) == null) {
client.create().creatingParentContainersIfNeeded().forPath(PATH.concat(INSTANCE_PATH));
}
} catch (Exception e) {
// do nothing
}
this.leaderSelector = new LeaderSelector(client, PATH.concat(LEADER_PATH), this);
this.leaderSelector.autoRequeue();
this.leaderSelector.start();
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
while (leaderSelector.getLeader() == null) {
Thread.currentThread().yield();
}
if (!leaderSelector.hasLeadership()) {
isLeader = false;
if (slavePath != null && client.checkExists().forPath(slavePath) != null) {
return;
}
slavePath = client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(PATH.concat("/instance/node"), "ready".getBytes());
while ("ready".equals(new String(client.getData().forPath(slavePath)))) {
Thread.currentThread().yield();
}
instanceId = Long.parseLong(new String(client.getData().forPath(slavePath)));
ready = true;
}
} catch (Exception e) {
LOGGER.warn("Caught exception while handling zk!", e);
}
}
};
timerExecutor.scheduleAtFixedRate(runnable, 1L, 10L, TimeUnit.SECONDS);
}
Aggregations