use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class AbstractClientCacheProxy method groupDataToPartitions.
private List<Map.Entry<Data, Data>>[] groupDataToPartitions(Map<? extends K, ? extends V> map, ClientPartitionService partitionService, int partitionCount) {
List<Map.Entry<Data, Data>>[] entriesPerPartition = new List[partitionCount];
SerializationService serializationService = clientContext.getSerializationService();
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
K key = entry.getKey();
V value = entry.getValue();
validateNotNull(key, value);
Data keyData = serializationService.toData(key);
Data valueData = serializationService.toData(value);
int partitionId = partitionService.getPartitionId(keyData);
List<Map.Entry<Data, Data>> entries = entriesPerPartition[partitionId];
if (entries == null) {
entries = new ArrayList<Map.Entry<Data, Data>>();
entriesPerPartition[partitionId] = entries;
}
entries.add(new AbstractMap.SimpleImmutableEntry<Data, Data>(keyData, valueData));
}
return entriesPerPartition;
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class AbstractClientCacheProxyBase method submitLoadAllTask.
protected void submitLoadAllTask(ClientMessage request, CompletionListener completionListener, final Set<Data> keys) {
final CompletionListener compListener = completionListener != null ? completionListener : NULL_COMPLETION_LISTENER;
ClientDelegatingFuture<V> delegatingFuture = null;
try {
injectDependencies(completionListener);
final long start = System.nanoTime();
ClientInvocationFuture future = new ClientInvocation((HazelcastClientInstanceImpl) clientContext.getHazelcastInstance(), request).invoke();
SerializationService serializationService = clientContext.getSerializationService();
delegatingFuture = new ClientDelegatingFuture<V>(future, serializationService, LOAD_ALL_DECODER);
final Future delFuture = delegatingFuture;
loadAllCalls.put(delegatingFuture, compListener);
delegatingFuture.andThen(new ExecutionCallback<V>() {
@Override
public void onResponse(V response) {
loadAllCalls.remove(delFuture);
onLoadAll(keys, response, start, System.nanoTime());
compListener.onCompletion();
}
@Override
public void onFailure(Throwable t) {
loadAllCalls.remove(delFuture);
handleFailureOnCompletionListener(compListener, t);
}
});
} catch (Throwable t) {
if (delegatingFuture != null) {
loadAllCalls.remove(delegatingFuture);
}
handleFailureOnCompletionListener(compListener, t);
}
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class QueueService method createLocalQueueStats.
/**
* Returns the local queue statistics for the queue with the given {@code name}. If this node is the owner of the queue,
* returned stats contain {@link LocalQueueStats#getOwnedItemCount()}, otherwise it contains
* {@link LocalQueueStats#getBackupItemCount()}.
*
* @param name the name of the queue for which the statistics are returned
* @return the statistics
*/
public LocalQueueStats createLocalQueueStats(String name) {
SerializationService serializationService = nodeEngine.getSerializationService();
IPartitionService partitionService = nodeEngine.getPartitionService();
Data keyData = serializationService.toData(name, StringPartitioningStrategy.INSTANCE);
int partitionId = partitionService.getPartitionId(keyData);
return createLocalQueueStats(name, partitionId);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class ClientMapProxy method getAsyncInternal.
protected ICompletableFuture<V> getAsyncInternal(Data keyData) {
SerializationService serializationService = getContext().getSerializationService();
ClientMessage request = MapGetCodec.encodeRequest(name, keyData, getThreadId());
try {
ClientInvocationFuture future = invokeOnKeyOwner(request, keyData);
return new ClientDelegatingFuture<V>(future, serializationService, GET_ASYNC_RESPONSE_DECODER);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class XAResourceProxy method finalizeTransactionRemotely.
private void finalizeTransactionRemotely(Xid xid, boolean isCommit) {
SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
SerializationService serializationService = getContext().getSerializationService();
Data xidData = serializationService.toData(serializableXID);
ClientMessage request = XATransactionFinalizeCodec.encodeRequest(serializableXID, isCommit);
invoke(request, xidData);
}
Aggregations