Search in sources :

Example 11 with MapMergeTypes

use of com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes in project hazelcast by hazelcast.

the class PutIfAbsentMergePolicyTest method merge_existingValueAbsent.

@Test
@SuppressWarnings("ConstantConditions")
public void merge_existingValueAbsent() {
    MapMergeTypes existing = null;
    MapMergeTypes merging = mergingValueWithGivenValue(MERGING);
    assertEquals(MERGING, mergePolicy.merge(merging, existing));
}
Also used : MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with MapMergeTypes

use of com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes in project hazelcast by hazelcast.

the class PutIfAbsentMergePolicyTest method merge_bothValuesNull.

@Test
public void merge_bothValuesNull() {
    MapMergeTypes existing = mergingValueWithGivenValue(null);
    MapMergeTypes merging = mergingValueWithGivenValue(null);
    assertNull(mergePolicy.merge(merging, existing));
}
Also used : MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with MapMergeTypes

use of com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes in project hazelcast by hazelcast.

the class DiscardMergePolicyTest method merge_mergingNull.

@Test
@SuppressWarnings("ConstantConditions")
public void merge_mergingNull() {
    MapMergeTypes existing = mergingValueWithGivenValue(EXISTING);
    MapMergeTypes merging = null;
    assertEquals(EXISTING, mergePolicy.merge(merging, existing));
}
Also used : MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 14 with MapMergeTypes

use of com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes in project hazelcast by hazelcast.

the class AbstractWanCustomPublisherMapTest method runMergeOpForWAN.

private void runMergeOpForWAN(boolean enableWANReplicationEvent) {
    // init hazelcast instances
    String mapName = "merge_operation_generates_wan_replication_event";
    initInstancesAndMap(mapName);
    // get internal services to use in this test
    HazelcastInstance node = instance1;
    NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(node);
    InternalPartitionService partitionService = nodeEngineImpl.getPartitionService();
    OperationServiceImpl operationService = nodeEngineImpl.getOperationService();
    SerializationService serializationService = nodeEngineImpl.getSerializationService();
    MapService mapService = nodeEngineImpl.getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapName);
    // prepare and send one merge operation
    Data data = serializationService.toData(1);
    MapOperation op;
    SimpleEntryView<Data, Data> entryView = new SimpleEntryView<Data, Data>().withKey(data).withValue(data);
    MapMergeTypes<Object, Object> mergingEntry = createMergingEntry(serializationService, entryView);
    SplitBrainMergePolicy<Object, MapMergeTypes<Object, Object>, Object> mergePolicy = new com.hazelcast.spi.merge.PassThroughMergePolicy<>();
    op = operationProvider.createMergeOperation(mapName, mergingEntry, mergePolicy, !enableWANReplicationEvent);
    operationService.createInvocationBuilder(MapService.SERVICE_NAME, op, partitionService.getPartitionId(data)).invoke();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapOperation(com.hazelcast.map.impl.operation.MapOperation) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SimpleEntryView(com.hazelcast.map.impl.SimpleEntryView) MapService(com.hazelcast.map.impl.MapService) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Aggregations

MapMergeTypes (com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes)14 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 Test (org.junit.Test)9 Data (com.hazelcast.internal.serialization.Data)2 SerializationService (com.hazelcast.internal.serialization.SerializationService)2 MapOperation (com.hazelcast.map.impl.operation.MapOperation)2 MapOperationProvider (com.hazelcast.map.impl.operation.MapOperationProvider)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 SimpleEntryView (com.hazelcast.map.impl.SimpleEntryView)1 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 Record (com.hazelcast.map.impl.record.Record)1 ExpiryMetadata (com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)1 SplitBrainMergePolicy (com.hazelcast.spi.merge.SplitBrainMergePolicy)1 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)1