use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class QueueProxySupport method invokeAndGetData.
private Object invokeAndGetData(QueueOperation operation) {
final NodeEngine nodeEngine = getNodeEngine();
try {
OperationService operationService = nodeEngine.getOperationService();
Future f = operationService.invokeOnPartition(QueueService.SERVICE_NAME, operation, partitionId);
return f.get();
} catch (Throwable throwable) {
throw ExceptionUtil.rethrow(throwable);
}
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class QueueProxySupport method invoke.
private InternalCompletableFuture invoke(Operation operation) {
final NodeEngine nodeEngine = getNodeEngine();
OperationService operationService = nodeEngine.getOperationService();
return operationService.invokeOnPartition(QueueService.SERVICE_NAME, operation, getPartitionId());
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class ConnectedClientOperationTest method testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects.
@Test
public void testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects() throws Exception {
HazelcastInstance instance = factory.newHazelcastInstance();
factory.newHazelcastClient();
factory.newHazelcastClient();
Node node = TestUtil.getNode(instance);
Operation operation = new GetConnectedClientsOperation();
OperationService operationService = node.nodeEngine.getOperationService();
Future<Map<String, ClientType>> future = operationService.invokeOnTarget(ClientEngineImpl.SERVICE_NAME, operation, node.address);
Map<String, ClientType> clients = future.get();
assertEquals(2, clients.size());
}
use of com.hazelcast.spi.OperationService 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.OperationService in project hazelcast by hazelcast.
the class CacheProxy method invoke.
@Override
public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... arguments) throws EntryProcessorException {
ensureOpen();
validateNotNull(key);
checkNotNull(entryProcessor, "Entry Processor is null");
Data keyData = serializationService.toData(key);
Integer completionId = registerCompletionLatch(1);
Operation op = operationProvider.createEntryProcessorOperation(keyData, completionId, entryProcessor, arguments);
try {
OperationService operationService = getNodeEngine().getOperationService();
int partitionId = getPartitionId(keyData);
InternalCompletableFuture<T> future = operationService.invokeOnPartition(getServiceName(), op, partitionId);
T safely = future.join();
waitCompletionLatch(completionId);
return safely;
} catch (CacheException ce) {
deregisterCompletionLatch(completionId);
throw ce;
} catch (Exception e) {
deregisterCompletionLatch(completionId);
throw new EntryProcessorException(e);
}
}
Aggregations