use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method setExpiryPolicyInternal.
protected boolean setExpiryPolicyInternal(K key, ExpiryPolicy expiryPolicy) {
ensureOpen();
validateNotNull(key);
validateNotNull(expiryPolicy);
Data keyData = toData(key);
Data expiryPolicyData = toData(expiryPolicy);
List<Data> list = Collections.singletonList(keyData);
ClientMessage request = CacheSetExpiryPolicyCodec.encodeRequest(nameWithPrefix, list, expiryPolicyData);
ClientInvocationFuture future = invoke(request, keyData, IGNORE_COMPLETION);
ClientDelegatingFuture<Boolean> delegatingFuture = newDelegatingFuture(future, CacheSetExpiryPolicyCodec::decodeResponse);
try {
return delegatingFuture.get();
} catch (Throwable e) {
throw rethrowAllowedTypeFirst(e, CacheException.class);
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method getInternal.
private ClientDelegatingFuture<V> getInternal(Data keyData, ExpiryPolicy expiryPolicy, boolean deserializeResponse) {
Data expiryPolicyData = toData(expiryPolicy);
ClientMessage request = CacheGetCodec.encodeRequest(nameWithPrefix, keyData, expiryPolicyData);
int partitionId = getContext().getPartitionService().getPartitionId(keyData);
ClientInvocation clientInvocation = new ClientInvocation(getClient(), request, name, partitionId);
ClientInvocationFuture future = clientInvocation.invoke();
return newDelegatingFuture(future, CacheGetCodec::decodeResponse, deserializeResponse);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method callPutSync.
protected V callPutSync(K key, Data keyData, V value, Data valueData, Data expiryPolicyData, boolean isGet) throws InterruptedException, ExecutionException {
ClientInvocationFuture invocationFuture = putInternal(keyData, valueData, expiryPolicyData, isGet, true);
ClientDelegatingFuture<V> delegatingFuture = newDelegatingFuture(invocationFuture, CachePutCodec::decodeResponse);
return delegatingFuture.get();
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method getAndRemoveInternal.
private <T> ClientDelegatingFuture<T> getAndRemoveInternal(Data keyData, boolean withCompletionEvent) {
int completionId = withCompletionEvent ? nextCompletionId() : -1;
ClientMessage request = CacheGetAndRemoveCodec.encodeRequest(nameWithPrefix, keyData, completionId);
ClientInvocationFuture future = invoke(request, keyData, completionId);
return newDelegatingFuture(future, CacheGetAndRemoveCodec::decodeResponse);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method submitLoadAllTask.
private void submitLoadAllTask(ClientMessage request, CompletionListener completionListener, final List<Data> binaryKeys) {
final CompletionListener listener = completionListener != null ? injectDependencies(completionListener) : NULL_COMPLETION_LISTENER;
ClientDelegatingFuture<V> delegatingFuture = null;
try {
final long startNanos = nowInNanosOrDefault();
ClientInvocationFuture future = new ClientInvocation(getClient(), request, getName()).invoke();
delegatingFuture = newDelegatingFuture(future, clientMessage -> Boolean.TRUE);
final Future delFuture = delegatingFuture;
loadAllCalls.put(delegatingFuture, listener);
delegatingFuture.whenCompleteAsync((response, t) -> {
if (t == null) {
loadAllCalls.remove(delFuture);
onLoadAll(binaryKeys, startNanos);
listener.onCompletion();
} else {
loadAllCalls.remove(delFuture);
handleFailureOnCompletionListener(listener, t);
}
});
} catch (Throwable t) {
if (delegatingFuture != null) {
loadAllCalls.remove(delegatingFuture);
}
handleFailureOnCompletionListener(listener, t);
}
}
Aggregations