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();
}
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();
}
use of org.apache.curator.test.Timing in project xian by happyyangyuan.
the class TestFramework method testOverrideCreateParentContainers.
@Test
public void testOverrideCreateParentContainers() throws Exception {
if (!checkForContainers()) {
return;
}
CuratorFramework client = CuratorFrameworkFactory.builder().connectString(server.getConnectString()).retryPolicy(new RetryOneTime(1)).dontUseContainerParents().build();
try {
client.start();
client.create().creatingParentContainersIfNeeded().forPath("/one/two/three", "foo".getBytes());
byte[] data = client.getData().forPath("/one/two/three");
Assert.assertEquals(data, "foo".getBytes());
client.delete().forPath("/one/two/three");
new Timing().sleepABit();
Assert.assertNotNull(client.checkExists().forPath("/one/two"));
new Timing().sleepABit();
Assert.assertNotNull(client.checkExists().forPath("/one"));
} finally {
CloseableUtils.closeQuietly(client);
}
}
use of org.apache.curator.test.Timing in project xian by happyyangyuan.
the class TestNeverConnected method testNeverConnected.
@Test
public void testNeverConnected() throws Exception {
Timing timing = new Timing();
// use a connection string to a non-existent server
CuratorFramework client = CuratorFrameworkFactory.newClient("localhost:1111", 100, 100, new RetryOneTime(1));
try {
final BlockingQueue<ConnectionState> queue = Queues.newLinkedBlockingQueue();
ConnectionStateListener listener = new ConnectionStateListener() {
@Override
public void stateChanged(CuratorFramework client, ConnectionState state) {
queue.add(state);
}
};
client.getConnectionStateListenable().addListener(listener);
client.start();
client.create().inBackground().forPath("/");
ConnectionState polled = queue.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
Assert.assertEquals(polled, ConnectionState.SUSPENDED);
polled = queue.poll(timing.forWaiting().seconds(), TimeUnit.SECONDS);
Assert.assertEquals(polled, ConnectionState.LOST);
} finally {
CloseableUtils.closeQuietly(client);
}
}
use of org.apache.curator.test.Timing in project xian by happyyangyuan.
the class TestWatcherIdentity method testZKWatcher.
@Test
public void testZKWatcher() throws Exception {
Timing timing = new Timing();
CountZKWatcher watcher = new CountZKWatcher();
CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
try {
client.start();
client.create().forPath(PATH);
// Add twice the same watcher on the same path
client.getData().usingWatcher(watcher).forPath(PATH);
client.getData().usingWatcher(watcher).forPath(PATH);
// Ok, let's test it
client.setData().forPath(PATH, new byte[] {});
timing.sleepABit();
Assert.assertEquals(1, watcher.count.get());
} finally {
CloseableUtils.closeQuietly(client);
}
}
Aggregations