Search in sources :

Example 21 with EntryView

use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.

the class PutAllOperation method put.

private void put(Data dataKey, Data dataValue) {
    Object oldValue = putToRecordStore(dataKey, dataValue);
    dataValue = getValueOrPostProcessedValue(dataKey, dataValue);
    mapServiceContext.interceptAfterPut(name, dataValue);
    if (hasMapListener) {
        EntryEventType eventType = (oldValue == null ? ADDED : UPDATED);
        mapEventPublisher.publishEvent(getCallerAddress(), name, eventType, dataKey, oldValue, dataValue);
    }
    Record record = (hasWanReplication || hasBackups) ? recordStore.getRecord(dataKey) : null;
    if (hasWanReplication) {
        EntryView entryView = createSimpleEntryView(dataKey, dataValue, record);
        mapEventPublisher.publishWanReplicationUpdate(name, entryView);
    }
    if (hasBackups) {
        RecordInfo replicationInfo = buildRecordInfo(record);
        backupRecordInfos.add(replicationInfo);
    }
    evict(dataKey);
    if (hasInvalidation) {
        invalidationKeys.add(dataKey);
    }
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType) RecordInfo(com.hazelcast.map.impl.record.RecordInfo) Records.buildRecordInfo(com.hazelcast.map.impl.record.Records.buildRecordInfo) EntryView(com.hazelcast.core.EntryView) EntryViews.createSimpleEntryView(com.hazelcast.map.impl.EntryViews.createSimpleEntryView) Record(com.hazelcast.map.impl.record.Record)

Example 22 with EntryView

use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.

the class PutFromLoadAllBackupOperation method publishWanReplicationEvent.

private void publishWanReplicationEvent(Data key, Data value, Record record) {
    if (record == null) {
        return;
    }
    if (mapContainer.getWanReplicationPublisher() != null && mapContainer.getWanMergePolicy() != null) {
        EntryView entryView = EntryViews.createSimpleEntryView(key, value, record);
        mapEventPublisher.publishWanReplicationUpdateBackup(name, entryView);
    }
}
Also used : EntryView(com.hazelcast.core.EntryView)

Example 23 with EntryView

use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.

the class ClientMapBasicTest method testGetEntryView.

@Test
public void testGetEntryView() {
    IMap<String, String> map = client.getMap(randomString());
    String key = "Key";
    String value = "Value";
    map.put(key, value);
    EntryView view = map.getEntryView(key);
    assertEquals(key, view.getKey());
    assertEquals(value, view.getValue());
}
Also used : EntryView(com.hazelcast.core.EntryView) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 24 with EntryView

use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.

the class AbstractMultipleEntryBackupOperation method publishWanReplicationEventBackup.

protected void publishWanReplicationEventBackup(Data key, Object value, EntryEventType eventType) {
    if (mapContainer.isWanReplicationEnabled()) {
        if (REMOVED.equals(eventType)) {
            mapEventPublisher.publishWanReplicationRemoveBackup(name, key, getNow());
        } else {
            final Record record = recordStore.getRecord(key);
            if (record != null) {
                final Data dataValueAsData = toData(value);
                final EntryView entryView = createSimpleEntryView(key, dataValueAsData, record);
                mapEventPublisher.publishWanReplicationUpdateBackup(name, entryView);
            }
        }
    }
}
Also used : EntryView(com.hazelcast.core.EntryView) EntryViews.createSimpleEntryView(com.hazelcast.map.impl.EntryViews.createSimpleEntryView) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data)

Example 25 with EntryView

use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.

the class AbstractMultipleEntryOperation method publishWanReplicationEvent.

protected void publishWanReplicationEvent(Data key, Data value, EntryEventType eventType) {
    if (EntryEventType.REMOVED == eventType) {
        mapEventPublisher.publishWanReplicationRemove(name, key, getNow());
        wanEventList.add(new WanEventWrapper(key, null, EntryEventType.REMOVED));
    } else {
        final Record record = recordStore.getRecord(key);
        if (record != null) {
            final Data dataValueAsData = toData(value);
            final EntryView entryView = createSimpleEntryView(key, dataValueAsData, record);
            mapEventPublisher.publishWanReplicationUpdate(name, entryView);
            wanEventList.add(new WanEventWrapper(key, value, EntryEventType.UPDATED));
        }
    }
}
Also used : EntryView(com.hazelcast.core.EntryView) EntryViews.createSimpleEntryView(com.hazelcast.map.impl.EntryViews.createSimpleEntryView) Record(com.hazelcast.map.impl.record.Record) Data(com.hazelcast.nio.serialization.Data)

Aggregations

EntryView (com.hazelcast.core.EntryView)30 Test (org.junit.Test)14 ParallelTest (com.hazelcast.test.annotation.ParallelTest)11 QuickTest (com.hazelcast.test.annotation.QuickTest)11 Record (com.hazelcast.map.impl.record.Record)10 Data (com.hazelcast.nio.serialization.Data)9 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)6 IMap (com.hazelcast.core.IMap)2 MapContainer (com.hazelcast.map.impl.MapContainer)2 MapEventPublisher (com.hazelcast.map.impl.event.MapEventPublisher)2 MapOperation (com.hazelcast.map.impl.operation.MapOperation)2 Future (java.util.concurrent.Future)2 JsonObject (com.eclipsesource.json.JsonObject)1 EntryEventType (com.hazelcast.core.EntryEventType)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 Node (com.hazelcast.instance.Node)1 MapOperationProvider (com.hazelcast.map.impl.operation.MapOperationProvider)1 MergeOperation (com.hazelcast.map.impl.operation.MergeOperation)1 RecordInfo (com.hazelcast.map.impl.record.RecordInfo)1 Records.buildRecordInfo (com.hazelcast.map.impl.record.Records.buildRecordInfo)1