use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project knox by apache.
the class RemoteConfigurationRegistryClientServiceTest method initializeTestClientAndZNodes.
/**
* Create a ZooKeeper client with SASL digest auth configured, and initialize the test znodes.
*/
private CuratorFramework initializeTestClientAndZNodes(TestingCluster zkCluster, String principal) throws Exception {
// Create the client for the test cluster
CuratorFramework setupClient = CuratorFrameworkFactory.builder().connectString(zkCluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(100, 3)).build();
assertNotNull(setupClient);
setupClient.start();
List<ACL> acls = new ArrayList<>();
if (principal != null) {
acls.add(new ACL(ZooDefs.Perms.ALL, new Id("sasl", principal)));
} else {
acls.add(new ACL(ZooDefs.Perms.ALL, ZooDefs.Ids.ANYONE_ID_UNSAFE));
}
setupClient.create().creatingParentsIfNeeded().withACL(acls).forPath("/knox/config/descriptors");
setupClient.create().creatingParentsIfNeeded().withACL(acls).forPath("/knox/config/shared-providers");
List<ACL> negativeACLs = new ArrayList<>();
if (principal != null) {
negativeACLs.add(new ACL(ZooDefs.Perms.ALL, new Id("sasl", "notyou")));
} else {
negativeACLs.add(new ACL(ZooDefs.Perms.ALL, ZooDefs.Ids.ANYONE_ID_UNSAFE));
}
setupClient.create().creatingParentsIfNeeded().withACL(negativeACLs).forPath("/someotherconfig");
return setupClient;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project twister2 by DSC-SPIDAL.
the class ZKUtil method connectToServer.
/**
* connect to ZooKeeper server
* @param config
* @return
*/
public static CuratorFramework connectToServer(Config config) {
String zkServerAddress = ZKContext.zooKeeperServerIP(config);
String zkServerPort = ZKContext.zooKeeperServerPort(config);
String zkServer = zkServerAddress + ":" + zkServerPort;
try {
CuratorFramework client = CuratorFrameworkFactory.newClient(zkServer, new ExponentialBackoffRetry(1000, 3));
client.start();
LOG.log(Level.INFO, "Connected to ZooKeeper server: " + zkServer);
return client;
} catch (Exception e) {
LOG.log(Level.SEVERE, "Could not connect to ZooKeeper server" + zkServer, e);
throw new RuntimeException(e);
}
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project phoenix by apache.
the class LoadBalancer method start.
private void start() throws Exception {
curaFramework = CuratorFrameworkFactory.newClient(getZkConnectString(), new ExponentialBackoffRetry(1000, 3));
curaFramework.start();
curaFramework.setACL().withACL(CONFIG.getAcls());
connectionStateListener = getConnectionStateListener();
curaFramework.getConnectionStateListenable().addListener(connectionStateListener);
unhandledErrorListener = getUnhandledErrorListener();
curaFramework.getUnhandledErrorListenable().addListener(unhandledErrorListener);
cache = new PathChildrenCache(curaFramework, CONFIG.getParentPath(), true);
cache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
closeAbles.add(cache);
closeAbles.add(curaFramework);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project phoenix by apache.
the class ZookeeperRegistry method registerServer.
@Override
public void registerServer(LoadBalanceZookeeperConf configuration, int pqsPort, String zookeeperConnectString, String pqsHost) throws Exception {
this.client = CuratorFrameworkFactory.newClient(zookeeperConnectString, new ExponentialBackoffRetry(1000, 10));
this.client.start();
HostAndPort hostAndPort = HostAndPort.fromParts(pqsHost, pqsPort);
String path = configuration.getFullPathToNode(hostAndPort);
String node = hostAndPort.toString();
this.client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(path, node.getBytes(StandardCharsets.UTF_8));
Stat stat = this.client.setACL().withACL(configuration.getAcls()).forPath(path);
if (stat != null) {
LOG.info(" node created with right ACL");
} else {
LOG.error("could not create node with right ACL. So, system would exit now.");
throw new RuntimeException(" Unable to connect to Zookeeper");
}
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project metron by apache.
the class MaasIntegrationTest method setupBeforeClass.
@BeforeAll
public static void setupBeforeClass() throws Exception {
UnitTestHelper.setJavaLoggingLevel(Level.SEVERE);
LOG.info("Starting up YARN cluster");
zkServerComponent = new ZKServerComponent();
yarnComponent = new YarnComponent().withApplicationMasterClass(ApplicationMaster.class).withTestName(MaasIntegrationTest.class.getSimpleName());
runner = new ComponentRunner.Builder().withComponent("yarn", yarnComponent).withComponent("zk", zkServerComponent).withMillisecondsBetweenAttempts(15000).withNumRetries(10).build();
runner.start();
String zookeeperUrl = zkServerComponent.getConnectionString();
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
client = CuratorFrameworkFactory.newClient(zookeeperUrl, retryPolicy);
client.start();
}
Aggregations