/** * Flushes all expired profiles. * * <p>If a profile has not received a message for an extended period of time then it is * marked as expired. Periodically we need to flush these expired profiles to ensure * that their state is not lost. */ protected void flushExpired() { List<ProfileMeasurement> measurements = null; try { // flush the expired profiles synchronized (messageDistributor) { measurements = messageDistributor.flushExpired(); emitMeasurements(measurements); } } catch(Throwable t) { // need to catch the exception, otherwise subsequent executions would be suppressed. // see java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate LOG.error("Failed to flush expired profiles", t); } LOG.debug("Flushed expired profiles and found {} measurement(s).", CollectionUtils.size(measurements)); }