Search in sources :

Example 6 with RecentlyActiveSplitBrainProtectionFunction

use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.

the class XMLConfigBuilderTest method testConfig_whenRecentlyActiveSplitBrainProtection_withCustomValues.

@Override
@Test
public void testConfig_whenRecentlyActiveSplitBrainProtection_withCustomValues() {
    String xml = HAZELCAST_START_TAG + "      <split-brain-protection enabled=\"true\" name=\"mySplitBrainProtection\">\n" + "        <minimum-cluster-size>3</minimum-cluster-size>\n" + "        <recently-active-split-brain-protection heartbeat-tolerance-millis=\"13000\" />" + "    </split-brain-protection>\n" + HAZELCAST_END_TAG;
    Config config = buildConfig(xml);
    SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
    assertEquals(3, splitBrainProtectionConfig.getMinimumClusterSize());
    assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
    RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
    assertEquals(13000, splitBrainProtectionFunction.getHeartbeatToleranceMillis());
}
Also used : RecentlyActiveSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction) TokenIdentityConfig(com.hazelcast.config.security.TokenIdentityConfig) LdapAuthenticationConfig(com.hazelcast.config.security.LdapAuthenticationConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) RaftAlgorithmConfig(com.hazelcast.config.cp.RaftAlgorithmConfig) SimpleAuthenticationConfig(com.hazelcast.config.security.SimpleAuthenticationConfig) KerberosIdentityConfig(com.hazelcast.config.security.KerberosIdentityConfig) KerberosAuthenticationConfig(com.hazelcast.config.security.KerberosAuthenticationConfig) RealmConfig(com.hazelcast.config.security.RealmConfig) FencedLockConfig(com.hazelcast.config.cp.FencedLockConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with RecentlyActiveSplitBrainProtectionFunction

use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.

the class YamlConfigBuilderTest method testConfig_whenRecentlyActiveSplitBrainProtection_withCustomValues.

@Override
@Test
public void testConfig_whenRecentlyActiveSplitBrainProtection_withCustomValues() {
    String yaml = "" + "hazelcast:\n" + "  split-brain-protection:\n" + "    mySplitBrainProtection:\n" + "      enabled: true\n" + "      minimum-cluster-size: 3\n" + "      recently-active-split-brain-protection:\n" + "        heartbeat-tolerance-millis: 13000\n";
    Config config = buildConfig(yaml);
    SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
    assertEquals(3, splitBrainProtectionConfig.getMinimumClusterSize());
    assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
    RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
    assertEquals(13000, splitBrainProtectionFunction.getHeartbeatToleranceMillis());
}
Also used : RecentlyActiveSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction) LdapAuthenticationConfig(com.hazelcast.config.security.LdapAuthenticationConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) RaftAlgorithmConfig(com.hazelcast.config.cp.RaftAlgorithmConfig) SimpleAuthenticationConfig(com.hazelcast.config.security.SimpleAuthenticationConfig) KerberosIdentityConfig(com.hazelcast.config.security.KerberosIdentityConfig) KerberosAuthenticationConfig(com.hazelcast.config.security.KerberosAuthenticationConfig) RealmConfig(com.hazelcast.config.security.RealmConfig) FencedLockConfig(com.hazelcast.config.cp.FencedLockConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with RecentlyActiveSplitBrainProtectionFunction

use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction in project hazelcast by hazelcast.

the class SplitBrainProtectionTest method testRecentlyActiveSplitBrainProtectionConsidersLocalMember.

@Test
public void testRecentlyActiveSplitBrainProtectionConsidersLocalMember() {
    final String splitBrainProtectionName = randomString();
    SplitBrainProtectionFunction splitBrainProtectionFunction = new RecentlyActiveSplitBrainProtectionFunction(1, 10000);
    SplitBrainProtectionConfig splitBrainProtectionConfig = new SplitBrainProtectionConfig().setName(splitBrainProtectionName).setEnabled(true).setFunctionImplementation(splitBrainProtectionFunction);
    Config config = new Config().addSplitBrainProtectionConfig(splitBrainProtectionConfig).setProperty(ClusterProperty.HEARTBEAT_INTERVAL_SECONDS.getName(), "1");
    HazelcastInstance instance = createHazelcastInstance(config);
    final SplitBrainProtection splitBrainProtection = instance.getSplitBrainProtectionService().getSplitBrainProtection(splitBrainProtectionName);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertTrue(splitBrainProtection.hasMinimumSize());
        }
    });
}
Also used : RecentlyActiveSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction) HazelcastInstance(com.hazelcast.core.HazelcastInstance) RecentlyActiveSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction) ProbabilisticSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction) MapConfig(com.hazelcast.config.MapConfig) SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig) Config(com.hazelcast.config.Config) AssertTask(com.hazelcast.test.AssertTask) SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

RecentlyActiveSplitBrainProtectionFunction (com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction)8 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)5 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)4 FencedLockConfig (com.hazelcast.config.cp.FencedLockConfig)4 RaftAlgorithmConfig (com.hazelcast.config.cp.RaftAlgorithmConfig)4 SemaphoreConfig (com.hazelcast.config.cp.SemaphoreConfig)4 KerberosAuthenticationConfig (com.hazelcast.config.security.KerberosAuthenticationConfig)4 KerberosIdentityConfig (com.hazelcast.config.security.KerberosIdentityConfig)4 LdapAuthenticationConfig (com.hazelcast.config.security.LdapAuthenticationConfig)4 RealmConfig (com.hazelcast.config.security.RealmConfig)4 SimpleAuthenticationConfig (com.hazelcast.config.security.SimpleAuthenticationConfig)4 SplitBrainProtectionConfig (com.hazelcast.config.SplitBrainProtectionConfig)2 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)2 ProbabilisticSplitBrainProtectionFunction (com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction)2 Config (com.hazelcast.config.Config)1 MapConfig (com.hazelcast.config.MapConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 AssertTask (com.hazelcast.test.AssertTask)1