Search in sources :

Example 16 with RetryPolicy

use of org.apache.curator.RetryPolicy in project drill by apache.

the class TestZookeeperClient method setUp.

@Before
public void setUp() throws Exception {
    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();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) RetryNTimes(org.apache.curator.retry.RetryNTimes) RetryPolicy(org.apache.curator.RetryPolicy) Before(org.junit.Before)

Example 17 with RetryPolicy

use of org.apache.curator.RetryPolicy in project lucene-solr by apache.

the class HadoopAuthFilter method getCuratorClient.

protected CuratorFramework getCuratorClient(SolrZkClient zkClient) {
    // should we try to build a RetryPolicy off of the ZkController?
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    if (zkClient == null) {
        throw new IllegalArgumentException("zkClient required");
    }
    String zkHost = zkClient.getZkServerAddress();
    String zkChroot = zkHost.contains("/") ? zkHost.substring(zkHost.indexOf("/")) : "";
    String zkNamespace = zkChroot + SecurityAwareZkACLProvider.SECURITY_ZNODE_PATH;
    zkNamespace = zkNamespace.startsWith("/") ? zkNamespace.substring(1) : zkNamespace;
    String zkConnectionString = zkHost.contains("/") ? zkHost.substring(0, zkHost.indexOf("/")) : zkHost;
    SolrZkToCuratorCredentialsACLs curatorToSolrZk = new SolrZkToCuratorCredentialsACLs(zkClient);
    // this value is currently hard coded, see SOLR-7561.
    final int connectionTimeoutMs = 30000;
    curatorFramework = CuratorFrameworkFactory.builder().namespace(zkNamespace).connectString(zkConnectionString).retryPolicy(retryPolicy).aclProvider(curatorToSolrZk.getACLProvider()).authorization(curatorToSolrZk.getAuthInfos()).sessionTimeoutMs(zkClient.getZkClientTimeout()).connectionTimeoutMs(connectionTimeoutMs).build();
    curatorFramework.start();
    return curatorFramework;
}
Also used : ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) RetryPolicy(org.apache.curator.RetryPolicy)

Example 18 with RetryPolicy

use of org.apache.curator.RetryPolicy in project lucene-solr by apache.

the class DelegationTokenKerberosFilter method getCuratorClient.

protected CuratorFramework getCuratorClient(SolrZkClient zkClient) {
    // should we try to build a RetryPolicy off of the ZkController?
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    if (zkClient == null) {
        throw new IllegalArgumentException("zkClient required");
    }
    String zkHost = zkClient.getZkServerAddress();
    String zkChroot = zkHost.contains("/") ? zkHost.substring(zkHost.indexOf("/")) : "";
    String zkNamespace = zkChroot + SecurityAwareZkACLProvider.SECURITY_ZNODE_PATH;
    zkNamespace = zkNamespace.startsWith("/") ? zkNamespace.substring(1) : zkNamespace;
    String zkConnectionString = zkHost.contains("/") ? zkHost.substring(0, zkHost.indexOf("/")) : zkHost;
    SolrZkToCuratorCredentialsACLs curatorToSolrZk = new SolrZkToCuratorCredentialsACLs(zkClient);
    // this value is currently hard coded, see SOLR-7561.
    final int connectionTimeoutMs = 30000;
    curatorFramework = CuratorFrameworkFactory.builder().namespace(zkNamespace).connectString(zkConnectionString).retryPolicy(retryPolicy).aclProvider(curatorToSolrZk.getACLProvider()).authorization(curatorToSolrZk.getAuthInfos()).sessionTimeoutMs(zkClient.getZkClientTimeout()).connectionTimeoutMs(connectionTimeoutMs).build();
    curatorFramework.start();
    return curatorFramework;
}
Also used : ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) RetryPolicy(org.apache.curator.RetryPolicy)

Example 19 with RetryPolicy

use of org.apache.curator.RetryPolicy in project metron by apache.

the class TestConfig method client.

@Bean(initMethod = "start", destroyMethod = "close")
public CuratorFramework client(ComponentRunner componentRunner) {
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    ZKServerComponent zkServerComponent = componentRunner.getComponent("zk", ZKServerComponent.class);
    return CuratorFrameworkFactory.newClient(zkServerComponent.getConnectionString(), retryPolicy);
}
Also used : ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) ZKServerComponent(org.apache.metron.integration.components.ZKServerComponent) RetryPolicy(org.apache.curator.RetryPolicy) Bean(org.springframework.context.annotation.Bean)

Example 20 with RetryPolicy

use of org.apache.curator.RetryPolicy in project metron by apache.

the class ProfileBuilderBolt method setupZookeeper.

private void setupZookeeper() {
    try {
        if (zookeeperClient == null) {
            RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
            zookeeperClient = CuratorFrameworkFactory.newClient(zookeeperUrl, retryPolicy);
        }
        zookeeperClient.start();
        // this is temporary to ensure that any validation passes. the individual bolt
        // will reinitialize stellar to dynamically pull from zookeeper.
        ConfigurationsUtils.setupStellarStatically(zookeeperClient);
        if (zookeeperCache == null) {
            ConfigurationsUpdater<ProfilerConfigurations> updater = createUpdater();
            SimpleEventListener listener = new SimpleEventListener.Builder().with(updater::update, TreeCacheEvent.Type.NODE_ADDED, TreeCacheEvent.Type.NODE_UPDATED).with(updater::delete, TreeCacheEvent.Type.NODE_REMOVED).build();
            zookeeperCache = new ZKCache.Builder().withClient(zookeeperClient).withListener(listener).withRoot(Constants.ZOOKEEPER_TOPOLOGY_ROOT).build();
            updater.forceUpdate(zookeeperClient);
            zookeeperCache.start();
        }
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
}
Also used : SimpleEventListener(org.apache.metron.zookeeper.SimpleEventListener) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) ZKCache(org.apache.metron.zookeeper.ZKCache) RetryPolicy(org.apache.curator.RetryPolicy) ProfilerConfigurations(org.apache.metron.common.configuration.profiler.ProfilerConfigurations)

Aggregations

RetryPolicy (org.apache.curator.RetryPolicy)26 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)21 CuratorFramework (org.apache.curator.framework.CuratorFramework)12 IOException (java.io.IOException)6 ACLProvider (org.apache.curator.framework.api.ACLProvider)5 DefaultZooKeeperClient (com.spotify.helios.servicescommon.coordination.DefaultZooKeeperClient)4 ZooKeeperClient (com.spotify.helios.servicescommon.coordination.ZooKeeperClient)4 TestingServer (org.apache.curator.test.TestingServer)4 Before (org.junit.Before)4 AuthInfo (org.apache.curator.framework.AuthInfo)3 MaaSConfig (org.apache.metron.maas.config.MaaSConfig)3 ServiceDiscoverer (org.apache.metron.maas.discovery.ServiceDiscoverer)3 HeliosRuntimeException (com.spotify.helios.common.HeliosRuntimeException)2 CuratorClientFactoryImpl (com.spotify.helios.servicescommon.coordination.CuratorClientFactoryImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 RetryNTimes (org.apache.curator.retry.RetryNTimes)2