use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.
the class AbstractClientInternalCacheProxy method getAndRemoveAsyncInternal.
protected <T> ICompletableFuture<T> getAndRemoveAsyncInternal(K key, boolean withCompletionEvent, boolean async) {
final long start = System.nanoTime();
ensureOpen();
validateNotNull(key);
CacheProxyUtil.validateConfiguredTypes(cacheConfig, key);
final Data keyData = toData(key);
final int completionId = withCompletionEvent ? nextCompletionId() : -1;
ClientMessage request = CacheGetAndRemoveCodec.encodeRequest(nameWithPrefix, keyData, completionId);
ClientInvocationFuture future;
try {
future = invoke(request, keyData, completionId);
invalidateNearCache(keyData);
} catch (Exception e) {
throw rethrow(e);
}
ClientDelegatingFuture<T> delegatingFuture = new ClientDelegatingFuture<T>(future, clientContext.getSerializationService(), GET_AND_REMOVE_RESPONSE_DECODER);
if (async && statisticsEnabled) {
delegatingFuture.andThenInternal(new ExecutionCallback<T>() {
public void onResponse(T response) {
handleStatisticsOnRemove(true, start, response);
}
public void onFailure(Throwable t) {
}
}, true);
}
return delegatingFuture;
}
use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.
the class AbstractClientInternalCacheProxy method putIfAbsentInternal.
protected Object putIfAbsentInternal(K key, V value, ExpiryPolicy expiryPolicy, boolean withCompletionEvent, boolean async) {
long start = System.nanoTime();
ensureOpen();
validateNotNull(key, value);
CacheProxyUtil.validateConfiguredTypes(cacheConfig, key, value);
Data keyData = toData(key);
Data valueData = toData(value);
Data expiryPolicyData = toData(expiryPolicy);
int completionId = withCompletionEvent ? nextCompletionId() : -1;
ClientMessage request = CachePutIfAbsentCodec.encodeRequest(nameWithPrefix, keyData, valueData, expiryPolicyData, completionId);
ClientInvocationFuture future;
try {
future = invoke(request, keyData, completionId);
} catch (Throwable t) {
throw rethrow(t);
}
ClientDelegatingFuture<Boolean> delegatingFuture = new ClientDelegatingFuture<Boolean>(future, clientContext.getSerializationService(), PUT_IF_ABSENT_RESPONSE_DECODER);
if (async) {
return putIfAbsentInternalAsync(value, start, keyData, valueData, delegatingFuture);
}
return putIfAbsentInternalSync(value, start, keyData, valueData, delegatingFuture);
}
use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.
the class ClientQueueProxy method removeAll.
@Override
public boolean removeAll(Collection<?> c) {
Preconditions.checkNotNull(c);
Collection<Data> dataCollection = CollectionUtil.objectToDataCollection(c, getSerializationService());
ClientMessage request = QueueCompareAndRemoveAllCodec.encodeRequest(name, dataCollection);
ClientMessage response = invokeOnPartition(request);
QueueCompareAndRemoveAllCodec.ResponseParameters resultParameters = QueueCompareAndRemoveAllCodec.decodeResponse(response);
return resultParameters.response;
}
use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.
the class ClientQueueProxy method put.
@Override
public void put(E e) throws InterruptedException {
Data data = toData(e);
ClientMessage request = QueuePutCodec.encodeRequest(name, data);
invokeOnPartitionInterruptibly(request);
}
use of com.hazelcast.client.impl.protocol.ClientMessage in project hazelcast by hazelcast.
the class ClientReplicatedMapProxy method containsValue.
@Override
public boolean containsValue(Object value) {
checkNotNull(value, NULL_KEY_IS_NOT_ALLOWED);
Data valueData = toData(value);
ClientMessage request = ReplicatedMapContainsValueCodec.encodeRequest(name, valueData);
ClientMessage response = invokeOnPartition(request, targetPartitionId);
ReplicatedMapContainsValueCodec.ResponseParameters result = ReplicatedMapContainsValueCodec.decodeResponse(response);
return result.response;
}
Aggregations