Search in sources :

Example 6 with CacheKey

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);
}
Also used : CacheKey(io.pravega.segmentstore.server.CacheKey)

Aggregations

CacheKey (io.pravega.segmentstore.server.CacheKey)6 lombok.val (lombok.val)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Cleanup (lombok.Cleanup)2 Test (org.junit.Test)2 Futures (io.pravega.common.concurrent.Futures)1 StreamHelpers (io.pravega.common.io.StreamHelpers)1 ReadResult (io.pravega.segmentstore.contracts.ReadResult)1 ReadResultEntry (io.pravega.segmentstore.contracts.ReadResultEntry)1 ReadResultEntryContents (io.pravega.segmentstore.contracts.ReadResultEntryContents)1 ReadResultEntryType (io.pravega.segmentstore.contracts.ReadResultEntryType)1 StreamSegmentNotExistsException (io.pravega.segmentstore.contracts.StreamSegmentNotExistsException)1 StreamSegmentSealedException (io.pravega.segmentstore.contracts.StreamSegmentSealedException)1 StreamSegmentTruncatedException (io.pravega.segmentstore.contracts.StreamSegmentTruncatedException)1