@Test public void testBucketingCoverageTransition() throws Exception { assumeTrue(bucketingEnabled); CountDownLatch scanStartedLatch = new CountDownLatch(1); MockThrottler mockThrottler = new MockThrottler(scanStartedLatch, new CountDownLatch(0), 50, 100); throttlers.put(BlobStoreStats.IO_SCHEDULER_JOB_TYPE, mockThrottler); long expiresAtInMs = state.time.milliseconds() + TimeUnit.SECONDS.toMillis(20); state.addPutEntries(1, PUT_RECORD_SIZE, expiresAtInMs); long initialScanTimeInMs = state.time.milliseconds(); BlobStoreStats blobStoreStats = setupBlobStoreStats(1, 0); int expectedThrottleCount = state.referenceIndex.size(); assertTrue("IndexScanner took too long to start", scanStartedLatch.await(5, TimeUnit.SECONDS)); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(initialScanTimeInMs, 0L)); verifyAndGetContainerValidSize(blobStoreStats, initialScanTimeInMs); state.advanceTime(expiresAtInMs - state.time.milliseconds()); CountDownLatch scanHoldLatch = new CountDownLatch(1); scanStartedLatch = new CountDownLatch(1); mockThrottler.holdLatch = scanHoldLatch; mockThrottler.startedLatch = scanStartedLatch; mockThrottler.isThrottlerStarted = false; assertTrue("IndexScanner took too long to start", scanStartedLatch.await(5, TimeUnit.SECONDS)); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(initialScanTimeInMs, 0L)); verifyAndGetContainerValidSize(blobStoreStats, initialScanTimeInMs); assertEquals("Throttle count mismatch from expected value", expectedThrottleCount + 1, mockThrottler.throttleCount.get()); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(0L, 0L)); verifyAndGetContainerValidSize(blobStoreStats, 0L); scanHoldLatch.countDown(); verifyAndGetContainerValidSize(blobStoreStats, state.time.milliseconds()); verifyAndGetLogSegmentValidSize(blobStoreStats, new TimeRange(state.time.milliseconds(), 0L)); expectedThrottleCount = (2 + 3) * expectedThrottleCount; assertEquals("Throttle count mismatch from expected value", expectedThrottleCount, mockThrottler.throttleCount.get()); blobStoreStats.close(); }
@Override public void close() { if (enabled.compareAndSet(true, false)) { if (indexScanner != null) { indexScanner.cancel(); } if (queueProcessor != null) { queueProcessor.cancel(); } } }
BlobStoreStats implements StoreStats, Closeable { @Override public void close() { if (enabled.compareAndSet(true, false)) { if (indexScanner != null) { indexScanner.cancel(); } if (queueProcessor != null) { queueProcessor.cancel(); } } } }
BlobStoreStats implements StoreStats, Closeable { @Override public void close() { if (enabled.compareAndSet(true, false)) { if (indexScanner != null) { indexScanner.cancel(); } if (queueProcessor != null) { queueProcessor.cancel(); } } } BlobStoreStats(String storeId, PersistentIndex index, int bucketCount, long bucketSpanTimeInMs,
      long logSegmentForecastOffsetMs, long queueProcessingPeriodInMs, long waitTimeoutInSecs,
      boolean enableBucketForLogSegmentReports, Time time, ScheduledExecutorService longLiveTaskScheduler,
      ScheduledExecutorService shortLiveTaskScheduler, DiskIOScheduler diskIOScheduler, StoreMetrics metrics); }
BlobStoreStats implements StoreStats, Closeable { @Override public void close() { if (enabled.compareAndSet(true, false)) { if (indexScanner != null) { indexScanner.cancel(); } if (queueProcessor != null) { queueProcessor.cancel(); } } } BlobStoreStats(String storeId, PersistentIndex index, int bucketCount, long bucketSpanTimeInMs,
      long logSegmentForecastOffsetMs, long queueProcessingPeriodInMs, long waitTimeoutInSecs,
      boolean enableBucketForLogSegmentReports, Time time, ScheduledExecutorService longLiveTaskScheduler,
      ScheduledExecutorService shortLiveTaskScheduler, DiskIOScheduler diskIOScheduler, StoreMetrics metrics); @Override Pair<Long, Long> getValidSize(TimeRange timeRange); @Override Map<StatsReportType, StatsSnapshot> getStatsSnapshots(Set<StatsReportType> statsReportTypes,
      long referenceTimeInMs); @Override void close(); }
BlobStoreStats implements StoreStats, Closeable { @Override public void close() { if (enabled.compareAndSet(true, false)) { if (indexScanner != null) { indexScanner.cancel(); } if (queueProcessor != null) { queueProcessor.cancel(); } } } BlobStoreStats(String storeId, PersistentIndex index, int bucketCount, long bucketSpanTimeInMs,
      long logSegmentForecastOffsetMs, long queueProcessingPeriodInMs, long waitTimeoutInSecs,
      boolean enableBucketForLogSegmentReports, Time time, ScheduledExecutorService longLiveTaskScheduler,
      ScheduledExecutorService shortLiveTaskScheduler, DiskIOScheduler diskIOScheduler, StoreMetrics metrics); @Override Pair<Long, Long> getValidSize(TimeRange timeRange); @Override Map<StatsReportType, StatsSnapshot> getStatsSnapshots(Set<StatsReportType> statsReportTypes,
      long referenceTimeInMs); @Override void close();  }