@Test public void testRunAtWithOverlappingOperations() { final int metricsDelaySecs = 0; offHeapChunkManagerTask = new OffHeapChunkManagerTask(chunkManager, metricsDelaySecs, 4 * 3600); assertTrue(chunkManager.getChunkMap().isEmpty()); offHeapChunkManagerTask.runAt(Instant.ofEpochSecond(startTimeSecs)); assertTrue(chunkManager.getChunkMap().isEmpty()); assertEquals(0, getReadOnlyChunkCount(chunkManager)); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimeSecs + 1, testValue)); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimePlusTwoHoursSecs, testValue)); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimePlusFourHoursSecs, testValue)); assertEquals(3, chunkManager.getChunkMap().size()); offHeapChunkManagerTask.runAt(Instant.ofEpochSecond(startTimeSecs)); assertEquals(3, chunkManager.getChunkMap().size()); assertEquals(0, getReadOnlyChunkCount(chunkManager)); offHeapChunkManagerTask.runAt(Instant.ofEpochSecond(startTimePlusTwoHoursSecs)); assertEquals(3, chunkManager.getChunkMap().size()); assertEquals(1, getReadOnlyChunkCount(chunkManager)); offHeapChunkManagerTask.runAt(Instant.ofEpochSecond(startTimePlusFourHoursSecs)); assertEquals(3, chunkManager.getChunkMap().size()); assertEquals(2, getReadOnlyChunkCount(chunkManager)); offHeapChunkManagerTask.runAt(Instant.ofEpochSecond(startTimePlusSixHoursSecs)); assertEquals(2, chunkManager.getChunkMap().size()); assertEquals(2, getReadOnlyChunkCount(chunkManager)); offHeapChunkManagerTask.runAt(Instant.ofEpochSecond(startTimePlusSixHoursSecs + 10 * 60)); assertEquals(2, chunkManager.getChunkMap().size()); assertEquals(2, getReadOnlyChunkCount(chunkManager)); offHeapChunkManagerTask.runAt(Instant.ofEpochSecond(startTimePlusEightHoursSecs)); assertEquals(1, chunkManager.getChunkMap().size()); assertEquals(1, getReadOnlyChunkCount(chunkManager)); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimeSecs, testValue)); assertEquals(2, chunkManager.getChunkMap().size()); assertEquals(1, getReadOnlyChunkCount(chunkManager)); offHeapChunkManagerTask.runAt(Instant.ofEpochSecond(startTimePlusEightHoursSecs + 2 * 3600)); assertTrue(chunkManager.getChunkMap().isEmpty()); assertEquals(0, getReadOnlyChunkCount(chunkManager)); }
@VisibleForTesting void runAt(Instant instant) { LOG.info("Starting offHeapChunkManagerTask."); deleteStaleData(instant); detectReadOnlyChunks(instant); LOG.info("Finished offHeapChunkManagerTask."); }
OffHeapChunkManagerTask implements Runnable { @VisibleForTesting void runAt(Instant instant) { LOG.info("Starting offHeapChunkManagerTask."); deleteStaleData(instant); detectReadOnlyChunks(instant); LOG.info("Finished offHeapChunkManagerTask."); } }
OffHeapChunkManagerTask implements Runnable { @VisibleForTesting void runAt(Instant instant) { LOG.info("Starting offHeapChunkManagerTask."); deleteStaleData(instant); detectReadOnlyChunks(instant); LOG.info("Finished offHeapChunkManagerTask."); } OffHeapChunkManagerTask(ChunkManager chunkManager);  OffHeapChunkManagerTask(ChunkManager chunkManager,
                                 int metricsDelaySecs,
                                 int staleDataDelaySecs); }
OffHeapChunkManagerTask implements Runnable { @VisibleForTesting void runAt(Instant instant) { LOG.info("Starting offHeapChunkManagerTask."); deleteStaleData(instant); detectReadOnlyChunks(instant); LOG.info("Finished offHeapChunkManagerTask."); } OffHeapChunkManagerTask(ChunkManager chunkManager);  OffHeapChunkManagerTask(ChunkManager chunkManager,
                                 int metricsDelaySecs,
                                 int staleDataDelaySecs); @Override void run(); }
OffHeapChunkManagerTask implements Runnable { @VisibleForTesting void runAt(Instant instant) { LOG.info("Starting offHeapChunkManagerTask."); deleteStaleData(instant); detectReadOnlyChunks(instant); LOG.info("Finished offHeapChunkManagerTask."); } OffHeapChunkManagerTask(ChunkManager chunkManager);  OffHeapChunkManagerTask(ChunkManager chunkManager,
                                 int metricsDelaySecs,
                                 int staleDataDelaySecs); @Override void run(); static final int DEFAULT_METRICS_DELAY_SECS; static final int DEFAULT_STALE_DATA_DELAY_SECS; }