use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.
the class PNCounterProxy method invokeInternal.
/**
* Invokes the {@code operation} recursively on viable replica addresses
* until successful or the list of viable replicas is exhausted.
* Replicas with addresses contained in the {@code excludedAddresses} are
* skipped. If there are no viable replicas, this method will throw the
* {@code lastException} if not {@code null} or a
* {@link NoDataMemberInClusterException} if the {@code lastException} is
* {@code null}.
*
* @param operation the operation to invoke on a CRDT replica
* @param excludedAddresses the addresses to exclude when choosing a replica
* address, must not be {@code null}
* @param lastException the exception thrown from the last invocation of
* the {@code operation} on a replica, may be {@code null}
* @return the result of the operation invocation on a replica
* @throws NoDataMemberInClusterException if there are no replicas and the
* {@code lastException} is {@code null}
*/
private long invokeInternal(Operation operation, List<Address> excludedAddresses, HazelcastException lastException) {
final Address target = getCRDTOperationTarget(excludedAddresses);
if (target == null) {
throw lastException != null ? lastException : new NoDataMemberInClusterException("Cannot invoke operations on a CRDT because the cluster does not contain any data members");
}
try {
final InvocationBuilder builder = getNodeEngine().getOperationService().createInvocationBuilder(SERVICE_NAME, operation, target);
if (operationTryCount > 0) {
builder.setTryCount(operationTryCount);
}
final InvocationFuture<CRDTTimestampedLong> future = builder.invoke();
final CRDTTimestampedLong result = future.joinInternal();
updateObservedReplicaTimestamps(result.getVectorClock());
return result.getValue();
} catch (HazelcastException e) {
logger.fine("Exception occurred while invoking operation on target " + target + ", choosing different target", e);
if (excludedAddresses == EMPTY_ADDRESS_LIST) {
excludedAddresses = new ArrayList<Address>();
}
excludedAddresses.add(target);
return invokeInternal(operation, excludedAddresses, e);
}
}
use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.
the class MapPublisherCreateWithValueMessageTask method createPublishersAndGetSnapshotOf.
private List<Future> createPublishersAndGetSnapshotOf(Collection<MemberImpl> members) {
List<Future> futures = new ArrayList<Future>(members.size());
OperationServiceImpl operationService = nodeEngine.getOperationService();
for (MemberImpl member : members) {
Predicate predicate = serializationService.toObject(parameters.predicate);
AccumulatorInfo accumulatorInfo = AccumulatorInfo.toAccumulatorInfo(parameters.mapName, parameters.cacheName, predicate, parameters.batchSize, parameters.bufferSize, parameters.delaySeconds, true, parameters.populate, parameters.coalesce);
PublisherCreateOperation operation = new PublisherCreateOperation(accumulatorInfo);
operation.setCallerUuid(endpoint.getUuid());
Address address = member.getAddress();
InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(SERVICE_NAME, operation, address);
Future future = invocationBuilder.invoke();
futures.add(future);
}
return futures;
}
use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.
the class AbstractMultiTargetMessageTask method processInternal.
@Override
protected CompletableFuture<Object> processInternal() {
Supplier<Operation> operationSupplier = createOperationSupplier();
Collection<Member> targets = getTargets();
CompletableFuture<Object> finalResult = new CompletableFuture<>();
if (targets.isEmpty()) {
finalResult.complete(EMPTY_MAP);
return finalResult;
}
final OperationServiceImpl operationService = nodeEngine.getOperationService();
MultiTargetCallback callback = new MultiTargetCallback(targets, finalResult);
for (Member target : targets) {
Operation op = operationSupplier.get();
op.setCallerUuid(endpoint.getUuid());
InvocationBuilder builder = operationService.createInvocationBuilder(getServiceName(), op, target.getAddress()).setResultDeserialized(false);
InvocationFuture<Object> invocationFuture = builder.invoke();
invocationFuture.whenCompleteAsync(new SingleTargetCallback(target, callback), CALLER_RUNS);
}
return finalResult;
}
use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.
the class XAClearRemoteTransactionMessageTask method call.
@Override
protected Object call() throws Exception {
OperationServiceImpl operationService = nodeEngine.getOperationService();
InternalPartitionService partitionService = nodeEngine.getPartitionService();
Data xidData = serializationService.toData(parameters);
Operation op = new ClearRemoteTransactionOperation(xidData);
op.setCallerUuid(endpoint.getUuid());
int partitionId = partitionService.getPartitionId(xidData);
InvocationBuilder builder = operationService.createInvocationBuilder(getServiceName(), op, partitionId);
builder.setTryCount(TRY_COUNT).setResultDeserialized(false);
builder.invoke();
return XATransactionClearRemoteCodec.encodeResponse();
}
use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.
the class StaleReadDuringMigrationTest method invokeOperation.
private InternalCompletableFuture<Boolean> invokeOperation(final Config config) {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
final HazelcastInstance instance = factory.newHazelcastInstance(config);
warmUpPartitions(instance);
final int partitionId = 0;
final InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) getPartitionService(instance);
final InternalPartitionImpl partition = (InternalPartitionImpl) partitionService.getPartition(partitionId);
partition.setMigrating();
final OperationServiceImpl operationService = getOperationService(instance);
final InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(InternalPartitionService.SERVICE_NAME, new DummyOperation(), partitionId);
return invocationBuilder.invoke();
}
Aggregations