Search in sources :

Example 1 with JobResult

use of com.hazelcast.jet.impl.JobResult in project hazelcast-jet by hazelcast.

the class ExecutionLifecycleTest method getJobResult.

private JobResult getJobResult(Job job) {
    JetService jetService = getJetService(instance);
    assertNull(jetService.getJobRepository().getJobRecord(job.getId()));
    JobResult jobResult = jetService.getJobRepository().getJobResult(job.getId());
    assertNotNull(jobResult);
    return jobResult;
}
Also used : JetService(com.hazelcast.jet.impl.JetService) JobResult(com.hazelcast.jet.impl.JobResult)

Example 2 with JobResult

use of com.hazelcast.jet.impl.JobResult in project hazelcast-jet by hazelcast.

the class ExecutionLifecycleTest method assertJobFailed.

private void assertJobFailed(Job job, Throwable e) {
    JobResult jobResult = getJobResult(job);
    assertFalse("jobResult.isSuccessful", jobResult.isSuccessful());
    assertExceptionInCauses(e, jobResult.getFailure());
    JobStatus expectedStatus = e instanceof CancellationException ? JobStatus.COMPLETED : JobStatus.FAILED;
    assertEquals("jobStatus", expectedStatus, job.getStatus());
}
Also used : JobResult(com.hazelcast.jet.impl.JobResult) CancellationException(java.util.concurrent.CancellationException)

Example 3 with JobResult

use of com.hazelcast.jet.impl.JobResult in project hazelcast-jet by hazelcast.

the class TopologyChangeTest method when_coordinatorLeavesDuringExecution_then_jobCompletes.

@Test
public void when_coordinatorLeavesDuringExecution_then_jobCompletes() throws Throwable {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(StuckProcessor::new, nodeCount)));
    // When
    Long jobId = null;
    try {
        Job job = instances[0].newJob(dag);
        Future<Void> future = job.getFuture();
        jobId = job.getId();
        StuckProcessor.executionStarted.await();
        instances[0].getHazelcastInstance().getLifecycleService().terminate();
        StuckProcessor.proceedLatch.countDown();
        future.get();
        fail();
    } catch (ExecutionException expected) {
        assertTrue(expected.getCause() instanceof HazelcastInstanceNotActiveException);
    }
    // Then
    assertNotNull(jobId);
    final long completedJobId = jobId;
    JobRepository jobRepository = getJetService(instances[1]).getJobRepository();
    assertTrueEventually(() -> {
        JobResult jobResult = jobRepository.getJobResult(completedJobId);
        assertNotNull(jobResult);
        assertTrue(jobResult.isSuccessful());
    });
    final int count = liteMemberFlags[0] ? (2 * nodeCount) : (2 * nodeCount - 1);
    assertEquals(count, MockPS.initCount.get());
    assertTrueEventually(() -> {
        assertEquals(count, MockPS.closeCount.get());
        assertEquals(nodeCount, MockPS.receivedCloseErrors.size());
        for (int i = 0; i < MockPS.receivedCloseErrors.size(); i++) {
            Throwable error = MockPS.receivedCloseErrors.get(i);
            assertTrue(error instanceof TopologyChangedException || error instanceof HazelcastInstanceNotActiveException);
        }
    });
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) JobResult(com.hazelcast.jet.impl.JobResult) JobRepository(com.hazelcast.jet.impl.JobRepository) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) StuckProcessor(com.hazelcast.jet.core.TestProcessors.StuckProcessor) Job(com.hazelcast.jet.Job) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 4 with JobResult

use of com.hazelcast.jet.impl.JobResult in project hazelcast by hazelcast.

the class TopologyChangeTest method when_coordinatorLeavesDuringExecution_then_jobCompletes.

@Test
public void when_coordinatorLeavesDuringExecution_then_jobCompletes() throws Throwable {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, nodeCount)));
    // When
    Long jobId = null;
    try {
        Job job = instances[0].getJet().newJob(dag);
        Future<Void> future = job.getFuture();
        jobId = job.getId();
        NoOutputSourceP.executionStarted.await();
        instances[0].getLifecycleService().terminate();
        // Processor#close.
        for (int i = 1; i < instances.length; i++) {
            JetServiceBackend jetServiceBackend = getJetServiceBackend(instances[i]);
            jetServiceBackend.getJobExecutionService().waitAllExecutionsTerminated();
        }
        NoOutputSourceP.proceedLatch.countDown();
        future.get();
        fail();
    } catch (ExecutionException expected) {
        assertTrue(expected.getCause() instanceof HazelcastInstanceNotActiveException);
    }
    // Then
    assertNotNull(jobId);
    final long completedJobId = jobId;
    JobRepository jobRepository = getJetServiceBackend(instances[1]).getJobRepository();
    assertTrueEventually(() -> {
        JobResult jobResult = jobRepository.getJobResult(completedJobId);
        assertNotNull(jobResult);
        assertTrue(jobResult.isSuccessful());
    });
    final int count = liteMemberFlags[0] ? (2 * nodeCount) : (2 * nodeCount - 1);
    assertEquals(count, MockPS.initCount.get());
    assertTrueEventually(() -> {
        assertEquals(count, MockPS.closeCount.get());
        assertEquals(nodeCount, MockPS.receivedCloseErrors.size());
        for (Throwable error : MockPS.receivedCloseErrors) {
            assertTrue("unexpected exc: " + error, error instanceof CancellationException);
        }
    });
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) JobResult(com.hazelcast.jet.impl.JobResult) JobRepository(com.hazelcast.jet.impl.JobRepository) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) CancellationException(java.util.concurrent.CancellationException) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) ExecutionException(java.util.concurrent.ExecutionException) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 5 with JobResult

use of com.hazelcast.jet.impl.JobResult in project hazelcast by hazelcast.

the class ExecutionLifecycleTest method assertJobSucceeded.

private void assertJobSucceeded(Job job) {
    assertTrue(job.getFuture().isDone());
    job.join();
    if (!job.isLightJob()) {
        JobResult jobResult = getJobResult(job);
        assertTrue(jobResult.isSuccessful());
        assertNull(jobResult.getFailureText());
    }
}
Also used : JobResult(com.hazelcast.jet.impl.JobResult)

Aggregations

JobResult (com.hazelcast.jet.impl.JobResult)9 Job (com.hazelcast.jet.Job)4 JobRepository (com.hazelcast.jet.impl.JobRepository)3 CancellationException (java.util.concurrent.CancellationException)3 Test (org.junit.Test)3 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)2 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)2 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 SlowTest (com.hazelcast.test.annotation.SlowTest)2 ExecutionException (java.util.concurrent.ExecutionException)2 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)1 StuckProcessor (com.hazelcast.jet.core.TestProcessors.StuckProcessor)1 JetService (com.hazelcast.jet.impl.JetService)1