|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hazelcast.map.impl.DefaultRecordStore
public class DefaultRecordStore
Default implementation of record-store.
Field Summary | |
---|---|
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 Summary | |
---|---|
DefaultRecordStore(MapContainer mapContainer,
int partitionId)
|
Method Summary | |
---|---|
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()
|
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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.hazelcast.map.impl.RecordStore |
---|
evictEntries, evictExpiredEntries, getHeapCost, getMapContainer, getName, getPartitionId, isExpirable |
Field Detail |
---|
protected 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
Constructor Detail |
---|
public DefaultRecordStore(MapContainer mapContainer, int partitionId)
Method Detail |
---|
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 Record getRecord(Data key)
getRecord
in interface RecordStore
public void putRecord(Data key, Record record)
RecordStore
putRecord
in interface RecordStore
key
- the data key to put record store.record
- the value for record store.MapReplicationOperation
public Record putBackup(Data key, Object value)
putBackup
in interface RecordStore
public 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 Iterator<Record> iterator()
RecordStore
iterator
in interface RecordStore
public Iterator<Record> iterator(long now, boolean backup)
RecordStore
iterator
in interface RecordStore
public Iterator<Record> loadAwareIterator(long now, boolean backup)
RecordStore
IMap.keySet(com.hazelcast.query.Predicate)
,
this method can be used to return a read-only iterator.
loadAwareIterator
in interface RecordStore
now
- current time in millisbackup
- true
if a backup partition, otherwise false
.
public Map<Data,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 isTransactionallyLocked(Data key)
isTransactionallyLocked
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, long now)
getMapEntry
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, boolean backup)
RecordStore
RecordStore
.
Loads missing keys from map store.
get
in interface RecordStore
key
- key.backup
- true
if a backup partition, otherwise false
.
RecordStore
public Data readBackupData(Data key)
RecordStore
MapConfig.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 RecordStore
key
- key to be accessed
Data
independent of InMemoryFormat
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 update)
replace
in interface RecordStore
public boolean replace(Data key, Object expect, Object update)
RecordStore
RecordFactory.isEquals(java.lang.Object, java.lang.Object)
comparison
of current value and expected value is true
.
replace
in interface RecordStore
key
- key which's value is requested to be replaced.expect
- the expected valueupdate
- the new value
true
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 RecordStore
public Object putFromLoad(Data key, Object value)
RecordStore
putFromLoad
in interface RecordStore
key
- key to put.value
- to put.
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.
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 MapDataStore<Data,Object> getMapDataStore()
getMapDataStore
in interface RecordStore
public Record getRecordOrNull(Data key)
RecordStore
getRecordOrNull
in interface RecordStore
key
- key to be accessed
RecordStore.get(com.hazelcast.nio.serialization.Data, boolean)
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()
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
- Record
public boolean isExpired(Record record, long now, boolean backup)
protected void accessRecord(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 Record createRecord(Data key, Object value, long ttl, long now)
protected Record createRecord(Data key, Object value, long now)
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()
protected void updateRecord(Record record, Object value, long now)
public int getPartitionId()
getPartitionId
in interface RecordStore
protected void saveIndex(Record record)
protected void removeIndex(Data key)
protected void removeIndex(Set<Data> keys)
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()
protected void clearRecordsMap(Map<Data,Record> excludeRecords)
protected Data toData(Object value)
public void setSizeEstimator(SizeEstimator sizeEstimator)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |