Search in sources :

Example 1 with RecentlyActiveSplitBrainProtectionFunction

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

the class YamlConfigBuilderTest method testConfig_whenRecentlyActiveSplitBrainProtection_withDefaultValues.

@Override
@Test
public void testConfig_whenRecentlyActiveSplitBrainProtection_withDefaultValues() {
    String yaml = "" + "hazelcast:\n" + "  split-brain-protection:\n" + "    mySplitBrainProtection:\n" + "      enabled: true\n" + "      minimum-cluster-size: 3\n" + "      recently-active-split-brain-protection: {}";
    Config config = buildConfig(yaml);
    SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
    assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
    RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
    assertEquals(RecentlyActiveSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_TOLERANCE_MILLIS, 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 2 with RecentlyActiveSplitBrainProtectionFunction

use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction 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 RecentlyActiveSplitBrainProtectionFunction

use of com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction 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 4 with RecentlyActiveSplitBrainProtectionFunction

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

the class RecentlyActiveSplitBrainProtectionConfigBuilder method build.

public SplitBrainProtectionConfig build() {
    RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = new RecentlyActiveSplitBrainProtectionFunction(size, heartbeatToleranceMillis);
    SplitBrainProtectionConfig splitBrainProtectionConfig = new SplitBrainProtectionConfig(name, enabled, size);
    splitBrainProtectionConfig.setFunctionImplementation(splitBrainProtectionFunction);
    return splitBrainProtectionConfig;
}
Also used : RecentlyActiveSplitBrainProtectionFunction(com.hazelcast.splitbrainprotection.impl.RecentlyActiveSplitBrainProtectionFunction)

Example 5 with RecentlyActiveSplitBrainProtectionFunction

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

the class XMLConfigBuilderTest method testConfig_whenRecentlyActiveSplitBrainProtection_withDefaultValues.

@Override
@Test
public void testConfig_whenRecentlyActiveSplitBrainProtection_withDefaultValues() {
    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 />" + "    </split-brain-protection>\n" + HAZELCAST_END_TAG;
    Config config = buildConfig(xml);
    SplitBrainProtectionConfig splitBrainProtectionConfig = config.getSplitBrainProtectionConfig("mySplitBrainProtection");
    assertInstanceOf(RecentlyActiveSplitBrainProtectionFunction.class, splitBrainProtectionConfig.getFunctionImplementation());
    RecentlyActiveSplitBrainProtectionFunction splitBrainProtectionFunction = (RecentlyActiveSplitBrainProtectionFunction) splitBrainProtectionConfig.getFunctionImplementation();
    assertEquals(RecentlyActiveSplitBrainProtectionConfigBuilder.DEFAULT_HEARTBEAT_TOLERANCE_MILLIS, 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)

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