use of com.hazelcast.config.WanReplicationRef 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();
}
}
}
use of com.hazelcast.config.WanReplicationRef in project hazelcast by hazelcast.
the class NodeEngineImpl method checkMapMergePolicies.
private void checkMapMergePolicies(Node node) {
Map<String, MapConfig> mapConfigs = node.config.getMapConfigs();
for (MapConfig mapConfig : mapConfigs.values()) {
WanReplicationRef wanReplicationRef = mapConfig.getWanReplicationRef();
if (wanReplicationRef != null) {
String wanMergePolicyClassName = mapConfig.getWanReplicationRef().getMergePolicyClassName();
checkMapMergePolicy(mapConfig, wanMergePolicyClassName, splitBrainMergePolicyProvider);
}
String splitBrainMergePolicyClassName = mapConfig.getMergePolicyConfig().getPolicy();
checkMapMergePolicy(mapConfig, splitBrainMergePolicyClassName, splitBrainMergePolicyProvider);
}
}
use of com.hazelcast.config.WanReplicationRef in project hazelcast by hazelcast.
the class TestFullApplicationContext method testCacheConfig.
@Test
public void testCacheConfig() {
assertNotNull(config);
assertEquals(1, config.getCacheConfigs().size());
CacheSimpleConfig cacheConfig = config.getCacheConfig("testCache");
assertEquals("testCache", cacheConfig.getName());
assertTrue(cacheConfig.isDisablePerEntryInvalidationEvents());
assertTrue(cacheConfig.getDataPersistenceConfig().isEnabled());
assertTrue(cacheConfig.getDataPersistenceConfig().isFsync());
EventJournalConfig journalConfig = cacheConfig.getEventJournalConfig();
assertTrue(journalConfig.isEnabled());
assertEquals(123, journalConfig.getCapacity());
assertEquals(321, journalConfig.getTimeToLiveSeconds());
WanReplicationRef wanRef = cacheConfig.getWanReplicationRef();
assertEquals("testWan", wanRef.getName());
assertEquals("PutIfAbsentMergePolicy", wanRef.getMergePolicyClassName());
assertEquals(1, wanRef.getFilters().size());
assertEquals("com.example.SampleFilter", wanRef.getFilters().get(0));
assertTrue(cacheConfig.getMerkleTreeConfig().isEnabled());
assertEquals(20, cacheConfig.getMerkleTreeConfig().getDepth());
}
use of com.hazelcast.config.WanReplicationRef in project hazelcast by hazelcast.
the class TestFullApplicationContext method testMapConfig.
@Test
public void testMapConfig() {
assertNotNull(config);
long mapConfigSize = config.getMapConfigs().keySet().stream().filter(name -> !name.startsWith(INTERNAL_JET_OBJECTS_PREFIX)).count();
assertEquals(27, mapConfigSize);
MapConfig testMapConfig = config.getMapConfig("testMap");
assertNotNull(testMapConfig);
assertEquals("testMap", testMapConfig.getName());
assertEquals(2, testMapConfig.getBackupCount());
assertEquals(EvictionPolicy.NONE, testMapConfig.getEvictionConfig().getEvictionPolicy());
assertEquals(Integer.MAX_VALUE, testMapConfig.getEvictionConfig().getSize());
assertEquals(0, testMapConfig.getTimeToLiveSeconds());
assertTrue(testMapConfig.getMerkleTreeConfig().isEnabled());
assertEquals(20, testMapConfig.getMerkleTreeConfig().getDepth());
assertTrue(testMapConfig.getDataPersistenceConfig().isEnabled());
assertTrue(testMapConfig.getDataPersistenceConfig().isFsync());
EventJournalConfig journalConfig = testMapConfig.getEventJournalConfig();
assertTrue(journalConfig.isEnabled());
assertEquals(123, journalConfig.getCapacity());
assertEquals(321, journalConfig.getTimeToLiveSeconds());
assertEquals(MetadataPolicy.OFF, testMapConfig.getMetadataPolicy());
assertTrue(testMapConfig.isReadBackupData());
assertEquals(2, testMapConfig.getIndexConfigs().size());
for (IndexConfig index : testMapConfig.getIndexConfigs()) {
if ("name".equals(index.getAttributes().get(0))) {
assertEquals(IndexType.HASH, index.getType());
assertNull(index.getName());
} else if ("age".equals(index.getAttributes().get(0))) {
assertEquals(IndexType.SORTED, index.getType());
assertEquals("sortedIndex", index.getName());
assertEquals("name", index.getAttributes().get(1));
} else {
fail("unknown index!");
}
}
assertEquals(2, testMapConfig.getAttributeConfigs().size());
for (AttributeConfig attribute : testMapConfig.getAttributeConfigs()) {
if ("power".equals(attribute.getName())) {
assertEquals("com.car.PowerExtractor", attribute.getExtractorClassName());
} else if ("weight".equals(attribute.getName())) {
assertEquals("com.car.WeightExtractor", attribute.getExtractorClassName());
} else {
fail("unknown attribute!");
}
}
assertEquals("my-split-brain-protection", testMapConfig.getSplitBrainProtectionName());
MergePolicyConfig mergePolicyConfig = testMapConfig.getMergePolicyConfig();
assertNotNull(mergePolicyConfig);
assertEquals("PassThroughMergePolicy", mergePolicyConfig.getPolicy());
assertEquals(2342, mergePolicyConfig.getBatchSize());
// test that the testMapConfig has a mapStoreConfig and it is correct
MapStoreConfig testMapStoreConfig = testMapConfig.getMapStoreConfig();
assertNotNull(testMapStoreConfig);
assertEquals("com.hazelcast.spring.DummyStore", testMapStoreConfig.getClassName());
assertTrue(testMapStoreConfig.isEnabled());
assertEquals(0, testMapStoreConfig.getWriteDelaySeconds());
assertEquals(10, testMapStoreConfig.getWriteBatchSize());
assertTrue(testMapStoreConfig.isWriteCoalescing());
assertEquals(MapStoreConfig.InitialLoadMode.EAGER, testMapStoreConfig.getInitialLoadMode());
// test that the testMapConfig has a nearCacheConfig and it is correct
NearCacheConfig testNearCacheConfig = testMapConfig.getNearCacheConfig();
assertNotNull(testNearCacheConfig);
assertEquals(0, testNearCacheConfig.getTimeToLiveSeconds());
assertEquals(60, testNearCacheConfig.getMaxIdleSeconds());
assertEquals(EvictionPolicy.LRU, testNearCacheConfig.getEvictionConfig().getEvictionPolicy());
assertEquals(5000, testNearCacheConfig.getEvictionConfig().getSize());
assertTrue(testNearCacheConfig.isInvalidateOnChange());
assertFalse(testNearCacheConfig.isSerializeKeys());
// test that the testMapConfig2's mapStoreConfig implementation
MapConfig testMapConfig2 = config.getMapConfig("testMap2");
assertNotNull(testMapConfig2.getMapStoreConfig().getImplementation());
assertEquals(dummyMapStore, testMapConfig2.getMapStoreConfig().getImplementation());
assertEquals(MapStoreConfig.InitialLoadMode.LAZY, testMapConfig2.getMapStoreConfig().getInitialLoadMode());
// test testMapConfig2's WanReplicationConfig
WanReplicationRef wanReplicationRef = testMapConfig2.getWanReplicationRef();
assertEquals("testWan", wanReplicationRef.getName());
assertEquals("PutIfAbsentMergePolicy", wanReplicationRef.getMergePolicyClassName());
assertTrue(wanReplicationRef.isRepublishingEnabled());
assertEquals(1000, testMapConfig2.getEvictionConfig().getSize());
assertEquals(MaxSizePolicy.PER_NODE, testMapConfig2.getEvictionConfig().getMaxSizePolicy());
assertEquals(2, testMapConfig2.getEntryListenerConfigs().size());
for (EntryListenerConfig listener : testMapConfig2.getEntryListenerConfigs()) {
if (listener.getClassName() != null) {
assertNull(listener.getImplementation());
assertTrue(listener.isIncludeValue());
assertFalse(listener.isLocal());
} else {
assertNotNull(listener.getImplementation());
assertEquals(entryListener, listener.getImplementation());
assertTrue(listener.isLocal());
assertTrue(listener.isIncludeValue());
}
}
MapConfig simpleMapConfig = config.getMapConfig("simpleMap");
assertNotNull(simpleMapConfig);
assertEquals("simpleMap", simpleMapConfig.getName());
assertEquals(3, simpleMapConfig.getBackupCount());
assertEquals(1, simpleMapConfig.getAsyncBackupCount());
assertEquals(EvictionPolicy.LRU, simpleMapConfig.getEvictionConfig().getEvictionPolicy());
assertEquals(10, simpleMapConfig.getEvictionConfig().getSize());
assertEquals(1, simpleMapConfig.getTimeToLiveSeconds());
// test that the simpleMapConfig does NOT have a nearCacheConfig
assertNull(simpleMapConfig.getNearCacheConfig());
MapConfig testMapConfig3 = config.getMapConfig("testMap3");
assertEquals("com.hazelcast.spring.DummyStoreFactory", testMapConfig3.getMapStoreConfig().getFactoryClassName());
assertFalse(testMapConfig3.getMapStoreConfig().getProperties().isEmpty());
assertEquals(testMapConfig3.getMapStoreConfig().getProperty("dummy.property"), "value");
MapConfig testMapConfig4 = config.getMapConfig("testMap4");
assertEquals(dummyMapStoreFactory, testMapConfig4.getMapStoreConfig().getFactoryImplementation());
MapConfig mapWithValueCachingSetToNever = config.getMapConfig("mapWithValueCachingSetToNever");
assertEquals(CacheDeserializedValues.NEVER, mapWithValueCachingSetToNever.getCacheDeserializedValues());
MapConfig mapWithValueCachingSetToAlways = config.getMapConfig("mapWithValueCachingSetToAlways");
assertEquals(CacheDeserializedValues.ALWAYS, mapWithValueCachingSetToAlways.getCacheDeserializedValues());
MapConfig mapWithDefaultValueCaching = config.getMapConfig("mapWithDefaultValueCaching");
assertEquals(CacheDeserializedValues.INDEX_ONLY, mapWithDefaultValueCaching.getCacheDeserializedValues());
MapConfig testMapWithPartitionLostListenerConfig = config.getMapConfig("mapWithPartitionLostListener");
List<MapPartitionLostListenerConfig> partitionLostListenerConfigs = testMapWithPartitionLostListenerConfig.getPartitionLostListenerConfigs();
assertEquals(1, partitionLostListenerConfigs.size());
assertEquals("DummyMapPartitionLostListenerImpl", partitionLostListenerConfigs.get(0).getClassName());
MapConfig testMapWithPartitionStrategyConfig = config.getMapConfig("mapWithPartitionStrategy");
assertEquals("com.hazelcast.spring.DummyPartitionStrategy", testMapWithPartitionStrategyConfig.getPartitioningStrategyConfig().getPartitioningStrategyClass());
MapConfig testMapConfig5 = config.getMapConfig("testMap5");
TieredStoreConfig tieredStoreConfig = testMapConfig5.getTieredStoreConfig();
assertTrue(tieredStoreConfig.isEnabled());
MemoryTierConfig memoryTierConfig = tieredStoreConfig.getMemoryTierConfig();
assertEquals(MemoryUnit.MEGABYTES, memoryTierConfig.getCapacity().getUnit());
assertEquals(128L, memoryTierConfig.getCapacity().getValue());
DiskTierConfig diskTierConfig = tieredStoreConfig.getDiskTierConfig();
assertTrue(diskTierConfig.isEnabled());
assertEquals("the-local0751", diskTierConfig.getDeviceName());
}
use of com.hazelcast.config.WanReplicationRef in project hazelcast by hazelcast.
the class TestFullApplicationContext method testMapNoWanMergePolicy.
@Test
public void testMapNoWanMergePolicy() {
MapConfig testMapConfig2 = config.getMapConfig("testMap2");
// test testMapConfig2's WanReplicationConfig
WanReplicationRef wanReplicationRef = testMapConfig2.getWanReplicationRef();
assertEquals("testWan", wanReplicationRef.getName());
assertEquals("PutIfAbsentMergePolicy", wanReplicationRef.getMergePolicyClassName());
}
Aggregations