use of com.hazelcast.spi.Operation in project hazelcast-jet by hazelcast.
the class MasterContext method invokeOnParticipants.
private void invokeOnParticipants(Map<MemberInfo, InternalCompletableFuture<Object>> futures, CompletableFuture<Void> doneFuture, Function<ExecutionPlan, Operation> opCtor) {
AtomicInteger remainingCount = new AtomicInteger(executionPlanMap.size());
for (Entry<MemberInfo, ExecutionPlan> e : executionPlanMap.entrySet()) {
MemberInfo member = e.getKey();
Operation op = opCtor.apply(e.getValue());
InternalCompletableFuture<Object> future = nodeEngine.getOperationService().createInvocationBuilder(JetService.SERVICE_NAME, op, member.getAddress()).setDoneCallback(() -> {
if (remainingCount.decrementAndGet() == 0) {
doneFuture.complete(null);
}
}).invoke();
futures.put(member, future);
}
}
use of com.hazelcast.spi.Operation in project hazelcast-jet by hazelcast.
the class MasterContext method invokeStartExecution.
// If a participant leaves or the execution fails in a participant locally, executions are cancelled
// on the remaining participants and the callback is completed after all invocations return.
private void invokeStartExecution() {
logger.fine("Executing " + jobIdString());
long executionId = this.executionId;
ExecutionInvocationCallback callback = new ExecutionInvocationCallback(executionId);
cancellationToken.whenCompleted(callback::cancelInvocations);
CompletionToken executionRestartToken = new CompletionToken(logger);
executionRestartToken.whenCompleted(callback::cancelInvocations);
Function<ExecutionPlan, Operation> operationCtor = plan -> new StartExecutionOperation(jobId, executionId);
Consumer<Map<MemberInfo, Object>> completionCallback = results -> {
this.executionRestartToken = null;
onExecuteStepCompleted(results, executionRestartToken.isCompleted());
};
// We must set executionRestartToken before we call invoke() method because once all invocations
// are done, executionRestartToken will be reset. Therefore, setting it after the invoke() call is racy.
this.executionRestartToken = executionRestartToken;
jobStatus.set(RUNNING);
invoke(operationCtor, completionCallback, callback);
if (isSnapshottingEnabled()) {
coordinationService.scheduleSnapshot(jobId, executionId);
}
}
use of com.hazelcast.spi.Operation in project hazelcast-jet by hazelcast.
the class JobExecutionService method initExecution.
/**
* Initiates the given execution if the local node accepts the coordinator
* as its master, and has an up-to-date member list information.
* <ul><li>
* If the local node has a stale member list, it retries the init operation
* until it receives the new member list from the master.
* </li><li>
* If the local node detects that the member list changed after the init
* operation is sent but before executed, then it sends a graceful failure
* so that the job init will be retried properly.
* </li><li>
* If there is an already ongoing execution for the given job, then the
* init execution is retried.
* </li></ul>
*/
public void initExecution(long jobId, long executionId, Address coordinator, int coordinatorMemberListVersion, Set<MemberInfo> participants, ExecutionPlan plan) {
verifyClusterInformation(jobId, executionId, coordinator, coordinatorMemberListVersion, participants);
failIfNotRunning();
if (!executionContextJobIds.add(jobId)) {
ExecutionContext current = executionContexts.get(executionId);
if (current != null) {
throw new IllegalStateException(String.format("Execution context for %s for coordinator %s already exists for coordinator %s", jobAndExecutionId(jobId, executionId), coordinator, current.coordinator()));
}
executionContexts.values().stream().filter(e -> e.jobId() == jobId).forEach(e -> logger.fine(String.format("Execution context for %s for coordinator %s already exists" + " with local execution %s for coordinator %s", jobAndExecutionId(jobId, executionId), coordinator, idToString(e.jobId()), e.coordinator())));
throw new RetryableHazelcastException();
}
Set<Address> addresses = participants.stream().map(MemberInfo::getAddress).collect(toSet());
ExecutionContext created = new ExecutionContext(nodeEngine, taskletExecutionService, jobId, executionId, coordinator, addresses);
try {
created.initialize(plan);
} finally {
executionContexts.put(executionId, created);
}
logger.info("Execution plan for " + jobAndExecutionId(jobId, executionId) + " initialized");
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class AbstractAddressMessageTask method processMessage.
@Override
public final void processMessage() {
beforeProcess();
Operation op = prepareOperation();
op.setCallerUuid(endpoint.getUuid());
ICompletableFuture f = nodeEngine.getOperationService().createInvocationBuilder(getServiceName(), op, getAddress()).setResultDeserialized(false).invoke();
f.andThen(this, this);
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class AbstractPartitionMessageTask method processMessage.
@Override
public final void processMessage() {
beforeProcess();
Operation op = prepareOperation();
op.setCallerUuid(endpoint.getUuid());
ICompletableFuture f = nodeEngine.getOperationService().createInvocationBuilder(getServiceName(), op, getPartitionId()).setResultDeserialized(false).invoke();
f.andThen(this, this);
}
Aggregations