Search in sources :

Example 31 with JetServiceBackend

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");
}
Also used : SimpleEvent(com.hazelcast.jet.pipeline.test.SimpleEvent) HazelcastException(com.hazelcast.core.HazelcastException) JobClassLoaderService(com.hazelcast.jet.impl.JobClassLoaderService) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend) Pipeline(com.hazelcast.jet.pipeline.Pipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 32 with JetServiceBackend

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();
    }
}
Also used : Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Logger(com.hazelcast.logging.Logger) AfterClass(org.junit.AfterClass) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) Collection(java.util.Collection) RunWith(org.junit.runner.RunWith) Collectors(java.util.stream.Collectors) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) Collectors.joining(java.util.stream.Collectors.joining) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Util.idToString(com.hazelcast.jet.Util.idToString) DistributedObject(com.hazelcast.core.DistributedObject) PacketFiltersUtil(com.hazelcast.test.PacketFiltersUtil) ILogger(com.hazelcast.logging.ILogger) After(org.junit.After) ClientConfig(com.hazelcast.client.config.ClientConfig) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend) DistributedObject(com.hazelcast.core.DistributedObject) HazelcastInstance(com.hazelcast.core.HazelcastInstance) JetServiceBackend(com.hazelcast.jet.impl.JetServiceBackend) After(org.junit.After)

Aggregations

JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)32 JobConfig (com.hazelcast.jet.config.JobConfig)14 Test (org.junit.Test)14 Job (com.hazelcast.jet.Job)13 HazelcastInstance (com.hazelcast.core.HazelcastInstance)11 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)9 NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)9 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 JobRepository (com.hazelcast.jet.impl.JobRepository)8 Map (java.util.Map)8 Assert.assertEquals (org.junit.Assert.assertEquals)8 Config (com.hazelcast.config.Config)7 Category (org.junit.experimental.categories.Category)7 RunWith (org.junit.runner.RunWith)7 Address (com.hazelcast.cluster.Address)6 RUNNING (com.hazelcast.jet.core.JobStatus.RUNNING)6 HazelcastSerialClassRunner (com.hazelcast.test.HazelcastSerialClassRunner)6 CancellationException (java.util.concurrent.CancellationException)6 Collectors (java.util.stream.Collectors)6 Assert.assertTrue (org.junit.Assert.assertTrue)6