Search in sources :

Example 46 with Record

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

the class TxnSetOperation method getBackupOperation.

public Operation getBackupOperation() {
    final Record record = recordStore.getRecord(dataKey);
    final RecordInfo replicationInfo = record != null ? Records.buildRecordInfo(record) : null;
    return new PutBackupOperation(name, dataKey, dataValue, replicationInfo, true, false);
}
Also used : RecordInfo(com.hazelcast.map.impl.record.RecordInfo) Record(com.hazelcast.map.impl.record.Record) PutBackupOperation(com.hazelcast.map.impl.operation.PutBackupOperation)

Example 47 with Record

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

the class TxnSetOperation method run.

@Override
public void run() {
    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())) {
            dataOldValue = record == null ? null : mapServiceContext.toData(record.getValue());
        }
        eventType = record == null ? EntryEventType.ADDED : EntryEventType.UPDATED;
        recordStore.set(dataKey, dataValue, ttl);
        shouldBackup = true;
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record) EventService(com.hazelcast.spi.EventService)

Example 48 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) {
    checkIfLoaded();
    final long now = getNow();
    final Record record = getRecordOrNull(key, now, false);
    if (record == null) {
        mapDataStore.remove(key, now);
    } else {
        return removeRecord(key, record, now) != null;
    }
    return false;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 49 with Record

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

the class DefaultRecordStore method readBackupData.

@Override
public Data readBackupData(Data key) {
    final long now = getNow();
    final Record record = getRecord(key);
    if (record == null) {
        return null;
    }
    // expiration has delay on backups, but reading backup data should not be affected by this delay.
    // this is the reason why we are passing `false` to isExpired() method.
    final boolean expired = isExpired(record, now, false);
    if (expired) {
        return null;
    }
    final MapServiceContext mapServiceContext = this.mapServiceContext;
    final Object value = record.getValue();
    mapServiceContext.interceptAfterGet(name, 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) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 50 with Record

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

the class DefaultRecordStore method loadRecordOrNull.

@Override
public Record loadRecordOrNull(Data key, boolean backup) {
    Record record = null;
    final Object value = mapDataStore.load(key);
    if (value != null) {
        record = createRecord(value, DEFAULT_TTL, getNow());
        storage.put(key, record);
        if (!backup) {
            saveIndex(record, null);
        }
        evictEntries(key);
    }
    // otherwise query-caches cannot see loaded entries
    if (!backup && record != null && hasQueryCache()) {
        addEventToQueryCache(record);
    }
    return record;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Aggregations

Record (com.hazelcast.map.impl.record.Record)58 Data (com.hazelcast.nio.serialization.Data)25 EntryView (com.hazelcast.core.EntryView)9 Map (java.util.Map)7 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)6 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)5 MapContainer (com.hazelcast.map.impl.MapContainer)4 RecordInfo (com.hazelcast.map.impl.record.RecordInfo)4 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)4 Indexes (com.hazelcast.query.impl.Indexes)4 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)3 SerializationService (com.hazelcast.spi.serialization.SerializationService)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 MapConfig (com.hazelcast.config.MapConfig)2 EntryEventType (com.hazelcast.core.EntryEventType)2 TestUtil.toData (com.hazelcast.instance.TestUtil.toData)2 MapEntries (com.hazelcast.map.impl.MapEntries)2 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)2