Search in sources :

Example 11 with SemaphoreConfig

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

the class MemberDomConfigProcessor method handleSemaphores.

void handleSemaphores(CPSubsystemConfig cpSubsystemConfig, Node node) {
    for (Node child : childElements(node)) {
        SemaphoreConfig semaphoreConfig = new SemaphoreConfig();
        for (Node subChild : childElements(child)) {
            String nodeName = cleanNodeName(subChild);
            if (matches("name", nodeName)) {
                semaphoreConfig.setName(getTextContent(subChild));
            } else if (matches("jdk-compatible", nodeName)) {
                semaphoreConfig.setJDKCompatible(Boolean.parseBoolean(getTextContent(subChild)));
            } else if (matches("initial-permits", nodeName)) {
                semaphoreConfig.setInitialPermits(Integer.parseInt(getTextContent(subChild)));
            }
        }
        cpSubsystemConfig.addSemaphoreConfig(semaphoreConfig);
    }
}
Also used : Node(org.w3c.dom.Node) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig)

Example 12 with SemaphoreConfig

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

the class YamlMemberDomConfigProcessor method handleSemaphores.

@Override
void handleSemaphores(CPSubsystemConfig cpSubsystemConfig, Node node) {
    for (Node child : childElements(node)) {
        SemaphoreConfig semaphoreConfig = new SemaphoreConfig();
        semaphoreConfig.setName(child.getNodeName());
        for (Node subChild : childElements(child)) {
            String nodeName = cleanNodeName(subChild);
            if (matches("jdk-compatible", nodeName)) {
                semaphoreConfig.setJDKCompatible(Boolean.parseBoolean(getTextContent(subChild)));
            } else if (matches("initial-permits", nodeName)) {
                semaphoreConfig.setInitialPermits(Integer.parseInt(getTextContent(subChild)));
            }
        }
        cpSubsystemConfig.addSemaphoreConfig(semaphoreConfig);
    }
}
Also used : Node(org.w3c.dom.Node) YamlNode(com.hazelcast.internal.yaml.YamlNode) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig)

Example 13 with SemaphoreConfig

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

the class SemaphoreAdvancedTest method createConfig.

@Override
protected Config createConfig(int cpNodeCount, int groupSize) {
    Config config = super.createConfig(cpNodeCount, groupSize);
    CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig();
    cpSubsystemConfig.getRaftAlgorithmConfig().setCommitIndexAdvanceCountToSnapshot(LOG_ENTRY_COUNT_TO_SNAPSHOT);
    cpSubsystemConfig.setSessionTimeToLiveSeconds(10);
    cpSubsystemConfig.setSessionHeartbeatIntervalSeconds(1);
    SemaphoreConfig semaphoreConfig = new SemaphoreConfig();
    semaphoreConfig.setName(objectName);
    cpSubsystemConfig.addSemaphoreConfig(semaphoreConfig);
    return config;
}
Also used : SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) Config(com.hazelcast.config.Config) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig)

Example 14 with SemaphoreConfig

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

the class XMLConfigBuilderTest method testCPSubsystemConfig.

@Override
@Test
public void testCPSubsystemConfig() {
    String xml = HAZELCAST_START_TAG + "<cp-subsystem>\n" + "  <cp-member-count>10</cp-member-count>\n" + "  <group-size>5</group-size>\n" + "  <session-time-to-live-seconds>15</session-time-to-live-seconds>\n" + "  <session-heartbeat-interval-seconds>3</session-heartbeat-interval-seconds>\n" + "  <missing-cp-member-auto-removal-seconds>120</missing-cp-member-auto-removal-seconds>\n" + "  <fail-on-indeterminate-operation-state>true</fail-on-indeterminate-operation-state>\n" + "  <persistence-enabled>true</persistence-enabled>\n" + "  <base-dir>/mnt/cp-data</base-dir>\n" + "  <data-load-timeout-seconds>30</data-load-timeout-seconds>\n" + "  <raft-algorithm>\n" + "    <leader-election-timeout-in-millis>500</leader-election-timeout-in-millis>\n" + "    <leader-heartbeat-period-in-millis>100</leader-heartbeat-period-in-millis>\n" + "    <max-missed-leader-heartbeat-count>3</max-missed-leader-heartbeat-count>\n" + "    <append-request-max-entry-count>25</append-request-max-entry-count>\n" + "    <commit-index-advance-count-to-snapshot>250</commit-index-advance-count-to-snapshot>\n" + "    <uncommitted-entry-count-to-reject-new-appends>75</uncommitted-entry-count-to-reject-new-appends>\n" + "    <append-request-backoff-timeout-in-millis>50</append-request-backoff-timeout-in-millis>\n" + "  </raft-algorithm>\n" + "  <semaphores>\n" + "    <semaphore>\n" + "      <name>sem1</name>\n" + "      <jdk-compatible>true</jdk-compatible>\n" + "      <initial-permits>1</initial-permits>\n" + "    </semaphore>\n" + "    <semaphore>\n" + "      <name>sem2</name>\n" + "      <jdk-compatible>false</jdk-compatible>\n" + "      <initial-permits>2</initial-permits>\n" + "    </semaphore>\n" + "  </semaphores>\n" + "  <locks>\n" + "    <fenced-lock>\n" + "      <name>lock1</name>\n" + "      <lock-acquire-limit>1</lock-acquire-limit>\n" + "    </fenced-lock>\n" + "    <fenced-lock>\n" + "      <name>lock2</name>\n" + "      <lock-acquire-limit>2</lock-acquire-limit>\n" + "    </fenced-lock>\n" + "  </locks>\n" + "</cp-subsystem>" + HAZELCAST_END_TAG;
    Config config = new InMemoryXmlConfig(xml);
    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) 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) 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 15 with SemaphoreConfig

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

the class SessionlessSemaphoreBasicTest method createConfig.

@Override
protected Config createConfig(int cpNodeCount, int groupSize) {
    Config config = super.createConfig(cpNodeCount, groupSize);
    SemaphoreConfig semaphoreConfig = new SemaphoreConfig(objectName, true, 0);
    config.getCPSubsystemConfig().addSemaphoreConfig(semaphoreConfig);
    return config;
}
Also used : Config(com.hazelcast.config.Config) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig)

Aggregations

SemaphoreConfig (com.hazelcast.config.cp.SemaphoreConfig)19 Config (com.hazelcast.config.Config)9 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)8 FencedLockConfig (com.hazelcast.config.cp.FencedLockConfig)5 RaftAlgorithmConfig (com.hazelcast.config.cp.RaftAlgorithmConfig)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 File (java.io.File)4 Test (org.junit.Test)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 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)2 File.createTempFile (java.io.File.createTempFile)2 Node (org.w3c.dom.Node)2 CPSubsystemConfigChecker (com.hazelcast.config.ConfigCompatibilityChecker.CPSubsystemConfigChecker)1 JaasAuthenticationConfig (com.hazelcast.config.security.JaasAuthenticationConfig)1 TlsAuthenticationConfig (com.hazelcast.config.security.TlsAuthenticationConfig)1