Search in sources :

Example 6 with EntryView

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

the class PutIfAbsentMapMergePolicyTest method merge_existingValuePresent.

@Test
public void merge_existingValuePresent() {
    EntryView existing = entryWithGivenValue(EXISTING);
    EntryView merging = entryWithGivenValue(MERGING);
    assertEquals(EXISTING, policy.merge("map", merging, existing));
}
Also used : EntryView(com.hazelcast.core.EntryView) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with EntryView

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

the class EvictorImpl method evict.

@Override
public void evict(RecordStore recordStore, Data excludedKey) {
    EntryView evictableEntry = selectEvictableEntry(recordStore, excludedKey);
    if (evictableEntry == null) {
        return;
    }
    evictEntry(recordStore, evictableEntry);
}
Also used : EntryView(com.hazelcast.core.EntryView)

Example 8 with EntryView

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

the class EvictorImpl method selectEvictableEntry.

private EntryView selectEvictableEntry(RecordStore recordStore, Data excludedKey) {
    Iterable<EntryView> samples = getSamples(recordStore);
    EntryView excluded = null;
    EntryView selected = null;
    for (EntryView candidate : samples) {
        if (excludedKey != null && excluded == null && getDataKey(candidate).equals(excludedKey)) {
            excluded = candidate;
            continue;
        }
        if (selected == null) {
            selected = candidate;
        } else if (mapEvictionPolicy.compare(candidate, selected) < 0) {
            selected = candidate;
        }
    }
    return selected == null ? excluded : selected;
}
Also used : EntryView(com.hazelcast.core.EntryView)

Example 9 with EntryView

use of com.hazelcast.core.EntryView 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 10 with EntryView

use of com.hazelcast.core.EntryView 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)

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