Search in sources :

Example 1 with SplitBrainMergePolicyProvider

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);
    }
}
Also used : MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) ConfigValidator.checkMapConfig(com.hazelcast.internal.config.ConfigValidator.checkMapConfig) ConfigValidator.checkNearCacheConfig(com.hazelcast.internal.config.ConfigValidator.checkNearCacheConfig) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) NearCachedMapProxyImpl(com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl) NearCachedMapProxyImpl(com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl) MapConfig(com.hazelcast.config.MapConfig) ConfigValidator.checkMapConfig(com.hazelcast.internal.config.ConfigValidator.checkMapConfig) SplitBrainMergePolicyProvider(com.hazelcast.spi.merge.SplitBrainMergePolicyProvider)

Example 2 with SplitBrainMergePolicyProvider

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);
}
Also used : SplitBrainMergePolicyProvider(com.hazelcast.spi.merge.SplitBrainMergePolicyProvider)

Example 3 with SplitBrainMergePolicyProvider

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);
}
Also used : InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) CacheConfig(com.hazelcast.config.CacheConfig) ConfigValidator.checkCacheConfig(com.hazelcast.internal.config.ConfigValidator.checkCacheConfig) PreJoinCacheConfig(com.hazelcast.cache.impl.PreJoinCacheConfig) SplitBrainMergePolicyProvider(com.hazelcast.spi.merge.SplitBrainMergePolicyProvider) CacheService(com.hazelcast.cache.impl.CacheService) ICacheService(com.hazelcast.cache.impl.ICacheService)

Example 4 with SplitBrainMergePolicyProvider

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();
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) SplitBrainMergePolicy(com.hazelcast.spi.merge.SplitBrainMergePolicy) HazelcastInstance(com.hazelcast.core.HazelcastInstance) PutIfAbsentMergePolicy(com.hazelcast.spi.merge.PutIfAbsentMergePolicy) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) SimpleEntryView(com.hazelcast.map.impl.SimpleEntryView) Data(com.hazelcast.internal.serialization.Data) SplitBrainMergePolicyProvider(com.hazelcast.spi.merge.SplitBrainMergePolicyProvider) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with SplitBrainMergePolicyProvider

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();
        }
    }
}
Also used : WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanReplicationRef(com.hazelcast.config.WanReplicationRef) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) MapConfig(com.hazelcast.config.MapConfig) IndexConfig(com.hazelcast.config.IndexConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) WanSyncConfig(com.hazelcast.config.WanSyncConfig) Config(com.hazelcast.config.Config) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanReplicationService(com.hazelcast.wan.impl.WanReplicationService) SplitBrainMergePolicyProvider(com.hazelcast.spi.merge.SplitBrainMergePolicyProvider) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

SplitBrainMergePolicyProvider (com.hazelcast.spi.merge.SplitBrainMergePolicyProvider)10 NodeEngine (com.hazelcast.spi.impl.NodeEngine)5 Config (com.hazelcast.config.Config)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 Data (com.hazelcast.internal.serialization.Data)4 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)4 SimpleEntryView (com.hazelcast.map.impl.SimpleEntryView)4 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)4 SplitBrainMergePolicy (com.hazelcast.spi.merge.SplitBrainMergePolicy)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 MapConfig (com.hazelcast.config.MapConfig)3 ConfigValidator.checkCacheConfig (com.hazelcast.internal.config.ConfigValidator.checkCacheConfig)2 ConfigValidator.checkMapConfig (com.hazelcast.internal.config.ConfigValidator.checkMapConfig)2 PutIfAbsentMergePolicy (com.hazelcast.spi.merge.PutIfAbsentMergePolicy)2 Before (org.junit.Before)2 CacheService (com.hazelcast.cache.impl.CacheService)1 ICacheService (com.hazelcast.cache.impl.ICacheService)1 PreJoinCacheConfig (com.hazelcast.cache.impl.PreJoinCacheConfig)1