@Override public void run() { Bucket toDelete = updateBuffer(); createSnapshot(toDelete); }
private MetricManager(ManagerConfig settings, Updater<Bucket, Sample> updater) { log.log(LogLevel.CONFIG, "setting up simple metrics gathering." + " reportPeriodSeconds=" + settings.reportPeriodSeconds() + ", pointsToKeepPerMetric=" + settings.pointsToKeepPerMetric()); metricsCollection = new ThreadLocalDirectory<>(updater); final AtomicReference<Bucket> currentSnapshot = new AtomicReference<>(null); executor = new ScheduledThreadPoolExecutor(1); // Fixed rate, not fixed delay, is it is not too important that each // bucket has data for exactly one second, but one should strive for // this.buffer to contain data for as close a period to the report // interval as possible executor.scheduleAtFixedRate(new MetricAggregator(metricsCollection, currentSnapshot, settings), 1, 1, TimeUnit.SECONDS); receiver = new MetricReceiver(metricsCollection, currentSnapshot); }