Search in sources :

Example 1 with JobExecutionService

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);
}
Also used : JobExecutionService(com.hazelcast.jet.impl.JobExecutionService) Address(com.hazelcast.cluster.Address) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend)

Example 2 with JobExecutionService

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();
}
Also used : JobExecutionService(com.hazelcast.jet.impl.JobExecutionService) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 3 with JobExecutionService

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;
}
Also used : JobExecutionService(com.hazelcast.jet.impl.JobExecutionService)

Example 4 with JobExecutionService

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());
}
Also used : JobExecutionService(com.hazelcast.jet.impl.JobExecutionService) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend)

Example 5 with JobExecutionService

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()));
}
Also used : JobExecutionService(com.hazelcast.jet.impl.JobExecutionService) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend)

Aggregations

JobExecutionService (com.hazelcast.jet.impl.JobExecutionService)6 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)3 ExecutionContext (com.hazelcast.jet.impl.execution.ExecutionContext)2 Address (com.hazelcast.cluster.Address)1 Job (com.hazelcast.jet.Job)1 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)1 JetService (com.hazelcast.jet.impl.JetService)1 Address (com.hazelcast.nio.Address)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1 Test (org.junit.Test)1