use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class NodeInvokerWrapper method invokeOnAllPartitions.
@Override
public Map<Integer, Object> invokeOnAllPartitions(Object request, boolean urgent) throws Exception {
checkInstanceOf(OperationFactory.class, request, "request");
OperationFactory factory = (OperationFactory) request;
return operationService.invokeOnAllPartitions(MapService.SERVICE_NAME, factory);
}
use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class TransactionalMapProxySupport method sizeInternal.
int sizeInternal() {
try {
OperationFactory sizeOperationFactory = operationProvider.createMapSizeOperationFactory(name);
Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, sizeOperationFactory);
int total = 0;
for (Object result : results.values()) {
Integer size = getNodeEngine().toObject(result);
total += size;
}
return total;
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class OperationDescriptors method toOperationDesc.
public static String toOperationDesc(Operation op) {
Class<? extends Operation> operationClass = op.getClass();
if (PartitionIteratingOperation.class.isAssignableFrom(operationClass)) {
PartitionIteratingOperation partitionIteratingOperation = (PartitionIteratingOperation) op;
OperationFactory operationFactory = partitionIteratingOperation.getOperationFactory();
String desc = DESCRIPTORS.get(operationFactory.getClass().getName());
if (desc == null) {
desc = PartitionIteratingOperation.class.getSimpleName() + "(" + operationFactory.getClass().getName() + ")";
DESCRIPTORS.put(operationFactory.getClass().getName(), desc);
}
return desc;
} else if (Backup.class.isAssignableFrom(operationClass)) {
Backup backup = (Backup) op;
Operation backupOperation = backup.getBackupOp();
String desc = DESCRIPTORS.get(backupOperation.getClass().getName());
if (desc == null) {
desc = Backup.class.getSimpleName() + "(" + backup.getBackupOp().getClass().getName() + ")";
DESCRIPTORS.put(backupOperation.getClass().getName(), desc);
}
return desc;
} else {
return operationClass.getName();
}
}
use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method submitToKeysInternal.
public <R> InternalCompletableFuture<Map<K, R>> submitToKeysInternal(Set<K> keys, Set<Data> dataKeys, EntryProcessor<K, V, R> entryProcessor) {
if (dataKeys.isEmpty()) {
toDataCollectionWithNonNullKeyValidation(keys, dataKeys);
}
Collection<Integer> partitionsForKeys = getPartitionsForKeys(dataKeys);
OperationFactory operationFactory = operationProvider.createMultipleEntryOperationFactory(name, dataKeys, entryProcessor);
final InternalCompletableFuture resultFuture = new InternalCompletableFuture();
operationService.invokeOnPartitionsAsync(SERVICE_NAME, operationFactory, partitionsForKeys).whenCompleteAsync((response, throwable) -> {
if (throwable == null) {
Map<K, Object> result = null;
try {
result = createHashMap(response.size());
for (Object object : response.values()) {
MapEntries mapEntries = (MapEntries) object;
mapEntries.putAllToMap(serializationService, result);
}
} catch (Throwable e) {
resultFuture.completeExceptionally(e);
}
resultFuture.complete(result);
} else {
resultFuture.completeExceptionally(throwable);
}
});
return resultFuture;
}
use of com.hazelcast.spi.impl.operationservice.OperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method waitUntilLoaded.
public void waitUntilLoaded() {
try {
int mapNamesPartitionId = partitionService.getPartitionId(name);
// first we have to check if key-load finished - otherwise
// the loading on other partitions might not have started.
// In this case we can't invoke IsPartitionLoadedOperation
// -> they will return "true", but it won't be correct
int sleepDurationMillis = INITIAL_WAIT_LOAD_SLEEP_MILLIS;
while (true) {
Operation op = new IsKeyLoadFinishedOperation(name);
Future<Boolean> loadingFuture = operationService.invokeOnPartition(SERVICE_NAME, op, mapNamesPartitionId);
if (loadingFuture.get()) {
break;
}
// sleep with some back-off
TimeUnit.MILLISECONDS.sleep(sleepDurationMillis);
sleepDurationMillis = (sleepDurationMillis * 2 < MAXIMAL_WAIT_LOAD_SLEEP_MILLIS) ? sleepDurationMillis * 2 : MAXIMAL_WAIT_LOAD_SLEEP_MILLIS;
}
OperationFactory opFactory = new IsPartitionLoadedOperationFactory(name);
Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, opFactory);
// wait for all the data to be loaded on all partitions - wait forever
waitAllTrue(results, opFactory);
} catch (Throwable t) {
throw rethrow(t);
}
}
Aggregations