use of com.hazelcast.jet.impl.JobExecutionService in project hazelcast by hazelcast.
the class TerminateExecutionOperation method run.
@Override
public void run() {
JetServiceBackend service = getJetServiceBackend();
JobExecutionService executionService = service.getJobExecutionService();
Address callerAddress = getCallerAddress();
executionService.terminateExecution(jobId(), executionId, callerAddress, mode);
}
use of com.hazelcast.jet.impl.JobExecutionService in project hazelcast by hazelcast.
the class OperationLossTest method when_initExecutionOperationLost_then_initRetried_lightJob.
@Test
public void when_initExecutionOperationLost_then_initRetried_lightJob() {
PacketFiltersUtil.dropOperationsFrom(instance(), JetInitDataSerializerHook.FACTORY_ID, singletonList(JetInitDataSerializerHook.INIT_EXECUTION_OP));
DAG dag = new DAG();
Vertex v1 = dag.newVertex("v1", () -> new NoOutputSourceP());
Vertex v2 = dag.newVertex("v2", mapP(identity())).localParallelism(1);
dag.edge(between(v1, v2).distributed());
Job job = instance().getJet().newLightJob(dag);
// we assert that the PMS is initialized, but the PS isn't
JobExecutionService jobExecutionService = getNodeEngineImpl(instances()[1]).<JetServiceBackend>getService(JetServiceBackend.SERVICE_NAME).getJobExecutionService();
// assert that the execution doesn't start on the 2nd member. For light jobs, jobId == executionId
assertTrueAllTheTime(() -> assertNull(jobExecutionService.getExecutionContext(job.getId())), 1);
// now allow the job to complete normally
PacketFiltersUtil.resetPacketFiltersFrom(instance());
NoOutputSourceP.proceedLatch.countDown();
job.join();
}
use of com.hazelcast.jet.impl.JobExecutionService in project hazelcast by hazelcast.
the class JetTestSupport method assertJobRunningEventually.
/**
* Asserts that a job status is eventually RUNNING. When it's running,
* checks that the execution ID is different from the given {@code
* ignoredExecutionId}, if not, tries again.
* <p>
* This is useful when checking that the job is running after a restart:
* <pre>{@code
* job.restart();
* // This is racy, we might see the previous execution running.
* // Subsequent steps can fail because the job is restarting.
* assertJobStatusEventually(job, RUNNING);
* }</pre>
* <p>
* This method allows an equivalent code:
* <pre>{@code
* long oldExecutionId = assertJobRunningEventually(instance, job, null);
* // now we're sure the job is safe to restart - restart fails if the job isn't running
* job.restart();
* assertJobRunningEventually(instance, job, oldExecutionId);
* // now we're sure that a new execution is running
* }</pre>
*
* @param ignoredExecutionId If job is running and has this execution ID,
* wait longer. If null, no execution ID is ignored.
* @return the execution ID of the new execution or 0 if {@code
* ignoredExecutionId == null}
*/
public static long assertJobRunningEventually(HazelcastInstance instance, Job job, Long ignoredExecutionId) {
Long executionId;
JobExecutionService service = getJetServiceBackend(instance).getJobExecutionService();
long nullSince = Long.MIN_VALUE;
do {
assertJobStatusEventually(job, RUNNING);
// executionId can be null if the execution just terminated
executionId = service.getExecutionIdForJobId(job.getId());
if (executionId == null) {
if (nullSince == Long.MIN_VALUE) {
nullSince = System.nanoTime();
} else {
if (NANOSECONDS.toSeconds(System.nanoTime() - nullSince) > 10) {
// distributed edge will complete on all but one members immediately.
throw new RuntimeException("The executionId is null for 10 secs - is the job running on all members?");
}
}
} else {
nullSince = Long.MIN_VALUE;
}
} while (executionId == null || executionId.equals(ignoredExecutionId));
return executionId;
}
use of com.hazelcast.jet.impl.JobExecutionService in project hazelcast by hazelcast.
the class HazelcastConnector_RestartTest method executionId.
private Long executionId(HazelcastInstance instance, Job job) {
JetServiceBackend jetServiceBackend = getJetServiceBackend(instance);
JobExecutionService executionService = jetServiceBackend.getJobExecutionService();
return executionService.getExecutionIdForJobId(job.getId());
}
use of com.hazelcast.jet.impl.JobExecutionService in project hazelcast by hazelcast.
the class HazelcastConnector_RestartTest method waitExecutionDoneOnMember.
private void waitExecutionDoneOnMember(HazelcastInstance instance, long executionId) {
JetServiceBackend jetServiceBackend = getJetServiceBackend(instance);
JobExecutionService executionService = jetServiceBackend.getJobExecutionService();
ExecutionContext execCtx = executionService.getExecutionContext(executionId);
assertTrueEventually(() -> assertTrue(execCtx == null || execCtx.getExecutionFuture().isDone()));
}
Aggregations