Search in sources :

Example 1 with CPSubsystemConfig

use of com.hazelcast.config.cp.CPSubsystemConfig in project hazelcast by hazelcast.

the class ConfigXmlGeneratorTest method testCPSubsystemConfig.

@Test
public void testCPSubsystemConfig() {
    Config config = new Config();
    config.getCPSubsystemConfig().setCPMemberCount(10).setGroupSize(5).setSessionTimeToLiveSeconds(15).setSessionHeartbeatIntervalSeconds(3).setMissingCPMemberAutoRemovalSeconds(120).setFailOnIndeterminateOperationState(true).setPersistenceEnabled(true).setBaseDir(new File("/custom-dir"));
    config.getCPSubsystemConfig().getRaftAlgorithmConfig().setLeaderElectionTimeoutInMillis(500).setLeaderHeartbeatPeriodInMillis(100).setMaxMissedLeaderHeartbeatCount(10).setAppendRequestMaxEntryCount(25).setAppendRequestMaxEntryCount(250).setUncommittedEntryCountToRejectNewAppends(75).setAppendRequestBackoffTimeoutInMillis(50);
    config.getCPSubsystemConfig().addSemaphoreConfig(new SemaphoreConfig("sem1", true, 1)).addSemaphoreConfig(new SemaphoreConfig("sem2", false, 2));
    config.getCPSubsystemConfig().addLockConfig(new FencedLockConfig("lock1", 1)).addLockConfig(new FencedLockConfig("lock1", 2));
    CPSubsystemConfig generatedConfig = getNewConfigViaXMLGenerator(config).getCPSubsystemConfig();
    assertTrue(generatedConfig + " should be compatible with " + config.getCPSubsystemConfig(), new CPSubsystemConfigChecker().check(config.getCPSubsystemConfig(), generatedConfig));
}
Also used : CPSubsystemConfigChecker(com.hazelcast.config.ConfigCompatibilityChecker.CPSubsystemConfigChecker) FencedLockConfig(com.hazelcast.config.cp.FencedLockConfig) TlsAuthenticationConfig(com.hazelcast.config.security.TlsAuthenticationConfig) TokenIdentityConfig(com.hazelcast.config.security.TokenIdentityConfig) LdapAuthenticationConfig(com.hazelcast.config.security.LdapAuthenticationConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) SimpleAuthenticationConfig(com.hazelcast.config.security.SimpleAuthenticationConfig) KerberosIdentityConfig(com.hazelcast.config.security.KerberosIdentityConfig) KerberosAuthenticationConfig(com.hazelcast.config.security.KerberosAuthenticationConfig) RealmConfig(com.hazelcast.config.security.RealmConfig) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) JetConfig(com.hazelcast.jet.config.JetConfig) FencedLockConfig(com.hazelcast.config.cp.FencedLockConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) File(java.io.File) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with CPSubsystemConfig

use of com.hazelcast.config.cp.CPSubsystemConfig in project hazelcast by hazelcast.

the class YamlConfigBuilderTest method testCPSubsystemConfig.

