@Before public void setup() { supplier = new AggregatingVersionedSupplier<>( col -> col.stream().max(Comparator.naturalOrder()).orElse(0L), REFRESH_MILLIS); }
private MetricsForStrategy(MetricsManager manager, String strategy, Function<Long, Long> tsToMillis, Clock wallClock, long recomputeMillis) { Map<String, String> tag = ImmutableMap.of(AtlasDbMetricNames.TAG_STRATEGY, strategy); this.manager = manager; enqueuedWrites = registerAccumulating(AtlasDbMetricNames.ENQUEUED_WRITES, tag); entriesRead = registerAccumulating(AtlasDbMetricNames.ENTRIES_READ, tag); tombstonesPut = registerAccumulating(AtlasDbMetricNames.TOMBSTONES_PUT, tag); abortedWritesDeleted = registerAccumulating(AtlasDbMetricNames.ABORTED_WRITES_DELETED, tag); sweepTimestamp = register(AtlasDbMetricNames.SWEEP_TS, new CurrentValueMetric<>(), tag); AggregatingVersionedSupplier<Long> lastSweptTsSupplier = new AggregatingVersionedSupplier<>( TargetedSweepMetrics::minimum, recomputeMillis); lastSweptTs = register(AtlasDbMetricNames.LAST_SWEPT_TS, new AggregatingVersionedMetric<>(lastSweptTsSupplier), tag); Supplier<Long> millisSinceLastSweptTs = new CachedComposedSupplier<>( sweptTs -> estimateMillisSinceTs(sweptTs, wallClock, tsToMillis), lastSweptTs::getVersionedValue, recomputeMillis, wallClock); register(AtlasDbMetricNames.LAG_MILLIS, millisSinceLastSweptTs::get, tag); }
private MetricsForStrategy(MetricsManager manager, String strategy, Function<Long, Long> tsToMillis, Clock wallClock, long recomputeMillis) { Map<String, String> tag = ImmutableMap.of(AtlasDbMetricNames.TAG_STRATEGY, strategy); this.manager = manager; enqueuedWrites = registerAccumulating(AtlasDbMetricNames.ENQUEUED_WRITES, tag); entriesRead = registerAccumulating(AtlasDbMetricNames.ENTRIES_READ, tag); tombstonesPut = registerAccumulating(AtlasDbMetricNames.TOMBSTONES_PUT, tag); abortedWritesDeleted = registerAccumulating(AtlasDbMetricNames.ABORTED_WRITES_DELETED, tag); sweepTimestamp = register(AtlasDbMetricNames.SWEEP_TS, new CurrentValueMetric<>(), tag); AggregatingVersionedSupplier<Long> lastSweptTsSupplier = new AggregatingVersionedSupplier<>( TargetedSweepMetrics::minimum, recomputeMillis); lastSweptTs = register(AtlasDbMetricNames.LAST_SWEPT_TS, new AggregatingVersionedMetric<>(lastSweptTsSupplier), tag); Supplier<Long> millisSinceLastSweptTs = new CachedComposedSupplier<>( sweptTs -> estimateMillisSinceTs(sweptTs, wallClock, tsToMillis), lastSweptTs::getVersionedValue, recomputeMillis, wallClock); register(AtlasDbMetricNames.LAG_MILLIS, millisSinceLastSweptTs::get, tag); }