use of com.hazelcast.jet.JetService in project hazelcast by hazelcast.
the class HazelcastBootstrapTest method testHazelcast_bootstrappedInstance.
@Test
public void testHazelcast_bootstrappedInstance() {
HazelcastInstance hz = Hazelcast.bootstrappedInstance();
JetService jet = hz.getJet();
executeWithBootstrappedInstance(jet);
}
use of com.hazelcast.jet.JetService in project hazelcast by hazelcast.
the class JetTestSupport method shutdownJobsAndGetLeakedClassLoaders.
@Nonnull
private Map<Long, String> shutdownJobsAndGetLeakedClassLoaders() {
Map<Long, String> leakedClassloaders = new HashMap<>();
Collection<HazelcastInstance> instances = instanceFactory.getAllHazelcastInstances();
for (HazelcastInstance instance : instances) {
if (instance.getConfig().getJetConfig().isEnabled()) {
// Some tests leave jobs running, which keeps job classloader, shut down all running/starting jobs
JetService jet = instance.getJet();
List<Job> jobs = jet.getJobs();
for (Job job : jobs) {
ditchJob(job, instances.toArray(new HazelcastInstance[instances.size()]));
}
JobClassLoaderService jobClassLoaderService = ((HazelcastInstanceImpl) instance).node.getNodeEngine().<JetServiceBackend>getService(SERVICE_NAME).getJobClassLoaderService();
Map<Long, ?> classLoaders = jobClassLoaderService.getClassLoaders();
// The classloader cleanup is done asynchronously in some cases, wait up to 10s
for (int i = 0; i < 100 && !classLoaders.isEmpty(); i++) {
sleepMillis(100);
}
for (Entry<Long, ?> entry : classLoaders.entrySet()) {
leakedClassloaders.put(entry.getKey(), entry.toString());
}
}
}
return leakedClassloaders;
}
use of com.hazelcast.jet.JetService in project hazelcast by hazelcast.
the class ObservableRingbufferContainerLeakTest method testLeakingRingbufferContainerWhenUsingObservableIterator.
/**
* Regression test for #19580
*/
@Test
@Repeat(100)
public void testLeakingRingbufferContainerWhenUsingObservableIterator() {
Config config = smallInstanceConfig();
config.setProperty("hazelcast.partition.count", "1");
config.getJetConfig().setEnabled(true);
HazelcastInstance hz = createHazelcastInstance(config);
JetService jet = hz.getJet();
Ringbuffer<Object> ringbuffer = hz.getRingbuffer("__jet.observables.my-observable");
Observable<Object> obs = jet.getObservable("my-observable");
ringbuffer.add(42);
ringbuffer.addAsync(DoneItem.DONE_ITEM, OverflowPolicy.OVERWRITE);
Iterator<Object> it = obs.iterator();
it.hasNext();
it.next();
it.hasNext();
obs.destroy();
RingbufferService ringbufferService = Accessors.getService(hz, RingbufferService.SERVICE_NAME);
Map<ObjectNamespace, RingbufferContainer> containers = ringbufferService.getContainers().values().iterator().next();
assertThat(containers).hasSize(0);
}
use of com.hazelcast.jet.JetService in project hazelcast by hazelcast.
the class JobTest method test_manyJobs.
private void test_manyJobs(HazelcastInstance inst) {
JetService jet = inst.getJet();
DAG streamingDag = new DAG();
streamingDag.newVertex("v", () -> new MockP().streaming());
DAG batchDag = new DAG();
batchDag.newVertex("v", MockP::new);
// normal streaming job
Job streamingJob = jet.newJob(streamingDag);
assertJobStatusEventually(streamingJob, RUNNING);
// two normal batch job
Job batchJob1 = jet.newJob(batchDag);
batchJob1.join();
Job batchJob2 = jet.newJob(batchDag);
batchJob2.join();
// named streaming job name1
Job namedStreamingJob1 = jet.newJob(streamingDag, new JobConfig().setName("name1"));
assertJobStatusEventually(namedStreamingJob1, RUNNING);
// named streaming job name2, cancelled
Job namedStreamingJob2 = jet.newJob(streamingDag, new JobConfig().setName("name2"));
namedStreamingJob2.cancel();
joinAndExpectCancellation(namedStreamingJob2);
// named streaming job name2, again, not cancelled
Job namedStreamingJob2_1 = jet.newJob(streamingDag, new JobConfig().setName("name2"));
assertJobStatusEventually(namedStreamingJob2_1, RUNNING);
// light streaming job
Job lightStreamingJob = inst.getJet().newLightJob(streamingDag);
// light streaming job, cancelled
Job lightStreamingJobCancelled = jet.newLightJob(streamingDag);
lightStreamingJobCancelled.cancel();
joinAndExpectCancellation(lightStreamingJobCancelled);
// two light batch jobs
Job lightBatchJob1 = jet.newLightJob(batchDag);
Job lightBatchJob2 = jet.newLightJob(batchDag);
lightBatchJob1.join();
lightBatchJob2.join();
List<Job> allJobsExceptCompletedLightJobs = asList(streamingJob, batchJob1, batchJob2, namedStreamingJob1, namedStreamingJob2, namedStreamingJob2_1, lightStreamingJob);
List<Job> allJobs = new ArrayList<>();
allJobs.addAll(allJobsExceptCompletedLightJobs);
allJobs.add(lightStreamingJobCancelled);
allJobs.add(lightBatchJob1);
allJobs.add(lightBatchJob2);
// Then
// getJobs must include all submitted all jobs, except for the light batch jobs that are done
assertThat(toList(jet.getJobs(), this::jobEqualityString)).containsExactlyInAnyOrderElementsOf(toList(allJobsExceptCompletedLightJobs, this::jobEqualityString));
for (Job job : allJobs) {
Job trackedJobById = jet.getJob(job.getId());
Job trackedJobByName = job.getName() != null ? jet.getJob(job.getName()) : null;
if (allJobsExceptCompletedLightJobs.contains(job)) {
assertEquals(jobEqualityString(job), jobEqualityString(trackedJobById));
if (job.getName() != null && job != namedStreamingJob2) {
assertEquals(jobEqualityString(job), jobEqualityString(trackedJobByName));
}
} else {
assertNull(trackedJobById);
assertNull(trackedJobByName);
}
}
assertThat(toList(jet.getJobs("name1"), this::jobEqualityString)).containsExactlyElementsOf(toList(singletonList(namedStreamingJob1), this::jobEqualityString));
assertThat(toList(jet.getJobs("name2"), this::jobEqualityString)).containsExactlyElementsOf(toList(asList(namedStreamingJob2_1, namedStreamingJob2), this::jobEqualityString));
}
use of com.hazelcast.jet.JetService in project hazelcast by hazelcast.
the class NonSmartClientTest method when_jobSubmitted_then_jobCanBeFetchedByIdOrName.
@Test
public void when_jobSubmitted_then_jobCanBeFetchedByIdOrName() {
// Given
String jobName = randomName();
// When
DAG dag = streamingDag();
JetService jet = nonMasterClient.getJet();
Job job = jet.newJob(dag, new JobConfig().setName(jobName));
long jobId = job.getId();
// Then
assertTrueEventually(() -> {
assertNotNull(jet.getJob(jobId));
assertNotNull(jet.getJob(jobName));
assertTrue(jet.getJobs().stream().anyMatch(j -> j.getId() == jobId));
assertFalse(jet.getJobs(jobName).isEmpty());
assertNotNull(jet.getJob(jobId).getStatus());
assertEquals(jet.getJob(jobId).getStatus(), JobStatus.RUNNING);
Job j = jet.getJob(jobName);
assertNotNull(j.getConfig());
assertGreaterOrEquals("submissionTime", j.getSubmissionTime(), 0);
}, 10);
}
Aggregations