use of com.hazelcast.jet.impl.JetServiceBackend in project hazelcast by hazelcast.
the class ProcessorClassLoaderCleanupTest method processorClassLoaderRemovedAfterJobFinished.
@Test
public void processorClassLoaderRemovedAfterJobFinished() throws Exception {
Pipeline p = Pipeline.create();
StreamSource<SimpleEvent> source = TestSources.itemStream(1);
p.readFrom(source).withoutTimestamps().setLocalParallelism(1).writeTo(Sinks.logger());
JobConfig jobConfig = new JobConfig();
jobConfig.addCustomClasspath(source.name(), jarFile.getName());
Job job = jet.newJob(p, jobConfig);
assertJobStatusEventually(job, JobStatus.RUNNING);
JetServiceBackend jetServiceBackend = ((HazelcastInstanceProxy) member).getOriginal().node.getNodeEngine().getService(JetServiceBackend.SERVICE_NAME);
JobClassLoaderService jobClassLoaderService = jetServiceBackend.getJobClassLoaderService();
ChildFirstClassLoader classLoader = (ChildFirstClassLoader) jobClassLoaderService.getProcessorClassLoader(job.getId(), source.name());
job.suspend();
assertJobStatusEventually(job, JobStatus.SUSPENDED);
assertThat(classLoader.isClosed()).describedAs("classloader hasn't been closed").isTrue();
assertThatThrownBy(() -> jobClassLoaderService.getProcessorClassLoader(job.getId(), source.name())).isInstanceOf(HazelcastException.class).hasMessageContaining("JobClassLoaders for jobId=" + Util.idToString(job.getId()) + " requested, but it does not exists");
}
use of com.hazelcast.jet.impl.JetServiceBackend in project hazelcast by hazelcast.
the class SimpleTestInClusterSupport method supportAfter.
@After
public void supportAfter() {
if (instances == null) {
return;
}
for (HazelcastInstance inst : instances) {
PacketFiltersUtil.resetPacketFiltersFrom(inst);
}
// after each test ditch all jobs and objects
List<Job> jobs = instances[0].getJet().getJobs();
SUPPORT_LOGGER.info("Ditching " + jobs.size() + " jobs in SimpleTestInClusterSupport.@After: " + jobs.stream().map(j -> idToString(j.getId())).collect(joining(", ", "[", "]")));
for (Job job : jobs) {
ditchJob(job, instances());
}
// cancel all light jobs by cancelling their executions
for (HazelcastInstance inst : instances) {
JetServiceBackend jetServiceBackend = getJetServiceBackend(inst);
jetServiceBackend.getJobExecutionService().cancelAllExecutions("ditching all jobs after a test");
jetServiceBackend.getJobExecutionService().waitAllExecutionsTerminated();
}
Collection<DistributedObject> objects = instances()[0].getDistributedObjects();
SUPPORT_LOGGER.info("Destroying " + objects.size() + " distributed objects in SimpleTestInClusterSupport.@After: " + objects.stream().map(o -> o.getServiceName() + "/" + o.getName()).collect(Collectors.joining(", ", "[", "]")));
for (DistributedObject o : objects) {
o.destroy();
}
}
Aggregations