public class DefaultRecordStore extends Object implements RecordStore
| Modifier and Type | Field and Description |
|---|---|
protected static long |
DEFAULT_TTL |
protected MapContainer |
mapContainer |
protected MapServiceContext |
mapServiceContext |
protected String |
name |
protected int |
partitionId |
protected RecordFactory |
recordFactory |
protected ConcurrentMap<Data,Record> |
records |
protected SerializationService |
serializationService |
| Constructor and Description |
|---|
DefaultRecordStore(MapContainer mapContainer,
int partitionId) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
accessRecord(Record record) |
protected void |
accessRecord(Record record,
long now) |
protected long |
calculateRecordHeapCost(Collection<Record> collection)
Returns total heap cost of collection.
|
protected long |
calculateRecordHeapCost(Record record) |
boolean |
canAcquireLock(Data key,
String caller,
long threadId) |
void |
checkIfLoaded() |
int |
clear() |
void |
clearPartition() |
protected void |
clearRecordsMap(Map<Data,Record> excludeRecords) |
boolean |
containsKey(Data key) |
boolean |
containsValue(Object value) |
protected LockStore |
createLockStore() |
protected Record |
createRecord(Data key,
Object value,
long now) |
protected Record |
createRecord(Data key,
Object value,
long ttl,
long now) |
protected com.hazelcast.map.impl.RecordStoreLoader |
createRecordStoreLoader() |
boolean |
delete(Data key) |
Set<Map.Entry<Data,Data>> |
entrySetData() |
Object |
evict(Data key,
boolean backup) |
int |
evictAll(boolean backup)
Evicts all keys except locked ones.
|
void |
evictEntries(long now,
boolean backup)
TODO make checkEvictable fast by carrying threshold logic to partition.
|
void |
evictExpiredEntries(int percentage,
boolean backup)
Do expiration operations.
|
boolean |
extendLock(Data key,
String caller,
long threadId,
long ttl) |
void |
flush() |
boolean |
forceUnlock(Data dataKey) |
Object |
get(Data key,
boolean backup)
Gets record from
RecordStore. |
MapEntrySet |
getAll(Set<Data> keys) |
long |
getHeapCost() |
String |
getLockOwnerInfo(Data key) |
MapContainer |
getMapContainer() |
MapDataStore<Data,Object> |
getMapDataStore() |
Map.Entry<Data,Object> |
getMapEntry(Data key,
long now) |
String |
getName() |
protected long |
getNow() |
protected Record |
getOrNullIfExpired(Record record,
long now,
boolean backup)
Check if record is reachable according to ttl or idle times.
|
int |
getPartitionId() |
Record |
getRecord(Data key) |
Map<Data,Record> |
getRecordMap()
Returns records map.
|
Record |
getRecordOrNull(Data key)
Returns live record or null if record is already expired.
|
boolean |
isEmpty() |
boolean |
isExpirable() |
boolean |
isExpired(Record record,
long now,
boolean backup) |
boolean |
isLoaded() |
boolean |
isLocked(Data dataKey) |
boolean |
isTransactionallyLocked(Data key) |
Iterator<Record> |
iterator()
Iterates over record store values.
|
Iterator<Record> |
iterator(long now,
boolean backup)
Iterates over record store values by respecting expiration.
|
Set<Data> |
keySet() |
void |
loadAllFromStore(List<Data> keys,
boolean replaceExistingValues)
Loads all keys from defined map store.
|
Iterator<Record> |
loadAwareIterator(long now,
boolean backup)
Iterates over record store values but first waits map store to load.
|
protected void |
markRecordStoreExpirable(long ttl) |
boolean |
merge(Data key,
EntryView mergingEntry,
MapMergePolicy mergePolicy) |
protected void |
onStore(Record record) |
protected void |
postReadCleanUp(long now,
boolean backup)
If there is no clean-up caused by puts after some time,
try to clean-up from gets.
|
Object |
put(Data key,
Object value,
long ttl) |
void |
put(Map.Entry<Data,Object> entry) |
Record |
putBackup(Data key,
Object value) |
Record |
putBackup(Data key,
Object value,
long ttl) |
Object |
putFromLoad(Data key,
Object value)
Puts key-value pair to map which is the result of a load from map store operation.
|
Object |
putFromLoad(Data key,
Object value,
long ttl)
Puts key-value pair to map which is the result of a load from map store operation.
|
Object |
putIfAbsent(Data key,
Object value,
long ttl) |
void |
putRecord(Data key,
Record record)
Puts a data key and a record value to record-store.
|
void |
putTransient(Data key,
Object value,
long ttl) |
Data |
readBackupData(Data key)
Called when
MapConfig.isReadBackupData() is true from
MapProxySupport.getInternal(com.hazelcast.nio.serialization.Data)
Returns corresponding value for key as Data. |
Object |
remove(Data key) |
boolean |
remove(Data key,
Object testValue) |
void |
removeBackup(Data key)
Similar to
RecordStore.remove(com.hazelcast.nio.serialization.Data)
except removeBackup doesn't touch mapstore since it does not return previous value. |
protected void |
removeIndex(Data key) |
protected void |
removeIndex(Set<Data> keys) |
protected void |
removeIndexByPreservingKeys(Set<Data> keysToRemove,
Set<Data> keysToPreserve)
Removes indexes by excluding keysToPreserve.
|
Object |
replace(Data key,
Object update) |
boolean |
replace(Data key,
Object expect,
Object update)
Sets the value to the given updated value
if
RecordFactory.isEquals(java.lang.Object, java.lang.Object) comparison
of current value and expected value is true. |
void |
reset()
Resets the record store to it's initial state.
|
protected void |
resetAccessSequenceNumber() |
protected void |
resetSizeEstimator() |
protected void |
saveIndex(Record record) |
boolean |
set(Data key,
Object value,
long ttl) |
void |
setLoaded(boolean loaded) |
void |
setSizeEstimator(SizeEstimator sizeEstimator) |
protected boolean |
shouldEvict(long now) |
int |
size()
Size may not give precise size at a specific moment
due to the expiration logic.
|
protected Data |
toData(Object value) |
boolean |
tryPut(Data key,
Object value,
long ttl) |
boolean |
txnLock(Data key,
String caller,
long threadId,
long ttl) |
boolean |
unlock(Data key,
String caller,
long threadId) |
protected void |
updateRecord(Record record,
Object value,
long now) |
protected void |
updateSizeEstimator(long recordSize) |
Collection<Data> |
valuesData() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitevictEntries, evictExpiredEntries, getHeapCost, getMapContainer, getName, getPartitionId, isExpirableprotected static final long DEFAULT_TTL
protected final ConcurrentMap<Data,Record> records
protected final RecordFactory recordFactory
protected final String name
protected final MapContainer mapContainer
protected final MapServiceContext mapServiceContext
protected final SerializationService serializationService
protected final int partitionId
public DefaultRecordStore(MapContainer mapContainer, int partitionId)
public boolean isLoaded()
isLoaded in interface RecordStorepublic void setLoaded(boolean loaded)
setLoaded in interface RecordStorepublic void checkIfLoaded()
checkIfLoaded in interface RecordStorepublic void flush()
flush in interface RecordStorepublic Record getRecord(Data key)
getRecord in interface RecordStorepublic void putRecord(Data key, Record record)
RecordStoreputRecord in interface RecordStorekey - the data key to put record store.record - the value for record store.MapReplicationOperationpublic Record putBackup(Data key, Object value)
putBackup in interface RecordStorepublic Record putBackup(Data key, Object value, long ttl)
putBackup in interface RecordStorekey - the key to be processed.value - the value to be processed.ttl - milliseconds. Check out MapProxySupport.putInternal(com.hazelcast.nio.serialization.Data, com.hazelcast.nio.serialization.Data, long, java.util.concurrent.TimeUnit)public Iterator<Record> iterator()
RecordStoreiterator in interface RecordStorepublic Iterator<Record> iterator(long now, boolean backup)
RecordStoreiterator in interface RecordStorepublic Iterator<Record> loadAwareIterator(long now, boolean backup)
RecordStoreIMap.keySet(com.hazelcast.query.Predicate),
this method can be used to return a read-only iterator.loadAwareIterator in interface RecordStorenow - current time in millisbackup - true if a backup partition, otherwise false.public Map<Data,Record> getRecordMap()
RecordStoregetRecordMap in interface RecordStoreRecordStoreLoaderpublic void clearPartition()
clearPartition in interface RecordStorepublic int size()
size in interface RecordStorepublic boolean isEmpty()
isEmpty in interface RecordStorepublic boolean containsValue(Object value)
containsValue in interface RecordStorepublic boolean txnLock(Data key, String caller, long threadId, long ttl)
txnLock in interface RecordStorepublic boolean extendLock(Data key, String caller, long threadId, long ttl)
extendLock in interface RecordStorepublic boolean unlock(Data key, String caller, long threadId)
unlock in interface RecordStorepublic boolean forceUnlock(Data dataKey)
forceUnlock in interface RecordStorepublic boolean isLocked(Data dataKey)
isLocked in interface RecordStorepublic boolean isTransactionallyLocked(Data key)
isTransactionallyLocked in interface RecordStorepublic boolean canAcquireLock(Data key, String caller, long threadId)
canAcquireLock in interface RecordStorepublic String getLockOwnerInfo(Data key)
getLockOwnerInfo in interface RecordStorepublic Set<Map.Entry<Data,Data>> entrySetData()
entrySetData in interface RecordStorepublic Map.Entry<Data,Object> getMapEntry(Data key, long now)
getMapEntry in interface RecordStorepublic Set<Data> keySet()
keySet in interface RecordStorepublic Collection<Data> valuesData()
valuesData in interface RecordStorepublic int clear()
clear in interface RecordStorepublic void reset()
reset in interface RecordStorepublic Object evict(Data key, boolean backup)
evict in interface RecordStorepublic int evictAll(boolean backup)
RecordStoreevictAll in interface RecordStorebackup - true if a backup partition, otherwise false.public void removeBackup(Data key)
RecordStoreRecordStore.remove(com.hazelcast.nio.serialization.Data)
except removeBackup doesn't touch mapstore since it does not return previous value.removeBackup in interface RecordStorepublic Object remove(Data key)
remove in interface RecordStorepublic boolean remove(Data key, Object testValue)
remove in interface RecordStorepublic boolean delete(Data key)
delete in interface RecordStorepublic Object get(Data key, boolean backup)
RecordStoreRecordStore.
Loads missing keys from map store.get in interface RecordStorekey - key.backup - true if a backup partition, otherwise false.RecordStorepublic Data readBackupData(Data key)
RecordStoreMapConfig.isReadBackupData() is true from
MapProxySupport.getInternal(com.hazelcast.nio.serialization.Data)
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.readBackupData in interface RecordStorekey - key to be accessedData
independent of InMemoryFormatpublic MapEntrySet getAll(Set<Data> keys)
getAll in interface RecordStorepublic boolean containsKey(Data key)
containsKey in interface RecordStorepublic void put(Map.Entry<Data,Object> entry)
put in interface RecordStorepublic Object put(Data key, Object value, long ttl)
put in interface RecordStorepublic boolean set(Data key, Object value, long ttl)
set in interface RecordStorepublic boolean merge(Data key, EntryView mergingEntry, MapMergePolicy mergePolicy)
merge in interface RecordStorepublic Object replace(Data key, Object update)
replace in interface RecordStorepublic boolean replace(Data key, Object expect, Object update)
RecordStoreRecordFactory.isEquals(java.lang.Object, java.lang.Object) comparison
of current value and expected value is true.replace in interface RecordStorekey - 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.public void putTransient(Data key, Object value, long ttl)
putTransient in interface RecordStorepublic Object putFromLoad(Data key, Object value)
RecordStoreputFromLoad in interface RecordStorekey - key to put.value - to put.PutFromLoadAllOperationpublic Object putFromLoad(Data key, Object value, long ttl)
RecordStoreputFromLoad in interface RecordStorekey - key to put.value - to put.ttl - time to live seconds.PutAllOperationpublic boolean tryPut(Data key, Object value, long ttl)
tryPut in interface RecordStorepublic Object putIfAbsent(Data key, Object value, long ttl)
putIfAbsent in interface RecordStorepublic void loadAllFromStore(List<Data> keys, boolean replaceExistingValues)
RecordStoreloadAllFromStore in interface RecordStorekeys - keys to be loaded.replaceExistingValues - true if need to replace existing values otherwise falsepublic MapDataStore<Data,Object> getMapDataStore()
getMapDataStore in interface RecordStorepublic Record getRecordOrNull(Data key)
RecordStoregetRecordOrNull in interface RecordStorekey - key to be accessedRecordStore.get(com.hazelcast.nio.serialization.Data, boolean)public void evictExpiredEntries(int percentage,
boolean backup)
RecordStorepercentage - of max expirables according to the record store size.backup - true if a backup partition, otherwise false.public boolean isExpirable()
true if record store has at least one candidate entry
for expiration else return false.protected void resetAccessSequenceNumber()
public void evictEntries(long now,
boolean backup)
now - now in time.protected void postReadCleanUp(long now,
boolean backup)
now - now.protected boolean shouldEvict(long now)
protected void markRecordStoreExpirable(long ttl)
protected Record getOrNullIfExpired(Record record, long now, boolean backup)
record - Recordpublic boolean isExpired(Record record, long now, boolean backup)
protected void accessRecord(Record record, long now)
public String getName()
getName in interface RecordStorepublic MapContainer getMapContainer()
getMapContainer in interface RecordStorepublic long getHeapCost()
getHeapCost in interface RecordStoreprotected long getNow()
protected void accessRecord(Record record)
protected void updateSizeEstimator(long recordSize)
protected long calculateRecordHeapCost(Record record)
protected long calculateRecordHeapCost(Collection<Record> collection)
collection - size to be calculated.protected void resetSizeEstimator()
public int getPartitionId()
getPartitionId in interface RecordStoreprotected void saveIndex(Record record)
protected void removeIndex(Data key)
protected void removeIndexByPreservingKeys(Set<Data> keysToRemove, Set<Data> keysToPreserve)
keysToRemove - remove these keys from index.keysToPreserve - do not remove these keys.protected LockStore createLockStore()
protected void onStore(Record record)
protected com.hazelcast.map.impl.RecordStoreLoader createRecordStoreLoader()
public void setSizeEstimator(SizeEstimator sizeEstimator)
Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.