use of io.pravega.segmentstore.server.CacheKey in project pravega by pravega.
the class StreamSegmentReadIndex method removeAllEntries.
/**
* Removes all entries from the cache and the SortedIndex, regardless of their state.
*
* @throws IllegalStateException If the StreamSegmentReadIndex is not closed.
*/
private void removeAllEntries() {
// A bit unusual, but we want to make sure we do not call this while the index is active.
Preconditions.checkState(this.closed, "Cannot call removeAllEntries unless the ReadIndex is closed.");
int count;
synchronized (this.lock) {
this.indexEntries.forEach(entry -> {
if (entry.isDataEntry()) {
CacheKey key = getCacheKey(entry);
this.cache.remove(key);
}
});
count = this.indexEntries.size();
this.indexEntries.clear();
}
log.info("{}: Cleared all cache entries ({}).", this.traceObjectId, count);
}
Aggregations