|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.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,
MapKeyLoader keyLoader,
ILogger logger)
|
|
| 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(MapStoreContext mapStoreContext)
|
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 |
loadAll(boolean replaceExistingValues)
Loads all keys and values |
void |
loadAllFromStore(List<Data> keys,
boolean replaceExistingValues,
boolean lastBatch)
Loads all given 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)
|
void |
maybeDoInitialLoad()
Performs initial loading from a MapLoader if it has not been done before |
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,
boolean putTransient)
|
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 |
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. |
void |
startLoading()
|
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,
MapKeyLoader keyLoader,
ILogger logger)
| Method Detail |
|---|
public void startLoading()
public boolean isLoaded()
isLoaded in interface RecordStorepublic void loadAll(boolean replaceExistingValues)
RecordStore
loadAll in interface RecordStorereplaceExistingValues - true if need to replace existing values otherwise false
public void loadAllFromStore(List<Data> keys,
boolean replaceExistingValues,
boolean lastBatch)
RecordStore
loadAllFromStore in interface RecordStorekeys - keys to be loaded.replaceExistingValues - true if need to replace existing values otherwise falselastBatch - when keys are sent is batches this indicates the last batch. Used to indicate loading is complete.public void maybeDoInitialLoad()
RecordStore
maybeDoInitialLoad in interface RecordStorepublic void checkIfLoaded()
checkIfLoaded in interface RecordStorepublic void flush()
flush in interface RecordStorepublic Record getRecord(Data key)
getRecord in interface RecordStore
public void putRecord(Data key,
Record record)
RecordStore
putRecord in interface RecordStorekey - 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,
boolean putTransient)
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)putTransient - true if putting transient entry, otherwise false
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)
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()
RecordStore
getRecordMap 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 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 RecordStorepublic boolean forceUnlock(Data dataKey)
forceUnlock in interface RecordStorepublic boolean isLocked(Data dataKey)
isLocked in interface RecordStorepublic boolean isTransactionallyLocked(Data key)
isTransactionallyLocked in interface RecordStore
public 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 RecordStore
public 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 RecordStore
public Object evict(Data key,
boolean backup)
evict in interface RecordStorepublic int evictAll(boolean backup)
RecordStore
evictAll 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 RecordStore
public boolean remove(Data key,
Object testValue)
remove in interface RecordStorepublic boolean delete(Data key)
delete in interface RecordStore
public 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 accessed
Data
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 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)
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 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 RecordStorekey - key to put.value - to put.
PutFromLoadAllOperation
public Object putFromLoad(Data key,
Object value,
long ttl)
RecordStore
putFromLoad in interface RecordStorekey - 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 RecordStorepublic MapDataStore<Data,Object> getMapDataStore()
getMapDataStore in interface RecordStorepublic Record getRecordOrNull(Data key)
RecordStore
getRecordOrNull in interface RecordStorekey - 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 RecordStorepublic MapContainer getMapContainer()
getMapContainer in interface RecordStorepublic long getHeapCost()
getHeapCost in interface RecordStoreprotected 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 RecordStoreprotected 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(MapStoreContext mapStoreContext)
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 | |||||||||