use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientMapProxy method setAsyncInternal.
protected InternalCompletableFuture<Void> setAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value) {
try {
Data keyData = toData(key);
Data valueData = toData(value);
long ttlMillis = timeInMsOrOneIfResultIsZero(ttl, timeunit);
ClientMessage request;
if (maxIdle != null) {
request = MapSetWithMaxIdleCodec.encodeRequest(name, keyData, valueData, getThreadId(), ttlMillis, timeInMsOrOneIfResultIsZero(maxIdle, maxIdleUnit));
} else {
request = MapSetCodec.encodeRequest(name, keyData, valueData, getThreadId(), ttlMillis);
}
ClientInvocationFuture future = invokeOnKeyOwner(request, keyData);
return new ClientDelegatingFuture<>(future, getSerializationService(), clientMessage -> null);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientMapProxy method putAsyncInternal.
protected InternalCompletableFuture<V> putAsyncInternal(long ttl, TimeUnit timeunit, Long maxIdle, TimeUnit maxIdleUnit, Object key, Object value) {
try {
Data keyData = toData(key);
Data valueData = toData(value);
long ttlMillis = timeInMsOrOneIfResultIsZero(ttl, timeunit);
ClientMessage request;
if (maxIdle != null) {
request = MapPutWithMaxIdleCodec.encodeRequest(name, keyData, valueData, getThreadId(), ttlMillis, timeInMsOrOneIfResultIsZero(maxIdle, maxIdleUnit));
} else {
request = MapPutCodec.encodeRequest(name, keyData, valueData, getThreadId(), ttlMillis);
}
ClientInvocationFuture future = invokeOnKeyOwner(request, keyData);
SerializationService ss = getSerializationService();
return new ClientDelegatingFuture<>(future, ss, MapPutCodec::decodeResponse);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientMapProxy method submitToKeyInternal.
public <R> InternalCompletableFuture<R> submitToKeyInternal(Object key, EntryProcessor<K, V, R> entryProcessor) {
try {
Data keyData = toData(key);
ClientMessage request = MapSubmitToKeyCodec.encodeRequest(name, toData(entryProcessor), keyData, getThreadId());
ClientInvocationFuture future = invokeOnKeyOwner(request, keyData);
SerializationService ss = getSerializationService();
return new ClientDelegatingFuture(future, ss, MapSubmitToKeyCodec::decodeResponse);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class NearCachedClientMapProxy method getAsync.
@Override
public InternalCompletableFuture<V> getAsync(@Nonnull K key) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
final Object ncKey = toNearCacheKey(key);
Object value = getCachedValue(ncKey, false);
if (value != NOT_CACHED) {
return newCompletedFuture(value, getSerializationService());
}
Data keyData = toData(ncKey);
final long reservationId = nearCache.tryReserveForUpdate(ncKey, keyData, READ_UPDATE);
ClientInvocationFuture invocationFuture;
try {
invocationFuture = super.getAsyncInternal(keyData);
} catch (Throwable t) {
invalidateNearCache(ncKey);
throw rethrow(t);
}
if (reservationId != NOT_RESERVED) {
invocationFuture.whenCompleteAsync((response, t) -> {
if (t == null) {
Object newDecodedResponse = MapGetCodec.decodeResponse(response);
nearCache.tryPublishReserved(ncKey, newDecodedResponse, reservationId, false);
} else {
invalidateNearCache(ncKey);
}
}, getClient().getTaskScheduler());
}
return new ClientDelegatingFuture<>(getAsyncInternal(key), getSerializationService(), MapGetCodec::decodeResponse);
}
use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientCacheProxy method subscribeToEventJournal.
@Override
public InternalCompletableFuture<EventJournalInitialSubscriberState> subscribeToEventJournal(int partitionId) {
final ClientMessage request = CacheEventJournalSubscribeCodec.encodeRequest(nameWithPrefix);
final ClientInvocationFuture fut = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
return new ClientDelegatingFuture<>(fut, getSerializationService(), eventJournalSubscribeResponseDecoder);
}
Aggregations