@Test public void testDeleteStaleData() { assertTrue(chunkManager.getChunkMap().isEmpty()); assertEquals(0, deleteStaleData(startTimeSecs)); assertEquals(0, deleteStaleData(startTimeSecs + 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 2)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 3)); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimeSecs + 1, testValue)); final List<TimeSeries> timeSeries = queryChunkManager(startTimeSecs, startTimeSecs + 3600 * 3); assertEquals(1, timeSeries.size()); assertEquals(1, chunkManager.getChunkMap().size()); assertEquals(0, deleteStaleData(startTimeSecs)); assertEquals(0, deleteStaleData(startTimeSecs + 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 - 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 + 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 2 - 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 2)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 3)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 4)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 5)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 6)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 7)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 8 - 1)); assertEquals(1, deleteStaleData(startTimeSecs + 3600 * 8)); assertTrue(chunkManager.getChunkMap().isEmpty()); assertEquals(0, deleteStaleData(startTimeSecs)); assertEquals(0, deleteStaleData(startTimeSecs + 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 2)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 8)); final List<TimeSeries> timeSeries2 = queryChunkManager(startTimeSecs, startTimeSecs + 3600 * 3); assertTrue(timeSeries2.isEmpty()); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimeSecs + 1, testValue)); chunkManager.addMetric(MetricUtils.makeMetricString( testMetricName, inputTagString1, startTimePlusTwoHoursSecs + 1, testValue)); assertEquals(2, chunkManager.getChunkMap().size()); final List<TimeSeries> timeSeries3 = queryChunkManager(startTimeSecs, startTimeSecs + 3600 * 3); assertEquals(1, timeSeries3.size()); assertEquals(2, chunkManager.getChunkMap().size()); assertEquals(0, deleteStaleData(startTimeSecs)); assertEquals(0, deleteStaleData(startTimeSecs + 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 - 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 + 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 2 - 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 2)); assertEquals(1, deleteStaleData(startTimeSecs + 3600 * 8)); assertEquals(1, chunkManager.getChunkMap().size()); chunkManager.getChunkMap() .forEach((k, v) -> assertEquals(startTimePlusTwoHoursSecs, k.longValue())); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 2 + 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 3 - 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 3)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 3 + 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 4 - 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 4 + 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 6 - 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 6)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 8 - 1)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 8)); assertEquals(0, deleteStaleData(startTimeSecs + 3600 * 10 - 1)); assertEquals(1, deleteStaleData(startTimeSecs + 3600 * 10)); assertTrue(chunkManager.getChunkMap().isEmpty()); }
int deleteStaleData(Instant startInstant) { final long staleCutoffSecs = startInstant.minusSeconds(this.staleDataDelaySecs).getEpochSecond(); return deleteStaleChunks(staleCutoffSecs); }
OffHeapChunkManagerTask implements Runnable { int deleteStaleData(Instant startInstant) { final long staleCutoffSecs = startInstant.minusSeconds(this.staleDataDelaySecs).getEpochSecond(); return deleteStaleChunks(staleCutoffSecs); } }
OffHeapChunkManagerTask implements Runnable { int deleteStaleData(Instant startInstant) { final long staleCutoffSecs = startInstant.minusSeconds(this.staleDataDelaySecs).getEpochSecond(); return deleteStaleChunks(staleCutoffSecs); } OffHeapChunkManagerTask(ChunkManager chunkManager);  OffHeapChunkManagerTask(ChunkManager chunkManager,
                                 int metricsDelaySecs,
                                 int staleDataDelaySecs); }
OffHeapChunkManagerTask implements Runnable { int deleteStaleData(Instant startInstant) { final long staleCutoffSecs = startInstant.minusSeconds(this.staleDataDelaySecs).getEpochSecond(); return deleteStaleChunks(staleCutoffSecs); } OffHeapChunkManagerTask(ChunkManager chunkManager);  OffHeapChunkManagerTask(ChunkManager chunkManager,
                                 int metricsDelaySecs,
                                 int staleDataDelaySecs); @Override void run(); }
OffHeapChunkManagerTask implements Runnable { int deleteStaleData(Instant startInstant) { final long staleCutoffSecs = startInstant.minusSeconds(this.staleDataDelaySecs).getEpochSecond(); return deleteStaleChunks(staleCutoffSecs); } 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; }