use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class SessionAwareSemaphoreProxy method release.
@Override
public void release(int permits) {
checkPositive(permits, "Permits must be positive!");
long sessionId = sessionManager.getSession(groupId);
if (sessionId == NO_SESSION_ID) {
throw newIllegalStateException(null);
}
long threadId = getThreadId();
UUID invocationUid = newUnsecureUUID();
try {
ClientMessage request = SemaphoreReleaseCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid, permits);
HazelcastClientInstanceImpl client = getClient();
new ClientInvocation(client, request, objectName).invoke().joinInternal();
} catch (SessionExpiredException e) {
sessionManager.invalidateSession(this.groupId, sessionId);
throw newIllegalStateException(e);
} finally {
sessionManager.releaseSession(this.groupId, sessionId, permits);
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class SessionAwareSemaphoreProxy method doChangePermits.
private void doChangePermits(int delta) {
long sessionId = sessionManager.acquireSession(groupId);
long threadId = getThreadId();
UUID invocationUid = newUnsecureUUID();
try {
ClientMessage request = SemaphoreChangeCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid, delta);
new ClientInvocation(getClient(), request, objectName).invoke().joinInternal();
} catch (SessionExpiredException e) {
sessionManager.invalidateSession(this.groupId, sessionId);
throw newIllegalStateException(e);
} finally {
sessionManager.releaseSession(this.groupId, sessionId);
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class SessionAwareSemaphoreProxy method init.
@Override
public boolean init(int permits) {
checkNotNegative(permits, "Permits must be non-negative!");
ClientMessage request = SemaphoreInitCodec.encodeRequest(groupId, objectName, permits);
HazelcastClientInstanceImpl client = getClient();
ClientMessage response = new ClientInvocation(client, request, objectName).invoke().joinInternal();
return SemaphoreInitCodec.decodeResponse(response);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class SessionAwareSemaphoreProxy method drainPermits.
@Override
public int drainPermits() {
long threadId = getThreadId();
UUID invocationUid = newUnsecureUUID();
for (; ; ) {
long sessionId = sessionManager.acquireSession(this.groupId, DRAIN_SESSION_ACQ_COUNT);
try {
ClientMessage request = SemaphoreDrainCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid);
HazelcastClientInstanceImpl client = getClient();
ClientMessage response = new ClientInvocation(client, request, objectName).invoke().joinInternal();
int count = SemaphoreDrainCodec.decodeResponse(response);
sessionManager.releaseSession(groupId, sessionId, DRAIN_SESSION_ACQ_COUNT - count);
return count;
} catch (SessionExpiredException e) {
sessionManager.invalidateSession(this.groupId, sessionId);
} catch (RuntimeException e) {
sessionManager.releaseSession(this.groupId, sessionId, DRAIN_SESSION_ACQ_COUNT);
throw e;
}
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientMapQueryPartitionIterator method fetch.
@Override
protected List<Data> fetch() {
HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
ClientMessage request = MapFetchWithQueryCodec.encodeRequest(mapProxy.getName(), encodePointers(pointers), fetchSize, getSerializationService().toData(query.getProjection()), getSerializationService().toData(query.getPredicate()));
ClientInvocation clientInvocation = new ClientInvocation(client, request, mapProxy.getName(), partitionId);
try {
ClientInvocationFuture f = clientInvocation.invoke();
MapFetchWithQueryCodec.ResponseParameters responseParameters = MapFetchWithQueryCodec.decodeResponse(f.get());
List<Data> results = responseParameters.results;
IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
setLastTableIndex(results, pointers);
return results;
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
Aggregations