use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class CacheProxyLoadAllTask method run.
@Override
public void run() {
try {
completionListener = injectDependencies(completionListener);
OperationService operationService = nodeEngine.getOperationService();
OperationFactory operationFactory;
IPartitionService partitionService = nodeEngine.getPartitionService();
Map<Address, List<Integer>> memberPartitionsMap = partitionService.getMemberPartitionsMap();
int partitionCount = partitionService.getPartitionCount();
Map<Integer, Object> results = createHashMap(partitionCount);
for (Map.Entry<Address, List<Integer>> memberPartitions : memberPartitionsMap.entrySet()) {
Set<Integer> partitions = new PartitionIdSet(partitionCount, memberPartitions.getValue());
Set<Data> ownerKeys = filterOwnerKeys(partitionService, partitions);
operationFactory = operationProvider.createLoadAllOperationFactory(ownerKeys, replaceExistingValues);
Map<Integer, Object> memberResults;
memberResults = operationService.invokeOnPartitions(serviceName, operationFactory, partitions);
results.putAll(memberResults);
}
validateResults(results);
if (completionListener != null) {
completionListener.onCompletion();
}
} catch (Exception e) {
if (completionListener != null) {
completionListener.onException(e);
}
} catch (Throwable t) {
if (t instanceof OutOfMemoryError) {
throw rethrow(t);
} else {
if (completionListener != null) {
completionListener.onException(new CacheException(t));
}
}
}
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class ClientEngineImpl method getClientsInCluster.
Map<UUID, String> getClientsInCluster() {
OperationService operationService = node.nodeEngine.getOperationService();
Map<UUID, String> clientsMap = new HashMap<>();
for (Member member : node.getClusterService().getMembers()) {
Address target = member.getAddress();
Operation clientInfoOperation = new GetConnectedClientsOperation();
Future<Map<UUID, String>> future = operationService.invokeOnTarget(SERVICE_NAME, clientInfoOperation, target);
try {
Map<UUID, String> endpoints = future.get();
if (endpoints == null) {
continue;
}
// Merge connected clients according to their UUID
clientsMap.putAll(endpoints);
} catch (Exception e) {
logger.warning("Cannot get client information from: " + target.toString(), e);
}
}
return clientsMap;
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class QueueProxySupport method invoke.
private InvocationFuture<Object> invoke(Operation operation) {
final NodeEngine nodeEngine = getNodeEngine();
OperationService operationService = nodeEngine.getOperationService();
return operationService.invokeOnPartition(QueueService.SERVICE_NAME, operation, getPartitionId());
}
use of com.hazelcast.spi.impl.operationservice.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 rethrow(throwable);
}
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class QueueService method rollbackTransaction.
@Override
public void rollbackTransaction(UUID transactionId) {
final Set<String> queueNames = containerMap.keySet();
OperationService operationService = nodeEngine.getOperationService();
for (String name : queueNames) {
int partitionId = partitionService.getPartitionId(StringPartitioningStrategy.getPartitionKey(name));
Operation operation = new QueueTransactionRollbackOperation(name, transactionId).setPartitionId(partitionId).setService(this).setNodeEngine(nodeEngine);
operationService.invokeOnPartition(operation);
}
}
Aggregations