@Override
@Test
public void testCPSubsystemConfig() {
    String yaml = "" + "hazelcast:\n" + "  cp-subsystem:\n" + "    cp-member-count: 10\n" + "    group-size: 5\n" + "    session-time-to-live-seconds: 15\n" + "    session-heartbeat-interval-seconds: 3\n" + "    missing-cp-member-auto-removal-seconds: 120\n" + "    fail-on-indeterminate-operation-state: true\n" + "    persistence-enabled: true\n" + "    base-dir: /mnt/cp-data\n" + "    data-load-timeout-seconds: 30\n" + "    raft-algorithm:\n" + "      leader-election-timeout-in-millis: 500\n" + "      leader-heartbeat-period-in-millis: 100\n" + "      max-missed-leader-heartbeat-count: 3\n" + "      append-request-max-entry-count: 25\n" + "      commit-index-advance-count-to-snapshot: 250\n" + "      uncommitted-entry-count-to-reject-new-appends: 75\n" + "      append-request-backoff-timeout-in-millis: 50\n" + "    semaphores:\n" + "      sem1:\n" + "        jdk-compatible: true\n" + "        initial-permits: 1\n" + "      sem2:\n" + "        jdk-compatible: false\n" + "        initial-permits: 2\n" + "    locks:\n" + "      lock1:\n" + "        lock-acquire-limit: 1\n" + "      lock2:\n" + "        lock-acquire-limit: 2\n";
    Config config = buildConfig(yaml);
    CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig();
    assertEquals(10, cpSubsystemConfig.getCPMemberCount());
    assertEquals(5, cpSubsystemConfig.getGroupSize());
    assertEquals(15, cpSubsystemConfig.getSessionTimeToLiveSeconds());
    assertEquals(3, cpSubsystemConfig.getSessionHeartbeatIntervalSeconds());
    assertEquals(120, cpSubsystemConfig.getMissingCPMemberAutoRemovalSeconds());
    assertTrue(cpSubsystemConfig.isFailOnIndeterminateOperationState());
    assertTrue(cpSubsystemConfig.isPersistenceEnabled());
    assertEquals(new File("/mnt/cp-data").getAbsoluteFile(), cpSubsystemConfig.getBaseDir().getAbsoluteFile());
    assertEquals(30, cpSubsystemConfig.getDataLoadTimeoutSeconds());
    RaftAlgorithmConfig raftAlgorithmConfig = cpSubsystemConfig.getRaftAlgorithmConfig();
    assertEquals(500, raftAlgorithmConfig.getLeaderElectionTimeoutInMillis());
    assertEquals(100, raftAlgorithmConfig.getLeaderHeartbeatPeriodInMillis());
    assertEquals(3, raftAlgorithmConfig.getMaxMissedLeaderHeartbeatCount());
    assertEquals(25, raftAlgorithmConfig.getAppendRequestMaxEntryCount());
    assertEquals(250, raftAlgorithmConfig.getCommitIndexAdvanceCountToSnapshot());
    assertEquals(75, raftAlgorithmConfig.getUncommittedEntryCountToRejectNewAppends());
    assertEquals(50, raftAlgorithmConfig.getAppendRequestBackoffTimeoutInMillis());
    SemaphoreConfig semaphoreConfig1 = cpSubsystemConfig.findSemaphoreConfig("sem1");
    SemaphoreConfig semaphoreConfig2 = cpSubsystemConfig.findSemaphoreConfig("sem2");
    assertNotNull(semaphoreConfig1);
    assertNotNull(semaphoreConfig2);
    assertTrue(semaphoreConfig1.isJDKCompatible());
    assertFalse(semaphoreConfig2.isJDKCompatible());
    assertEquals(1, semaphoreConfig1.getInitialPermits());
    assertEquals(2, semaphoreConfig2.getInitialPermits());
    FencedLockConfig lockConfig1 = cpSubsystemConfig.findLockConfig("lock1");
    FencedLockConfig lockConfig2 = cpSubsystemConfig.findLockConfig("lock2");
    assertNotNull(lockConfig1);
    assertNotNull(lockConfig2);
    assertEquals(1, lockConfig1.getLockAcquireLimit());
    assertEquals(2, lockConfig2.getLockAcquireLimit());
}
Also used : RaftAlgorithmConfig(com.hazelcast.config.cp.RaftAlgorithmConfig) FencedLockConfig(com.hazelcast.config.cp.FencedLockConfig) 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) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) File.createTempFile(java.io.File.createTempFile) File(java.io.File) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with CPSubsystemConfig

use of com.hazelcast.config.cp.CPSubsystemConfig in project hazelcast by hazelcast.

the class CPConfigCheckerTest method whenGroupSize_greaterThanMemberCount.

@Test(expected = IllegalArgumentException.class)
public void whenGroupSize_greaterThanMemberCount() {
    Config config = new Config();
    CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig();
    cpSubsystemConfig.setCPMemberCount(3);
    cpSubsystemConfig.setGroupSize(5);
    checkCPSubsystemConfig(cpSubsystemConfig);
}
Also used : Config(com.hazelcast.config.Config) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) ConfigValidator.checkCPSubsystemConfig(com.hazelcast.internal.config.ConfigValidator.checkCPSubsystemConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) ConfigValidator.checkCPSubsystemConfig(com.hazelcast.internal.config.ConfigValidator.checkCPSubsystemConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with CPSubsystemConfig

use of com.hazelcast.config.cp.CPSubsystemConfig in project hazelcast by hazelcast.

the class CPConfigCheckerTest method whenGroupSize_smallerThanMin.

@Test(expected = IllegalArgumentException.class)
public void whenGroupSize_smallerThanMin() {
    Config config = new Config();
    CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig();
    cpSubsystemConfig.setGroupSize(CPSubsystemConfig.MIN_GROUP_SIZE - 1);
}
Also used : Config(com.hazelcast.config.Config) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) ConfigValidator.checkCPSubsystemConfig(com.hazelcast.internal.config.ConfigValidator.checkCPSubsystemConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) ConfigValidator.checkCPSubsystemConfig(com.hazelcast.internal.config.ConfigValidator.checkCPSubsystemConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with CPSubsystemConfig

use of com.hazelcast.config.cp.CPSubsystemConfig in project hazelcast by hazelcast.

the class CPConfigCheckerTest method whenSessionTTL_greaterThanMissingMemberTimeout.

@Test(expected = IllegalArgumentException.class)
public void whenSessionTTL_greaterThanMissingMemberTimeout() {
    Config config = new Config();
    CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig();
    cpSubsystemConfig.setSessionTimeToLiveSeconds(100);
    cpSubsystemConfig.setMissingCPMemberAutoRemovalSeconds(10);
    checkCPSubsystemConfig(cpSubsystemConfig);
}
Also used : Config(com.hazelcast.config.Config) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) ConfigValidator.checkCPSubsystemConfig(com.hazelcast.internal.config.ConfigValidator.checkCPSubsystemConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) ConfigValidator.checkCPSubsystemConfig(com.hazelcast.internal.config.ConfigValidator.checkCPSubsystemConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)28 Config (com.hazelcast.config.Config)18 QuickTest (com.hazelcast.test.annotation.QuickTest)16 Test (org.junit.Test)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 ConfigValidator.checkCPSubsystemConfig (com.hazelcast.internal.config.ConfigValidator.checkCPSubsystemConfig)12 SemaphoreConfig (com.hazelcast.config.cp.SemaphoreConfig)8 FencedLockConfig (com.hazelcast.config.cp.FencedLockConfig)5 RaftAlgorithmConfig (com.hazelcast.config.cp.RaftAlgorithmConfig)4 File (java.io.File)4 KerberosAuthenticationConfig (com.hazelcast.config.security.KerberosAuthenticationConfig)3 KerberosIdentityConfig (com.hazelcast.config.security.KerberosIdentityConfig)3 LdapAuthenticationConfig (com.hazelcast.config.security.LdapAuthenticationConfig)3 RealmConfig (com.hazelcast.config.security.RealmConfig)3 SimpleAuthenticationConfig (com.hazelcast.config.security.SimpleAuthenticationConfig)3 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)2 File.createTempFile (java.io.File.createTempFile)2 CPSubsystemConfigChecker (com.hazelcast.config.ConfigCompatibilityChecker.CPSubsystemConfigChecker)1 PersistenceConfig (com.hazelcast.config.PersistenceConfig)1 JaasAuthenticationConfig (com.hazelcast.config.security.JaasAuthenticationConfig)1