Search in sources :

Example 16 with ExponentialBackoffRetry

use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project Saturn by vipshop.

the class InitSaturnJob method main.

/**
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    String zkConnection = System.getProperty("VIP_SATURN_ZK_CONNECTION");
    System.out.println("zkConnection=" + zkConnection);
    if (zkConnection == null || "".equals(zkConnection.trim())) {
        zkConnection = "localhost:2182";
    }
    CuratorFramework client = CuratorFrameworkFactory.builder().connectString(zkConnection).namespace("saturn-it.vip.com").sessionTimeoutMs(10000).retryPolicy(retryPolicy).build();
    client.start();
    addJavaJob(client, "demoJavaJob");
    System.out.println("done add a java-job.");
    addShellJob(client, "demoShellJob");
    System.out.println("done add a shell-job.");
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) RetryPolicy(org.apache.curator.RetryPolicy)

Example 17 with ExponentialBackoffRetry

use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project fabric8 by jboss-fuse.

the class CuratorFactoryBean method getObject.

// FactoryBean interface
// -------------------------------------------------------------------------
public CuratorFramework getObject() throws Exception {
    LOG.debug("Connecting to ZooKeeper on " + connectString);
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString(connectString).retryPolicy(new ExponentialBackoffRetry(5, 10)).connectionTimeoutMs(getTimeout());
    if (password != null && !password.isEmpty()) {
        builder.aclProvider(new CuratorACLManager());
        builder.authorization("digest", ("fabric:" + password).getBytes("UTF-8"));
    }
    this.curator = builder.build();
    LOG.debug("Starting curator " + curator);
    curator.start();
    return curator;
}
Also used : CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) CuratorACLManager(io.fabric8.zookeeper.curator.CuratorACLManager)

Example 18 with ExponentialBackoffRetry

use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project knox by apache.

the class HBaseZookeeperURLManagerTest method setup.

@Before
public void setup() throws Exception {
    cluster = new TestingCluster(3);
    cluster.start();
    CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(cluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
    zooKeeperClient.start();
    zooKeeperClient.create().forPath("/hbase-unsecure");
    zooKeeperClient.create().forPath("/hbase-unsecure/rs");
    zooKeeperClient.close();
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) TestingCluster(org.apache.curator.test.TestingCluster) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) Before(org.junit.Before)

Example 19 with ExponentialBackoffRetry

use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project knox by apache.

the class HS2ZookeeperURLManagerTest method setup.

@Before
public void setup() throws Exception {
    cluster = new TestingCluster(3);
    cluster.start();
    CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(cluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
    String host1 = "hive.server2.authentication=NONE;hive.server2.transport.mode=http;hive.server2.thrift.http.path=cliservice;" + "hive.server2.thrift.http.port=10001;hive.server2.thrift.bind.host=host1;hive.server2.use.SSL=true";
    String host2 = "hive.server2.authentication=NONE;hive.server2.transport.mode=http;hive.server2.thrift.http.path=foobar;" + "hive.server2.thrift.http.port=10002;hive.server2.thrift.bind.host=host2;hive.server2.use.SSL=false";
    String host3 = "hive.server2.authentication=NONE;hive.server2.transport.mode=http;hive.server2.thrift.http.path=cliservice;" + "hive.server2.thrift.http.port=10003;hive.server2.thrift.bind.host=host3;hive.server2.use.SSL=false";
    String host4 = "hive.server2.authentication=NONE;hive.server2.transport.mode=http;hive.server2.thrift.http.path=cliservice;" + "hive.server2.thrift.http.port=10004;hive.server2.thrift.bind.host=host4;hive.server2.use.SSL=true";
    zooKeeperClient.start();
    zooKeeperClient.create().forPath("/hiveServer2");
    zooKeeperClient.create().forPath("/hiveServer2/host1", host1.getBytes());
    zooKeeperClient.create().forPath("/hiveServer2/host2", host2.getBytes());
    zooKeeperClient.create().forPath("/hiveServer2/host3", host3.getBytes());
    zooKeeperClient.create().forPath("/hiveServer2/host4", host4.getBytes());
    zooKeeperClient.close();
    manager = new HS2ZookeeperURLManager();
    HaServiceConfig config = new DefaultHaServiceConfig("HIVE");
    config.setEnabled(true);
    config.setZookeeperEnsemble(cluster.getConnectString());
    config.setZookeeperNamespace("hiveServer2");
    manager.setConfig(config);
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) TestingCluster(org.apache.curator.test.TestingCluster) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) HaServiceConfig(org.apache.knox.gateway.ha.provider.HaServiceConfig) Before(org.junit.Before)

Example 20 with ExponentialBackoffRetry

use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project knox by apache.

the class SOLRZookeeperURLManagerTest method setup.

@Before
public void setup() throws Exception {
    cluster = new TestingCluster(3);
    cluster.start();
    CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(cluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
    zooKeeperClient.start();
    zooKeeperClient.create().forPath("/live_nodes");
    zooKeeperClient.create().forPath("/live_nodes/host1:8983_solr");
    zooKeeperClient.create().forPath("/live_nodes/host2:8983_solr");
    zooKeeperClient.create().forPath("/live_nodes/host3:8983_solr");
    zooKeeperClient.close();
    manager = new SOLRZookeeperURLManager();
    HaServiceConfig config = new DefaultHaServiceConfig("SOLR");
    config.setEnabled(true);
    config.setZookeeperEnsemble(cluster.getConnectString());
    manager.setConfig(config);
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) TestingCluster(org.apache.curator.test.TestingCluster) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) HaServiceConfig(org.apache.knox.gateway.ha.provider.HaServiceConfig) Before(org.junit.Before)

Aggregations

ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)189 CuratorFramework (org.apache.curator.framework.CuratorFramework)113 RetryPolicy (org.apache.curator.RetryPolicy)46 Before (org.junit.Before)31 TestingCluster (org.apache.curator.test.TestingCluster)28 Test (org.testng.annotations.Test)23 TestingServer (org.apache.curator.test.TestingServer)19 IOException (java.io.IOException)18 Timing (org.apache.curator.test.Timing)16 CountDownLatch (java.util.concurrent.CountDownLatch)15 ArrayList (java.util.ArrayList)14 CuratorFrameworkFactory (org.apache.curator.framework.CuratorFrameworkFactory)12 ACLProvider (org.apache.curator.framework.api.ACLProvider)12 Test (org.junit.Test)12 ConnectionState (org.apache.curator.framework.state.ConnectionState)11 ExecutorService (java.util.concurrent.ExecutorService)10 ConnectionStateListener (org.apache.curator.framework.state.ConnectionStateListener)10 TestingServerStarter (io.pravega.test.common.TestingServerStarter)9 HashMap (java.util.HashMap)8 KeeperException (org.apache.zookeeper.KeeperException)8