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(); }
announceSegmentForServer(druidServers.get(i), segments.get(i), zkPathsConfig, jsonMapper); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch));
private void waitForUpdateEvents(int count) throws Exception { final Timing forWaitingTiming = timing.forWaiting(); Stopwatch stopwatch = Stopwatch.createStarted(); while (inventoryUpdateCounter.get() != count) { Thread.sleep(100); if (stopwatch.elapsed(TimeUnit.MILLISECONDS) > forWaitingTiming.milliseconds()) { throw new ISE( "BatchServerInventoryView is not updating counter expected[%d] value[%d]", count, inventoryUpdateCounter.get() ); } } }
@Test public void testSimple() throws Exception { Timing timing = new Timing(); ChildReaper reaper = null; CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try { client.start(); for ( int i = 0; i < 10; ++i ) { client.create().creatingParentsIfNeeded().forPath("/test/" + Integer.toString(i)); } reaper = new ChildReaper(client, "/test", Reaper.Mode.REAP_UNTIL_DELETE, 1); reaper.start(); timing.forWaiting().sleepABit(); Stat stat = client.checkExists().forPath("/test"); Assert.assertEquals(stat.getNumChildren(), 0); } finally { CloseableUtils.closeQuietly(reaper); CloseableUtils.closeQuietly(client); } }
curator.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath("/container/billy", new byte[]{}); Assert.assertTrue(timing.awaitLatch(containerLatch)); strategy.setNewContainerLatch(null); curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/bob", Ints.toByteArray(2287)); Assert.assertTrue(timing.awaitLatch(inventoryLatch)); strategy.setNewInventoryLatch(null); curator.delete().forPath("/inventory/billy/1"); Assert.assertTrue(timing.awaitLatch(deleteLatch)); strategy.setDeadInventoryLatch(null); curator.create().withMode(CreateMode.EPHEMERAL).forPath("/inventory/billy/1", Ints.toByteArray(100)); Assert.assertTrue(timing.awaitLatch(inventoryLatch)); strategy.setNewInventoryLatch(null); Assert.assertTrue(timing.awaitLatch(latch));
@Test public void testSimple() throws Exception { Timing timing = new Timing(); ChildReaper reaper = null; CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try { client.start(); for ( int i = 0; i < 10; ++i ) { client.create().creatingParentsIfNeeded().forPath("/test/" + Integer.toString(i)); } reaper = new ChildReaper(client, "/test", Reaper.Mode.REAP_UNTIL_DELETE, 1); reaper.start(); timing.forWaiting().sleepABit(); Stat stat = client.checkExists().forPath("/test"); Assert.assertEquals(stat.getNumChildren(), 0); } finally { CloseableUtils.closeQuietly(reaper); CloseableUtils.closeQuietly(client); } }
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.size(Iterables.get(batchServerInventoryView.getInventory(), 0).getSegments()) != testSegments.size()) { Thread.sleep(100); if (stopwatch.elapsed(TimeUnit.MILLISECONDS) > forWaitingTiming.milliseconds()) { throw new ISE("BatchServerInventoryView is not updating"); } } }
Timing timing = new Timing(); ChildReaper reaper = null; CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try reaper.start(); timing.forWaiting().sleepABit();
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(); }
announceSegmentForServer(druidServers.get(i), segments.get(i), zkPathsConfig, jsonMapper); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch));
Timing timing = new Timing(); ChildReaper reaper = null; CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try reaper.start(); timing.forWaiting().sleepABit();
@Test public void syncMapOperation() throws Exception { Timing timing = new Timing(); TestingServer server = new TestingServer(); CuratorFramework curator = CuratorFrameworkFactory.builder() .namespace("io.vertx") .sessionTimeoutMs(timing.session()) .connectionTimeoutMs(timing.connection()) .connectString(server.getConnectString()) .retryPolicy(retryPolicy)
Assert.assertTrue(timing.forWaiting().awaitLatch(loadRequestSignal)); Assert.assertNotNull(curator.checkExists().forPath(loadRequestPath)); Assert.assertEquals( Assert.assertTrue(timing.forWaiting().awaitLatch(segmentLoadedSignal)); Assert.assertEquals(0, loadQueuePeon.getSegmentsToLoad().size()); Assert.assertEquals(0L, loadQueuePeon.getLoadQueueSize());
@Test public void testMultiPath() throws Exception Timing timing = new Timing(); ChildReaper reaper = null; CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try reaper.addPath("/test1"); timing.forWaiting().sleepABit();
@Test public void syncMapOperation() throws Exception { Timing timing = new Timing(); TestingServer server = new TestingServer(); CuratorFramework curator = CuratorFrameworkFactory.builder() .namespace("io.vertx") .sessionTimeoutMs(timing.session()) .connectionTimeoutMs(timing.connection()) .connectString(server.getConnectString()) .retryPolicy(retryPolicy)
Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); destinationLoadQueueChildrenCache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT); Assert.assertTrue(timing.forWaiting().awaitLatch(srcCountdown)); Assert.assertTrue(timing.forWaiting().awaitLatch(destCountdown)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch));
@Test public void testMultiPath() throws Exception Timing timing = new Timing(); ChildReaper reaper = null; CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try reaper.addPath("/test1"); timing.forWaiting().sleepABit();
Assert.assertTrue(timing.forWaiting().awaitLatch(dropRequestSignal[requestSignalIdx.get()])); Assert.assertNotNull(curator.checkExists().forPath(dropRequestPath)); Assert.assertEquals( Assert.assertTrue(timing.forWaiting().awaitLatch(segmentDroppedSignal[segmentSignalIdx.get()])); Assert.assertTrue(timing.forWaiting().awaitLatch(loadRequestSignal[requestSignalIdx.get()])); Assert.assertNotNull(curator.checkExists().forPath(loadRequestPath)); Assert.assertEquals( Assert.assertTrue(timing.forWaiting().awaitLatch(segmentLoadedSignal[segmentSignalIdx.get()]));
@Test public void testNamespace() throws Exception Timing timing = new Timing(); ChildReaper reaper = null; CuratorFramework client = CuratorFrameworkFactory.builder() .connectString(server.getConnectString()) .sessionTimeoutMs(timing.session()) .connectionTimeoutMs(timing.connection()) .retryPolicy(new RetryOneTime(1)) .namespace("foo") reaper.start(); timing.forWaiting().sleepABit();
Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch));