Search in sources :

Example 1 with ProbabilisticSplitBrainProtectionFunction

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

the class YamlConfigBuilderTest method testConfig_whenProbabilisticSplitBrainProtection_withDefaultValues.

@Override
@Test
public void testConfig_whenProbabilisticSplitBrainProtection_withDefaultValues() {
    String yaml = "" + "hazelcast:\n" + "  split-brain-protection:\n" + "    mySplitBrainProtection:\n" + "      enabled: true\n" + "      minimum-cluster-size: 3\n" + "      probabilistic-split-brain-protection: {}";
    Config config = buildConfig(yaml);
    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) 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 2 with ProbabilisticSplitBrainProtectionFunction

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

the class ConfigXmlGenerator method handleSplitBrainProtectionFunction.

private static void handleSplitBrainProtectionFunction(XmlGenerator gen, SplitBrainProtectionConfig splitBrainProtectionConfig) {
    if (splitBrainProtectionConfig.getFunctionImplementation() instanceof ProbabilisticSplitBrainProtectionFunction) {
        ProbabilisticSplitBrainProtectionFunction qf = (ProbabilisticSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
        long acceptableHeartbeatPause = qf.getAcceptableHeartbeatPauseMillis();
        double threshold = qf.getSuspicionThreshold();
        int maxSampleSize = qf.getMaxSampleSize();
        long minStdDeviation = qf.getMinStdDeviationMillis();
        long firstHeartbeatEstimate = qf.getHeartbeatIntervalMillis();
        gen.open("probabilistic-split-brain-protection", "acceptable-heartbeat-pause-millis", acceptableHeartbeatPause, "suspicion-threshold", threshold, "max-sample-size", maxSampleSize, "min-std-deviation-millis", minStdDeviation, "heartbeat-interval-millis", firstHeartbeatEstimate);
        gen.close();
    } else if (splitBrainProtectionConfig.getFunctionImplementation() instanceof RecentlyActiveSplitBrainProtectionFunction) {
        RecentlyActiveSplitBrainProtectionFunction qf = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
        gen.open("recently-active-split-brain-protection", "heartbeat-tolerance-millis", qf.getHeartbeatToleranceMillis());
        gen.close();
    } else {
        gen.node("function-class-name", classNameOrImplClass(splitBrainProtectionConfig.getFunctionClassName(), splitBrainProtectionConfig.getFunctionImplementation()));
    }
}
Also used : RecentlyActiveSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction) ProbabilisticSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction)

Example 3 with ProbabilisticSplitBrainProtectionFunction

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

the class SplitBrainProtectionTest method testProbabilisticSplitBrainProtectionConsidersLocalMember.

@Test
public void testProbabilisticSplitBrainProtectionConsidersLocalMember() {
    String splitBrainProtectionName = randomString();
    SplitBrainProtectionFunction splitBrainProtectionFunction = new ProbabilisticSplitBrainProtectionFunction(1, 100, 1250, 20, 100, 20);
    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 : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ProbabilisticSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction) 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)

Example 4 with ProbabilisticSplitBrainProtectionFunction

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

the class TestFullApplicationContext method testProbabilisticSplitBrainProtectionConfig.

@Test
public void testProbabilisticSplitBrainProtectionConfig() {
    SplitBrainProtectionConfig probabilisticSplitBrainProtectionConfig = config.getSplitBrainProtectionConfig("probabilistic-split-brain-protection");
    assertNotNull(probabilisticSplitBrainProtectionConfig);
    assertEquals("probabilistic-split-brain-protection", probabilisticSplitBrainProtectionConfig.getName());
    assertNotNull(probabilisticSplitBrainProtectionConfig.getFunctionImplementation());
    assertInstanceOf(ProbabilisticSplitBrainProtectionFunction.class, probabilisticSplitBrainProtectionConfig.getFunctionImplementation());
    assertTrue(probabilisticSplitBrainProtectionConfig.isEnabled());
    assertEquals(3, probabilisticSplitBrainProtectionConfig.getMinimumClusterSize());
    assertEquals(2, probabilisticSplitBrainProtectionConfig.getListenerConfigs().size());
    assertEquals(SplitBrainProtectionOn.READ_WRITE, probabilisticSplitBrainProtectionConfig.getProtectOn());
    assertEquals("com.hazelcast.spring.DummySplitBrainProtectionListener", probabilisticSplitBrainProtectionConfig.getListenerConfigs().get(0).getClassName());
    assertNotNull(probabilisticSplitBrainProtectionConfig.getListenerConfigs().get(1).getImplementation());
    ProbabilisticSplitBrainProtectionFunction splitBrainProtectionFunction = (ProbabilisticSplitBrainProtectionFunction) probabilisticSplitBrainProtectionConfig.getFunctionImplementation();
    assertEquals(11, splitBrainProtectionFunction.getSuspicionThreshold(), 0.001d);
    assertEquals(31415, splitBrainProtectionFunction.getAcceptableHeartbeatPauseMillis());
    assertEquals(42, splitBrainProtectionFunction.getMaxSampleSize());
    assertEquals(77123, splitBrainProtectionFunction.getHeartbeatIntervalMillis());
    assertEquals(1000, splitBrainProtectionFunction.getMinStdDeviationMillis());
}
Also used : ProbabilisticSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction) SplitBrainProtectionConfig(com.hazelcast.config.SplitBrainProtectionConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 5 with ProbabilisticSplitBrainProtectionFunction

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

the class ProbabilisticSplitBrainProtectionConfigBuilder method build.

public SplitBrainProtectionConfig build() {
    ProbabilisticSplitBrainProtectionFunction splitBrainProtectionFunction = new ProbabilisticSplitBrainProtectionFunction(minimumClusterSize, heartbeatIntervalMillis, acceptableHeartbeatPauseMillis, maxSampleSize, minStdDeviationMillis, phiThreshold);
    SplitBrainProtectionConfig config = new SplitBrainProtectionConfig();
    config.setName(name);
    config.setEnabled(enabled);
    config.setMinimumClusterSize(minimumClusterSize);
    config.setFunctionImplementation(splitBrainProtectionFunction);
    return config;
}
Also used : ProbabilisticSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.ProbabilisticSplitBrainProtectionFunction)

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