K - the type of the key stored in Near CacheV - the type of the value stored in Near CacheKS - the type of the key of the underlying NearCacheRecordMapR - the type of the value of the underlying NearCacheRecordMapNCRM - the type of the underlying NearCacheRecordMappublic abstract class AbstractNearCacheRecordStore<K,V,KS,R extends NearCacheRecord,NCRM extends SampleableNearCacheRecordMap<KS,R>> extends Object implements NearCacheRecordStore<K,V>, EvictionListener<KS,R>
NearCacheRecordStore and EvictionListener.| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractNearCacheRecordStore.ReserveForUpdateFunction |
| Modifier and Type | Field and Description |
|---|---|
protected ClassLoader |
classLoader |
protected EvictionChecker |
evictionChecker |
protected boolean |
evictionDisabled |
protected EvictionPolicyEvaluator<KS,R> |
evictionPolicyEvaluator |
protected SamplingEvictionStrategy<KS,R,NCRM> |
evictionStrategy |
protected long |
maxIdleMillis |
protected static long |
MILLI_SECONDS_IN_A_SECOND |
protected NearCacheConfig |
nearCacheConfig |
protected NearCacheStatsImpl |
nearCacheStats |
protected NCRM |
records |
protected static long |
REFERENCE_SIZE
If Unsafe is available, Object array index scale (every index represents a reference)
can be assumed as reference size.
|
protected static AtomicLongFieldUpdater<AbstractNearCacheRecordStore> |
RESERVATION_ID |
protected long |
reservationId |
protected SerializationService |
serializationService |
protected StaleReadDetector |
staleReadDetector |
protected long |
timeToLiveMillis |
NO_LISTENER| Modifier | Constructor and Description |
|---|---|
protected |
AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig,
NearCacheStatsImpl nearCacheStats,
SerializationService serializationService,
ClassLoader classLoader) |
|
AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig,
SerializationService serializationService,
ClassLoader classLoader) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkAvailable() |
void |
clear()
Removes all stored values.
|
protected abstract boolean |
containsRecordKey(K key) |
protected abstract EvictionChecker |
createNearCacheEvictionChecker(EvictionConfig evictionConfig,
NearCacheConfig nearCacheConfig) |
protected abstract NCRM |
createNearCacheRecordMap(NearCacheConfig nearCacheConfig) |
protected V |
dataToValue(Data data) |
void |
destroy()
Clears the record store and destroys it.
|
void |
doEviction()
Does eviction as specified configuration
EvictionConfig
in NearCacheConfig regardless from the max-size policy. |
void |
doEvictionIfRequired()
Does eviction as specified configuration
EvictionConfig
in NearCacheConfig. |
V |
get(K key)
Gets the value associated with the given
key. |
protected abstract long |
getKeyStorageMemoryCost(K key) |
NearCacheStats |
getNearCacheStats()
Get the
NearCacheStats instance to monitor this record store. |
protected abstract R |
getOrCreateToReserve(K key,
Data keyData) |
abstract R |
getRecord(K key)
Gets the record associated with the given
key. |
protected abstract long |
getRecordStorageMemoryCost(R record) |
StaleReadDetector |
getStaleReadDetector() |
protected long |
getTotalStorageMemoryCost(K key,
R record) |
void |
initialize() |
protected boolean |
isAvailable() |
protected boolean |
isRecordExpired(R record) |
void |
onEvict(KS key,
R record,
boolean wasExpired)
Called when an
Evictable entry is evicted. |
protected void |
onExpire(K key,
R record) |
protected void |
onGet(K key,
V value,
R record) |
protected void |
onGetError(K key,
V value,
R record,
Throwable error) |
protected void |
onPut(K key,
V value,
R record,
R oldRecord) |
protected void |
onPutError(K key,
V value,
R record,
R oldRecord,
Throwable error) |
protected void |
onRecordCreate(K key,
Data keyData,
R record) |
protected void |
onRemove(K key,
R record,
boolean removed) |
protected void |
onRemoveError(K key,
R record,
boolean removed,
Throwable error) |
void |
put(K key,
Data keyData,
V value)
Puts (associates) a value with the given
key. |
protected abstract R |
putRecord(K key,
R record) |
protected abstract V |
recordToValue(R record) |
boolean |
remove(K key)
Removes the value associated with the given
key. |
protected abstract R |
removeRecord(K key) |
void |
setStaleReadDetector(StaleReadDetector staleReadDetector) |
int |
size()
Gets the number of stored records.
|
protected Data |
toData(Object obj) |
protected V |
toValue(Object obj) |
V |
tryPublishReserved(K key,
V value,
long reservationId,
boolean deserialize) |
long |
tryReserveForUpdate(K key,
Data keyData) |
protected abstract V |
updateAndGetReserved(K key,
V value,
long reservationId,
boolean deserialize) |
protected abstract void |
updateRecordValue(R record,
V value) |
protected R |
updateReservedRecordInternal(K key,
V value,
R reservedRecord,
long reservationId) |
protected Data |
valueToData(V value) |
protected abstract R |
valueToRecord(V value) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdoExpiration, loadKeys, selectToSave, storeKeysprotected static final AtomicLongFieldUpdater<AbstractNearCacheRecordStore> RESERVATION_ID
protected static final long REFERENCE_SIZE
Otherwise, we assume reference size as integer size that means we assume 32 bit JVM or compressed-references enabled 64 bit JVM by ignoring compressed-references disable mode on 64 bit JVM.
protected static final long MILLI_SECONDS_IN_A_SECOND
protected final long timeToLiveMillis
protected final long maxIdleMillis
protected final NearCacheConfig nearCacheConfig
protected final SerializationService serializationService
protected final ClassLoader classLoader
protected final NearCacheStatsImpl nearCacheStats
protected final boolean evictionDisabled
protected EvictionChecker evictionChecker
protected SamplingEvictionStrategy<KS,R extends NearCacheRecord,NCRM extends SampleableNearCacheRecordMap<KS,R>> evictionStrategy
protected EvictionPolicyEvaluator<KS,R extends NearCacheRecord> evictionPolicyEvaluator
protected NCRM extends SampleableNearCacheRecordMap<KS,R> records
protected volatile StaleReadDetector staleReadDetector
protected volatile long reservationId
public AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig, SerializationService serializationService, ClassLoader classLoader)
protected AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig, NearCacheStatsImpl nearCacheStats, SerializationService serializationService, ClassLoader classLoader)
public void initialize()
initialize in interface InitializingObjectpublic void setStaleReadDetector(StaleReadDetector staleReadDetector)
setStaleReadDetector in interface NearCacheRecordStore<K,V>StaleReadDetectorpublic StaleReadDetector getStaleReadDetector()
getStaleReadDetector in interface NearCacheRecordStore<K,V>StaleReadDetectorpublic abstract R getRecord(K key)
NearCacheRecordStorekey.getRecord in interface NearCacheRecordStore<K,V>key - the key from which to get the associated NearCacheRecord.NearCacheRecord associated with the given key.protected abstract EvictionChecker createNearCacheEvictionChecker(EvictionConfig evictionConfig, NearCacheConfig nearCacheConfig)
protected abstract NCRM createNearCacheRecordMap(NearCacheConfig nearCacheConfig)
protected abstract long getKeyStorageMemoryCost(K key)
protected abstract long getRecordStorageMemoryCost(R record)
protected abstract V updateAndGetReserved(K key, V value, long reservationId, boolean deserialize)
protected abstract boolean containsRecordKey(K key)
protected void checkAvailable()
protected boolean isAvailable()
protected boolean isRecordExpired(R record)
public void onEvict(KS key, R record, boolean wasExpired)
EvictionListenerEvictable entry is evicted.onEvict in interface EvictionListener<KS,R extends NearCacheRecord>key - Accessor of the Evictable entry that is evicted.record - Evictable entry that is evicted.wasExpired - true if the entry was evicted due to expiration, false otherwisepublic V get(K key)
NearCacheRecordStorekey.get in interface NearCacheRecordStore<K,V>key - the key from which to get the associated value.key.public void put(K key, Data keyData, V value)
NearCacheRecordStorekey.put in interface NearCacheRecordStore<K,V>key - the key to which the given value will be associated.keyData - the key as Data to which the given value will be associated.value - the value that will be associated with the key.public boolean remove(K key)
NearCacheRecordStorekey.remove in interface NearCacheRecordStore<K,V>key - the key from which the value will be removed.true if the value was removed, otherwise false.public void clear()
NearCacheRecordStoreclear in interface NearCacheRecordStore<K,V>public void destroy()
NearCacheRecordStoredestroy in interface NearCacheRecordStore<K,V>public NearCacheStats getNearCacheStats()
NearCacheRecordStoreNearCacheStats instance to monitor this record store.getNearCacheStats in interface NearCacheRecordStore<K,V>NearCacheStats instance to monitor this record store.public int size()
NearCacheRecordStoresize in interface NearCacheRecordStore<K,V>public void doEvictionIfRequired()
NearCacheRecordStoreEvictionConfig
in NearCacheConfig.doEvictionIfRequired in interface NearCacheRecordStore<K,V>public void doEviction()
NearCacheRecordStoreEvictionConfig
in NearCacheConfig regardless from the max-size policy.doEviction in interface NearCacheRecordStore<K,V>public long tryReserveForUpdate(K key, Data keyData)
tryReserveForUpdate in interface NearCacheRecordStore<K,V>public V tryPublishReserved(K key, V value, long reservationId, boolean deserialize)
tryPublishReserved in interface NearCacheRecordStore<K,V>Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.