Search in sources :

Example 6 with ExpiryMetadata

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;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 7 with ExpiryMetadata

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();
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 8 with ExpiryMetadata

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);
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.internal.serialization.Data) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 9 with 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);
    }
}
Also used : ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 10 with ExpiryMetadata

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;
}
Also used : MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Aggregations

ExpiryMetadata (com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)16 Data (com.hazelcast.internal.serialization.Data)13 Record (com.hazelcast.map.impl.record.Record)11 ArrayList (java.util.ArrayList)3 List (java.util.List)3 EvictionConfig (com.hazelcast.config.EvictionConfig)2 Indexes (com.hazelcast.query.impl.Indexes)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 LocalRecordStoreStatsImpl (com.hazelcast.internal.monitor.impl.LocalRecordStoreStatsImpl)1 ToHeapDataConverter.toHeapData (com.hazelcast.internal.util.ToHeapDataConverter.toHeapData)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 ExpiryMetadataImpl (com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadataImpl)1 MapMergeTypes (com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes)1 LinkedList (java.util.LinkedList)1