use of com.hazelcast.config.cp.FencedLockConfig in project hazelcast by hazelcast.
the class NonReentrantFencedLockTest method createConfig.
@Override
protected Config createConfig(int cpNodeCount, int groupSize) {
Config config = super.createConfig(cpNodeCount, groupSize);
FencedLockConfig lockConfig = new FencedLockConfig(objectName, 1);
config.getCPSubsystemConfig().addLockConfig(lockConfig);
return config;
}
use of com.hazelcast.config.cp.FencedLockConfig 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.FencedLockConfig 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();
}
use of com.hazelcast.config.cp.FencedLockConfig in project hazelcast by hazelcast.
the class LockRegistry method createNewResource.
@Override
protected Lock createNewResource(CPGroupId groupId, String name) {
FencedLockConfig lockConfig = cpSubsystemConfig.findLockConfig(name);
int lockCountLimit = (lockConfig != null) ? lockConfig.getLockAcquireLimit() : DEFAULT_LOCK_ACQUIRE_LIMIT;
return new Lock(groupId, name, lockCountLimit);
}
use of com.hazelcast.config.cp.FencedLockConfig in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleFencedLocks.
void handleFencedLocks(CPSubsystemConfig cpSubsystemConfig, Node node) {
for (Node child : childElements(node)) {
FencedLockConfig lockConfig = new FencedLockConfig();
for (Node subChild : childElements(child)) {
String nodeName = cleanNodeName(subChild);
if (matches("name", nodeName)) {
lockConfig.setName(getTextContent(subChild));
} else if (matches("lock-acquire-limit", nodeName)) {
lockConfig.setLockAcquireLimit(Integer.parseInt(getTextContent(subChild)));
}
}
cpSubsystemConfig.addLockConfig(lockConfig);
}
}
Aggregations