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);
}
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);
}
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;
}
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());
}
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();
}
Aggregations