use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class SessionlessSemaphoreProxy method doTryAcquire.
private boolean doTryAcquire(int permits, long timeoutMs) {
long clusterWideThreadId = sessionManager.getOrCreateUniqueThreadId(groupId);
UUID invocationUid = newUnsecureUUID();
ClientMessage request = SemaphoreAcquireCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, invocationUid, permits, timeoutMs);
try {
ClientMessage response = new ClientInvocation(getClient(), request, objectName).invoke().joinInternal();
return SemaphoreAcquireCodec.decodeResponse(response);
} catch (WaitKeyCancelledException e) {
throw new IllegalStateException("Semaphore[" + objectName + "] not acquired because the acquire call " + "on the CP group is cancelled, possibly because of another indeterminate call from the same thread.");
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class SessionlessSemaphoreProxy method doChangePermits.
private void doChangePermits(int delta) {
long clusterWideThreadId = sessionManager.getOrCreateUniqueThreadId(groupId);
UUID invocationUid = newUnsecureUUID();
ClientMessage request = SemaphoreChangeCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, invocationUid, delta);
new ClientInvocation(getClient(), request, objectName).invoke().joinInternal();
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class SessionlessSemaphoreProxy method release.
@Override
public void release(int permits) {
checkPositive(permits, "Permits must be positive!");
long clusterWideThreadId = sessionManager.getOrCreateUniqueThreadId(groupId);
UUID invocationUid = newUnsecureUUID();
ClientMessage request = SemaphoreReleaseCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, invocationUid, permits);
HazelcastClientInstanceImpl client = getClient();
new ClientInvocation(client, request, objectName).invoke().joinInternal();
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class HazelcastClientInstanceImpl method getDistributedObjects.
@Override
public Collection<DistributedObject> getDistributedObjects() {
try {
ClientMessage request = ClientGetDistributedObjectsCodec.encodeRequest();
final Future<ClientMessage> future = new ClientInvocation(this, request, getName()).invoke();
ClientMessage response = future.get();
Collection<? extends DistributedObject> distributedObjects = proxyManager.getDistributedObjects();
Set<DistributedObjectInfo> localDistributedObjects = new HashSet<>();
for (DistributedObject localInfo : distributedObjects) {
localDistributedObjects.add(new DistributedObjectInfo(localInfo.getServiceName(), localInfo.getName()));
}
for (DistributedObjectInfo distributedObjectInfo : ClientGetDistributedObjectsCodec.decodeResponse(response)) {
localDistributedObjects.remove(distributedObjectInfo);
getDistributedObject(distributedObjectInfo.getServiceName(), distributedObjectInfo.getName(), false);
}
for (DistributedObjectInfo distributedObjectInfo : localDistributedObjects) {
proxyManager.destroyProxyLocally(distributedObjectInfo.getServiceName(), distributedObjectInfo.getName());
}
return (Collection<DistributedObject>) proxyManager.getDistributedObjects();
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientDynamicClusterConfig method invoke.
private void invoke(ClientMessage request) {
try {
ClientInvocation invocation = new ClientInvocation(instance, request, null);
ClientInvocationFuture future = invocation.invoke();
future.get();
} catch (Exception e) {
throw rethrow(e);
}
}
Aggregations