use of com.hazelcast.spi.merge.SplitBrainMergePolicyProvider in project hazelcast by hazelcast.
the class MapRemoteService method createDistributedObject.
@Override
public DistributedObject createDistributedObject(String name, UUID source, boolean local) {
Config config = nodeEngine.getConfig();
MapConfig mapConfig = config.findMapConfig(name);
SplitBrainMergePolicyProvider mergePolicyProvider = nodeEngine.getSplitBrainMergePolicyProvider();
checkMapConfig(mapConfig, config.getNativeMemoryConfig(), mergePolicyProvider, mapServiceContext.getNodeEngine().getProperties(), nodeEngine.getLogger(MapConfig.class));
if (mapConfig.isNearCacheEnabled()) {
checkNearCacheConfig(name, mapConfig.getNearCacheConfig(), config.getNativeMemoryConfig(), false);
return new NearCachedMapProxyImpl(name, mapServiceContext.getService(), nodeEngine, mapConfig);
} else {
return new MapProxyImpl(name, mapServiceContext.getService(), nodeEngine, mapConfig);
}
}
use of com.hazelcast.spi.merge.SplitBrainMergePolicyProvider in project hazelcast by hazelcast.
the class HazelcastServerCacheManager method validateCacheConfig.
@Override
protected <K, V> void validateCacheConfig(CacheConfig<K, V> cacheConfig) {
SplitBrainMergePolicyProvider mergePolicyProvider = nodeEngine.getSplitBrainMergePolicyProvider();
checkCacheConfig(cacheConfig, mergePolicyProvider);
}
use of com.hazelcast.spi.merge.SplitBrainMergePolicyProvider in project hazelcast by hazelcast.
the class CacheCreateConfigMessageTask method processMessage.
@Override
protected void processMessage() {
// parameters.cacheConfig is not nullable by protocol definition, hence no need for null check
CacheConfig cacheConfig = parameters.cacheConfig.asCacheConfig(serializationService);
CacheService cacheService = getService(CacheService.SERVICE_NAME);
SplitBrainMergePolicyProvider mergePolicyProvider = nodeEngine.getSplitBrainMergePolicyProvider();
checkCacheConfig(cacheConfig, mergePolicyProvider);
InternalCompletableFuture future = cacheService.createCacheConfigOnAllMembersAsync(PreJoinCacheConfig.of(cacheConfig));
future.whenCompleteAsync(this);
}
use of com.hazelcast.spi.merge.SplitBrainMergePolicyProvider in project hazelcast by hazelcast.
the class MapMergePolicyQuickTest method testPutIfAbsentMapMergePolicy.
@Test
public void testPutIfAbsentMapMergePolicy() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
String name = randomString();
IMap<String, String> map = instance.getMap(name);
MapServiceContext mapServiceContext = getMapServiceContext(instance);
Data dataKey = mapServiceContext.toData("key");
Data dataValue = mapServiceContext.toData("value1");
Data dataValue2 = mapServiceContext.toData("value2");
RecordStore recordStore = mapServiceContext.getRecordStore(getPartitionId(instance, "key"), name);
recordStore.beforeOperation();
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
SplitBrainMergePolicyProvider mergePolicyProvider = nodeEngine.getSplitBrainMergePolicyProvider();
SplitBrainMergePolicy mergePolicy = mergePolicyProvider.getMergePolicy(PutIfAbsentMergePolicy.class.getName());
SimpleEntryView<Data, Data> initialEntry = new SimpleEntryView<>(dataKey, dataValue);
recordStore.merge(createMergingEntry(nodeEngine.getSerializationService(), initialEntry), mergePolicy, CallerProvenance.NOT_WAN);
SimpleEntryView<Data, Data> mergingEntry = new SimpleEntryView<>(dataKey, dataValue2);
recordStore.merge(createMergingEntry(nodeEngine.getSerializationService(), mergingEntry), mergePolicy, CallerProvenance.NOT_WAN);
assertEquals("value1", map.get("key"));
recordStore.afterOperation();
}
use of com.hazelcast.spi.merge.SplitBrainMergePolicyProvider in project hazelcast by hazelcast.
the class MapContainer method initWanReplication.
public void initWanReplication(NodeEngine nodeEngine) {
WanReplicationRef wanReplicationRef = mapConfig.getWanReplicationRef();
if (wanReplicationRef == null) {
return;
}
String wanReplicationRefName = wanReplicationRef.getName();
Config config = nodeEngine.getConfig();
if (!TRUE.equals(mapConfig.getMerkleTreeConfig().getEnabled()) && hasPublisherWithMerkleTreeSync(config, wanReplicationRefName)) {
throw new InvalidConfigurationException("Map " + name + " has disabled merkle trees but the WAN replication scheme " + wanReplicationRefName + " has publishers that use merkle trees." + " Please enable merkle trees for the map.");
}
WanReplicationService wanReplicationService = nodeEngine.getWanReplicationService();
wanReplicationDelegate = wanReplicationService.getWanReplicationPublishers(wanReplicationRefName);
SplitBrainMergePolicyProvider mergePolicyProvider = nodeEngine.getSplitBrainMergePolicyProvider();
wanMergePolicy = mergePolicyProvider.getMergePolicy(wanReplicationRef.getMergePolicyClassName());
checkMapMergePolicy(mapConfig, wanReplicationRef.getMergePolicyClassName(), mergePolicyProvider);
WanReplicationConfig wanReplicationConfig = config.getWanReplicationConfig(wanReplicationRefName);
if (wanReplicationConfig != null) {
WanConsumerConfig wanConsumerConfig = wanReplicationConfig.getConsumerConfig();
if (wanConsumerConfig != null) {
persistWanReplicatedData = wanConsumerConfig.isPersistWanReplicatedData();
}
}
}
Aggregations