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;
}
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());
}
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);
}
});
}
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);
}
});
}
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());
}
}
Aggregations