use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class PutAllBackupOperation method runInternal.
@Override
@SuppressWarnings("checkstyle:magicnumber")
protected void runInternal() {
List keyRecordExpiry = this.keyRecordExpiry;
if (keyRecordExpiry != null) {
for (int i = lastIndex; i < keyRecordExpiry.size(); i += 3) {
Data key = (Data) keyRecordExpiry.get(i);
Record record = (Record) keyRecordExpiry.get(i + 1);
ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyRecordExpiry.get(i + 2);
putBackup(key, record, expiryMetadata);
lastIndex = i;
}
} else {
// If dataKeyRecord is null and we are in
// `runInternal` method, means this operation
// has not been serialized/deserialized
// and is running directly on caller node
List keyValueRecordExpiry = this.keyValueRecordExpiry;
for (int i = lastIndex; i < keyValueRecordExpiry.size(); i += 4) {
Data key = (Data) keyValueRecordExpiry.get(i);
Record record = (Record) keyValueRecordExpiry.get(i + 2);
ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyValueRecordExpiry.get(i + 3);
putBackup(key, record, expiryMetadata);
lastIndex = i;
}
}
}
use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class PutAllBackupOperation method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
super.readInternal(in);
int size = in.readInt();
List keyRecordExpiry = new ArrayList<>(size * 3);
for (int i = 0; i < size; i++) {
Data dataKey = IOUtil.readData(in);
Record record = Records.readRecord(in);
ExpiryMetadata expiryMetadata = Records.readExpiry(in);
keyRecordExpiry.add(dataKey);
keyRecordExpiry.add(record);
keyRecordExpiry.add(expiryMetadata);
}
this.keyRecordExpiry = keyRecordExpiry;
this.disableWanReplicationEvent = in.readBoolean();
}
use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class GetEntryViewOperation method runInternal.
@Override
protected void runInternal() {
Record record = recordStore.getRecordOrNull(dataKey);
if (record != null) {
Data value = mapServiceContext.toData(record.getValue());
ExpiryMetadata expiryMetadata = recordStore.getExpirySystem().getExpiryMetadata(dataKey);
result = EntryViews.createSimpleEntryView(dataKey, value, record, expiryMetadata);
}
}
use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class AbstractEvictableRecordStore method mergeRecordExpiration.
protected void mergeRecordExpiration(Data key, Record record, MapMergeTypes mergingEntry, long now) {
mergeRecordExpiration(record, mergingEntry.getCreationTime(), mergingEntry.getLastAccessTime(), mergingEntry.getLastUpdateTime());
// WAN events received from source cluster also carry null maxIdle
// see com.hazelcast.map.impl.wan.WanMapEntryView.getMaxIdle
Long maxIdle = mergingEntry.getMaxIdle();
if (maxIdle != null) {
getExpirySystem().add(key, mergingEntry.getTtl(), maxIdle, mergingEntry.getExpirationTime(), mergingEntry.getLastUpdateTime(), now);
} else {
ExpiryMetadata expiryMetadata = getExpirySystem().getExpiryMetadata(key);
getExpirySystem().add(key, mergingEntry.getTtl(), expiryMetadata.getMaxIdle(), mergingEntry.getExpirationTime(), mergingEntry.getLastUpdateTime(), now);
}
}
use of com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata in project hazelcast by hazelcast.
the class DefaultRecordStore method merge.
@Override
public boolean merge(MapMergeTypes<Object, Object> mergingEntry, SplitBrainMergePolicy<Object, MapMergeTypes<Object, Object>, Object> mergePolicy, CallerProvenance provenance) {
checkIfLoaded();
long now = getNow();
mergingEntry = (MapMergeTypes<Object, Object>) serializationService.getManagedContext().initialize(mergingEntry);
mergePolicy = (SplitBrainMergePolicy<Object, MapMergeTypes<Object, Object>, Object>) serializationService.getManagedContext().initialize(mergePolicy);
Data key = (Data) mergingEntry.getRawKey();
Record record = getRecordOrNull(key, now, false);
Object newValue;
Object oldValue;
if (record == null) {
newValue = mergePolicy.merge(mergingEntry, null);
if (newValue == null) {
return false;
}
boolean persist = persistenceEnabledFor(provenance);
putNewRecord(key, null, newValue, UNSET, UNSET, UNSET, now, null, ADDED, persist, false);
} else {
oldValue = record.getValue();
ExpiryMetadata expiryMetadata = expirySystem.getExpiryMetadata(key);
MapMergeTypes<Object, Object> existingEntry = createMergingEntry(serializationService, key, record, expiryMetadata);
newValue = mergePolicy.merge(mergingEntry, existingEntry);
// existing entry will be removed
if (newValue == null) {
if (persistenceEnabledFor(provenance)) {
mapDataStore.remove(key, now, null);
}
onStore(record);
mutationObserver.onRemoveRecord(key, record);
removeKeyFromExpirySystem(key);
storage.removeRecord(key, record);
return true;
}
if (valueComparator.isEqual(newValue, oldValue, serializationService)) {
mergeRecordExpiration(key, record, mergingEntry, now);
return true;
}
boolean persist = persistenceEnabledFor(provenance);
updateRecord(record, key, oldValue, newValue, UNSET, UNSET, UNSET, now, null, persist, true, false);
}
return newValue != null;
}
Aggregations