Search in sources :

Example 1 with Record

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

the class EntryBackupOperation method publishWanReplicationEvent.

private void publishWanReplicationEvent(EntryEventType eventType) {
    final MapContainer mapContainer = this.mapContainer;
    if (!mapContainer.isWanReplicationEnabled()) {
        return;
    }
    final MapEventPublisher mapEventPublisher = mapContainer.getMapServiceContext().getMapEventPublisher();
    final Data key = dataKey;
    if (EntryEventType.REMOVED == eventType) {
        mapEventPublisher.publishWanReplicationRemoveBackup(name, key, Clock.currentTimeMillis());
    } else {
        final Record record = recordStore.getRecord(key);
        if (record != null) {
            dataValue = mapContainer.getMapServiceContext().toData(dataValue);
            final EntryView entryView = createSimpleEntryView(key, dataValue, record);
            mapEventPublisher.publishWanReplicationUpdateBackup(name, entryView);
        }
    }
}
Also used : EntryView(com.hazelcast.core.EntryView) EntryViews.createSimpleEntryView(com.hazelcast.map.impl.EntryViews.createSimpleEntryView) Data(com.hazelcast.nio.serialization.Data) Record(com.hazelcast.map.impl.record.Record) MapContainer(com.hazelcast.map.impl.MapContainer) MapEventPublisher(com.hazelcast.map.impl.event.MapEventPublisher)

Example 2 with Record

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

the class EntryOperation method publishWanReplicationEvent.

private void publishWanReplicationEvent() {
    final MapContainer mapContainer = this.mapContainer;
    if (mapContainer.getWanReplicationPublisher() == null && mapContainer.getWanMergePolicy() == null) {
        return;
    }
    final Data key = dataKey;
    if (REMOVED.equals(eventType)) {
        mapEventPublisher.publishWanReplicationRemove(name, key, getNow());
    } else {
        final Record record = recordStore.getRecord(key);
        if (record != null) {
            dataValue = toData(dataValue);
            final EntryView entryView = createSimpleEntryView(key, dataValue, record);
            mapEventPublisher.publishWanReplicationUpdate(name, entryView);
        }
    }
}
Also used : EntryView(com.hazelcast.core.EntryView) EntryViews.createSimpleEntryView(com.hazelcast.map.impl.EntryViews.createSimpleEntryView) Data(com.hazelcast.nio.serialization.Data) Record(com.hazelcast.map.impl.record.Record) MapContainer(com.hazelcast.map.impl.MapContainer)

Example 3 with Record

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

the class GetEntryViewOperation method run.

@Override
public void run() {
    Record record = recordStore.getRecordOrNull(dataKey);
    if (record != null) {
        Data value = mapServiceContext.toData(record.getValue());
        result = EntryViews.createSimpleEntryView(dataKey, value, record);
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data)

Example 4 with Record

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

the class MapSplitBrainHandlerService method prepareMergeRunnable.

@Override
public Runnable prepareMergeRunnable() {
    final long now = getNow();
    final Map<String, MapContainer> mapContainers = getMapContainers();
    final Map<MapContainer, Collection<Record>> recordMap = new HashMap<MapContainer, Collection<Record>>(mapContainers.size());
    final IPartitionService partitionService = nodeEngine.getPartitionService();
    final int partitionCount = partitionService.getPartitionCount();
    final Address thisAddress = nodeEngine.getClusterService().getThisAddress();
    for (MapContainer mapContainer : mapContainers.values()) {
        for (int i = 0; i < partitionCount; i++) {
            RecordStore recordStore = mapServiceContext.getPartitionContainer(i).getRecordStore(mapContainer.getName());
            // add your owned entries to the map so they will be merged
            if (thisAddress.equals(partitionService.getPartitionOwner(i))) {
                Collection<Record> records = recordMap.get(mapContainer);
                if (records == null) {
                    records = new ArrayList<Record>();
                    recordMap.put(mapContainer, records);
                }
                final Iterator<Record> iterator = recordStore.iterator(now, false);
                while (iterator.hasNext()) {
                    final Record record = iterator.next();
                    records.add(record);
                }
            }
            // clear all records either owned or backup
            recordStore.reset();
        }
        Indexes indexes = mapContainer.getIndexes();
        indexes.clearIndexes();
    }
    return new Merger(recordMap);
}
Also used : Address(com.hazelcast.nio.Address) HashMap(java.util.HashMap) IPartitionService(com.hazelcast.spi.partition.IPartitionService) Indexes(com.hazelcast.query.impl.Indexes) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) Collection(java.util.Collection) Record(com.hazelcast.map.impl.record.Record)

Example 5 with Record

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

the class BasePutOperation method getBackupOperation.

@Override
public Operation getBackupOperation() {
    final Record record = recordStore.getRecord(dataKey);
    final RecordInfo replicationInfo = buildRecordInfo(record);
    if (isPostProcessing(recordStore)) {
        dataValue = mapServiceContext.toData(record.getValue());
    }
    return new PutBackupOperation(name, dataKey, dataValue, replicationInfo, putTransient);
}
Also used : Records.buildRecordInfo(com.hazelcast.map.impl.record.Records.buildRecordInfo) RecordInfo(com.hazelcast.map.impl.record.RecordInfo) 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