/** * Flush all active profiles. * * <p>A profile will remain active as long as it continues to receive messages. If a profile * does not receive a message for an extended duration, it may be marked as expired. * * <p>Flushes all active {@link ProfileBuilder} objects that this distributor is responsible for. * * @return The {@link ProfileMeasurement} values; one for each (profile, entity) pair. */ @Override public List<ProfileMeasurement> flush() { LOG.debug("About to flush active profiles"); // cache maintenance needed here to ensure active profiles will expire cacheMaintenance(); List<ProfileMeasurement> measurements = flushCache(activeCache); return measurements; }
/** * Flush all expired profiles. * * <p>Flushes all expired {@link ProfileBuilder}s that this distributor is responsible for. * * <p>If a profile has not received messages for an extended period of time, it will be marked as * expired. When a profile is expired, it can no longer receive new messages. Expired profiles * remain only to give the client a chance to flush them. * * <p>If the client does not flush the expired profiles periodically, any state maintained in the * profile since the last flush may be lost. * * @return The {@link ProfileMeasurement} values; one for each (profile, entity) pair. */ @Override public List<ProfileMeasurement> flushExpired() { LOG.debug("About to flush expired profiles"); // cache maintenance needed here to ensure active profiles will expire cacheMaintenance(); // flush all expired profiles List<ProfileMeasurement> measurements = flushCache(expiredCache); // once the expired profiles have been flushed, they are no longer needed expiredCache.invalidateAll(); return measurements; }