Search in sources :

Example 6 with Timing

use of org.apache.curator.test.Timing in project druid by druid-io.

the class OverlordTest method setupServerAndCurator.

private void setupServerAndCurator() throws Exception {
    server = new TestingServer();
    timing = new Timing();
    curator = CuratorFrameworkFactory.builder().connectString(server.getConnectString()).sessionTimeoutMs(timing.session()).connectionTimeoutMs(timing.connection()).retryPolicy(new RetryOneTime(1)).compressionProvider(new PotentiallyGzippedCompressionProvider(true)).build();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) RetryOneTime(org.apache.curator.retry.RetryOneTime) Timing(org.apache.curator.test.Timing) PotentiallyGzippedCompressionProvider(io.druid.curator.PotentiallyGzippedCompressionProvider)

Example 7 with Timing

use of org.apache.curator.test.Timing in project druid by druid-io.

the class BatchServerInventoryViewTest method waitForSync.

private static void waitForSync(BatchServerInventoryView batchServerInventoryView, Set<DataSegment> testSegments) throws Exception {
    final Timing forWaitingTiming = timing.forWaiting();
    Stopwatch stopwatch = Stopwatch.createStarted();
    while (Iterables.isEmpty(batchServerInventoryView.getInventory()) || Iterables.get(batchServerInventoryView.getInventory(), 0).getSegments().size() != testSegments.size()) {
        Thread.sleep(100);
        if (stopwatch.elapsed(TimeUnit.MILLISECONDS) > forWaitingTiming.milliseconds()) {
            throw new ISE("BatchServerInventoryView is not updating");
        }
    }
}
Also used : Stopwatch(com.google.common.base.Stopwatch) ISE(io.druid.java.util.common.ISE) Timing(org.apache.curator.test.Timing)

Example 8 with Timing

use of org.apache.curator.test.Timing in project druid by druid-io.

the class CuratorTestBase method setupServerAndCurator.

protected void setupServerAndCurator() throws Exception {
    server = new TestingServer();
    timing = new Timing();
    curator = CuratorFrameworkFactory.builder().connectString(server.getConnectString()).sessionTimeoutMs(timing.session()).connectionTimeoutMs(timing.connection()).retryPolicy(new RetryOneTime(1)).compressionProvider(new PotentiallyGzippedCompressionProvider(true)).build();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) RetryOneTime(org.apache.curator.retry.RetryOneTime) Timing(org.apache.curator.test.Timing)

Example 9 with Timing

use of org.apache.curator.test.Timing in project curator by Netflix.

the class ZkTestSystem method createZkConnection.

public static IZkConnection createZkConnection(String connectString) {
    Timing timing = new Timing();
    CuratorFramework client = CuratorFrameworkFactory.newClient(connectString, timing.session(), timing.connection(), new RetryOneTime(1));
    client.start();
    try {
        return new CuratorZKClientBridge(client);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) RetryOneTime(org.apache.curator.retry.RetryOneTime) CuratorZKClientBridge(com.netflix.curator.x.zkclientbridge.CuratorZKClientBridge) Timing(org.apache.curator.test.Timing) IOException(java.io.IOException)

Example 10 with Timing

use of org.apache.curator.test.Timing in project exhibitor by soabase.

the class TestZookeeperConfigProvider method setup.

@BeforeMethod
public void setup() throws Exception {
    timing = new Timing();
    cluster = new TestingCluster(3);
    cluster.start();
    client = CuratorFrameworkFactory.newClient(cluster.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
    client.start();
}
Also used : TestingCluster(org.apache.curator.test.TestingCluster) RetryOneTime(org.apache.curator.retry.RetryOneTime) Timing(org.apache.curator.test.Timing) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Timing (org.apache.curator.test.Timing)10 RetryOneTime (org.apache.curator.retry.RetryOneTime)8 CuratorFramework (org.apache.curator.framework.CuratorFramework)5 Stat (org.apache.zookeeper.data.Stat)4 Test (org.junit.Test)4 Stopwatch (com.google.common.base.Stopwatch)2 ISE (io.druid.java.util.common.ISE)2 TestingServer (org.apache.curator.test.TestingServer)2 CuratorZKClientBridge (com.netflix.curator.x.zkclientbridge.CuratorZKClientBridge)1 PotentiallyGzippedCompressionProvider (io.druid.curator.PotentiallyGzippedCompressionProvider)1 IOException (java.io.IOException)1 Random (java.util.Random)1 TestingCluster (org.apache.curator.test.TestingCluster)1 BeforeMethod (org.testng.annotations.BeforeMethod)1