/** * Writes the oldest data to the storage. */ private void writeOldest() { IAggregatedData<E> oldest = queue.poll(); E data = oldest.getData(); map.remove(getCacheHash(data, data.getTimeStamp().getTime())); elementCount.decrementAndGet(); passToStorageWriter(data); }
/** * {@inheritDoc} */ @Override public Collection<Future<Void>> flush() { Collection<Future<Void>> futures = new ArrayList<>(); IAggregatedData<E> oldest = queue.poll(); while (null != oldest) { E data = oldest.getData(); map.remove(getCacheHash(data, data.getTimeStamp().getTime())); elementCount.decrementAndGet(); Future<Void> future = passToStorageWriter(data); CollectionUtils.addIgnoreNull(futures, future); oldest = queue.poll(); } return futures; }