Search in sources :

Example 61 with Record

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

the class DefaultRecordStore method putTransient.

@Override
public Object putTransient(Data key, Object value, long ttl) {
    checkIfLoaded();
    final long now = getNow();
    markRecordStoreExpirable(ttl);
    Record record = getRecordOrNull(key, now, false);
    Object oldValue = null;
    if (record == null) {
        value = mapServiceContext.interceptPut(name, null, value);
        record = createRecord(value, ttl, now);
        storage.put(key, record);
    } else {
        oldValue = record.getValue();
        value = mapServiceContext.interceptPut(name, oldValue, value);
        updateRecord(key, record, value, now);
        updateExpiryTime(record, ttl, mapContainer.getMapConfig());
    }
    saveIndex(record, oldValue);
    mapDataStore.addTransient(key, now);
    return oldValue;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 62 with Record

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

the class DefaultRecordStore method keySet.

@Override
public Set<Data> keySet() {
    checkIfLoaded();
    long now = getNow();
    Collection<Record> records = storage.values();
    Set<Data> keySet = EMPTY_SET;
    for (Record record : records) {
        Data key = record.getKey();
        record = getOrNullIfExpired(record, now, false);
        if (record == null) {
            continue;
        }
        if (keySet == EMPTY_SET) {
            keySet = new HashSet<Data>();
        }
        keySet.add(key);
    }
    return keySet;
}
Also used : Record(com.hazelcast.map.impl.record.Record) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) Data(com.hazelcast.nio.serialization.Data)

Example 63 with Record

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

the class DefaultRecordStore method clearPartition.

@Override
public void clearPartition(boolean onShutdown) {
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        final DefaultObjectNamespace namespace = new DefaultObjectNamespace(MapService.SERVICE_NAME, name);
        lockService.clearLockStore(partitionId, namespace);
    }
    Indexes indexes = mapContainer.getIndexes();
    if (indexes.hasIndex()) {
        for (Record record : storage.values()) {
            Data key = record.getKey();
            Object value = Records.getValueOrCachedValue(record, serializationService);
            indexes.removeEntryIndex(key, value);
        }
    }
    mapDataStore.reset();
    if (onShutdown) {
        NativeMemoryConfig nativeMemoryConfig = nodeEngine.getConfig().getNativeMemoryConfig();
        boolean shouldClear = (nativeMemoryConfig != null && nativeMemoryConfig.getAllocatorType() != POOLED);
        if (shouldClear) {
            storage.clear(true);
        }
        storage.destroy(true);
    } else {
        storage.clear(false);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) DefaultObjectNamespace(com.hazelcast.spi.DefaultObjectNamespace) LockService(com.hazelcast.concurrent.lock.LockService) Record(com.hazelcast.map.impl.record.Record) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) Data(com.hazelcast.nio.serialization.Data) Indexes(com.hazelcast.query.impl.Indexes)

Example 64 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 65 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)

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