use of com.hazelcast.spi.OperationFactory in project hazelcast by hazelcast.
the class AbstractInternalCacheProxy method removeAllInternal.
void removeAllInternal(Set<? extends K> keys) {
Set<Data> keysData = null;
if (keys != null) {
keysData = new HashSet<Data>();
for (K key : keys) {
keysData.add(serializationService.toData(key));
}
}
int partitionCount = getNodeEngine().getPartitionService().getPartitionCount();
Integer completionId = registerCompletionLatch(partitionCount);
OperationService operationService = getNodeEngine().getOperationService();
OperationFactory operationFactory = operationProvider.createRemoveAllOperationFactory(keysData, completionId);
try {
Map<Integer, Object> results = operationService.invokeOnAllPartitions(getServiceName(), operationFactory);
int completionCount = 0;
for (Object result : results.values()) {
if (result != null && result instanceof CacheClearResponse) {
Object response = ((CacheClearResponse) result).getResponse();
if (response instanceof Boolean) {
completionCount++;
}
if (response instanceof Throwable) {
throw (Throwable) response;
}
}
}
waitCompletionLatch(completionId, partitionCount - completionCount);
} catch (Throwable t) {
deregisterCompletionLatch(completionId);
throw rethrowAllowedTypeFirst(t, CacheException.class);
}
}
use of com.hazelcast.spi.OperationFactory in project hazelcast by hazelcast.
the class AbstractMultiPartitionMessageTask method call.
@Override
protected Object call() throws Exception {
ClientEndpoint endpoint = getEndpoint();
OperationFactory operationFactory = new OperationFactoryWrapper(createOperationFactory(), endpoint.getUuid());
final InternalOperationService operationService = nodeEngine.getOperationService();
Map<Integer, Object> map = operationService.invokeOnPartitions(getServiceName(), operationFactory, getPartitions());
return reduce(map);
}
use of com.hazelcast.spi.OperationFactory in project hazelcast by hazelcast.
the class AbstractCacheProxy method size.
@Override
public int size() {
ensureOpen();
try {
OperationFactory operationFactory = operationProvider.createSizeOperationFactory();
Map<Integer, Object> results = getNodeEngine().getOperationService().invokeOnAllPartitions(getServiceName(), operationFactory);
int total = 0;
for (Object result : results.values()) {
//noinspection RedundantCast
total += (Integer) getNodeEngine().toObject(result);
}
return total;
} catch (Throwable t) {
throw rethrowAllowedTypeFirst(t, CacheException.class);
}
}
use of com.hazelcast.spi.OperationFactory in project hazelcast by hazelcast.
the class AbstractCacheProxy method getAll.
@Override
public Map<K, V> getAll(Set<? extends K> keys, ExpiryPolicy expiryPolicy) {
ensureOpen();
validateNotNull(keys);
if (keys.isEmpty()) {
return Collections.EMPTY_MAP;
}
Set<Data> ks = new HashSet<Data>(keys.size());
for (K key : keys) {
Data dataKey = serializationService.toData(key);
ks.add(dataKey);
}
Map<K, V> result = new HashMap<K, V>();
Collection<Integer> partitions = getPartitionsForKeys(ks);
try {
OperationFactory factory = operationProvider.createGetAllOperationFactory(ks, expiryPolicy);
OperationService operationService = getNodeEngine().getOperationService();
Map<Integer, Object> responses = operationService.invokeOnPartitions(getServiceName(), factory, partitions);
for (Object response : responses.values()) {
MapEntries mapEntries = serializationService.toObject(response);
mapEntries.putAllToMap(serializationService, result);
}
} catch (Throwable e) {
throw rethrowAllowedTypeFirst(e, CacheException.class);
}
return result;
}
use of com.hazelcast.spi.OperationFactory in project hazelcast by hazelcast.
the class AbstractAllPartitionsMessageTask method processMessage.
@Override
protected void processMessage() throws Exception {
ClientEndpoint endpoint = getEndpoint();
OperationFactory operationFactory = new OperationFactoryWrapper(createOperationFactory(), endpoint.getUuid());
final InternalOperationService operationService = nodeEngine.getOperationService();
Map<Integer, Object> map = operationService.invokeOnAllPartitions(getServiceName(), operationFactory);
sendResponse(reduce(map));
}
Aggregations