Search in sources :

Example 96 with Record

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;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 97 with Record

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;
}
Also used : DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) MergingValueFactory.createMergingEntry(com.hazelcast.spi.impl.merge.MergingValueFactory.createMergingEntry) Set(java.util.Set) MetadataAwareValue(com.hazelcast.map.EntryLoader.MetadataAwareValue) 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 98 with Record

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

Example 99 with Record

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;
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record) EventService(com.hazelcast.spi.impl.eventservice.EventService)

Example 100 with Record

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

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