public abstract class AbstractCacheRecordStore<R extends CacheRecord,CRM extends SampleableCacheRecordMap<Data,R>> extends Object implements ICacheRecordStore, EvictionListener<Data,R>
NO_LISTENER
Constructor and Description |
---|
AbstractCacheRecordStore(String cacheNameWithPrefix,
int partitionId,
NodeEngine nodeEngine,
AbstractCacheService cacheService) |
Modifier and Type | Method and Description |
---|---|
R |
accessRecord(Data key,
R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now) |
protected void |
accumulateOrSendExpiredKeysToBackup(Data key,
R record) |
void |
clear()
clears all internal data without publishing any events
|
void |
close(boolean onShutdown)
Close is equivalent to below operations in the given order:
close resources.
unregister all listeners.
|
protected void |
closeListeners() |
protected boolean |
compare(Object v1,
Object v2) |
boolean |
contains(Data key)
Determines if this store contains an entry for the specified key.
|
protected abstract CacheEntryProcessorEntry |
createCacheEntryProcessorEntry(Data key,
R record,
long now,
int completionId) |
protected EvictionChecker |
createCacheEvictionChecker(int size,
EvictionConfig.MaxSizePolicy maxSizePolicy)
Creates an instance for checking if the maximum cache size has been reached.
|
protected EvictionPolicyEvaluator<Data,R> |
createEvictionPolicyEvaluator(EvictionConfig evictionConfig) |
protected SamplingEvictionStrategy<Data,R,CRM> |
createEvictionStrategy(EvictionConfig cacheEvictionConfig) |
protected R |
createRecord(Data keyData,
Object value,
long expirationTime,
int completionId) |
protected R |
createRecord(Data key,
Object value,
long expiryTime,
long now,
boolean disableWriteThrough,
int completionId,
String origin) |
protected R |
createRecord(long expiryTime) |
protected R |
createRecord(Object value,
long expiryTime) |
protected abstract R |
createRecord(Object value,
long creationTime,
long expiryTime) |
protected abstract CRM |
createRecordCacheMap() |
protected R |
createRecordWithExpiry(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now,
boolean disableWriteThrough,
int completionId) |
protected R |
createRecordWithExpiry(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now,
boolean disableWriteThrough,
int completionId,
String origin) |
protected R |
createRecordWithExpiry(Data key,
Object value,
long expiryTime,
long now,
boolean disableWriteThrough,
int completionId) |
protected R |
createRecordWithExpiry(Data key,
Object value,
long expiryTime,
long now,
boolean disableWriteThrough,
int completionId,
String origin) |
protected abstract Object |
dataToValue(Data data) |
protected void |
deleteAllCacheEntry(Set<Data> keys) |
protected void |
deleteCacheEntry(Data key) |
protected void |
deleteCacheEntry(Data key,
CallerProvenance provenance) |
protected boolean |
deleteRecord(Data key,
int completionId) |
protected boolean |
deleteRecord(Data key,
int completionId,
String source) |
protected boolean |
deleteRecord(Data key,
int completionId,
String source,
String origin) |
void |
destroy()
Destroy is equivalent to below operations in the given order:
clear all.
close resources.
unregister all listeners.
|
protected void |
destroyEventJournal() |
void |
destroyInternals()
Like
ICacheRecordStore.destroy() but does not touch state on other services
like event journal service. |
protected R |
doPutRecord(Data key,
R record,
String source,
boolean updateJournal) |
protected R |
doRemoveRecord(Data key,
String source) |
void |
evictExpiredEntries(int expirationPercentage)
Do expiration operations.
|
protected boolean |
evictIfExpired(Data key,
R record,
long now) |
boolean |
evictIfRequired()
Evict cache record store if eviction is required.
|
protected Object |
extractExpiryPolicyOfRecord(CacheRecord record) |
CacheEntryIterationResult |
fetchEntries(int tableIndex,
int size)
Starting from the provided table index, a set of entries are returned with a maximum size of
size |
CacheKeyIterationResult |
fetchKeys(int tableIndex,
int size)
Starting from the provided table index, a set of keys are returned with a maximum size of
size |
protected void |
forceRemoveRecord(Data key) |
Object |
get(Data key,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Gets the value to which the specified key is mapped,
or
null if this cache contains no mapping for the key. |
MapEntries |
getAll(Set<Data> keySet,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Gets a collection of entries from the store, returning them as
Map of the values associated with the set of keys requested. |
Object |
getAndPut(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
int completionId)
Associates the specified value with the specified key in this cache,
returning an existing value if one existed.
|
Object |
getAndRemove(Data key,
String source,
int completionId)
Atomically removes the entry for a key only if it is currently mapped to some
value.
|
Object |
getAndRemove(Data key,
String source,
int completionId,
String origin) |
Object |
getAndReplace(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
int completionId)
Atomically replaces the value for a given key if and only if there is a
value currently mapped by the key.
|
CacheStatisticsImpl |
getCacheStats()
Gets the Cache statistics associated with this
CacheService . |
CacheConfig |
getConfig()
Gets the configuration of the cache that this store belongs to.
|
InvalidationQueue<ExpiredKey> |
getExpiredKeysQueue() |
protected javax.cache.expiry.ExpiryPolicy |
getExpiryPolicy(CacheRecord record,
javax.cache.expiry.ExpiryPolicy expiryPolicy) |
Object |
getExpiryPolicy(Data key) |
String |
getName()
Gets the name of the distributed object name of the cache.
|
ObjectNamespace |
getObjectNamespace()
Returns
ObjectNamespace associated with this record store. |
int |
getPartitionId() |
Map<Data,CacheRecord> |
getReadOnlyRecords()
Returns a readonly map of the internal key value store.
|
CacheRecord |
getRecord(Data key)
Gets internal record of the store by key.
|
protected ValueComparator |
getValueComparatorOf(InMemoryFormat inMemoryFormat) |
void |
init()
Initializes record store.
|
protected void |
initExpirationIterator() |
void |
instrument(NodeEngine nodeEngine) |
protected void |
invalidateEntry(Data key) |
protected void |
invalidateEntry(Data key,
String source) |
Object |
invoke(Data key,
javax.cache.processor.EntryProcessor entryProcessor,
Object[] arguments,
int completionId)
Invokes an
EntryProcessor against the Cache.Entry specified by
the provided key. |
protected boolean |
isEventsEnabled() |
protected boolean |
isEvictionEnabled() |
boolean |
isExpirable() |
protected boolean |
isInvalidationEnabled() |
protected boolean |
isReadThrough() |
protected boolean |
isStatisticsEnabled() |
boolean |
isWanReplicationEnabled()
Determines whether wan replication is enabled or not for this record store.
|
protected boolean |
isWriteThrough() |
Set<Data> |
loadAll(Set<Data> keys,
boolean replaceExistingValues)
Synchronously loads the specified entries into the cache using the
configured
CacheLoader for the given keys. |
protected Map<Data,Object> |
loadAllCacheEntry(Set<Data> keys) |
protected void |
markExpirable(long expiryTime)
This method marks current replica as expirable and also starts expiration task if necessary.
|
CacheRecord |
merge(CacheEntryView<Data,Data> cacheEntryView,
CacheMergePolicy mergePolicy,
String caller,
String origin,
int completionId,
CallerProvenance callerProvenance)
Merges the given
CacheEntryView via the given CacheMergePolicy . |
CacheRecord |
merge(SplitBrainMergeTypes.CacheMergeTypes mergingEntry,
SplitBrainMergePolicy<Data,SplitBrainMergeTypes.CacheMergeTypes> mergePolicy,
CallerProvenance callerProvenance)
Merges the given
SplitBrainMergeTypes.CacheMergeTypes via the given SplitBrainMergePolicy . |
protected void |
onCreateRecordError(Data key,
Object value,
long expiryTime,
long now,
boolean disableWriteThrough,
int completionId,
String origin,
R record,
Throwable error) |
protected void |
onDeleteRecord(Data key,
R record,
boolean deleted) |
protected void |
onDestroy() |
void |
onEvict(Data key,
R record,
boolean wasExpired)
Called when an
Evictable entry is evicted. |
protected void |
onGet(Data key,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
Object value,
R record) |
protected void |
onGetError(Data key,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
Object value,
R record,
Throwable error) |
protected void |
onProcessExpiredEntry(Data key,
R record,
long expiryTime,
long now,
String source,
String origin) |
protected void |
onPut(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
boolean getValue,
boolean disableWriteThrough,
R record,
Object oldValue,
boolean isExpired,
boolean isNewPut,
boolean isSaveSucceed) |
protected void |
onPutError(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
boolean getValue,
boolean disableWriteThrough,
R record,
Object oldValue,
boolean wouldBeNewPut,
Throwable error) |
protected void |
onPutIfAbsent(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
boolean disableWriteThrough,
R record,
boolean isExpired,
boolean isSaveSucceed) |
protected void |
onPutIfAbsentError(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
boolean disableWriteThrough,
R record,
Throwable error) |
protected long |
onRecordAccess(Data key,
R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now) |
protected void |
onRemove(Data key,
Object value,
String source,
boolean getValue,
R record,
boolean removed) |
protected void |
onRemoveError(Data key,
Object value,
String source,
boolean getValue,
R record,
boolean removed,
Throwable error) |
protected void |
onReplace(Data key,
Object oldValue,
Object newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
boolean getValue,
R record,
boolean isExpired,
boolean replaced) |
protected void |
onReplaceError(Data key,
Object oldValue,
Object newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
boolean getValue,
R record,
boolean isExpired,
boolean replaced,
Throwable error) |
protected void |
onUpdateExpiryPolicy(Data key,
R record,
Data oldDataExpiryPolicy) |
protected void |
onUpdateExpiryPolicyError(Data key,
R record,
Data oldDataExpiryPolicy) |
protected void |
onUpdateRecord(Data key,
R record,
Object value,
Data oldDataValue) |
protected void |
onUpdateRecordError(Data key,
R record,
Object value,
Data newDataValue,
Data oldDataValue,
Throwable error) |
protected boolean |
processExpiredEntry(Data key,
R record,
long now) |
protected R |
processExpiredEntry(Data key,
R record,
long expiryTime,
long now,
String source) |
protected R |
processExpiredEntry(Data key,
R record,
long expiryTime,
long now,
String source,
String origin) |
protected boolean |
processExpiredEntry(Data key,
R record,
long now,
String source) |
protected boolean |
processExpiredEntry(Data key,
R record,
long now,
String source,
String origin) |
protected void |
publishBatchedEvents(String cacheName,
CacheEventType cacheEventType,
int orderKey) |
protected void |
publishEvent(CacheEventContext cacheEventContext) |
protected Object |
put(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
boolean getValue,
boolean disableWriteThrough,
int completionId) |
protected Object |
put(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
boolean getValue,
int completionId) |
R |
put(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
int completionId)
Associates the specified value with the specified key in this cache,
returning an existing value if one existed.
|
protected boolean |
putIfAbsent(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
boolean disableWriteThrough,
int completionId) |
boolean |
putIfAbsent(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
int completionId)
Removes the mapping for a key from this cache if it is present.
|
void |
putRecord(Data key,
CacheRecord record,
boolean updateJournal)
Associates the specified record with the specified key.
|
Object |
readThroughCache(Data key) |
R |
readThroughRecord(Data key,
long now) |
protected abstract Data |
recordToData(R record) |
protected abstract Object |
recordToValue(R record) |
boolean |
remove(Data key,
Object value,
String source,
String origin,
int completionId)
Atomically removes the mapping for a key only if currently mapped to the
given value.
|
boolean |
remove(Data key,
String source,
String origin,
int completionId) |
boolean |
remove(Data key,
String source,
String origin,
int completionId,
CallerProvenance provenance)
Removes the mapping for a key from this cache if it is present.
|
void |
removeAll(Set<Data> keys,
int completionId)
records of keys will be deleted one by one and will publish a REMOVE event
for each key.
|
CacheRecord |
removeRecord(Data key)
Removes the record for a key.
|
boolean |
replace(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
int completionId)
Atomically replaces the entry for a key only if currently mapped to some
value.
|
boolean |
replace(Data key,
Object oldValue,
Object newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String source,
int completionId)
Atomically replaces the entry for a key only if currently mapped to a
given value.
|
void |
reset()
Resets the record store to it's initial state.
|
void |
sampleAndForceRemoveEntries(int entryCountToRemove) |
boolean |
setExpiryPolicy(Collection<Data> keys,
Object expiryPolicy,
String source)
Sets expiry policy for the records with given keys if and only if there is a
value currently mapped by the key
|
int |
size()
Calculates the entry size of this store which reflects the partition size of the cache.
|
protected Data |
toData(Object obj) |
Data |
toEventData(Object obj) |
protected abstract Data |
toHeapData(Object obj) |
protected Object |
toStorageValue(Object obj) |
protected Object |
toValue(Object obj) |
protected long |
updateAccessDuration(Data key,
R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now) |
protected void |
updateExpiryPolicyOfRecord(Data key,
R record,
Object expiryPolicy) |
protected void |
updateGetAndPutStat(boolean isPutSucceed,
boolean getValue,
boolean oldValueNull,
long start) |
protected void |
updateRecord(Data key,
CacheRecord record,
long expiryTime,
long now,
String origin) |
protected void |
updateRecord(Data key,
R record,
Object value,
long expiryTime,
long now,
boolean disableWriteThrough,
int completionId,
String source,
String origin) |
protected void |
updateRecordValue(R record,
Object recordValue) |
protected void |
updateRecordWithExpiry(Data key,
CacheRecord record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now,
String source) |
protected boolean |
updateRecordWithExpiry(Data key,
Object value,
R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now,
boolean disableWriteThrough,
int completionId) |
protected boolean |
updateRecordWithExpiry(Data key,
Object value,
R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now,
boolean disableWriteThrough,
int completionId,
String source) |
protected boolean |
updateRecordWithExpiry(Data key,
Object value,
R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now,
boolean disableWriteThrough,
int completionId,
String source,
String origin) |
protected boolean |
updateRecordWithExpiry(Data key,
Object value,
R record,
long expiryTime,
long now,
boolean disableWriteThrough,
int completionId) |
protected boolean |
updateRecordWithExpiry(Data key,
Object value,
R record,
long expiryTime,
long now,
boolean disableWriteThrough,
int completionId,
String source) |
protected boolean |
updateRecordWithExpiry(Data key,
Object value,
R record,
long expiryTime,
long now,
boolean disableWriteThrough,
int completionId,
String source,
String origin) |
protected void |
updateReplaceStat(boolean result,
boolean isHit,
long start) |
protected abstract Data |
valueToData(Object value) |
void |
writeThroughCache(Data key,
Object value) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
disposeDeferredBlocks
public static final String SOURCE_NOT_AVAILABLE
protected static final int DEFAULT_INITIAL_CAPACITY
protected final int partitionId
protected final int partitionCount
protected final boolean wanReplicationEnabled
protected final boolean persistWanReplicatedData
protected final boolean disablePerEntryInvalidationEvents
protected final String name
protected final NodeEngine nodeEngine
protected final CacheConfig cacheConfig
protected final SerializationService ss
protected final EvictionConfig evictionConfig
protected final ValueComparator valueComparator
protected final EvictionChecker evictionChecker
protected final ObjectNamespace objectNamespace
protected final AbstractCacheService cacheService
protected final CacheRecordFactory cacheRecordFactory
protected final EventJournalConfig eventJournalConfig
protected final ClearExpiredRecordsTask clearExpiredRecordsTask
protected final SamplingEvictionStrategy<Data,R extends CacheRecord,CRM extends SampleableCacheRecordMap<Data,R>> evictionStrategy
protected final EvictionPolicyEvaluator<Data,R extends CacheRecord> evictionPolicyEvaluator
protected final Map<CacheEventType,Set<CacheEventData>> batchEvent
protected boolean primary
protected boolean eventsEnabled
protected boolean eventsBatchingEnabled
protected CRM extends SampleableCacheRecordMap<Data,R> records
protected javax.cache.integration.CacheLoader cacheLoader
protected javax.cache.integration.CacheWriter cacheWriter
protected CacheContext cacheContext
protected CacheStatisticsImpl statistics
protected javax.cache.expiry.ExpiryPolicy defaultExpiryPolicy
protected Iterator<Map.Entry<Data,R extends CacheRecord>> expirationIterator
protected InvalidationQueue<ExpiredKey> expiredKeys
protected boolean hasEntryWithExpiration
public AbstractCacheRecordStore(String cacheNameWithPrefix, int partitionId, NodeEngine nodeEngine, AbstractCacheService cacheService)
protected ValueComparator getValueComparatorOf(InMemoryFormat inMemoryFormat)
public void instrument(NodeEngine nodeEngine)
public void init()
ICacheRecordStore
init
in interface ICacheRecordStore
protected boolean isReadThrough()
protected boolean isWriteThrough()
protected boolean isStatisticsEnabled()
protected abstract CRM createRecordCacheMap()
protected abstract CacheEntryProcessorEntry createCacheEntryProcessorEntry(Data key, R record, long now, int completionId)
protected EvictionChecker createCacheEvictionChecker(int size, EvictionConfig.MaxSizePolicy maxSizePolicy)
EvictionConfig.MaxSizePolicy.ENTRY_COUNT
policy. Returns null if other maxSizePolicy
is used.size
- the maximum number of entriesmaxSizePolicy
- the way in which the size is interpreted, only the EvictionConfig.MaxSizePolicy.ENTRY_COUNT
policy is
supported.maxSizePolicy
is not EvictionConfig.MaxSizePolicy.ENTRY_COUNT
IllegalArgumentException
- if the maxSizePolicy
is nullprotected EvictionPolicyEvaluator<Data,R> createEvictionPolicyEvaluator(EvictionConfig evictionConfig)
protected SamplingEvictionStrategy<Data,R,CRM> createEvictionStrategy(EvictionConfig cacheEvictionConfig)
protected boolean isEvictionEnabled()
protected boolean isEventsEnabled()
protected boolean isInvalidationEnabled()
public boolean evictIfRequired()
ICacheRecordStore
Eviction logic is handled as specified EvictionPolicy
in CacheConfig
for this record store
evictIfRequired
in interface ICacheRecordStore
public void sampleAndForceRemoveEntries(int entryCountToRemove)
sampleAndForceRemoveEntries
in interface ICacheRecordStore
protected void forceRemoveRecord(Data key)
protected javax.cache.expiry.ExpiryPolicy getExpiryPolicy(CacheRecord record, javax.cache.expiry.ExpiryPolicy expiryPolicy)
protected boolean processExpiredEntry(Data key, R record, long now, String source)
protected boolean processExpiredEntry(Data key, R record, long now, String source, String origin)
protected R processExpiredEntry(Data key, R record, long expiryTime, long now, String source)
protected R processExpiredEntry(Data key, R record, long expiryTime, long now, String source, String origin)
protected void onProcessExpiredEntry(Data key, R record, long expiryTime, long now, String source, String origin)
protected void accumulateOrSendExpiredKeysToBackup(Data key, R record)
public boolean isExpirable()
isExpirable
in interface ICacheRecordStore
public R accessRecord(Data key, R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now)
public void onEvict(Data key, R record, boolean wasExpired)
EvictionListener
Evictable
entry is evicted.onEvict
in interface EvictionListener<Data,R extends CacheRecord>
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
otherwiseprotected void invalidateEntry(Data key)
protected void updateGetAndPutStat(boolean isPutSucceed, boolean getValue, boolean oldValueNull, long start)
protected long updateAccessDuration(Data key, R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now)
protected long onRecordAccess(Data key, R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now)
protected void updateReplaceStat(boolean result, boolean isHit, long start)
protected void publishEvent(CacheEventContext cacheEventContext)
protected void publishBatchedEvents(String cacheName, CacheEventType cacheEventType, int orderKey)
protected R createRecord(long expiryTime)
protected R createRecord(Data keyData, Object value, long expirationTime, int completionId)
protected void onCreateRecordError(Data key, Object value, long expiryTime, long now, boolean disableWriteThrough, int completionId, String origin, R record, Throwable error)
protected R createRecord(Data key, Object value, long expiryTime, long now, boolean disableWriteThrough, int completionId, String origin)
protected R createRecordWithExpiry(Data key, Object value, long expiryTime, long now, boolean disableWriteThrough, int completionId, String origin)
protected R createRecordWithExpiry(Data key, Object value, long expiryTime, long now, boolean disableWriteThrough, int completionId)
protected R createRecordWithExpiry(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now, boolean disableWriteThrough, int completionId)
protected R createRecordWithExpiry(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now, boolean disableWriteThrough, int completionId, String origin)
protected void onUpdateRecordError(Data key, R record, Object value, Data newDataValue, Data oldDataValue, Throwable error)
protected void onUpdateExpiryPolicy(Data key, R record, Data oldDataExpiryPolicy)
protected void onUpdateExpiryPolicyError(Data key, R record, Data oldDataExpiryPolicy)
protected void updateRecord(Data key, CacheRecord record, long expiryTime, long now, String origin)
protected void updateRecord(Data key, R record, Object value, long expiryTime, long now, boolean disableWriteThrough, int completionId, String source, String origin)
protected void updateExpiryPolicyOfRecord(Data key, R record, Object expiryPolicy)
protected Object extractExpiryPolicyOfRecord(CacheRecord record)
protected boolean updateRecordWithExpiry(Data key, Object value, R record, long expiryTime, long now, boolean disableWriteThrough, int completionId, String source, String origin)
protected boolean updateRecordWithExpiry(Data key, Object value, R record, long expiryTime, long now, boolean disableWriteThrough, int completionId)
protected boolean updateRecordWithExpiry(Data key, Object value, R record, long expiryTime, long now, boolean disableWriteThrough, int completionId, String source)
protected boolean updateRecordWithExpiry(Data key, Object value, R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now, boolean disableWriteThrough, int completionId)
protected boolean updateRecordWithExpiry(Data key, Object value, R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now, boolean disableWriteThrough, int completionId, String source)
protected boolean updateRecordWithExpiry(Data key, Object value, R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now, boolean disableWriteThrough, int completionId, String source, String origin)
protected void updateRecordWithExpiry(Data key, CacheRecord record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now, String source)
protected boolean deleteRecord(Data key, int completionId)
protected boolean deleteRecord(Data key, int completionId, String source, String origin)
public Object readThroughCache(Data key) throws javax.cache.integration.CacheLoaderException
javax.cache.integration.CacheLoaderException
public void writeThroughCache(Data key, Object value) throws javax.cache.integration.CacheWriterException
javax.cache.integration.CacheWriterException
protected void deleteCacheEntry(Data key)
protected void deleteCacheEntry(Data key, CallerProvenance provenance)
public CacheRecord getRecord(Data key)
ICacheRecordStore
getRecord
in interface ICacheRecordStore
key
- the key to the entry.CacheRecord
instance mapped.public void putRecord(Data key, CacheRecord record, boolean updateJournal)
ICacheRecordStore
putRecord
in interface ICacheRecordStore
key
- the key to the entry.record
- the value to be associated with the specified key.updateJournal
- when true an event is appended to related event-journalpublic CacheRecord removeRecord(Data key)
ICacheRecordStore
removeRecord
in interface ICacheRecordStore
key
- the key to the entry.protected void onGet(Data key, javax.cache.expiry.ExpiryPolicy expiryPolicy, Object value, R record)
protected void onGetError(Data key, javax.cache.expiry.ExpiryPolicy expiryPolicy, Object value, R record, Throwable error)
public Object get(Data key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheRecordStore
null
if this cache contains no mapping for the key.
If the cache is configured to use read-through, and get would return null
because the entry is missing from the cache, the Cache's CacheLoader
is called in an attempt to load the entry.
get
in interface ICacheRecordStore
key
- the key whose associated value is to be returned.expiryPolicy
- custom expiry policy or null to use configured default value.public void evictExpiredEntries(int expirationPercentage)
ICacheRecordStore
evictExpiredEntries
in interface ICacheRecordStore
expirationPercentage
- of max expirables according to the record store size.protected void initExpirationIterator()
public boolean contains(Data key)
ICacheRecordStore
More formally, returns true if and only if this store contains a mapping for a key k such that key.equals(k) (There can be at most one such mapping.)
contains
in interface ICacheRecordStore
key
- key whose presence in this store is to be tested.protected void onPut(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, boolean getValue, boolean disableWriteThrough, R record, Object oldValue, boolean isExpired, boolean isNewPut, boolean isSaveSucceed)
protected void onPutError(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, boolean getValue, boolean disableWriteThrough, R record, Object oldValue, boolean wouldBeNewPut, Throwable error)
protected Object put(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, boolean getValue, boolean disableWriteThrough, int completionId)
protected Object put(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, boolean getValue, int completionId)
public R put(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, int completionId)
ICacheRecordStore
If the cache previously contained a mapping for
the key, the old value is replaced by the specified value. (A cache
c is said to contain a mapping for a key k if and only
if c.contains(k)
would return
true.)
The previous value is returned, or null if there was no value associated with the key previously.
put
in interface ICacheRecordStore
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.source
- UUID of the calling node or client.CacheRecord
(added as new record or updated). null
if record has expired.public Object getAndPut(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, int completionId)
ICacheRecordStore
If the cache previously contained a mapping for
the key, the old value is replaced by the specified value. (A cache
c is said to contain a mapping for a key k if and only
if c.contains(k)
would return
true.)
The previous value is returned, or null if there was no value associated with the key previously.
getAndPut
in interface ICacheRecordStore
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.source
- UUID of the calling node or client.protected void onPutIfAbsent(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, boolean disableWriteThrough, R record, boolean isExpired, boolean isSaveSucceed)
protected void onPutIfAbsentError(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, boolean disableWriteThrough, R record, Throwable error)
protected boolean putIfAbsent(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, boolean disableWriteThrough, int completionId)
public boolean putIfAbsent(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, int completionId)
ICacheRecordStore
More formally, if this cache contains a mapping from key k to
value v such that
(key==null ? k==null : key.equals(k))
, that mapping is removed.
(The cache can contain at most one such mapping.)
Returns true if this cache previously associated the key, or false if the cache contained no mapping for the key.
The cache will not contain a mapping for the specified key once the call returns.
putIfAbsent
in interface ICacheRecordStore
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.source
- UUID of the calling node or client.protected void onReplace(Data key, Object oldValue, Object newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, boolean getValue, R record, boolean isExpired, boolean replaced)
protected void onReplaceError(Data key, Object oldValue, Object newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, boolean getValue, R record, boolean isExpired, boolean replaced, Throwable error)
public boolean replace(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, int completionId)
ICacheRecordStore
This is equivalent to
if (cache.containsKey(key)) {
cache.put(key, value);
return true;
} else {
return false;
}
except that the action is performed atomically.replace
in interface ICacheRecordStore
key
- the key with which the specified value is associated.value
- the value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.source
- UUID of the calling node or client.public boolean replace(Data key, Object oldValue, Object newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, int completionId)
ICacheRecordStore
This is equivalent to:
if (cache.containsKey(key) && equals(cache.get(key), oldValue)) {
cache.put(key, newValue);
return true;
} else {
return false;
}
except that the action is performed atomically.replace
in interface ICacheRecordStore
key
- key with which the specified value is associated.oldValue
- value expected to be associated with the specified key.newValue
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.source
- UUID of the calling node or client.public Object getAndReplace(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String source, int completionId)
ICacheRecordStore
This is equivalent to
if (cache.containsKey(key)) {
V oldValue = cache.get(key);
cache.put(key, value);
return oldValue;
} else {
return null;
}
except that the action is performed atomically.getAndReplace
in interface ICacheRecordStore
key
- key with which the specified value is associated.value
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.source
- uuid of the calling node or client.public boolean setExpiryPolicy(Collection<Data> keys, Object expiryPolicy, String source)
ICacheRecordStore
setExpiryPolicy
in interface ICacheRecordStore
keys
- keys for the entriesexpiryPolicy
- custom expiry policy or null to use configured default valuepublic Object getExpiryPolicy(Data key)
getExpiryPolicy
in interface ICacheRecordStore
protected void onRemove(Data key, Object value, String source, boolean getValue, R record, boolean removed)
protected void onRemoveError(Data key, Object value, String source, boolean getValue, R record, boolean removed, Throwable error)
public boolean remove(Data key, String source, String origin, int completionId)
remove
in interface ICacheRecordStore
public boolean remove(Data key, String source, String origin, int completionId, CallerProvenance provenance)
ICacheRecordStore
More formally, if this cache contains a mapping from key k to
value v such that
(key==null ? k==null : key.equals(k))
, that mapping is removed.
(The cache can contain at most one such mapping.)
Returns true if this cache previously associated the key, or false if the cache contained no mapping for the key.
The cache will not contain a mapping for the specified key once the call returns.
remove
in interface ICacheRecordStore
key
- key whose mapping is to be removed from the cache.source
- UUID of the calling node or client.origin
- Source of the callcompletionId
- User generated id which shall be received as a field of the cache event upon completion of
the request in the cluster.provenance
- caller operation provenancepublic InvalidationQueue<ExpiredKey> getExpiredKeysQueue()
getExpiredKeysQueue
in interface ICacheRecordStore
public boolean remove(Data key, Object value, String source, String origin, int completionId)
ICacheRecordStore
This is equivalent to:
if (cache.containsKey(key) && equals(cache.get(key), oldValue) {
cache.remove(key);
return true;
} else {
return false;
}
except that the action is performed atomically.remove
in interface ICacheRecordStore
key
- key whose mapping is to be removed from the cache.value
- value expected to be associated with the specified key.source
- UUID of the calling node or client.origin
- Source of the callcompletionId
- User generated id which shall be received as a field of the cache event upon completion of
the request in the cluster.protected void markExpirable(long expiryTime)
expiryTime
- public Object getAndRemove(Data key, String source, int completionId)
ICacheRecordStore
This is equivalent to:
if (cache.containsKey(key)) {
V oldValue = cache.get(key);
cache.remove(key);
return oldValue;
} else {
return null;
}
except that the action is performed atomically.getAndRemove
in interface ICacheRecordStore
key
- key with which the specified value is associated.source
- UUID of the calling node or client.public MapEntries getAll(Set<Data> keySet, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheRecordStore
Map
of the values associated with the set of keys requested.
If the cache is configured read-through, and a get for a key would
return null because an entry is missing from the cache, the Cache's
CacheLoader
is called in an attempt to load the entry. If an
entry cannot be loaded for a given key, the key will not be present in
the returned Map.
getAll
in interface ICacheRecordStore
keySet
- keys whose associated values are to be returned.expiryPolicy
- custom expiry policy or null to use configured default value.public void removeAll(Set<Data> keys, int completionId)
ICacheRecordStore
removeAll
in interface ICacheRecordStore
keys
- set of keys to be cleaned.public Set<Data> loadAll(Set<Data> keys, boolean replaceExistingValues)
ICacheRecordStore
CacheLoader
for the given keys.
If an entry for a key already exists in the cache, a value will be loaded
if and only if replaceExistingValues
is true. If no loader
is configured for the cache, no objects will be loaded.
loadAll
in interface ICacheRecordStore
keys
- the keys to be loaded.replaceExistingValues
- when true, existing values in the cache will
be replaced by those loaded from a CacheLoader.public CacheRecord merge(SplitBrainMergeTypes.CacheMergeTypes mergingEntry, SplitBrainMergePolicy<Data,SplitBrainMergeTypes.CacheMergeTypes> mergePolicy, CallerProvenance callerProvenance)
ICacheRecordStore
SplitBrainMergeTypes.CacheMergeTypes
via the given SplitBrainMergePolicy
.merge
in interface ICacheRecordStore
mergingEntry
- the SplitBrainMergeTypes.CacheMergeTypes
instance to mergemergePolicy
- the SplitBrainMergePolicy
instance to applyCacheRecord
if merge is applied, otherwise null
public CacheRecord merge(CacheEntryView<Data,Data> cacheEntryView, CacheMergePolicy mergePolicy, String caller, String origin, int completionId, CallerProvenance callerProvenance)
ICacheRecordStore
CacheEntryView
via the given CacheMergePolicy
.merge
in interface ICacheRecordStore
cacheEntryView
- the CacheEntryView
instance to mergemergePolicy
- the CacheMergePolicy
instance to applycaller
- the UUID of the callerorigin
- source of the callcompletionId
- User generated id which shall be received as a field of the cache event upon completion of
the request in the cluster.CacheRecord
if merge is applied, otherwise null
public CacheKeyIterationResult fetchKeys(int tableIndex, int size)
ICacheRecordStore
size
fetchKeys
in interface ICacheRecordStore
tableIndex
- initial table index.size
- maximum key set size.CacheKeyIterationResult
which wraps keys and last tableIndex.public CacheEntryIterationResult fetchEntries(int tableIndex, int size)
ICacheRecordStore
size
fetchEntries
in interface ICacheRecordStore
tableIndex
- initial table index.size
- maximum entry set size.CacheEntryIterationResult
which wraps entries and last tableIndex.public Object invoke(Data key, javax.cache.processor.EntryProcessor entryProcessor, Object[] arguments, int completionId)
ICacheRecordStore
EntryProcessor
against the Cache.Entry
specified by
the provided key. If an Cache.Entry
does not exist for the specified key,
an attempt is made to load it (if a loader is configured) or a surrogate
Cache.Entry
, consisting of the key with a null value is used instead.
invoke
in interface ICacheRecordStore
key
- the key of the entry.entryProcessor
- the EntryProcessor
to be invoked.arguments
- additional arguments to be passed to the
EntryProcessor
.EntryProcessor
implementation.public int size()
ICacheRecordStore
size
in interface ICacheRecordStore
public CacheStatisticsImpl getCacheStats()
ICacheRecordStore
CacheService
.getCacheStats
in interface ICacheRecordStore
CacheStatisticsImpl
cache statistics.public CacheConfig getConfig()
ICacheRecordStore
getConfig
in interface ICacheRecordStore
CacheConfig
public String getName()
getName
in interface ICacheRecordStore
public Map<Data,CacheRecord> getReadOnlyRecords()
ICacheRecordStore
getReadOnlyRecords
in interface ICacheRecordStore
public void clear()
ICacheRecordStore
clear
in interface ICacheRecordStore
protected void destroyEventJournal()
public void reset()
ICacheRecordStore
reset
in interface ICacheRecordStore
public void close(boolean onShutdown)
ICacheRecordStore
close
in interface ICacheRecordStore
onShutdown
- true if close
is called during CacheService shutdown,
false otherwise.ICacheRecordStore.clear()
,
ICacheRecordStore.destroy()
public void destroy()
ICacheRecordStore
destroy
in interface ICacheRecordStore
ICacheRecordStore.clear()
,
ICacheRecordStore.close(boolean)
public void destroyInternals()
ICacheRecordStore
ICacheRecordStore.destroy()
but does not touch state on other services
like event journal service.destroyInternals
in interface ICacheRecordStore
protected void onDestroy()
protected void closeListeners()
public boolean isWanReplicationEnabled()
ICacheRecordStore
isWanReplicationEnabled
in interface ICacheRecordStore
public ObjectNamespace getObjectNamespace()
ICacheRecordStore
ObjectNamespace
associated with this record store.getObjectNamespace
in interface ICacheRecordStore
public int getPartitionId()
getPartitionId
in interface ICacheRecordStore
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.