use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_jobIsSubmitted_then_jobSubmissionTimeIsQueried.
private void when_jobIsSubmitted_then_jobSubmissionTimeIsQueried(HazelcastInstance instance, boolean useLightJob) throws Exception {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
// When
Job job = useLightJob ? instances()[1].getJet().newLightJob(dag) : instance().getJet().newJob(dag);
NoOutputSourceP.executionStarted.await();
Job trackedJob = instance.getJet().getJob(job.getId());
// Then
assertNotNull(trackedJob);
long submissionTime = job.getSubmissionTime();
long trackedJobSubmissionTime = trackedJob.getSubmissionTime();
assertNotEquals(0, submissionTime);
assertNotEquals(0, trackedJobSubmissionTime);
assertEquals(submissionTime, trackedJobSubmissionTime);
assertBetween("submissionTime", submissionTime, System.currentTimeMillis() - MINUTES.toMillis(10), System.currentTimeMillis() + SECONDS.toMillis(1));
NoOutputSourceP.proceedLatch.countDown();
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_executionCancelledBeforeStart_then_jobIsCancelled.
@Test
public void when_executionCancelledBeforeStart_then_jobIsCancelled() {
// not applicable to light jobs - light jobs don't use the StartExecutionOperation
assumeFalse(useLightJob);
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, MEMBER_COUNT)));
delayOperationsFrom(instance(), JetInitDataSerializerHook.FACTORY_ID, singletonList(JetInitDataSerializerHook.START_EXECUTION_OP));
Job job = instance().getJet().newJob(dag);
// RUNNING status is set on master before sending the StartOp
assertJobStatusEventually(job, RUNNING);
job.cancel();
assertThatThrownBy(() -> job.join()).isInstanceOf(CancellationException.class);
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_jobCancelled_then_psCloseNotCalledBeforeTaskletsDone.
@Test
public void when_jobCancelled_then_psCloseNotCalledBeforeTaskletsDone() {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(() -> new NoOutputSourceP(10_000), MEMBER_COUNT)));
Job job = newJob(dag);
assertOpenEventually(NoOutputSourceP.executionStarted);
// When
job.cancel();
assertTrueAllTheTime(() -> {
// Then
assertEquals("PS.close called before execution finished", 0, MockPS.closeCount.get());
}, 1);
NoOutputSourceP.proceedLatch.countDown();
expectedException.expect(CancellationException.class);
job.join();
assertEquals("PS.close not called after execution finished", MEMBER_COUNT, MockPS.closeCount.get());
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_executionCancelledBeforeStart_then_jobFutureIsCancelledOnExecute.
@Test
public void when_executionCancelledBeforeStart_then_jobFutureIsCancelledOnExecute() {
// not applicable to light jobs - we hack around with ExecutionContext
assumeFalse(useLightJob);
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, MEMBER_COUNT)));
NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(instance());
Address localAddress = nodeEngineImpl.getThisAddress();
ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngineImpl.getClusterService();
MembersView membersView = clusterService.getMembershipManager().getMembersView();
int memberListVersion = membersView.getVersion();
JetServiceBackend jetServiceBackend = getJetServiceBackend(instance());
long jobId = 0;
long executionId = 1;
JobConfig jobConfig = new JobConfig();
final Map<MemberInfo, ExecutionPlan> executionPlans = ExecutionPlanBuilder.createExecutionPlans(nodeEngineImpl, membersView.getMembers(), dag, jobId, executionId, jobConfig, NO_SNAPSHOT, false, null);
ExecutionPlan executionPlan = executionPlans.get(membersView.getMember(localAddress));
jetServiceBackend.getJobClassLoaderService().getOrCreateClassLoader(jobConfig, jobId, COORDINATOR);
Set<MemberInfo> participants = new HashSet<>(membersView.getMembers());
jetServiceBackend.getJobExecutionService().initExecution(jobId, executionId, localAddress, memberListVersion, participants, executionPlan);
ExecutionContext executionContext = jetServiceBackend.getJobExecutionService().getExecutionContext(executionId);
executionContext.terminateExecution(null);
// When
CompletableFuture<Void> future = executionContext.beginExecution(jetServiceBackend.getTaskletExecutionService());
// Then
expectedException.expect(CancellationException.class);
future.join();
}
use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.
the class JobTest method when_jobSubmitted_then_trackedJobCanQueryJobStatus.
@Test
public void when_jobSubmitted_then_trackedJobCanQueryJobStatus() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
// When
Job submittedJob = instance().getJet().newJob(dag);
NoOutputSourceP.executionStarted.await();
Collection<Job> trackedJobs = instances()[1].getJet().getJobs();
Job trackedJob = trackedJobs.stream().filter(j -> j.getId() == submittedJob.getId()).findFirst().orElse(null);
assertNotNull(trackedJob);
// Then
assertJobStatusEventually(trackedJob, RUNNING);
cancelAndJoin(submittedJob);
}
Aggregations