Search in sources :

Example 41 with RetryNTimes

use of org.apache.curator.retry.RetryNTimes 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();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) RetryNTimes(org.apache.curator.retry.RetryNTimes) RetryPolicy(org.apache.curator.RetryPolicy) Before(org.junit.Before)

Example 42 with RetryNTimes

use of org.apache.curator.retry.RetryNTimes in project drill by axbaretto.

the class TestPStoreProviders method createCurator.

private CuratorFramework createCurator() {
    String connect = zkHelper.getConnectionString();
    DrillConfig config = zkHelper.getConfig();
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().namespace(zkHelper.getConfig().getString(ExecConstants.ZK_ROOT)).retryPolicy(new RetryNTimes(1, 100)).connectionTimeoutMs(config.getInt(ExecConstants.ZK_TIMEOUT)).connectString(connect);
    return builder.build();
}
Also used : RetryNTimes(org.apache.curator.retry.RetryNTimes) DrillConfig(org.apache.drill.common.config.DrillConfig) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory)

Example 43 with RetryNTimes

use of org.apache.curator.retry.RetryNTimes in project drill by axbaretto.

the class TestZkRegistry method connectToZk.

/**
 * Connect to the test ZK for the simulated Drillbit side of the test. (The AM
 * side of the test uses the actual AM code, which is what we're testing
 * here...)
 *
 * @param connectString
 * @return
 */
public static CuratorFramework connectToZk(String connectString) {
    CuratorFramework client = CuratorFrameworkFactory.builder().namespace(ZK_ROOT + "/" + CLUSTER_ID).connectString(connectString).retryPolicy(new RetryNTimes(3, 1000)).build();
    client.start();
    return client;
}
Also used : RetryNTimes(org.apache.curator.retry.RetryNTimes) CuratorFramework(org.apache.curator.framework.CuratorFramework)

Example 44 with RetryNTimes

use of org.apache.curator.retry.RetryNTimes in project x-pipe by ctripcorp.

the class MetaServerPrepareResourcesAndStart method connectToZk.

private CuratorFramework connectToZk(String connectString) throws InterruptedException {
    Builder builder = CuratorFrameworkFactory.builder();
    builder.connectionTimeoutMs(3000);
    builder.connectString(connectString);
    builder.maxCloseWaitMs(3000);
    builder.namespace("xpipe");
    builder.retryPolicy(new RetryNTimes(3, 1000));
    builder.sessionTimeoutMs(5000);
    CuratorFramework client = builder.build();
    client.start();
    client.blockUntilConnected();
    return client;
}
Also used : RetryNTimes(org.apache.curator.retry.RetryNTimes) CuratorFramework(org.apache.curator.framework.CuratorFramework) Builder(org.apache.curator.framework.CuratorFrameworkFactory.Builder)

Example 45 with RetryNTimes

use of org.apache.curator.retry.RetryNTimes in project x-pipe by ctripcorp.

the class DefaultZkConfig method create.

@Override
public CuratorFramework create(String address) throws InterruptedException {
    Builder builder = CuratorFrameworkFactory.builder();
    builder.connectionTimeoutMs(getZkConnectionTimeoutMillis());
    builder.connectString(address);
    builder.maxCloseWaitMs(getZkCloseWaitMillis());
    builder.namespace(getZkNamespace());
    builder.retryPolicy(new RetryNTimes(getZkRetries(), getSleepMsBetweenRetries()));
    builder.sessionTimeoutMs(getZkSessionTimeoutMillis());
    builder.threadFactory(XpipeThreadFactory.create("Xpipe-ZK-" + address, true));
    logger.info("[create]{}, {}", Codec.DEFAULT.encode(this), address);
    CuratorFramework curatorFramework = builder.build();
    curatorFramework.start();
    curatorFramework.blockUntilConnected(waitForZkConnectedMillis(), TimeUnit.MILLISECONDS);
    return curatorFramework;
}
Also used : RetryNTimes(org.apache.curator.retry.RetryNTimes) CuratorFramework(org.apache.curator.framework.CuratorFramework) Builder(org.apache.curator.framework.CuratorFrameworkFactory.Builder)

Aggregations

RetryNTimes (org.apache.curator.retry.RetryNTimes)68 CuratorFramework (org.apache.curator.framework.CuratorFramework)51 Test (org.junit.Test)20 RetryPolicy (org.apache.curator.RetryPolicy)12 NIOServerCnxnFactory (org.apache.zookeeper.server.NIOServerCnxnFactory)12 Test (org.testng.annotations.Test)11 CuratorFrameworkFactory (org.apache.curator.framework.CuratorFrameworkFactory)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 ZooKeeperGroup (io.fabric8.groups.internal.ZooKeeperGroup)8 IOException (java.io.IOException)6 ZooKeeperGroup (org.apache.camel.component.zookeepermaster.group.internal.ZooKeeperGroup)6 Before (org.junit.Before)6 ArrayList (java.util.ArrayList)5 TestingServer (org.apache.curator.test.TestingServer)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 ConnectionState (org.apache.curator.framework.state.ConnectionState)4 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 BackgroundCallback (org.apache.curator.framework.api.BackgroundCallback)3 CuratorEvent (org.apache.curator.framework.api.CuratorEvent)3