use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method evict.
@Override
public Object evict(Data key, boolean backup) {
Record record = storage.get(key);
Object value = null;
if (record != null) {
value = record.getValue();
mapDataStore.flush(key, value, backup);
mutationObserver.onEvictRecord(key, record);
removeKeyFromExpirySystem(key);
storage.removeRecord(key, record);
if (!backup) {
mapServiceContext.interceptRemove(interceptorRegistry, value);
}
}
return value;
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method loadEntries.
private Map<Data, Object> loadEntries(Set<Data> keys, Address callerAddress) {
Map loadedEntries = mapDataStore.loadAll(keys);
if (isNullOrEmpty(loadedEntries)) {
return Collections.emptyMap();
}
// holds serialized keys and if values are
// serialized, also holds them in serialized format.
Map<Data, Object> resultMap = createHashMap(loadedEntries.size());
// add loaded key-value pairs to this record-store.
Set entrySet = loadedEntries.entrySet();
for (Object object : entrySet) {
Map.Entry entry = (Map.Entry) object;
Data key = toData(entry.getKey());
Object value = entry.getValue();
if (mapDataStore.isWithExpirationTime()) {
MetadataAwareValue loaderEntry = (MetadataAwareValue) value;
if (expirationTimeToTtl(loaderEntry.getExpirationTime()) > 0) {
resultMap.put(key, loaderEntry.getValue());
}
putFromLoad(key, loaderEntry.getValue(), loaderEntry.getExpirationTime(), callerAddress);
} else {
resultMap.put(key, value);
putFromLoad(key, value, callerAddress);
}
}
if (hasQueryCache()) {
for (Data key : resultMap.keySet()) {
Record record = storage.get(key);
// here we are only publishing events for loaded
// entries. This is required for notifying query-caches
// otherwise query-caches cannot see loaded entries
addEventToQueryCache(key, record);
}
}
return resultMap;
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class TxnLockAndGetOperation method runInternal.
@Override
protected void runInternal() {
if (!recordStore.txnLock(getKey(), ownerUuid, getThreadId(), getCallId(), ttl, blockReads)) {
throw new TransactionException("Transaction couldn't obtain lock.");
}
Record record = recordStore.getRecordOrNull(dataKey);
if (record == null && shouldLoad) {
record = recordStore.loadRecordOrNull(dataKey, false, getCallerAddress());
}
Data value = record == null ? null : mapServiceContext.toData(record.getValue());
response = new VersionedValue(value, record == null ? 0 : record.getVersion());
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class TxnSetOperation method runInternal.
@Override
protected void runInternal() {
recordStore.unlock(dataKey, ownerUuid, threadId, getCallId());
Record record = recordStore.getRecordOrNull(dataKey);
if (record == null || version == record.getVersion()) {
EventService eventService = getNodeEngine().getEventService();
if (eventService.hasEventRegistration(MapService.SERVICE_NAME, getName())) {
oldValue = record == null ? null : mapServiceContext.toData(record.getValue());
}
eventType = record == null ? EntryEventType.ADDED : EntryEventType.UPDATED;
recordStore.setTxn(dataKey, dataValue, ttl, UNSET, transactionId);
shouldBackup = true;
}
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class TxnSetOperation method getBackupOperation.
@Override
public Operation getBackupOperation() {
Record record = recordStore.getRecord(dataKey);
dataValue = getValueOrPostProcessedValue(record, dataValue);
ExpiryMetadata expiryMetadata = recordStore.getExpirySystem().getExpiryMetadata(dataKey);
return new TxnSetBackupOperation(name, dataKey, record, dataValue, expiryMetadata, transactionId);
}
Aggregations