Package org.cache2k.core.eviction
Interface Eviction
-
- All Known Implementing Classes:
AbstractEviction,ClockProPlusEviction,RandomEviction,SegmentedEviction
public interface EvictionInterface to the eviction data structure.- Author:
- Jens Wilke
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidchangeCapacity(long entryCountOrWeight)Change the capacity.voidcheckIntegrity(IntegrityState integrityState)voidclose()Free resources, for example thread pool or queue.booleandrain()Drain eviction queue and do updates in the eviction data structures.voidevictEventually()Evict if needed, checks all segments.voidevictEventuallyBeforeInsert()Evict if needed, checks all segments.voidevictEventuallyBeforeInsertOnSegment(int hashCodeHint)Evict if needed, focused on the segment addressed by the hash code.EvictionMetricsgetMetrics()Get metrics related to the eviction.booleanisWeigherPresent()longremoveAll()Remove all entries from the eviction data structure.<T> TrunLocked(Supplier<T> j)Runs job making sure concurrent evictions operations pause.voidstart()Start concurrent eviction threads.voidstop()Stop concurrent threads that may access the eviction data structures.booleansubmitWithoutTriggeringEviction(Entry e)Submit to eviction for inserting or removing from the replacement list.booleanupdateWeight(Entry e)Updates the weight on the entry and recalculates the total weight if needed.
-
-
-
Method Detail
-
submitWithoutTriggeringEviction
boolean submitWithoutTriggeringEviction(Entry e)
Submit to eviction for inserting or removing from the replacement list. However, eviction should not be triggered (which in turn triggers a hash table update) since the hash segment lock is hold at the moment.
-
updateWeight
boolean updateWeight(Entry e)
Updates the weight on the entry and recalculates the total weight if needed.Expected not to hold the entry lock, which means, that this does not run in sync with the actual update. That is okay as long as it runs after every update.
Since we need to lock the eviction structure, this can happen in a separate thread.
- Returns:
- hint whether eviction should be run. for a bulk operation we want to do eviction once, so not do it within this method
-
evictEventuallyBeforeInsertOnSegment
void evictEventuallyBeforeInsertOnSegment(int hashCodeHint)
Evict if needed, focused on the segment addressed by the hash code. Called before a new entry is inserted (changed from after in v1.4)
-
evictEventuallyBeforeInsert
void evictEventuallyBeforeInsert()
Evict if needed, checks all segments. Called before a new entry is inserted (changed from after in v1.4)
-
evictEventually
void evictEventually()
Evict if needed, checks all segments.
-
removeAll
long removeAll()
Remove all entries from the eviction data structure.- Returns:
- entry count
-
drain
boolean drain()
Drain eviction queue and do updates in the eviction data structures. Does no eviction when size limit is reached.- Returns:
- true, if eviction is needed
-
start
void start()
Start concurrent eviction threads.
-
stop
void stop()
Stop concurrent threads that may access the eviction data structures. Needs to be called before checkIntegrity or accessing the counter values.
-
close
void close()
Free resources, for example thread pool or queue.
-
runLocked
<T> T runLocked(Supplier<T> j)
Runs job making sure concurrent evictions operations pause.
-
checkIntegrity
void checkIntegrity(IntegrityState integrityState)
-
getMetrics
EvictionMetrics getMetrics()
Get metrics related to the eviction. No lock is needed before calling this method. Best efforts are mad to extract consistent statistics and interruption short.
-
isWeigherPresent
boolean isWeigherPresent()
-
changeCapacity
void changeCapacity(long entryCountOrWeight)
Change the capacity. If capacity is reduced, it will evict entries before returning.
-
-