use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method getAllInternal.
protected void getAllInternal(Set<K> keys, List<Data> dataKeys, List<Object> resultingKeyValuePairs) {
if (keys == null || keys.isEmpty()) {
return;
}
if (dataKeys.isEmpty()) {
toDataCollectionWithNonNullKeyValidation(keys, dataKeys);
}
Collection<Integer> partitions = getPartitionsForKeys(dataKeys);
Map<Integer, Object> responses;
try {
OperationFactory operationFactory = operationProvider.createGetAllOperationFactory(name, dataKeys);
long startTimeNanos = Timer.nanos();
responses = operationService.invokeOnPartitions(SERVICE_NAME, operationFactory, partitions);
for (Object response : responses.values()) {
MapEntries entries = toObject(response);
for (int i = 0; i < entries.size(); i++) {
resultingKeyValuePairs.add(entries.getKey(i));
resultingKeyValuePairs.add(entries.getValue(i));
}
}
localMapStats.incrementGetLatencyNanos(dataKeys.size(), Timer.nanosElapsed(startTimeNanos));
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class MapRemoveAllMessageTask method processMessage.
@Override
protected void processMessage() {
if (!(predicate instanceof PartitionPredicate)) {
super.processMessage();
return;
}
int partitionId = clientMessage.getPartitionId();
OperationFactory operationFactory = createOperationFactory();
OperationServiceImpl operationService = nodeEngine.getOperationService();
// We are running on a partition thread now and we are not allowed
// to call invokeOnPartitions(Async) on operation service because of
// that.
Operation operation;
if (operationFactory instanceof PartitionAwareOperationFactory) {
// If operation factory is partition-aware, we should utilize this to our advantage
// since for the on-heap storages this may speed up the operation via indexes
// (see PartitionWideEntryWithPredicateOperationFactory.createFactoryOnRunner).
PartitionAwareOperationFactory partitionAwareOperationFactory = (PartitionAwareOperationFactory) operationFactory;
partitionAwareOperationFactory = partitionAwareOperationFactory.createFactoryOnRunner(nodeEngine, new int[] { partitionId });
operation = partitionAwareOperationFactory.createPartitionOperation(partitionId);
} else {
operation = operationFactory.createOperation();
}
final int thisPartitionId = partitionId;
operation.setCallerUuid(endpoint.getUuid());
InvocationFuture<Object> future = operationService.invokeOnPartition(getServiceName(), operation, partitionId);
future.whenCompleteAsync((response, throwable) -> {
if (throwable == null) {
sendResponse(reduce(Collections.singletonMap(thisPartitionId, response)));
} else {
handleProcessingFailure(throwable);
}
});
}
Aggregations