use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project knox by apache.
the class AtlasZookeeperURLManager method lookupURLs.
public List<String> lookupURLs() {
List<String> serverHosts = new ArrayList<>();
try (CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(zooKeeperEnsemble).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build()) {
zooKeeperClient.start();
zooKeeperClient.blockUntilConnected(10, TimeUnit.SECONDS);
byte[] bytes = zooKeeperClient.getData().forPath(zooKeeperNamespace + APACHE_ATLAS_ACTIVE_SERVER_INFO);
String activeURL = new String(bytes, StandardCharsets.UTF_8);
serverHosts.add(activeURL);
} catch (Exception e) {
LOG.failedToGetZookeeperUrls(e);
throw new RuntimeException(e);
}
return serverHosts;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project knox by apache.
the class KafkaZookeeperURLManager method retrieveHosts.
// -------------------------------------------------------------------------------------
// Private methods
// -------------------------------------------------------------------------------------
/**
* @return Retrieve lists of hosts from ZooKeeper
*/
private List<String> retrieveHosts() {
List<String> serverHosts = new ArrayList<>();
try (CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(getZookeeperEnsemble()).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build()) {
zooKeeperClient.start();
zooKeeperClient.blockUntilConnected(10, TimeUnit.SECONDS);
// Retrieve list of host URLs from ZooKeeper
List<String> brokers = zooKeeperClient.getChildren().forPath(BASE_PATH);
for (String broker : brokers) {
String serverInfo = new String(zooKeeperClient.getData().forPath(BASE_PATH + "/" + broker), StandardCharsets.UTF_8);
String serverURL = constructURL(serverInfo);
serverHosts.add(serverURL);
}
} catch (Exception e) {
LOG.failedToGetZookeeperUrls(e);
throw new RuntimeException(e);
}
return serverHosts;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project knox by apache.
the class SOLRZookeeperURLManager method retrieveHosts.
// -------------------------------------------------------------------------------------
// Private methods
// -------------------------------------------------------------------------------------
/**
* @return Retrieve lists of hosts from ZooKeeper
*/
private List<String> retrieveHosts() {
List<String> serverHosts = new ArrayList<>();
try (CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(getZookeeperEnsemble()).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build()) {
zooKeeperClient.start();
zooKeeperClient.blockUntilConnected(10, TimeUnit.SECONDS);
List<String> serverNodes = zooKeeperClient.getChildren().forPath("/live_nodes");
for (String serverNode : serverNodes) {
String serverURL = constructURL(serverNode);
serverHosts.add(serverURL);
}
} catch (Exception e) {
LOG.failedToGetZookeeperUrls(e);
throw new RuntimeException(e);
}
return serverHosts;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project knox by apache.
the class AtlasZookeeperURLManagerTest method setUp.
@Before
public void setUp() throws Exception {
cluster = new TestingCluster(1);
cluster.start();
try (CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(cluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build()) {
zooKeeperClient.start();
assertTrue(zooKeeperClient.blockUntilConnected(10, TimeUnit.SECONDS));
zooKeeperClient.create().forPath("/apache_atlas");
zooKeeperClient.create().forPath("/apache_atlas/active_server_info");
zooKeeperClient.setData().forPath("/apache_atlas/active_server_info", atlasNode1.getBytes(StandardCharsets.UTF_8));
}
setAtlasActiveHostURLInZookeeper(atlasNode1);
manager = new AtlasZookeeperURLManager();
HaServiceConfig config = new DefaultHaServiceConfig("ATLAS-API");
config.setEnabled(true);
config.setZookeeperEnsemble(cluster.getConnectString());
config.setZookeeperNamespace("apache_atlas");
manager.setConfig(config);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project knox by apache.
the class KafkaZookeeperURLManagerTest method setUp.
@Before
public void setUp() throws Exception {
cluster = new TestingCluster(1);
cluster.start();
try (CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(cluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build()) {
zooKeeperClient.start();
assertTrue(zooKeeperClient.blockUntilConnected(10, TimeUnit.SECONDS));
zooKeeperClient.create().forPath("/brokers");
zooKeeperClient.create().forPath("/brokers/ids");
}
}
Aggregations