public class DefaultRecordStore extends Object implements RecordStore
Modifier and Type | Field and Description |
---|---|
protected static long |
DEFAULT_TTL |
protected boolean |
expirable
Flag for checking if this record store has at least one candidate entry
for expiration (idle or tll) or not.
|
protected Iterator<com.hazelcast.map.record.Record> |
expirationIterator
Iterates over a pre-set entry count/percentage in one round.
|
protected long |
lastEvictionTime
Last run time of cleanup operation.
|
protected long |
lruAccessSequenceNumber
used in LRU eviction logic.
|
protected MapContainer |
mapContainer |
protected MapServiceContext |
mapServiceContext |
protected String |
name |
protected int |
partitionId |
protected static int |
POST_READ_CHECK_POINT
Number of reads before clean up.
|
protected int |
readCountBeforeCleanUp
If there is no clean-up caused by puts after some time,
count a number of gets and start eviction.
|
protected com.hazelcast.map.record.RecordFactory |
recordFactory |
protected ConcurrentMap<Data,com.hazelcast.map.record.Record> |
records |
protected SerializationService |
serializationService |
Constructor and Description |
---|
DefaultRecordStore(MapContainer mapContainer,
int partitionId) |
Modifier and Type | Method and Description |
---|---|
protected void |
accessRecord(com.hazelcast.map.record.Record record) |
protected void |
accessRecord(com.hazelcast.map.record.Record record,
long now) |
protected long |
calculateRecordHeapCost(Collection<com.hazelcast.map.record.Record> collection)
Returns total heap cost of collection.
|
protected long |
calculateRecordHeapCost(com.hazelcast.map.record.Record record) |
boolean |
canAcquireLock(Data key,
String caller,
long threadId) |
void |
checkIfLoaded() |
int |
clear() |
void |
clearPartition() |
protected void |
clearRecordsMap(Map<Data,com.hazelcast.map.record.Record> excludeRecords) |
boolean |
containsKey(Data key) |
boolean |
containsValue(Object value) |
protected com.hazelcast.concurrent.lock.LockStore |
createLockStore() |
protected com.hazelcast.map.record.Record |
createRecord(Data key,
Object value,
long now) |
protected com.hazelcast.map.record.Record |
createRecord(Data key,
Object value,
long ttl,
long now) |
protected com.hazelcast.map.RecordStoreLoader |
createRecordStoreLoader() |
boolean |
delete(Data key) |
void |
deleteRecord(Data key) |
Set<Map.Entry<Data,Data>> |
entrySetData() |
Object |
evict(Data key,
boolean backup) |
int |
evictAll(boolean backup)
Evicts all keys except locked ones.
|
protected 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) |
MapEntrySet |
getAll(Set<Data> keys) |
long |
getHeapCost() |
String |
getLockOwnerInfo(Data key) |
MapContainer |
getMapContainer() |
com.hazelcast.map.mapstore.MapDataStore<Data,Object> |
getMapDataStore() |
Map.Entry<Data,Object> |
getMapEntry(Data key) |
Map.Entry<Data,Object> |
getMapEntryForBackup(Data dataKey) |
String |
getName() |
protected long |
getNow() |
protected com.hazelcast.map.record.Record |
getOrNullIfExpired(com.hazelcast.map.record.Record record,
boolean backup)
Check if record is reachable according to ttl or idle times.
|
int |
getPartitionId() |
com.hazelcast.map.record.Record |
getRecord(Data key) |
Map<Data,com.hazelcast.map.record.Record> |
getRecordMap()
Returns records map.
|
protected void |
increaseRecordEvictionCriteriaNumber(com.hazelcast.map.record.Record record,
MapConfig.EvictionPolicy evictionPolicy) |
boolean |
isEmpty() |
boolean |
isExpirable() |
boolean |
isLoaded() |
boolean |
isLocked(Data dataKey) |
Iterator<com.hazelcast.map.record.Record> |
iterator()
Iterates over record store values.
|
Set<Data> |
keySet() |
void |
loadAllFromStore(List<Data> keys,
boolean replaceExistingValues)
Loads all keys from defined map store.
|
Iterator<com.hazelcast.map.record.Record> |
loadAwareIterator()
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(com.hazelcast.map.record.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) |
com.hazelcast.map.record.Record |
putBackup(Data key,
Object value) |
com.hazelcast.map.record.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,
com.hazelcast.map.record.Record record)
Puts a data key and a record value to record-store.
|
void |
putTransient(Data key,
Object value,
long ttl) |
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 value) |
boolean |
replace(Data key,
Object testValue,
Object newValue) |
void |
reset() |
protected void |
resetAccessSequenceNumber() |
protected void |
resetSizeEstimator() |
protected void |
saveIndex(com.hazelcast.map.record.Record record) |
boolean |
set(Data key,
Object value,
long ttl) |
void |
setLoaded(boolean loaded) |
protected void |
setRecordValue(com.hazelcast.map.record.Record record,
Object value,
long now) |
void |
setSizeEstimator(SizeEstimator sizeEstimator) |
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 |
updateSizeEstimator(long recordSize) |
protected void |
updateTtl(com.hazelcast.map.record.Record record,
long ttl) |
Collection<Data> |
valuesData() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
evictExpiredEntries, getHeapCost, getMapContainer, getName, getPartitionId, isExpirable
protected static final int POST_READ_CHECK_POINT
protected volatile boolean expirable
protected Iterator<com.hazelcast.map.record.Record> expirationIterator
protected int readCountBeforeCleanUp
protected long lruAccessSequenceNumber
protected long lastEvictionTime
protected static final long DEFAULT_TTL
protected final ConcurrentMap<Data,com.hazelcast.map.record.Record> records
protected final com.hazelcast.map.record.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 RecordStore
public void setLoaded(boolean loaded)
setLoaded
in interface RecordStore
public void checkIfLoaded()
checkIfLoaded
in interface RecordStore
public void flush()
flush
in interface RecordStore
public com.hazelcast.map.record.Record getRecord(Data key)
getRecord
in interface RecordStore
public void putRecord(Data key, com.hazelcast.map.record.Record record)
RecordStore
putRecord
in interface RecordStore
key
- the data key to put record store.record
- the value for record store.com.hazelcast.map.operation.MapReplicationOperation}
public com.hazelcast.map.record.Record putBackup(Data key, Object value)
putBackup
in interface RecordStore
public com.hazelcast.map.record.Record putBackup(Data key, Object value, long ttl)
putBackup
in interface RecordStore
key
- 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 void deleteRecord(Data key)
deleteRecord
in interface RecordStore
public Iterator<com.hazelcast.map.record.Record> iterator()
RecordStore
iterator
in interface RecordStore
public Iterator<com.hazelcast.map.record.Record> loadAwareIterator()
RecordStore
IMap.keySet(com.hazelcast.query.Predicate)
,
this method can be used to return a read-only iterator.loadAwareIterator
in interface RecordStore
public Map<Data,com.hazelcast.map.record.Record> getRecordMap()
RecordStore
getRecordMap
in interface RecordStore
RecordStoreLoader
public void clearPartition()
clearPartition
in interface RecordStore
public int size()
size
in interface RecordStore
public boolean isEmpty()
isEmpty
in interface RecordStore
public boolean containsValue(Object value)
containsValue
in interface RecordStore
public boolean txnLock(Data key, String caller, long threadId, long ttl)
txnLock
in interface RecordStore
public boolean extendLock(Data key, String caller, long threadId, long ttl)
extendLock
in interface RecordStore
public boolean unlock(Data key, String caller, long threadId)
unlock
in interface RecordStore
public boolean forceUnlock(Data dataKey)
forceUnlock
in interface RecordStore
public boolean isLocked(Data dataKey)
isLocked
in interface RecordStore
public boolean canAcquireLock(Data key, String caller, long threadId)
canAcquireLock
in interface RecordStore
public String getLockOwnerInfo(Data key)
getLockOwnerInfo
in interface RecordStore
public Set<Map.Entry<Data,Data>> entrySetData()
entrySetData
in interface RecordStore
public Map.Entry<Data,Object> getMapEntry(Data key)
getMapEntry
in interface RecordStore
public Map.Entry<Data,Object> getMapEntryForBackup(Data dataKey)
getMapEntryForBackup
in interface RecordStore
public Set<Data> keySet()
keySet
in interface RecordStore
public Collection<Data> valuesData()
valuesData
in interface RecordStore
public int clear()
clear
in interface RecordStore
public void reset()
reset
in interface RecordStore
public Object evict(Data key, boolean backup)
evict
in interface RecordStore
public int evictAll(boolean backup)
RecordStore
evictAll
in interface RecordStore
backup
- true
if a backup partition, otherwise false
.public void removeBackup(Data key)
RecordStore
RecordStore.remove(com.hazelcast.nio.serialization.Data)
except removeBackup doesn't touch mapstore since it does not return previous value.removeBackup
in interface RecordStore
public Object remove(Data key)
remove
in interface RecordStore
public boolean remove(Data key, Object testValue)
remove
in interface RecordStore
public boolean delete(Data key)
delete
in interface RecordStore
public Object get(Data key)
get
in interface RecordStore
public MapEntrySet getAll(Set<Data> keys)
getAll
in interface RecordStore
public boolean containsKey(Data key)
containsKey
in interface RecordStore
public void put(Map.Entry<Data,Object> entry)
put
in interface RecordStore
public Object put(Data key, Object value, long ttl)
put
in interface RecordStore
public boolean set(Data key, Object value, long ttl)
set
in interface RecordStore
public boolean merge(Data key, EntryView mergingEntry, MapMergePolicy mergePolicy)
merge
in interface RecordStore
public Object replace(Data key, Object value)
replace
in interface RecordStore
public boolean replace(Data key, Object testValue, Object newValue)
replace
in interface RecordStore
public void putTransient(Data key, Object value, long ttl)
putTransient
in interface RecordStore
public Object putFromLoad(Data key, Object value)
RecordStore
putFromLoad
in interface RecordStore
key
- key to put.value
- to put.com.hazelcast.map.operation.PutFromLoadAllOperation}
public Object putFromLoad(Data key, Object value, long ttl)
RecordStore
putFromLoad
in interface RecordStore
key
- key to put.value
- to put.ttl
- time to live seconds.com.hazelcast.map.operation.PutAllOperation}
public boolean tryPut(Data key, Object value, long ttl)
tryPut
in interface RecordStore
public Object putIfAbsent(Data key, Object value, long ttl)
putIfAbsent
in interface RecordStore
public void loadAllFromStore(List<Data> keys, boolean replaceExistingValues)
RecordStore
loadAllFromStore
in interface RecordStore
keys
- keys to be loaded.replaceExistingValues
- true
if need to replace existing values otherwise false
public com.hazelcast.map.mapstore.MapDataStore<Data,Object> getMapDataStore()
getMapDataStore
in interface RecordStore
public void evictExpiredEntries(int percentage, boolean backup)
RecordStore
percentage
- 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()
protected void evictEntries(long now, boolean backup)
now
- now in time.protected void postReadCleanUp(long now, boolean backup)
now
- now.protected void markRecordStoreExpirable(long ttl)
protected com.hazelcast.map.record.Record getOrNullIfExpired(com.hazelcast.map.record.Record record, boolean backup)
record
- Record
protected void increaseRecordEvictionCriteriaNumber(com.hazelcast.map.record.Record record, MapConfig.EvictionPolicy evictionPolicy)
protected void accessRecord(com.hazelcast.map.record.Record record, long now)
public String getName()
getName
in interface RecordStore
public MapContainer getMapContainer()
getMapContainer
in interface RecordStore
public long getHeapCost()
getHeapCost
in interface RecordStore
protected long getNow()
protected com.hazelcast.map.record.Record createRecord(Data key, Object value, long ttl, long now)
protected com.hazelcast.map.record.Record createRecord(Data key, Object value, long now)
protected void accessRecord(com.hazelcast.map.record.Record record)
protected void updateSizeEstimator(long recordSize)
protected long calculateRecordHeapCost(com.hazelcast.map.record.Record record)
protected long calculateRecordHeapCost(Collection<com.hazelcast.map.record.Record> collection)
collection
- size to be calculated.protected void resetSizeEstimator()
protected void setRecordValue(com.hazelcast.map.record.Record record, Object value, long now)
public int getPartitionId()
getPartitionId
in interface RecordStore
protected void saveIndex(com.hazelcast.map.record.Record record)
protected void updateTtl(com.hazelcast.map.record.Record record, long ttl)
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 com.hazelcast.concurrent.lock.LockStore createLockStore()
protected void onStore(com.hazelcast.map.record.Record record)
protected com.hazelcast.map.RecordStoreLoader createRecordStoreLoader()
protected void clearRecordsMap(Map<Data,com.hazelcast.map.record.Record> excludeRecords)
public void setSizeEstimator(SizeEstimator sizeEstimator)
Copyright © 2014 Hazelcast, Inc.. All Rights Reserved.