Search in sources :

Example 6 with SemaphoreConfig

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

the class GetSemaphoreTypeMessageTask method processMessage.

@Override
protected void processMessage() {
    SemaphoreConfig config = nodeEngine.getConfig().getCPSubsystemConfig().findSemaphoreConfig(parameters);
    boolean jdkCompatible = (config != null && config.isJDKCompatible());
    sendResponse(jdkCompatible);
}
Also used : SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig)

Example 7 with SemaphoreConfig

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

the class UnsafeSessionlessSemaphoreBasicTest method createInstances.

@Override
protected HazelcastInstance[] createInstances() {
    Config config = new Config();
    SemaphoreConfig semaphoreConfig = new SemaphoreConfig(objectName, true, 0);
    config.getCPSubsystemConfig().addSemaphoreConfig(semaphoreConfig);
    return factory.newInstances(config, 2);
}
Also used : Config(com.hazelcast.config.Config) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig)

Example 8 with SemaphoreConfig

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

the class SemaphoreFailureTest method createConfig.

@Override
protected Config createConfig(int cpNodeCount, int groupSize) {
    Config config = super.createConfig(cpNodeCount, groupSize);
    SemaphoreConfig semaphoreConfig = new SemaphoreConfig(objectName, isJDKCompatible(), 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)

Example 9 with SemaphoreConfig

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

the class TestFullApplicationContext method testCPSubsystemConfig.

@Test
public void testCPSubsystemConfig() {
    CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig();
    assertEquals(0, cpSubsystemConfig.getCPMemberCount());
    assertEquals(0, cpSubsystemConfig.getGroupSize());
    assertEquals(15, cpSubsystemConfig.getSessionTimeToLiveSeconds());
    assertEquals(3, cpSubsystemConfig.getSessionHeartbeatIntervalSeconds());
    assertEquals(120, cpSubsystemConfig.getMissingCPMemberAutoRemovalSeconds());
    assertEquals(30, cpSubsystemConfig.getDataLoadTimeoutSeconds());
    assertTrue(cpSubsystemConfig.isFailOnIndeterminateOperationState());
    assertFalse(cpSubsystemConfig.isPersistenceEnabled());
    assertEquals(new File("/custom-dir").getAbsolutePath(), cpSubsystemConfig.getBaseDir().getAbsolutePath());
    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) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) File(java.io.File) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 10 with SemaphoreConfig

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

the class ConfigXmlGenerator method cpSubsystemConfig.

private static void cpSubsystemConfig(XmlGenerator gen, Config config) {
    CPSubsystemConfig cpSubsystemConfig = config.getCPSubsystemConfig();
    gen.open("cp-subsystem").node("cp-member-count", cpSubsystemConfig.getCPMemberCount()).node("group-size", cpSubsystemConfig.getGroupSize()).node("session-time-to-live-seconds", cpSubsystemConfig.getSessionTimeToLiveSeconds()).node("session-heartbeat-interval-seconds", cpSubsystemConfig.getSessionHeartbeatIntervalSeconds()).node("missing-cp-member-auto-removal-seconds", cpSubsystemConfig.getMissingCPMemberAutoRemovalSeconds()).node("fail-on-indeterminate-operation-state", cpSubsystemConfig.isFailOnIndeterminateOperationState()).node("persistence-enabled", cpSubsystemConfig.isPersistenceEnabled()).node("base-dir", cpSubsystemConfig.getBaseDir().getAbsolutePath()).node("data-load-timeout-seconds", cpSubsystemConfig.getDataLoadTimeoutSeconds());
    RaftAlgorithmConfig raftAlgorithmConfig = cpSubsystemConfig.getRaftAlgorithmConfig();
    gen.open("raft-algorithm").node("leader-election-timeout-in-millis", raftAlgorithmConfig.getLeaderElectionTimeoutInMillis()).node("leader-heartbeat-period-in-millis", raftAlgorithmConfig.getLeaderHeartbeatPeriodInMillis()).node("max-missed-leader-heartbeat-count", raftAlgorithmConfig.getMaxMissedLeaderHeartbeatCount()).node("append-request-max-entry-count", raftAlgorithmConfig.getAppendRequestMaxEntryCount()).node("commit-index-advance-count-to-snapshot", raftAlgorithmConfig.getCommitIndexAdvanceCountToSnapshot()).node("uncommitted-entry-count-to-reject-new-appends", raftAlgorithmConfig.getUncommittedEntryCountToRejectNewAppends()).node("append-request-backoff-timeout-in-millis", raftAlgorithmConfig.getAppendRequestBackoffTimeoutInMillis()).close();
    gen.open("semaphores");
    for (SemaphoreConfig semaphoreConfig : cpSubsystemConfig.getSemaphoreConfigs().values()) {
        gen.open("semaphore").node("name", semaphoreConfig.getName()).node("jdk-compatible", semaphoreConfig.isJDKCompatible()).node("initial-permits", semaphoreConfig.getInitialPermits()).close();
    }
    gen.close().open("locks");
    for (FencedLockConfig lockConfig : cpSubsystemConfig.getLockConfigs().values()) {
        gen.open("fenced-lock").node("name", lockConfig.getName()).node("lock-acquire-limit", lockConfig.getLockAcquireLimit()).close();
    }
    gen.close().close();
}
Also used : RaftAlgorithmConfig(com.hazelcast.config.cp.RaftAlgorithmConfig) FencedLockConfig(com.hazelcast.config.cp.FencedLockConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig)

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