@Override public <T> T getService(Class<T> serviceClass) { return services.getService(serviceClass); }
@Override public <T> T getService(Class<T> serviceClass) { return services.getService(serviceClass); }
@Override public void close() throws Exception { JobRegistryService jobRegistry = rts.get().getService(JobRegistryService.class); if (jobRegistry != null) { jobRegistry.removeListener(listener); } }
@Override public void close() throws Exception { PublishSubscribeService pubSub = rts.get().getService(PublishSubscribeService.class); if (pubSub != null) { pubSub.removeSubscriber(topic, submitter); } } }
@Override public void accept(Consumer<T> submitter) { PublishSubscribeService pubSub = rts.get().getService(PublishSubscribeService.class); if (pubSub != null) { this.submitter = submitter; pubSub.addSubscriber(topic, streamType, submitter); } } @Override
@Override public void accept(Consumer<T> submitter) { PublishSubscribeService pubSub = rts.get().getService(PublishSubscribeService.class); if (pubSub != null) { this.submitter = submitter; pubSub.addSubscriber(topic, streamType, submitter); } } @Override
@Override public void close() throws Exception { PublishSubscribeService pubSub = rts.get().getService(PublishSubscribeService.class); if (pubSub != null) { pubSub.removeSubscriber(topic, submitter); } } }
@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 accept(JsonObject value) { ControlService controlService = rts.get().getService(ControlService.class); JsonObject job = JobMonitorAppEvent.getJob(value); String applicationName = JobMonitorAppEvent.getJobName(job); logger.trace("close and restart: {}", value); closeJob(applicationName, controlService); submitApplication(applicationName, controlService); } }
@Override public void accept(JsonObject value) { ControlService controlService = rts.get().getService(ControlService.class); JsonObject job = JobMonitorAppEvent.getJob(value); String applicationName = JobMonitorAppEvent.getJobName(job); logger.trace("close and restart: {}", value); closeJob(applicationName, controlService); submitApplication(applicationName, controlService); } }
@Test public void testServiceRegistered() throws Exception { Topology t1 = newTopology(); StreamScopeRegistry rgy1 = t1.getRuntimeServiceSupplier().get() .getService(StreamScopeRegistry.class); assertNotNull(rgy1); Topology t2 = newTopology(); StreamScopeRegistry rgy2 = t2.getRuntimeServiceSupplier().get() .getService(StreamScopeRegistry.class); assertNotNull(rgy2); assertSame(rgy1, rgy2); }
static <T> void setPollFrequency(TStream<T> pollStream, long period, TimeUnit unit) { ControlService cs = pollStream.topology().getRuntimeServiceSupplier() .get().getService(ControlService.class); PeriodMXBean control = cs.getControl(TStream.TYPE, pollStream.getAlias(), PeriodMXBean.class); control.setPeriod(period, unit); }
StreamScopeRegistry rgy = (StreamScopeRegistry) t.getRuntimeServiceSupplier().get() .getService(StreamScopeRegistry.class); if (rgy == null) return;
@Test public void testRuntimeServices() throws Exception { Topology t = newTopology(); TStream<String> s = t.strings("A"); Supplier<RuntimeServices> serviceGetter = t.getRuntimeServiceSupplier(); TStream<Boolean> b = s.map(tuple -> serviceGetter.get().getService(ThreadFactory.class) != null && serviceGetter.get().getService(ScheduledExecutorService.class) != null ); Condition<List<Boolean>> tc = t.getTester().streamContents(b, Boolean.TRUE); complete(t, tc); assertTrue(tc.valid()); }
@Test public void testRegistryControlRegistered() throws Exception { Topology t1 = newTopology(); ControlService cs1 = t1.getRuntimeServiceSupplier().get() .getService(ControlService.class); StreamScopeRegistryMXBean rgy1 = cs1.getControl(StreamScopeRegistryMXBean.TYPE, StreamScopeRegistryMXBean.TYPE, StreamScopeRegistryMXBean.class); assertNotNull(rgy1); Topology t2 = newTopology(); ControlService cs2 = t2.getRuntimeServiceSupplier().get() .getService(ControlService.class); StreamScopeRegistryMXBean rgy2 = cs2.getControl(StreamScopeRegistryMXBean.TYPE, StreamScopeRegistryMXBean.TYPE, StreamScopeRegistryMXBean.class); assertNotNull(rgy2); // The rgy1, rgy1 mbean instances may or may not be the same object // depending on the ControlService implementation. For JMXControlService, // each getControl() yields a different MXBeanProxy instance but they are // for the underlying bean (same objectname). //assertSame(rgy1, rgy2); }
.getService(StreamScopeRegistry.class); assertNotNull(rgy); ControlService cs = t1.getRuntimeServiceSupplier().get() .getService(ControlService.class); StreamScopeRegistryMXBean rgyBean = cs.getControl(StreamScopeRegistryMXBean.TYPE,