Search in sources :

Example 86 with Record

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

the class MapReplicationStateHolder method forEachReplicatedRecord.

private void forEachReplicatedRecord(List keyRecordExpiry, MapContainer mapContainer, RecordStore recordStore, boolean populateIndexes, long nowInMillis) {
    long ownedEntryCountOnThisNode = entryCountOnThisNode(mapContainer);
    EvictionConfig evictionConfig = mapContainer.getMapConfig().getEvictionConfig();
    boolean perNodeEvictionConfigured = mapContainer.getEvictor() != Evictor.NULL_EVICTOR && evictionConfig.getMaxSizePolicy() == PER_NODE;
    for (int i = 0; i < keyRecordExpiry.size(); i += 3) {
        Data dataKey = (Data) keyRecordExpiry.get(i);
        Record record = (Record) keyRecordExpiry.get(i + 1);
        ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyRecordExpiry.get(i + 2);
        if (perNodeEvictionConfigured) {
            if (ownedEntryCountOnThisNode >= evictionConfig.getSize()) {
                if (operation.getReplicaIndex() == 0) {
                    recordStore.doPostEvictionOperations(dataKey, record.getValue(), ExpiryReason.NOT_EXPIRED);
                }
            } else {
                recordStore.putOrUpdateReplicatedRecord(dataKey, record, expiryMetadata, populateIndexes, nowInMillis);
                ownedEntryCountOnThisNode++;
            }
        } else {
            recordStore.putOrUpdateReplicatedRecord(dataKey, record, expiryMetadata, populateIndexes, nowInMillis);
            if (recordStore.shouldEvict()) {
                // No need to continue replicating records anymore.
                // We are already over eviction threshold, each put record will cause another eviction.
                recordStore.evictEntries(dataKey);
                break;
            }
        }
        recordStore.disposeDeferredBlocks();
    }
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 87 with Record

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

the class MergeOperation method toBackupListByRemovingEvictedRecords.

/**
 * Since records may get evicted on NOOME after
 * they have been merged. We are re-checking
 * backup pair list to eliminate evicted entries.
 *
 * @return list of existing records which can
 * safely be transferred to backup replica.
 */
@Nonnull
private List toBackupListByRemovingEvictedRecords() {
    List toBackupList = new ArrayList(backupPairs.size());
    for (int i = 0; i < backupPairs.size(); i += 2) {
        Data dataKey = ((Data) backupPairs.get(i));
        Record record = recordStore.getRecord(dataKey);
        if (record != null) {
            toBackupList.add(dataKey);
            toBackupList.add(backupPairs.get(i + 1));
            toBackupList.add(record);
            toBackupList.add(recordStore.getExpirySystem().getExpiryMetadata(dataKey));
        }
    }
    return toBackupList;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) Nonnull(javax.annotation.Nonnull)

Example 88 with Record

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

the class PutAllBackupOperation method putBackup.

private void putBackup(Data key, Record record, ExpiryMetadata expiryMetadata) {
    Record currentRecord = recordStore.putBackup(key, record, expiryMetadata.getTtl(), expiryMetadata.getMaxIdle(), expiryMetadata.getExpirationTime(), getCallerProvenance());
    Records.copyMetadataFrom(record, currentRecord);
    publishWanUpdate(key, record.getValue());
    evict(key);
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 89 with Record

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

the class MapChunk method putOrUpdateReplicatedDataWithPerNodeEviction.

// owned or backup
private void putOrUpdateReplicatedDataWithPerNodeEviction(RecordStore recordStore) {
    MapContainer mapContainer = recordStore.getMapContainer();
    EvictionConfig evictionConfig = mapContainer.getMapConfig().getEvictionConfig();
    long ownedEntryCountOnThisNode = entryCountOnThisNode(mapContainer);
    int count = 0;
    long nowInMillis = Clock.currentTimeMillis();
    do {
        Data dataKey = (Data) keyRecordExpiry.poll();
        Record record = (Record) keyRecordExpiry.poll();
        ExpiryMetadata expiryMetadata = (ExpiryMetadata) keyRecordExpiry.poll();
        if (ownedEntryCountOnThisNode >= evictionConfig.getSize()) {
            if (getReplicaIndex() == 0) {
                recordStore.doPostEvictionOperations(dataKey, record.getValue(), ExpiryReason.NOT_EXPIRED);
            }
        } else {
            Indexes indexes = mapContainer.getIndexes(recordStore.getPartitionId());
            recordStore.putOrUpdateReplicatedRecord(dataKey, record, expiryMetadata, indexesMustBePopulated(indexes), nowInMillis);
            ownedEntryCountOnThisNode++;
        }
        if (++count % DISPOSE_AT_COUNT == 0) {
            recordStore.disposeDeferredBlocks();
        }
    } while (!keyRecordExpiry.isEmpty());
    recordStore.disposeDeferredBlocks();
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig) Data(com.hazelcast.internal.serialization.Data) Record(com.hazelcast.map.impl.record.Record) Indexes(com.hazelcast.query.impl.Indexes) MapContainer(com.hazelcast.map.impl.MapContainer) ExpiryMetadata(com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)

Example 90 with Record

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

the class TxnSetBackupOperation method runInternal.

@Override
protected void runInternal() {
    Record currentRecord = recordStore.putBackupTxn(dataKey, record, expiryMetadata, isPutTransient(), getCallerProvenance(), transactionId);
    Records.copyMetadataFrom(record, currentRecord);
    recordStore.forceUnlock(dataKey);
}
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