Search in sources :

Example 11 with Record

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

the class AbstractRecordStore method createRecord.

@Override
public Record createRecord(Object value, long ttlMillis, long now) {
    MapConfig mapConfig = mapContainer.getMapConfig();
    Record record = recordFactory.newRecord(value);
    record.setCreationTime(now);
    record.setLastUpdateTime(now);
    final long ttlMillisFromConfig = calculateTTLMillis(mapConfig);
    final long ttl = pickTTL(ttlMillis, ttlMillisFromConfig);
    record.setTtl(ttl);
    final long maxIdleMillis = calculateMaxIdleMillis(mapConfig);
    setExpirationTime(record, maxIdleMillis);
    updateStatsOnPut(true, now);
    return record;
}
Also used : Record(com.hazelcast.map.impl.record.Record) MapConfig(com.hazelcast.config.MapConfig)

Example 12 with Record

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

the class DefaultRecordStore method removeRecords.

protected int removeRecords(Collection<Record> recordsToRemove) {
    if (CollectionUtil.isEmpty(recordsToRemove)) {
        return 0;
    }
    int removalSize = recordsToRemove.size();
    Iterator<Record> iterator = recordsToRemove.iterator();
    while (iterator.hasNext()) {
        Record record = iterator.next();
        storage.removeRecord(record);
        updateStatsOnRemove(record.getHits());
        iterator.remove();
    }
    return removalSize;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 13 with Record

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

the class DefaultRecordStore method getNotLockedRecords.

protected Collection<Record> getNotLockedRecords() {
    Set<Data> lockedKeySet = lockStore == null ? null : lockStore.getLockedKeys();
    if (CollectionUtil.isEmpty(lockedKeySet)) {
        return storage.values();
    }
    int notLockedKeyCount = storage.size() - lockedKeySet.size();
    if (notLockedKeyCount <= 0) {
        return emptyList();
    }
    List<Record> notLockedRecords = new ArrayList<Record>(notLockedKeyCount);
    Collection<Record> records = storage.values();
    for (Record record : records) {
        if (!lockedKeySet.contains(record.getKey())) {
            notLockedRecords.add(record);
        }
    }
    return notLockedRecords;
}
Also used : ArrayList(java.util.ArrayList) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) Data(com.hazelcast.nio.serialization.Data) Record(com.hazelcast.map.impl.record.Record)

Example 14 with Record

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

the class DefaultRecordStore method putBackup.

@Override
public Record putBackup(Data key, Object value, long ttl, boolean putTransient) {
    final long now = getNow();
    markRecordStoreExpirable(ttl);
    Record record = getRecordOrNull(key, now, true);
    if (record == null) {
        record = createRecord(value, ttl, now);
        storage.put(key, record);
    } else {
        updateRecord(key, record, value, now);
    }
    if (putTransient) {
        mapDataStore.addTransient(key, now);
    } else {
        mapDataStore.addBackup(key, value, now);
    }
    return record;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 15 with Record

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

the class DefaultRecordStore method removeBackup.

@Override
public void removeBackup(Data key) {
    final long now = getNow();
    final Record record = getRecordOrNull(key, now, true);
    if (record == null) {
        return;
    }
    storage.removeRecord(record);
    updateStatsOnRemove(record.getHits());
    mapDataStore.removeBackup(key, now);
}
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