Search in sources :

Example 91 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class DefaultRecordStore method readBackupData.

/**
 * This method is called directly by user threads, in other words
 * it is called outside of the partition threads.
 */
@Override
public Data readBackupData(Data key) {
    Record record = getRecord(key);
    if (record == null) {
        return null;
    } else {
        if (partitionService.isPartitionOwner(partitionId)) {
            // set last access time to prevent
            // premature removal of the entry because
            // of idleness based expiry
            record.setLastAccessTime(getNow());
        }
    }
    Object value = record.getValue();
    mapServiceContext.interceptAfterGet(interceptorRegistry, value);
    // this serialization step is needed not to expose the object, see issue 1292
    return mapServiceContext.toData(value);
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 92 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class DefaultRecordStore method forEach.

@Override
public void forEach(BiConsumer<Data, Record> consumer, boolean backup, boolean includeExpiredRecords) {
    long now = getNow();
    Iterator<Map.Entry<Data, Record>> entries = storage.mutationTolerantIterator();
    while (entries.hasNext()) {
        Map.Entry<Data, Record> entry = entries.next();
        Data key = entry.getKey();
        Record record = entry.getValue();
        if (includeExpiredRecords || hasExpired(key, now, backup) == ExpiryReason.NOT_EXPIRED) {
            consumer.accept(key, record);
        }
    }
}
Also used : DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) MergingValueFactory.createMergingEntry(com.hazelcast.spi.impl.merge.MergingValueFactory.createMergingEntry) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) Map(java.util.Map) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap)

Example 93 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class DefaultRecordStore method removeOrEvictEntries.

private int removeOrEvictEntries(ArrayList<Data> dataKeys, ArrayList<Record> records, boolean eviction) {
    for (int i = 0; i < dataKeys.size(); i++) {
        Data dataKey = dataKeys.get(i);
        Record record = records.get(i);
        removeOrEvictEntry(dataKey, record, eviction);
    }
    return dataKeys.size();
}
Also used : EntryEventData(com.hazelcast.map.impl.event.EntryEventData) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record)

Example 94 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class DefaultRecordStore method delete.

@Override
public boolean delete(Data key, CallerProvenance provenance) {
    checkIfLoaded();
    long now = getNow();
    Record record = getRecordOrNull(key, now, false);
    if (record == null) {
        if (persistenceEnabledFor(provenance)) {
            mapDataStore.remove(key, now, null);
        }
    } else {
        return removeRecord(key, record, now, provenance, null) != null;
    }
    return false;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 95 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class DefaultRecordStore method putBackupInternal.

private Record putBackupInternal(Data key, Object value, long ttl, long maxIdle, long expiryTime, boolean putTransient, CallerProvenance provenance, UUID transactionId) {
    long now = getNow();
    putInternal(key, value, ttl, maxIdle, expiryTime, now, false, false, false, false, false, false, null, false, false, null, null, true, true);
    Record record = getRecord(key);
    if (persistenceEnabledFor(provenance)) {
        if (putTransient) {
            mapDataStore.addTransient(key, now);
        } else {
            mapDataStore.addBackup(key, value, expirySystem.getExpiryMetadata(key).getExpirationTime(), now, transactionId);
        }
    }
    return record;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Aggregations

Record (com.hazelcast.map.impl.record.Record)109 Data (com.hazelcast.internal.serialization.Data)27 Data (com.hazelcast.nio.serialization.Data)22 Map (java.util.Map)13 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)11 ExpiryMetadata (com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)11 EntryView (com.hazelcast.core.EntryView)8 Indexes (com.hazelcast.query.impl.Indexes)8 ArrayList (java.util.ArrayList)7 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)6 MapContainer (com.hazelcast.map.impl.MapContainer)6 DelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)6 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)6 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)6 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)5 MapService (com.hazelcast.map.impl.MapService)5 List (java.util.List)5 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)3 MapEntries (com.hazelcast.map.impl.MapEntries)3