Search in sources :

Example 1 with SplitBrainProtectionConfig

use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.

the class TestFullApplicationContext method testSplitBrainProtectionConfig.

@Test
public void testSplitBrainProtectionConfig() {
    assertNotNull(config);
    assertEquals(3, config.getSplitBrainProtectionConfigs().size());
    SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("my-split-brain-protection");
    assertNotNull(splitBrainProtectionConfig);
    assertEquals("my-split-brain-protection", splitBrainProtectionConfig.getName());
    assertEquals("com.hazelcast.spring.DummySplitBrainProtectionFunction", splitBrainProtectionConfig.getFunctionClassName());
    assertTrue(splitBrainProtectionConfig.isEnabled());
    assertEquals(2, splitBrainProtectionConfig.getMinimumClusterSize());
    assertEquals(2, splitBrainProtectionConfig.getListenerConfigs().size());
    assertEquals(SplitBrainProtectionOn.READ, splitBrainProtectionConfig.getProtectOn());
    assertEquals("com.hazelcast.spring.DummySplitBrainProtectionListener", splitBrainProtectionConfig.getListenerConfigs().get(0).getClassName());
    assertNotNull(splitBrainProtectionConfig.getListenerConfigs().get(1).getImplementation());
}
Also used : SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 2 with SplitBrainProtectionConfig

use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.

the class TestFullApplicationContext method testRecentlyActiveSplitBrainProtectionConfig.

@Test
public void testRecentlyActiveSplitBrainProtectionConfig() {
    SplitBrainProtectionConfig recentlyActiveSplitBrainProtectionConfig = config.getSplitBrainProtectionConfig("recently-active-split-brain-protection");
    assertNotNull(recentlyActiveSplitBrainProtectionConfig);
    assertEquals("recently-active-split-brain-protection", recentlyActiveSplitBrainProtectionConfig.getName());
    assertNotNull(recentlyActiveSplitBrainProtectionConfig.getFunctionImplementation());
    assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, recentlyActiveSplitBrainProtectionConfig.getFunctionImplementation());
    assertTrue(recentlyActiveSplitBrainProtectionConfig.isEnabled());
    assertEquals(5, recentlyActiveSplitBrainProtectionConfig.getMinimumClusterSize());
    assertEquals(SplitBrainProtectionOn.READ_WRITE, recentlyActiveSplitBrainProtectionConfig.getProtectOn());
    RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) recentlyActiveSplitBrainProtectionConfig.getFunctionImplementation();
    assertEquals(5123, splitBrainProtectionFunction.getHeartbeatToleranceMillis());
}
Also used : RecentlyActiveSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction) SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 3 with SplitBrainProtectionConfig

use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.

the class YamlMemberDomConfigProcessor method handleSplitBrainProtection.

@Override
protected void handleSplitBrainProtection(Node node) {
    for (Node splitBrainProtectionNode : childElements(node)) {
        String name = splitBrainProtectionNode.getNodeName();
        SplitBrainProtectionConfig splitBrainProtectionConfig = ConfigUtils.getByNameOrNew(config.getSplitBrainProtectionConfigs(), name, SplitBrainProtectionConfig.class);
        handleSplitBrainProtectionNode(splitBrainProtectionNode, splitBrainProtectionConfig, name);
    }
}
Also used : Node(org.w3c.dom.Node) YamlNode(com.hazelcast.internal.yaml.YamlNode) SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig)

Example 4 with SplitBrainProtectionConfig

use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.

the class SplitBrainProtectionServiceImpl method initializeListeners.

private void initializeListeners() {
    for (Map.Entry<String, SplitBrainProtectionConfig> configEntry : nodeEngine.getConfig().getSplitBrainProtectionConfigs().entrySet()) {
        SplitBrainProtectionConfig config = configEntry.getValue();
        String instanceName = configEntry.getKey();
        for (SplitBrainProtectionListenerConfig listenerConfig : config.getListenerConfigs()) {
            initializeListenerInternal(instanceName, listenerConfig);
        }
    }
}
Also used : SplitBrainProtectionListenerConfig(com.hazelcast.config.SplitBrainProtectionListenerConfig) SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with SplitBrainProtectionConfig

use of com.hazelcast.config.SplitBrainProtectionConfig in project hazelcast by hazelcast.

the class CacheSplitBrainProtectionConfigTest method cacheConfigXmlTest.

@Test
public void cacheConfigXmlTest() throws IOException {
    final String cacheName = "configtestCache" + randomString();
    Config config = new XmlConfigBuilder(configUrl).build();
    CacheSimpleConfig cacheConfig1 = config.getCacheConfig(cacheName);
    final String splitBrainProtectionName = cacheConfig1.getSplitBrainProtectionName();
    assertEquals("cache-split-brain-protection", splitBrainProtectionName);
    SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig(splitBrainProtectionName);
    assertEquals(3, splitBrainProtectionConfig.getMinimumClusterSize());
    assertEquals(SplitBrainProtectionOn.READ_WRITE, splitBrainProtectionConfig.getProtectOn());
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig) Config(com.hazelcast.config.Config) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

SplitBrainProtectionConfig (com.hazelcast.config.SplitBrainProtectionConfig)32 Config (com.hazelcast.config.Config)21 QuickTest (com.hazelcast.test.annotation.QuickTest)21 Test (org.junit.Test)21 MapConfig (com.hazelcast.config.MapConfig)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)17 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 ProbabilisticSplitBrainProtectionFunction (com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction)9 RecentlyActiveSplitBrainProtectionFunction (com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction)9 Member (com.hazelcast.cluster.Member)7 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)6 SplitBrainProtectionListenerConfig (com.hazelcast.config.SplitBrainProtectionListenerConfig)4 InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)3 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2 AssertTask (com.hazelcast.test.AssertTask)2 IQueue (com.hazelcast.collection.IQueue)1 AttributeConfig (com.hazelcast.config.AttributeConfig)1 AwsConfig (com.hazelcast.config.AwsConfig)1 AzureConfig (com.hazelcast.config.AzureConfig)1 BitmapIndexOptions (com.hazelcast.config.BitmapIndexOptions)1