Search in sources :

Example 6 with MapMergeTypes

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

the class DiscardMergePolicyTest method merge_existingValuePresent.

@Test
public void merge_existingValuePresent() {
    MapMergeTypes existing = mergingValueWithGivenValue(EXISTING);
    MapMergeTypes merging = mergingValueWithGivenValue(MERGING);
    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 7 with MapMergeTypes

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

the class DiscardMergePolicyTest 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 8 with MapMergeTypes

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

the class WanMapSupportingService method handleAddOrUpdate.

private void handleAddOrUpdate(WanMapAddOrUpdateEvent replicationUpdate) {
    SplitBrainMergePolicy mergePolicy = replicationUpdate.getMergePolicy();
    String mapName = replicationUpdate.getObjectName();
    MapOperationProvider operationProvider = mapServiceContext.getMapOperationProvider(mapName);
    SerializationService serializationService = nodeEngine.getSerializationService();
    MapMergeTypes<Object, Object> mergingEntry = createMergingEntry(serializationService, replicationUpdate.getEntryView());
    // noinspection unchecked
    MapOperation operation = operationProvider.createMergeOperation(mapName, mergingEntry, (SplitBrainMergePolicy<Object, MapMergeTypes<Object, Object>, Object>) mergePolicy, true);
    try {
        int partitionId = nodeEngine.getPartitionService().getPartitionId(replicationUpdate.getEntryView().getKey());
        Future future = nodeEngine.getOperationService().invokeOnPartition(SERVICE_NAME, operation, partitionId);
        future.get();
        wanEventTypeCounters.incrementUpdate(mapName);
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : SplitBrainMergePolicy(com.hazelcast.spi.merge.SplitBrainMergePolicy) SerializationService(com.hazelcast.internal.serialization.SerializationService) Future(java.util.concurrent.Future) MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes) MapOperationProvider(com.hazelcast.map.impl.operation.MapOperationProvider) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Example 9 with MapMergeTypes

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

the class MergeOperation method writeInternal.

@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);
    out.writeInt(mergingEntries.size());
    for (MapMergeTypes mergingEntry : mergingEntries) {
        out.writeObject(mergingEntry);
    }
    out.writeObject(mergePolicy);
    out.writeBoolean(disableWanReplicationEvent);
}
Also used : MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes)

Example 10 with MapMergeTypes

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

the class MergeOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    int size = in.readInt();
    mergingEntries = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        MapMergeTypes mergingEntry = in.readObject();
        mergingEntries.add(mergingEntry);
    }
    mergePolicy = in.readObject();
    disableWanReplicationEvent = in.readBoolean();
}
Also used : MapMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.MapMergeTypes)

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