public interface RecordStore<R extends Record>
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_MAX_IDLE
Default Max Idle value of a record.
|
static long |
DEFAULT_TTL
Default TTL value of a record.
|
Modifier and Type | Method and Description |
---|---|
void |
accessRecord(Record record,
long now)
Touches the given record, updating its last access time to
now and
maintaining statistics. |
boolean |
canAcquireLock(Data key,
String caller,
long threadId) |
void |
checkIfLoaded() |
int |
clear()
Called by
IMap.clear() . |
void |
clearPartition(boolean onShutdown,
boolean onRecordStoreDestroy)
Called by
DistributedObject.destroy() or MapMigrationAwareService
Clears internal partition data. |
boolean |
containsKey(Data dataKey,
Address callerAddress) |
boolean |
containsValue(Object testValue) |
Record |
createRecord(Data key,
Object value,
long ttlMillis,
long maxIdle,
long now) |
Storage |
createStorage(RecordFactory<R> recordFactory,
InMemoryFormat memoryFormat) |
boolean |
delete(Data dataKey,
CallerProvenance provenance) |
void |
destroy()
Called by
DistributedObject.destroy() . |
void |
disposeDeferredBlocks()
This can be used to release unused resources.
|
void |
doPostEvictionOperations(Record record)
Does post eviction operations like sending events
|
Object |
evict(Data key,
boolean backup) |
int |
evictAll(boolean backup)
Evicts all keys except locked ones.
|
void |
evictEntries(Data excludedKey)
Evicts entries from this record-store.
|
void |
evictExpiredEntries(int percentage,
boolean backup)
Do expiration operations.
|
boolean |
existInMemory(Data key)
Checks if the key exist in memory without trying to load data from map-loader
|
boolean |
extendLock(Data key,
String caller,
long threadId,
long ttl) |
MapEntriesWithCursor |
fetchEntries(int tableIndex,
int size)
Fetches specified number of entries from provided tableIndex.
|
MapKeysWithCursor |
fetchKeys(int tableIndex,
int size)
Fetches specified number of keys from provided tableIndex.
|
boolean |
forceUnlock(Data dataKey) |
Object |
get(Data dataKey,
boolean backup,
Address callerAddress)
|
Object |
get(Data dataKey,
boolean backup,
Address callerAddress,
boolean touch)
Gets record from
RecordStore . |
MapEntries |
getAll(Set<Data> keySet,
Address callerAddress) |
InvalidationQueue<ExpiredKey> |
getExpiredKeysQueue() |
LocalRecordStoreStats |
getLocalRecordStoreStats() |
int |
getLockedEntryCount() |
String |
getLockOwnerInfo(Data key) |
MapContainer |
getMapContainer() |
MapDataStore<Data,Object> |
getMapDataStore() |
String |
getName() |
long |
getOwnedEntryCost() |
int |
getPartitionId()
Returns the partition id this RecordStore belongs to.
|
R |
getRecord(Data key) |
R |
getRecordOrNull(Data key)
Returns live record or null if record is already expired.
|
Storage |
getStorage() |
boolean |
hasQueryCache() |
void |
init()
Initialize the recordStore after creation
|
boolean |
isEmpty() |
boolean |
isExpirable() |
boolean |
isExpired(R record,
long now,
boolean backup)
Checks whether a record is expired or not.
|
boolean |
isKeyLoadFinished() |
boolean |
isLoaded()
Returns
true if all key and value loading tasks have completed
on this record store. |
boolean |
isLocked(Data key) |
boolean |
isLockedBy(Data key,
String caller,
long threadId) |
boolean |
isTransactionallyLocked(Data key) |
Iterator<Record> |
iterator()
Iterates over record store entries.
|
Iterator<Record> |
iterator(long now,
boolean backup)
Iterates over record store entries by respecting expiration.
|
void |
loadAll(boolean replaceExistingValues)
Triggers key and value loading if there is no ongoing or completed
key loading task, otherwise does nothing.
|
void |
loadAllFromStore(List<Data> keys,
boolean replaceExistingValues)
Triggers loading values for the given
keys from the
defined MapLoader . |
Iterator<Record> |
loadAwareIterator(long now,
boolean backup)
Iterates over record store entries but first waits map store to load.
|
Record |
loadRecordOrNull(Data key,
boolean backup,
Address callerAddress) |
boolean |
localLock(Data key,
String caller,
long threadId,
long referenceId,
long ttl) |
boolean |
lock(Data key,
String caller,
long threadId,
long referenceId,
long ttl) |
void |
maybeDoInitialLoad()
Resets the map loader state if necessary and triggers initial key and
value loading if it has not been done before.
|
boolean |
merge(Data dataKey,
EntryView mergingEntry,
MapMergePolicy mergePolicy) |
boolean |
merge(Data dataKey,
EntryView mergingEntry,
MapMergePolicy mergePolicy,
CallerProvenance provenance)
Merges the given
EntryView via the given MapMergePolicy . |
boolean |
merge(SplitBrainMergeTypes.MapMergeTypes mergingEntry,
SplitBrainMergePolicy<Data,SplitBrainMergeTypes.MapMergeTypes> mergePolicy) |
boolean |
merge(SplitBrainMergeTypes.MapMergeTypes mergingEntry,
SplitBrainMergePolicy<Data,SplitBrainMergeTypes.MapMergeTypes> mergePolicy,
CallerProvenance provenance)
Merges the given
SplitBrainMergeTypes.MapMergeTypes via the given SplitBrainMergePolicy . |
Object |
put(Data dataKey,
Object dataValue,
long ttl,
long maxIdle) |
R |
putBackup(Data key,
Object value,
CallerProvenance provenance) |
R |
putBackup(Data key,
Object value,
long ttl,
long maxIdle,
boolean putTransient,
CallerProvenance provenance) |
Object |
putFromLoad(Data key,
Object value,
Address callerAddress)
Puts key-value pair to map which is the result of a load from map store operation.
|
Object |
putFromLoadBackup(Data key,
Object value)
Puts key-value pair to map which is the result of a load from map store operation on backup.
|
Object |
putIfAbsent(Data dataKey,
Object value,
long ttl,
long maxIdle,
Address callerAddress) |
void |
putRecord(Data key,
R record)
Puts a data key and a record value to record-store.
|
Object |
putTransient(Data dataKey,
Object value,
long ttl,
long maxIdle) |
Data |
readBackupData(Data key)
Called when
MapConfig.isReadBackupData() is true from
MapProxySupport.getInternal(java.lang.Object)
Returns corresponding value for key as Data . |
Object |
remove(Data key,
CallerProvenance provenance) |
boolean |
remove(Data dataKey,
Object testValue) |
void |
removeBackup(Data dataKey,
CallerProvenance provenance)
Similar to
RecordStore##remove(Data, CallerProvenance)
except removeBackup doesn't touch mapstore since it does not return previous value. |
Object |
replace(Data dataKey,
Object update) |
boolean |
replace(Data dataKey,
Object expect,
Object update)
Sets the value to the given updated value
if
ValueComparator.isEqual(java.lang.Object, java.lang.Object, com.hazelcast.spi.serialization.SerializationService) comparison
of current value and expected value is true . |
void |
reset()
Resets the record store to it's initial state.
|
void |
sampleAndForceRemoveEntries(int entryCountToRemove) |
Object |
set(Data dataKey,
Object value,
long ttl,
long maxIdle) |
void |
setPreMigrationLoadedStatus(boolean loaded)
Informs this recordStore about the loading status of the recordStore
that this store is migrated from.
|
boolean |
setTtl(Data key,
long ttl) |
boolean |
setWithUncountedAccess(Data dataKey,
Object value,
long ttl,
long maxIdle)
Does exactly the same thing as
set(Data, Object, long, long) except the invocation is not counted as
a read access while updating the access statics. |
boolean |
shouldEvict()
Returns
true if eviction is allowed on this record-store, otherwise false |
int |
size() |
long |
softFlush() |
void |
startLoading()
Starts the map loader if there is a configured and enabled
MapLoader and the key loading has not already
been started. |
boolean |
txnLock(Data key,
String caller,
long threadId,
long referenceId,
long ttl,
boolean blockReads) |
boolean |
unlock(Data key,
String caller,
long threadId,
long referenceId) |
void |
updateLoadStatus(boolean lastBatch,
Throwable exception)
Advances the state of the map key loader for this partition and sets the key
loading future result if the
lastBatch is true . |
static final long DEFAULT_TTL
static final long DEFAULT_MAX_IDLE
LocalRecordStoreStats getLocalRecordStoreStats()
void accessRecord(Record record, long now)
now
and
maintaining statistics.
An implementation is not supposed to be thread safe.
record
- the accessed recordnow
- the current timeString getName()
Object set(Data dataKey, Object value, long ttl, long maxIdle)
MapLoader
Object put(Data dataKey, Object dataValue, long ttl, long maxIdle)
MapLoader
Object putIfAbsent(Data dataKey, Object value, long ttl, long maxIdle, Address callerAddress)
R putBackup(Data key, Object value, CallerProvenance provenance)
key
- the keyvalue
- the value to put backupprovenance
- origin of call to this method.R putBackup(Data key, Object value, long ttl, long maxIdle, boolean putTransient, CallerProvenance provenance)
key
- the key to be processed.value
- the value to be processed.ttl
- milliseconds. Check out MapProxySupport.putInternal(java.lang.Object, com.hazelcast.nio.serialization.Data, long, java.util.concurrent.TimeUnit, long, java.util.concurrent.TimeUnit)
maxIdle
- milliseconds. Check out MapProxySupport.putInternal(java.lang.Object, com.hazelcast.nio.serialization.Data, long, java.util.concurrent.TimeUnit, long, java.util.concurrent.TimeUnit)
putTransient
- true
if putting transient entry, otherwise false
provenance
- origin of call to this method.boolean setWithUncountedAccess(Data dataKey, Object value, long ttl, long maxIdle)
set(Data, Object, long, long)
except the invocation is not counted as
a read access while updating the access statics.Object remove(Data key, CallerProvenance provenance)
key
- the key to be removedprovenance
- origin of call to this method.boolean delete(Data dataKey, CallerProvenance provenance)
dataKey
- the key to be removedprovenance
- origin of call to this method.true
if entry is deleted, otherwise returns false
boolean setTtl(Data key, long ttl)
void removeBackup(Data dataKey, CallerProvenance provenance)
RecordStore##remove(Data, CallerProvenance)
except removeBackup doesn't touch mapstore since it does not return previous value.Object get(Data dataKey, boolean backup, Address callerAddress, boolean touch)
RecordStore
.
Loads missing keys from map store.dataKey
- key.backup
- true
if a backup partition, otherwise false
.touch
- when true
, if an existing record was found for the given key,
then its last access time is updated.RecordStore
Data readBackupData(Data key)
MapConfig.isReadBackupData()
is true
from
MapProxySupport.getInternal(java.lang.Object)
Returns corresponding value for key as Data
.
This adds an extra serialization step. For the reason of this behaviour please see issue 1292 on github.key
- key to be accessedData
independent of InMemoryFormat
MapEntries getAll(Set<Data> keySet, Address callerAddress)
boolean existInMemory(Data key)
int getLockedEntryCount()
boolean replace(Data dataKey, Object expect, Object update)
ValueComparator.isEqual(java.lang.Object, java.lang.Object, com.hazelcast.spi.serialization.SerializationService)
comparison
of current value and expected value is true
.dataKey
- key which's value is requested to be replaced.expect
- the expected valueupdate
- the new valuetrue
if successful. False return indicates that
the actual value was not equal to the expected value.Object putFromLoad(Data key, Object value, Address callerAddress)
key
- key to put.value
- to put.PutFromLoadAllOperation
Object putFromLoadBackup(Data key, Object value)
key
- key to put.value
- to put.PutFromLoadAllBackupOperation
boolean merge(SplitBrainMergeTypes.MapMergeTypes mergingEntry, SplitBrainMergePolicy<Data,SplitBrainMergeTypes.MapMergeTypes> mergePolicy)
boolean merge(SplitBrainMergeTypes.MapMergeTypes mergingEntry, SplitBrainMergePolicy<Data,SplitBrainMergeTypes.MapMergeTypes> mergePolicy, CallerProvenance provenance)
SplitBrainMergeTypes.MapMergeTypes
via the given SplitBrainMergePolicy
.mergingEntry
- the SplitBrainMergeTypes.MapMergeTypes
instance to mergemergePolicy
- the SplitBrainMergePolicy
instance to applyprovenance
- origin of call to this method.true
if merge is applied, otherwise false
boolean merge(Data dataKey, EntryView mergingEntry, MapMergePolicy mergePolicy)
boolean merge(Data dataKey, EntryView mergingEntry, MapMergePolicy mergePolicy, CallerProvenance provenance)
EntryView
via the given MapMergePolicy
.dataKey
- the key to be mergedmergingEntry
- the EntryView
instance to mergemergePolicy
- the MapMergePolicy
instance to applyprovenance
- origin of call to this method.true
if merge is applied, otherwise false
void putRecord(Data key, R record)
key
- the data key to put record store.record
- the value for record store.MapReplicationOperation
Iterator<Record> iterator()
Iterator<Record> iterator(long now, boolean backup)
MapKeysWithCursor fetchKeys(int tableIndex, int size)
MapKeysWithCursor
which is a holder for keys and next index to read from.MapEntriesWithCursor fetchEntries(int tableIndex, int size)
MapEntriesWithCursor
which is a holder for entries and next index to read from.Iterator<Record> loadAwareIterator(long now, boolean backup)
IMap.keySet(com.hazelcast.query.Predicate)
,
this method can be used to return a read-only iterator.now
- current time in millisbackup
- true
if a backup partition, otherwise false
.int size()
boolean txnLock(Data key, String caller, long threadId, long referenceId, long ttl, boolean blockReads)
boolean isLocked(Data key)
boolean isTransactionallyLocked(Data key)
boolean containsValue(Object testValue)
int evictAll(boolean backup)
backup
- true
if a backup partition, otherwise false
.MapContainer getMapContainer()
long softFlush()
MapDataStore.softFlush()
boolean forceUnlock(Data dataKey)
long getOwnedEntryCost()
boolean isEmpty()
void evictExpiredEntries(int percentage, boolean backup)
percentage
- of max expirables according to the record store size.backup
- true
if a backup partition, otherwise false
.boolean isExpirable()
true
if record store has at least one candidate entry
for expiration else return false
.boolean isExpired(R record, long now, boolean backup)
record
- the record from record-store.now
- current time in millisbackup
- true
if a backup partition, otherwise false
.true
if the record is expired, false
otherwise.void doPostEvictionOperations(Record record)
record
- record to processMapDataStore<Data,Object> getMapDataStore()
InvalidationQueue<ExpiredKey> getExpiredKeysQueue()
int getPartitionId()
R getRecordOrNull(Data key)
key
- key to be accessedget(com.hazelcast.nio.serialization.Data, boolean, com.hazelcast.nio.Address, boolean)
void evictEntries(Data excludedKey)
excludedKey
- this key has lowest priority to be selected for evictionboolean shouldEvict()
true
if eviction is allowed on this record-store, otherwise false
true
if eviction is allowed on this record-store, otherwise false
Storage createStorage(RecordFactory<R> recordFactory, InMemoryFormat memoryFormat)
void disposeDeferredBlocks()
void init()
Storage getStorage()
void sampleAndForceRemoveEntries(int entryCountToRemove)
void startLoading()
MapLoader
and the key loading has not already
been started.
The loading may start again if there was a migration and the record store
on the migration source has started but not completed the loading.void setPreMigrationLoadedStatus(boolean loaded)
startLoading()
,
otherwise has no effect.
This method should be deleted when the map's lifecycle has been cleaned-up. Currently it's impossible to pass additional state when the record store is created, thus this state has to be passed in post-creation setters which is cumbersome and error-prone.
boolean isKeyLoadFinished()
true
if the key loading and dispatching has finished on
this record storeboolean isLoaded()
true
if all key and value loading tasks have completed
on this record store.void checkIfLoaded() throws RetryableHazelcastException
RetryableHazelcastException
void loadAll(boolean replaceExistingValues)
replaceExistingValues
- if the existing entries for the loaded keys should be replacedvoid maybeDoInitialLoad()
void loadAllFromStore(List<Data> keys, boolean replaceExistingValues)
keys
from the
defined MapLoader
.
The values will be loaded asynchronously and this method will
return as soon as the value loading task has been offloaded
to a different thread.keys
- the keys for which values will be loadedreplaceExistingValues
- if the existing entries for the keys should
be replaced with the loaded valuesvoid updateLoadStatus(boolean lastBatch, Throwable exception)
lastBatch
is true
.
If there was an exception during key loading, you may pass it as the
exception
paramter and it will be set as the result of the future.
lastBatch
- if the last key batch was sentexception
- an exception that occurred during key loadingboolean hasQueryCache()
QueryCache
defined
for this map.void clearPartition(boolean onShutdown, boolean onRecordStoreDestroy)
DistributedObject.destroy()
or MapMigrationAwareService
Clears internal partition data.onShutdown
- true if close
is called during
MapService shutdown, false otherwise.onRecordStoreDestroy
- true if record-store will be destroyed,
otherwise false.int clear()
IMap.clear()
.
Clears data in this record store.void reset()
putRecord(Data, Record)
void destroy()
DistributedObject.destroy()
.
Destroys data in this record store.Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.