use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class FencedLockClientBasicTest method test_sessionIsClosedOnCPSubsystemReset.
@Test
public void test_sessionIsClosedOnCPSubsystemReset() throws Exception {
lock.lock();
instances[0].getCPSubsystem().getCPSubsystemManagementService().reset().toCompletableFuture().get();
assertTrueEventually(() -> {
HazelcastClientProxy clientProxy = (HazelcastClientProxy) client;
ClientProxySessionManager proxySessionManager = clientProxy.client.getProxySessionManager();
assertEquals(NO_SESSION_ID, proxySessionManager.getSession((RaftGroupId) lock.getGroupId()));
});
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class SessionAwareSemaphoreClientBasicTest method testDrain_ReleasesSessionProperly.
@Test
public void testDrain_ReleasesSessionProperly() throws InterruptedException {
int permits = 20;
assertTrue(semaphore.init(permits));
final int drainPermits = semaphore.drainPermits();
HazelcastClientProxy clientProxy = (HazelcastClientProxy) client;
ClientProxySessionManager proxySessionManager = clientProxy.client.getProxySessionManager();
SessionAwareSemaphoreProxy proxy = (SessionAwareSemaphoreProxy) semaphore;
RaftGroupId groupId = (RaftGroupId) proxy.getGroupId();
final long session = proxySessionManager.getSession(groupId);
assertEquals(drainPermits, proxySessionManager.getSessionAcquireCount(groupId, session));
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class ClientRaftProxyFactory method createProxy.
@Nonnull
public <T extends DistributedObject> T createProxy(String serviceName, String proxyName) {
proxyName = withoutDefaultGroupName(proxyName);
String objectName = getObjectNameForProxy(proxyName);
RaftGroupId groupId = getGroupId(proxyName, objectName);
if (serviceName.equals(AtomicLongService.SERVICE_NAME)) {
return (T) new AtomicLongProxy(context, groupId, proxyName, objectName);
} else if (serviceName.equals(AtomicRefService.SERVICE_NAME)) {
return (T) new AtomicRefProxy(context, groupId, proxyName, objectName);
} else if (serviceName.equals(CountDownLatchService.SERVICE_NAME)) {
return (T) new CountDownLatchProxy(context, groupId, proxyName, objectName);
} else if (serviceName.equals(LockService.SERVICE_NAME)) {
return (T) createFencedLock(groupId, proxyName, objectName);
} else if (serviceName.equals(SemaphoreService.SERVICE_NAME)) {
return (T) createSemaphore(groupId, proxyName, objectName);
} else {
throw new IllegalArgumentException();
}
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class RaftAtomicValueService method createProxy.
@Override
public final DistributedObject createProxy(String proxyName) {
try {
proxyName = withoutDefaultGroupName(proxyName);
RaftGroupId groupId = raftService.createRaftGroupForProxy(proxyName);
return newRaftAtomicProxy(nodeEngine, groupId, proxyName, getObjectNameForProxy(proxyName));
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.cp.internal.RaftGroupId in project hazelcast by hazelcast.
the class AbstractProxySessionManager method shutdown.
/**
* Invokes a shutdown call on server to close all existing sessions.
*/
public Map<RaftGroupId, InternalCompletableFuture<Object>> shutdown() {
lock.writeLock().lock();
try {
Map<RaftGroupId, InternalCompletableFuture<Object>> futures = new HashMap<>();
for (Entry<RaftGroupId, SessionState> e : sessions.entrySet()) {
RaftGroupId groupId = e.getKey();
long sessionId = e.getValue().id;
InternalCompletableFuture<Object> f = closeSession(groupId, sessionId);
futures.put(groupId, f);
}
sessions.clear();
running = false;
return futures;
} finally {
lock.writeLock().unlock();
}
}
Aggregations