use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class SetTtlBackupOperation method afterRunInternal.
@Override
protected void afterRunInternal() {
Record record = recordStore.getRecord(dataKey);
if (record != null) {
publishWanUpdate(dataKey, record.getValue());
}
super.afterRunInternal();
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method putInternal.
/**
* Core put method for all variants of puts/updates.
*
* @return old value if this is an update operation, otherwise returns null
*/
@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:parameternumber", "checkstyle:cyclomaticcomplexity" })
private Object putInternal(Data key, Object newValue, long ttl, long maxIdle, long expiryTime, long now, boolean load, boolean store, boolean putIfAbsent, boolean putIfExists, boolean putIfEqual, boolean putFromLoad, Object expectedValue, boolean setTtl, boolean checkIfLoaded, @Nullable UUID transactionId, Address callerAddress, boolean countAsAccess, boolean backup) {
// If this method has to wait end of map loading.
if (checkIfLoaded) {
checkIfLoaded();
}
Object oldValue = null;
// Get record by checking expiry, if expired, evict record.
Record record = getRecordOrNull(key, now, backup);
// Variants of loading oldValue
if (!putIfAbsent && !putIfExists) {
oldValue = record == null ? (load ? loadValueOf(key) : null) : record.getValue();
} else if (putIfAbsent) {
record = getOrLoadRecord(record, key, now, callerAddress, backup);
// if this is an existing record, return existing value.
if (record != null) {
return record.getValue();
}
} else if (putIfExists) {
// For methods like setTtl and replace,
// when no matching record, just return.
record = getOrLoadRecord(record, key, now, callerAddress, backup);
if (record == null) {
return null;
}
oldValue = record.getValue();
newValue = setTtl ? oldValue : newValue;
}
// For method replace, if current value is not expected one, return.
if (putIfEqual && !valueComparator.isEqual(expectedValue, oldValue, serializationService)) {
return null;
}
// Intercept put on owner partition.
if (!backup) {
newValue = mapServiceContext.interceptPut(interceptorRegistry, oldValue, newValue);
}
// Put new record or update existing one.
if (record == null) {
putNewRecord(key, oldValue, newValue, ttl, maxIdle, expiryTime, now, transactionId, putFromLoad ? LOADED : ADDED, store, backup);
} else {
oldValue = updateRecord(record, key, oldValue, newValue, ttl, maxIdle, expiryTime, now, transactionId, store, countAsAccess, backup);
}
return oldValue;
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method getAll.
@Override
public MapEntries getAll(Set<Data> keys, Address callerAddress) {
checkIfLoaded();
long now = getNow();
MapEntries mapEntries = new MapEntries(keys.size());
// first search in memory
Iterator<Data> iterator = keys.iterator();
while (iterator.hasNext()) {
Data key = iterator.next();
Record record = getRecordOrNull(key, now, false);
if (record != null) {
addToMapEntrySet(key, record.getValue(), mapEntries);
accessRecord(key, record, now);
iterator.remove();
}
}
// then try to load missing keys from map-store
if (mapDataStore != EMPTY_MAP_DATA_STORE && !keys.isEmpty()) {
Map loadedEntries = loadEntries(keys, callerAddress);
addToMapEntrySet(loadedEntries, mapEntries);
}
return mapEntries;
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method removeBackupInternal.
private void removeBackupInternal(Data key, CallerProvenance provenance, UUID transactionId) {
long now = getNow();
Record record = getRecordOrNull(key, now, true);
if (record == null) {
return;
}
mutationObserver.onRemoveRecord(key, record);
removeKeyFromExpirySystem(key);
storage.removeRecord(key, record);
if (persistenceEnabledFor(provenance)) {
mapDataStore.removeBackup(key, now, transactionId);
}
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method get.
@Override
public Object get(Data key, boolean backup, Address callerAddress, boolean touch) {
checkIfLoaded();
long now = getNow();
Record record = getRecordOrNull(key, now, backup);
if (record != null && touch) {
accessRecord(key, record, now);
} else if (record == null && mapDataStore != EMPTY_MAP_DATA_STORE) {
record = loadRecordOrNull(key, backup, callerAddress);
record = evictIfExpired(key, now, backup) ? null : record;
}
Object value = record == null ? null : record.getValue();
value = mapServiceContext.interceptGet(interceptorRegistry, value);
return value;
}
Aggregations