@Override public QueryRunner<Result<SearchResultValue>> createRunner(Segment adapter) { if (!(adapter instanceof ReferenceCountingSegment)) { throw new IAE("Expected instance of ReferenceCountingSegment, got %s", adapter.getClass()); } final ReferenceCountingSegment segment = (ReferenceCountingSegment) adapter; Assert.assertTrue(segment.getNumReferences() > 0); segmentReferences.add(segment); adapters.add((SegmentForTesting) segment.getBaseSegment()); return new BlockingQueryRunner<Result<SearchResultValue>>( new NoopQueryRunner<Result<SearchResultValue>>(), waitLatch, waitYieldLatch, notifyLatch); }
@Test public void testMultipleDrops() throws Exception { loadQueryable("test", "3", new Interval("2011-04-04/2011-04-05")); Future future = assertQueryable( QueryGranularity.DAY, "test", new Interval("2011-04-04/2011-04-06"), ImmutableList.<Pair<String, Interval>>of( new Pair<String, Interval>("3", new Interval("2011-04-04/2011-04-05")))); queryNotifyLatch.await(25, TimeUnit.MILLISECONDS); Assert.assertEquals(1, factory.getSegmentReferences().size()); for (ReferenceCountingSegment referenceCountingSegment : factory.getSegmentReferences()) { Assert.assertEquals(1, referenceCountingSegment.getNumReferences()); } queryWaitYieldLatch.countDown(); Assert.assertEquals(1, factory.getAdapters().size()); for (SegmentForTesting segmentForTesting : factory.getAdapters()) { Assert.assertFalse(segmentForTesting.isClosed()); } dropQueryable("test", "3", new Interval("2011-04-04/2011-04-05")); dropQueryable("test", "3", new Interval("2011-04-04/2011-04-05")); for (SegmentForTesting segmentForTesting : factory.getAdapters()) { Assert.assertFalse(segmentForTesting.isClosed()); } queryWaitLatch.countDown(); future.get(); for (SegmentForTesting segmentForTesting : factory.getAdapters()) { Assert.assertTrue(segmentForTesting.isClosed()); } }