use of com.hazelcast.jet.impl.execution.ExecutionContext in project hazelcast-jet by hazelcast.
the class StartExecutionOperation method doRun.
@Override
protected void doRun() throws Exception {
ExecutionContext execCtx = getExecutionCtx();
Address coordinator = getCallerAddress();
getLogger().info("Start execution of " + jobAndExecutionId(jobId(), executionId) + " from coordinator " + coordinator);
execCtx.beginExecution().whenComplete(withTryCatch(getLogger(), (i, e) -> {
if (e instanceof CancellationException) {
getLogger().fine("Execution of " + jobAndExecutionId(jobId(), executionId) + " was cancelled");
} else if (e != null) {
getLogger().fine("Execution of " + jobAndExecutionId(jobId(), executionId) + " completed with failure", e);
} else {
getLogger().fine("Execution of " + jobAndExecutionId(jobId(), executionId) + " completed");
}
doSendResponse(e);
}));
}
use of com.hazelcast.jet.impl.execution.ExecutionContext in project hazelcast-jet by hazelcast.
the class Networking method createFlowControlPacket.
private byte[] createFlowControlPacket(Address member) throws IOException {
try (BufferObjectDataOutput out = createObjectDataOutput(nodeEngine)) {
final boolean[] hasData = { false };
Map<Long, ExecutionContext> executionContexts = jobExecutionService.getExecutionContextsFor(member);
out.writeInt(executionContexts.size());
executionContexts.forEach((execId, exeCtx) -> uncheckRun(() -> {
out.writeLong(execId);
out.writeInt(exeCtx.receiverMap().values().stream().mapToInt(Map::size).sum());
exeCtx.receiverMap().forEach((vertexId, ordinalToSenderToTasklet) -> ordinalToSenderToTasklet.forEach((ordinal, senderToTasklet) -> uncheckRun(() -> {
out.writeInt(vertexId);
out.writeInt(ordinal);
out.writeInt(senderToTasklet.get(member).updateAndGetSendSeqLimitCompressed());
hasData[0] = true;
})));
}));
return hasData[0] ? out.toByteArray() : EMPTY_BYTES;
}
}
use of com.hazelcast.jet.impl.execution.ExecutionContext in project hazelcast-jet by hazelcast.
the class JobExecutionService method assertExecutionContext.
public ExecutionContext assertExecutionContext(Address coordinator, long jobId, long executionId, Operation callerOp) {
Address masterAddress = nodeEngine.getMasterAddress();
if (!coordinator.equals(masterAddress)) {
failIfNotRunning();
throw new IllegalStateException(String.format("Coordinator %s cannot do '%s' for %s: it is not the master, the master is %s", coordinator, callerOp.getClass().getSimpleName(), jobAndExecutionId(jobId, executionId), masterAddress));
}
failIfNotRunning();
ExecutionContext executionContext = executionContexts.get(executionId);
if (executionContext == null) {
throw new TopologyChangedException(String.format("%s not found for coordinator %s for '%s'", jobAndExecutionId(jobId, executionId), coordinator, callerOp.getClass().getSimpleName()));
} else if (!(executionContext.coordinator().equals(coordinator) && executionContext.jobId() == jobId)) {
throw new IllegalStateException(String.format("%s, originally from coordinator %s, cannot do '%s' by coordinator %s and execution %s", jobAndExecutionId(jobId, executionContext.executionId()), executionContext.coordinator(), callerOp.getClass().getSimpleName(), coordinator, idToString(executionId)));
}
return executionContext;
}
use of com.hazelcast.jet.impl.execution.ExecutionContext 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.jet.impl.execution.ExecutionContext in project hazelcast-jet by hazelcast.
the class JobExecutionService method completeExecution.
/**
* Completes and cleans up execution of the given job
*/
public void completeExecution(long executionId, Throwable error) {
ExecutionContext executionContext = executionContexts.remove(executionId);
if (executionContext != null) {
try {
executionContext.completeExecution(error);
} finally {
classLoaders.remove(executionContext.jobId());
executionContextJobIds.remove(executionContext.jobId());
logger.fine("Completed execution of " + jobAndExecutionId(executionContext.jobId(), executionId));
}
} else {
logger.fine("Execution " + idToString(executionId) + " not found for completion");
}
}
Aggregations