Search in sources :

Example 6 with ProbabilisticSplitBrainProtectionFunction

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

the class XMLConfigBuilderTest method testConfig_whenProbabilisticSplitBrainProtection_withDefaultValues.

@Override
@Test
public void testConfig_whenProbabilisticSplitBrainProtection_withDefaultValues() {
    String xml = HAZELCAST_START_TAG + "      <split-brain-protection enabled=\"true\" name=\"mySplitBrainProtection\">\n" + "        <minimum-cluster-size>3</minimum-cluster-size>\n" + "        <probabilistic-split-brain-protection />" + "    </split-brain-protection>\n" + HAZELCAST_END_TAG;
    Config config = buildConfig(xml);
    SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
    assertInstanceOf(ProbabilisticSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
    ProbabilisticSplitBrainProtectionFunction splitBrainProtectionFunction = (ProbabilisticSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
    assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_INTERVAL_MILLIS, splitBrainProtectionFunction.getHeartbeatIntervalMillis());
    assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_PAUSE_MILLIS, splitBrainProtectionFunction.getAcceptableHeartbeatPauseMillis());
    assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_MIN_STD_DEVIATION, splitBrainProtectionFunction.getMinStdDeviationMillis());
    assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_PHI_THRESHOLD, splitBrainProtectionFunction.getSuspicionThreshold(), 0.01);
    assertEquals(ProbabilisticSplitBrainProtectionConfigBuilder.DEFAULT_SAMPLE_SIZE, splitBrainProtectionFunction.getMaxSampleSize());
}
Also used : ProbabilisticSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction) 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 ProbabilisticSplitBrainProtectionFunction

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

the class XMLConfigBuilderTest method testConfig_whenProbabilisticSplitBrainProtection_withCustomValues.

@Override
@Test
public void testConfig_whenProbabilisticSplitBrainProtection_withCustomValues() {
    String xml = HAZELCAST_START_TAG + "      <split-brain-protection enabled=\"true\" name=\"mySplitBrainProtection\">\n" + "        <minimum-cluster-size>3</minimum-cluster-size>\n" + "        <probabilistic-split-brain-protection acceptable-heartbeat-pause-millis=\"37400\" suspicion-threshold=\"3.14592\" " + "                 max-sample-size=\"42\" min-std-deviation-millis=\"1234\"" + "                 heartbeat-interval-millis=\"4321\" />" + "    </split-brain-protection>\n" + HAZELCAST_END_TAG;
    Config config = buildConfig(xml);
    SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
    assertInstanceOf(ProbabilisticSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
    ProbabilisticSplitBrainProtectionFunction splitBrainProtectionFunction = (ProbabilisticSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
    assertEquals(4321, splitBrainProtectionFunction.getHeartbeatIntervalMillis());
    assertEquals(37400, splitBrainProtectionFunction.getAcceptableHeartbeatPauseMillis());
    assertEquals(1234, splitBrainProtectionFunction.getMinStdDeviationMillis());
    assertEquals(3.14592d, splitBrainProtectionFunction.getSuspicionThreshold(), 0.001d);
    assertEquals(42, splitBrainProtectionFunction.getMaxSampleSize());
}
Also used : ProbabilisticSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction) 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 8 with ProbabilisticSplitBrainProtectionFunction

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

the class YamlConfigBuilderTest method testConfig_whenProbabilisticSplitBrainProtection_withCustomValues.

@Override
@Test
public void testConfig_whenProbabilisticSplitBrainProtection_withCustomValues() {
    String yaml = "" + "hazelcast:\n" + "  split-brain-protection:\n" + "    mySplitBrainProtection:\n" + "      enabled: true\n" + "      minimum-cluster-size: 3\n" + "      probabilistic-split-brain-protection:\n" + "        acceptable-heartbeat-pause-millis: 37400\n" + "        suspicion-threshold: 3.14592\n" + "        max-sample-size: 42\n" + "        min-std-deviation-millis: 1234\n" + "        heartbeat-interval-millis: 4321";
    Config config = buildConfig(yaml);
    SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
    assertInstanceOf(ProbabilisticSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
    ProbabilisticSplitBrainProtectionFunction splitBrainProtectionFunction = (ProbabilisticSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
    assertEquals(4321, splitBrainProtectionFunction.getHeartbeatIntervalMillis());
    assertEquals(37400, splitBrainProtectionFunction.getAcceptableHeartbeatPauseMillis());
    assertEquals(1234, splitBrainProtectionFunction.getMinStdDeviationMillis());
    assertEquals(3.14592d, splitBrainProtectionFunction.getSuspicionThreshold(), 0.001d);
    assertEquals(42, splitBrainProtectionFunction.getMaxSampleSize());
}
Also used : ProbabilisticSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction) 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)

Aggregations

ProbabilisticSplitBrainProtectionFunction (com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction)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 RecentlyActiveSplitBrainProtectionFunction (com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction)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