Search in sources :

Example 26 with RetryPolicy

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

the class FluxTopologyComponent method start.

@Override
public void start() throws UnableToStartException {
    try {
        stormCluster = new LocalCluster();
        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        try (CuratorFramework client = CuratorFrameworkFactory.newClient(getZookeeperConnectString(), retryPolicy)) {
            client.start();
            String root = "/storm/leader-lock";
            Stat exists = client.checkExists().forPath(root);
            if (exists == null) {
                client.create().creatingParentsIfNeeded().forPath(root);
            }
        } catch (Exception e) {
            LOG.error("Unable to create leaderlock", e);
        } finally {
        }
    } catch (Exception e) {
        throw new UnableToStartException("Unable to start flux topology: " + getTopologyLocation(), e);
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) CuratorFramework(org.apache.curator.framework.CuratorFramework) Stat(org.apache.zookeeper.data.Stat) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) UnableToStartException(org.apache.metron.integration.UnableToStartException) RetryPolicy(org.apache.curator.RetryPolicy) UnableToStartException(org.apache.metron.integration.UnableToStartException) IOException(java.io.IOException) TException(org.apache.storm.thrift.TException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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