Search in sources :

Example 6 with Record

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

the class BasePutOperation method publishWANReplicationEvent.

private void publishWANReplicationEvent(MapEventPublisher mapEventPublisher, Object value) {
    if (!mapContainer.isWanReplicationEnabled()) {
        return;
    }
    Record record = recordStore.getRecord(dataKey);
    if (record == null) {
        return;
    }
    final Data valueConvertedData = mapServiceContext.toData(value);
    final EntryView entryView = EntryViews.createSimpleEntryView(dataKey, valueConvertedData, record);
    mapEventPublisher.publishWanReplicationUpdate(name, entryView);
}
Also used : EntryView(com.hazelcast.core.EntryView) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data)

Example 7 with Record

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

the class PartitionWideEntryBackupOperation method run.

@Override
public void run() {
    long now = getNow();
    boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
    SerializationService serializationService = getNodeEngine().getSerializationService();
    Iterator<Record> iterator = recordStore.iterator(now, true);
    while (iterator.hasNext()) {
        Record record = iterator.next();
        Data dataKey = record.getKey();
        Object oldValue = record.getValue();
        Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
        if (!applyPredicate(dataKey, value)) {
            continue;
        }
        Map.Entry entry = createMapEntry(dataKey, value);
        processBackup(entry);
        if (noOp(entry, oldValue)) {
            continue;
        }
        if (entryRemovedBackup(entry, dataKey)) {
            continue;
        }
        entryAddedOrUpdatedBackup(entry, dataKey);
        evict(dataKey);
    }
    publishWanReplicationEventBackups();
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data) Map(java.util.Map)

Example 8 with Record

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

the class PartitionWideEntryOperation method run.

@Override
public void run() {
    long now = getNow();
    boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
    SerializationService serializationService = getNodeEngine().getSerializationService();
    responses = new MapEntries(recordStore.size());
    Iterator<Record> iterator = recordStore.iterator(now, false);
    while (iterator.hasNext()) {
        Record record = iterator.next();
        Data dataKey = record.getKey();
        Object oldValue = record.getValue();
        Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
        if (!applyPredicate(dataKey, value)) {
            continue;
        }
        Map.Entry entry = createMapEntry(dataKey, value);
        Data response = process(entry);
        if (response != null) {
            responses.add(dataKey, response);
        }
        // first call noOp, other if checks below depends on it.
        if (noOp(entry, oldValue, now)) {
            continue;
        }
        if (entryRemoved(entry, dataKey, oldValue, now)) {
            continue;
        }
        entryAddedOrUpdated(entry, dataKey, oldValue, now);
        evict(dataKey);
    }
}
Also used : MapEntries(com.hazelcast.map.impl.MapEntries) SerializationService(com.hazelcast.spi.serialization.SerializationService) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data) Map(java.util.Map)

Example 9 with Record

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

the class PutBackupOperation method publishWANReplicationEventBackup.

private void publishWANReplicationEventBackup(MapServiceContext mapServiceContext, MapEventPublisher mapEventPublisher) {
    if (!mapContainer.isWanReplicationEnabled()) {
        return;
    }
    Record record = recordStore.getRecord(dataKey);
    if (record == null) {
        return;
    }
    final Data valueConvertedData = mapServiceContext.toData(dataValue);
    final EntryView entryView = EntryViews.createSimpleEntryView(dataKey, valueConvertedData, record);
    mapEventPublisher.publishWanReplicationUpdateBackup(name, entryView);
}
Also used : EntryView(com.hazelcast.core.EntryView) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data)

Example 10 with Record

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

the class AbstractEvictableRecordStore method evictExpiredEntriesInternal.

private int evictExpiredEntriesInternal(int maxIterationCount, long now, boolean backup) {
    int evictedCount = 0;
    int checkedEntryCount = 0;
    initExpirationIterator();
    while (expirationIterator.hasNext()) {
        if (checkedEntryCount >= maxIterationCount) {
            break;
        }
        checkedEntryCount++;
        Record record = expirationIterator.next();
        record = getOrNullIfExpired(record, now, backup);
        if (record == null) {
            evictedCount++;
        }
    }
    return evictedCount;
}
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