@Test public void testDetectReadOnlyChunksWithDefaultValues() { assertTrue(chunkManager.getChunkMap().isEmpty()); assertEquals(0, detectReadOnlyChunks(startTimeSecs)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + 1)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + 3600 * 2)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + 3600 * 3)); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimeSecs + 1, testValue)); assertEquals(1, chunkManager.getChunkMap().size()); assertEquals(0, detectReadOnlyChunks(startTimeSecs)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS - 1)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS + 1)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS + DEFAULT_METRICS_DELAY_SECS - 1)); assertEquals(1, detectReadOnlyChunks(startTimeSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS + DEFAULT_METRICS_DELAY_SECS)); assertEquals(1, chunkManager.getChunkMap().size()); assertEquals(1, getReadOnlyChunkCount(chunkManager)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS + DEFAULT_METRICS_DELAY_SECS + 1)); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimePlusTwoHoursSecs + 1, testValue)); assertEquals(2, chunkManager.getChunkMap().size()); assertEquals(0, detectReadOnlyChunks(startTimeSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS + DEFAULT_METRICS_DELAY_SECS)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS + DEFAULT_METRICS_DELAY_SECS + 3600)); assertEquals(1, detectReadOnlyChunks(startTimeSecs + 2 * DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS + DEFAULT_METRICS_DELAY_SECS)); assertEquals(2, getReadOnlyChunkCount(chunkManager)); assertEquals(2, chunkManager.getChunkMap().size()); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimePlusFourHoursSecs + 1, testValue)); assertEquals(3, chunkManager.getChunkMap().size()); assertEquals(0, detectReadOnlyChunks(startTimeSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS + DEFAULT_METRICS_DELAY_SECS)); assertEquals(0, detectReadOnlyChunks(startTimePlusTwoHoursSecs + DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS + DEFAULT_METRICS_DELAY_SECS)); assertEquals(0, detectReadOnlyChunks(startTimeSecs + (2 * DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS) + DEFAULT_METRICS_DELAY_SECS)); assertEquals(1, detectReadOnlyChunks(startTimeSecs + (3 * DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS) + DEFAULT_METRICS_DELAY_SECS)); assertEquals(3, getReadOnlyChunkCount(chunkManager)); assertEquals(3, chunkManager.getChunkMap().size()); assertEquals(0, detectReadOnlyChunks(startTimeSecs + (3 * DEFAULT_CHUNK_READ_ONLY_THRESHOLD_SECS) + DEFAULT_METRICS_DELAY_SECS)); }
@VisibleForTesting int detectReadOnlyChunks(Instant startInstant) { int secondsToSubtract = this.metricsDelay; final long offHeapCutoffSecs = startInstant.minusSeconds(secondsToSubtract).getEpochSecond(); return detectChunksPastCutOff(offHeapCutoffSecs); }
OffHeapChunkManagerTask implements Runnable { @VisibleForTesting int detectReadOnlyChunks(Instant startInstant) { int secondsToSubtract = this.metricsDelay; final long offHeapCutoffSecs = startInstant.minusSeconds(secondsToSubtract).getEpochSecond(); return detectChunksPastCutOff(offHeapCutoffSecs); } }
OffHeapChunkManagerTask implements Runnable { @VisibleForTesting int detectReadOnlyChunks(Instant startInstant) { int secondsToSubtract = this.metricsDelay; final long offHeapCutoffSecs = startInstant.minusSeconds(secondsToSubtract).getEpochSecond(); return detectChunksPastCutOff(offHeapCutoffSecs); } OffHeapChunkManagerTask(ChunkManager chunkManager);  OffHeapChunkManagerTask(ChunkManager chunkManager,
                                 int metricsDelaySecs,
                                 int staleDataDelaySecs); }
OffHeapChunkManagerTask implements Runnable { @VisibleForTesting int detectReadOnlyChunks(Instant startInstant) { int secondsToSubtract = this.metricsDelay; final long offHeapCutoffSecs = startInstant.minusSeconds(secondsToSubtract).getEpochSecond(); return detectChunksPastCutOff(offHeapCutoffSecs); } OffHeapChunkManagerTask(ChunkManager chunkManager);  OffHeapChunkManagerTask(ChunkManager chunkManager,
                                 int metricsDelaySecs,
                                 int staleDataDelaySecs); @Override void run(); }
OffHeapChunkManagerTask implements Runnable { @VisibleForTesting int detectReadOnlyChunks(Instant startInstant) { int secondsToSubtract = this.metricsDelay; final long offHeapCutoffSecs = startInstant.minusSeconds(secondsToSubtract).getEpochSecond(); return detectChunksPastCutOff(offHeapCutoffSecs); } 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; }