use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class CacheProxySupport method clearInternal.
protected void clearInternal() {
try {
OperationService operationService = getNodeEngine().getOperationService();
OperationFactory operationFactory = operationProvider.createClearOperationFactory();
Map<Integer, Object> results = operationService.invokeOnAllPartitions(getServiceName(), operationFactory);
for (Object result : results.values()) {
if (result != null && result instanceof CacheClearResponse) {
Object response = ((CacheClearResponse) result).getResponse();
if (response instanceof Throwable) {
throw (Throwable) response;
}
}
}
} catch (Throwable t) {
throw rethrowAllowedTypeFirst(t, CacheException.class);
}
}
use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class AbstractAllPartitionsMessageTask method processInternal.
@Override
protected CompletableFuture<Map<Integer, Object>> processInternal() {
OperationFactory operationFactory = new OperationFactoryWrapper(createOperationFactory(), endpoint.getUuid());
OperationServiceImpl operationService = nodeEngine.getOperationService();
return operationService.invokeOnAllPartitionsAsync(getServiceName(), operationFactory);
}
use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method executeOnEntriesInternal.
/**
* {@link IMap#executeOnEntries(EntryProcessor, Predicate)}
*/
public void executeOnEntriesInternal(EntryProcessor entryProcessor, Predicate predicate, List<Data> result) {
try {
Map<Integer, Object> results;
if (predicate instanceof PartitionPredicate) {
PartitionPredicate partitionPredicate = (PartitionPredicate) predicate;
Data key = toData(partitionPredicate.getPartitionKey());
int partitionId = partitionService.getPartitionId(key);
handleHazelcastInstanceAwareParams(partitionPredicate.getTarget());
OperationFactory operation = operationProvider.createPartitionWideEntryWithPredicateOperationFactory(name, entryProcessor, partitionPredicate.getTarget());
results = operationService.invokeOnPartitions(SERVICE_NAME, operation, singletonList(partitionId));
} else {
OperationFactory operation = operationProvider.createPartitionWideEntryWithPredicateOperationFactory(name, entryProcessor, predicate);
results = operationService.invokeOnAllPartitions(SERVICE_NAME, operation);
}
for (Object object : results.values()) {
if (object != null) {
MapEntries mapEntries = (MapEntries) object;
for (int i = 0; i < mapEntries.size(); i++) {
result.add(mapEntries.getKey(i));
result.add(mapEntries.getValue(i));
}
}
}
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method containsValueInternal.
public boolean containsValueInternal(Data dataValue) {
try {
OperationFactory operationFactory = operationProvider.createContainsValueOperationFactory(name, dataValue);
Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, operationFactory);
incrementOtherOperationsStat();
for (Object result : results.values()) {
Boolean contains = toObject(result);
if (contains) {
return true;
}
}
return false;
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method invokePutAllOperation.
@Nonnull
private InternalCompletableFuture<Void> invokePutAllOperation(Address address, List<Integer> memberPartitions, MapEntries[] entriesPerPartition, boolean triggerMapLoader) {
int size = memberPartitions.size();
int[] partitions = new int[size];
int index = 0;
for (Integer partitionId : memberPartitions) {
if (entriesPerPartition[partitionId] != null) {
partitions[index++] = partitionId;
}
}
if (index == 0) {
return newCompletedFuture(null);
}
// trim partition array to real size
if (index < size) {
partitions = Arrays.copyOf(partitions, index);
size = index;
}
index = 0;
MapEntries[] entries = new MapEntries[size];
long totalSize = 0;
for (int partitionId : partitions) {
int batchSize = entriesPerPartition[partitionId].size();
assert (putAllBatchSize == 0 || batchSize <= putAllBatchSize);
entries[index++] = entriesPerPartition[partitionId];
totalSize += batchSize;
entriesPerPartition[partitionId] = null;
}
if (totalSize == 0) {
return newCompletedFuture(null);
}
OperationFactory factory = operationProvider.createPutAllOperationFactory(name, partitions, entries, triggerMapLoader);
long startTimeNanos = Timer.nanos();
CompletableFuture<Map<Integer, Object>> future = operationService.invokeOnPartitionsAsync(SERVICE_NAME, factory, singletonMap(address, asIntegerList(partitions)));
InternalCompletableFuture<Void> resultFuture = new InternalCompletableFuture<>();
long finalTotalSize = totalSize;
future.whenCompleteAsync((response, t) -> {
putAllVisitSerializedKeys(entries);
if (t == null) {
localMapStats.incrementPutLatencyNanos(finalTotalSize, Timer.nanosElapsed(startTimeNanos));
resultFuture.complete(null);
} else {
resultFuture.completeExceptionally(t);
}
}, CALLER_RUNS);
return resultFuture;
}
Aggregations