use of org.apache.curator.RetryPolicy in project drill by axbaretto.
the class TestEphemeralStore method setUp.
@Before
public void setUp() throws Exception {
ZookeeperTestUtil.setZookeeperSaslTestConfigProps();
server = new TestingServer();
final RetryPolicy policy = new RetryNTimes(2, 1000);
curator = CuratorFrameworkFactory.newClient(server.getConnectString(), policy);
config = Mockito.mock(TransientStoreConfig.class);
Mockito.when(config.getName()).thenReturn(root);
Mockito.when(config.getSerializer()).thenReturn(new InstanceSerializer<String>() {
@Override
public byte[] serialize(final String instance) throws IOException {
if (instance == null) {
return null;
}
return instance.getBytes();
}
@Override
public String deserialize(final byte[] raw) throws IOException {
if (raw == null) {
return null;
}
return new String(raw);
}
});
store = new ZkEphemeralStore<>(config, curator);
server.start();
curator.start();
store.start();
}
use of org.apache.curator.RetryPolicy in project drill by axbaretto.
the class TestZookeeperClient method setUp.
@Before
public void setUp() throws Exception {
ZookeeperTestUtil.setZookeeperSaslTestConfigProps();
server = new TestingServer();
final RetryPolicy policy = new RetryNTimes(1, 1000);
curator = CuratorFrameworkFactory.newClient(server.getConnectString(), policy);
client = new ClientWithMockCache(curator, root, mode);
server.start();
curator.start();
client.start();
}
use of org.apache.curator.RetryPolicy in project oozie by apache.
the class ZKUtils method createClient.
private void createClient() throws Exception {
// Connect to the ZooKeeper server
RetryPolicy retryPolicy = ZKUtils.getRetryPolicy();
String zkConnectionString = ConfigurationService.get(ZK_CONNECTION_STRING);
String zkNamespace = getZKNameSpace();
int zkConnectionTimeout = ConfigurationService.getInt(ZK_CONNECTION_TIMEOUT);
int zkSessionTimeout = ConfigurationService.getInt(ZK_SESSION_TIMEOUT, 300);
ACLProvider aclProvider;
if (Services.get().getConf().getBoolean(ZK_SECURE, false)) {
log.info("Connecting to ZooKeeper with SASL/Kerberos and using 'sasl' ACLs");
setJaasConfiguration();
System.setProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "Client");
System.setProperty("zookeeper.authProvider.1", "org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
saslACL = Collections.singletonList(new ACL(Perms.ALL, new Id("sasl", getServicePrincipal())));
aclProvider = new SASLOwnerACLProvider();
} else {
log.info("Connecting to ZooKeeper without authentication");
// open to everyone
aclProvider = new DefaultACLProvider();
}
client = CuratorFrameworkFactory.builder().namespace(zkNamespace).connectString(zkConnectionString).retryPolicy(retryPolicy).aclProvider(aclProvider).connectionTimeoutMs(// in ms
zkConnectionTimeout * 1000).sessionTimeoutMs(// in ms
zkSessionTimeout * 1000).build();
client.start();
client.getConnectionStateListenable().addListener(new ZKConnectionListener());
}
use of org.apache.curator.RetryPolicy in project nakadi by zalando.
the class ZooKeeperHolder method initExhibitor.
private void initExhibitor() throws Exception {
final RetryPolicy retryPolicy = new ExponentialBackoffRetry(EXHIBITOR_RETRY_TIME, EXHIBITOR_RETRY_MAX);
final EnsembleProvider ensembleProvider;
if (exhibitorAddresses != null) {
final Collection<String> exhibitorHosts = Arrays.asList(exhibitorAddresses.split("\\s*,\\s*"));
final Exhibitors exhibitors = new Exhibitors(exhibitorHosts, exhibitorPort, () -> zookeeperBrokers + zookeeperKafkaNamespace);
final ExhibitorRestClient exhibitorRestClient = new DefaultExhibitorRestClient();
ensembleProvider = new ExhibitorEnsembleProvider(exhibitors, exhibitorRestClient, "/exhibitor/v1/cluster/list", EXHIBITOR_POLLING_MS, retryPolicy);
((ExhibitorEnsembleProvider) ensembleProvider).pollForInitialEnsemble();
} else {
ensembleProvider = new FixedEnsembleProvider(zookeeperBrokers + zookeeperKafkaNamespace);
}
zooKeeper = CuratorFrameworkFactory.builder().ensembleProvider(ensembleProvider).retryPolicy(retryPolicy).build();
zooKeeper.start();
}
use of org.apache.curator.RetryPolicy in project oozie by apache.
the class ZKXTestCase method createClient.
private void createClient() throws Exception {
RetryPolicy retryPolicy = ZKUtils.getRetryPolicy();
String zkConnectionString = Services.get().getConf().get("oozie.zookeeper.connection.string", zkServer.getConnectString());
String zkNamespace = Services.get().getConf().get("oozie.zookeeper.namespace", "oozie");
client = CuratorFrameworkFactory.builder().namespace(zkNamespace).connectString(zkConnectionString).retryPolicy(retryPolicy).build();
client.start();
}
Aggregations