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() ); } } }
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"); } } }
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));
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));
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());
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()]));
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));
KillSession.kill(curator.getZookeeperClient().getZooKeeper(), server.getConnectString()); Assert.assertTrue(timing.forWaiting().awaitLatch(latch));
Assert.assertTrue("Wait for /test1 to be created", timing.forWaiting().awaitLatch(latch));
timing.forWaiting().awaitLatch(removeCallbackLatch);
Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch));
Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch));
reaper.addPath("/test1"); timing.forWaiting().sleepABit();
reaper.start(); timing.forWaiting().sleepABit();
reaper.start(); timing.forWaiting().sleepABit();
reaper.addPath("/test1"); timing.forWaiting().sleepABit();
@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); } }
@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); } }
reaper.start(); timing.forWaiting().sleepABit();
reaper.start(); timing.forWaiting().sleepABit();