private void updateRegistry() { if (jobs != null) jobs.updateJob(this); }
@Test public void testUpdateJob() { JobRegistryService service = new JobRegistry(); service.addJob(new JobImpl("Job_1")); service.addJob(new JobImpl("Job_2")); service.addListener(new JobHandler(JobRegistryService.EventType.UPDATE)); service.updateJob(service.getJob("Job_1")); service.updateJob(service.getJob("Job_2")); }
@Test public void testRemoveJob() { JobRegistryService service = new JobRegistry(); service.addJob(new JobImpl("Job_1")); service.addJob(new JobImpl("Job_2")); service.addListener(new JobHandler(JobRegistryService.EventType.REMOVE)); service.removeJob("Job_1"); service.removeJob("Job_2"); }
@Test public void testAddJob() { JobRegistryService service = new JobRegistry(); service.addJob(new JobImpl("Job_1")); service.addListener((et, j) -> { assertEquals(JobRegistryService.EventType.ADD, et); assertEquals("Job_1", j.getId()); }); }
/** * Creates a new {@code EtiaoJob} instance which controls the lifecycle * of the specified graph. * * @param graph graph representation of the topology * @param topologyName name of the topology * @param jobName name of the Job. If null, a name of {@code topologyName_jobId} is assigned. * @param container service container */ EtiaoJob(DirectGraph graph, String topologyName, String jobName, ServiceContainer container) { this.graph = graph; this.id = ID_PREFIX + String.valueOf(jobID.getAndIncrement()); this.topologyName = topologyName; if (jobName == null) jobName = this.topologyName + "_" + this.id; this.name = jobName; this.containerServices = container; ControlService cs = container.getService(ControlService.class); if (cs != null) { EtiaoJobBean.registerControl(cs, this); } this.jobs = container.getService(JobRegistryService.class); if (jobs != null) jobs.addJob(this); }
@Override public void accept(Consumer<T> submitter) { JobRegistryService jobRegistry = rts.get().getService(JobRegistryService.class); if (jobRegistry != null) { listener.setSubmitter(submitter); jobRegistry.addListener(listener); } }
@Override public void close() throws Exception { JobRegistryService jobRegistry = rts.get().getService(JobRegistryService.class); if (jobRegistry != null) { jobRegistry.removeListener(listener); } }
@Test public void testAddJob2() { JobRegistryService service = new JobRegistry(); service.addListener((et, j) -> { assertEquals(JobRegistryService.EventType.ADD, et); assertEquals("Job_1", j.getId()); }); service.addJob(new JobImpl("Job_1")); }
/** * Creates a new {@code EtiaoJob} instance which controls the lifecycle * of the specified graph. * * @param graph graph representation of the topology * @param topologyName name of the topology * @param jobName name of the Job. If null, a name of {@code topologyName_jobId} is assigned. * @param container service container */ EtiaoJob(DirectGraph graph, String topologyName, String jobName, ServiceContainer container) { this.graph = graph; this.id = ID_PREFIX + String.valueOf(jobID.getAndIncrement()); this.topologyName = topologyName; if (jobName == null) jobName = this.topologyName + "_" + this.id; this.name = jobName; this.containerServices = container; ControlService cs = container.getService(ControlService.class); if (cs != null) { EtiaoJobBean.registerControl(cs, this); } this.jobs = container.getService(JobRegistryService.class); if (jobs != null) jobs.addJob(this); }
private void updateRegistry() { if (jobs != null) jobs.updateJob(this); }