/** * Acts as a service provider for executable elements in the graph, first * looking for a service specific to this job, and then one from the * container. */ @Override public <T> T getService(Class<T> serviceClass) { T service = jobServices.getService(serviceClass); if (service != null) return service; return containerServices.getService(serviceClass); }
@Override public <T> T getService(Class<T> serviceClass) { return services.getService(serviceClass); }
private void updateRegistry() { if (jobs != null) jobs.updateJob(this); }
/** * Creates and registers a {@link JobRegistry} with the given service * container. * * @param services provides access to service registration * @return service instance. */ public static JobRegistryService createAndRegister(ServiceContainer services) { JobRegistryService service = new JobRegistry(); services.addService(JobRegistryService.class, service); return service; }
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); }
@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); } }
/** * Unregister all StreamScopeMXBean for the oplet. * no-op if none registered. * <BR> * N.B. This does not unregister StreamScopes from the underlying StreamScopeRegistry. * @param jobId * @param opletId */ void unregister(String jobId, String opletId) { for (String controlId : controlIds(jobId, opletId)) { cs.unregister(controlId); } }
@Test public void testNotValid() { // Not an interface assertFalse(isControlServiceMBean(Object.class)); // List extends anther assertFalse(isControlServiceMBean(List.class)); // Is parameterized assertFalse(isControlServiceMBean(Callable.class)); // Methods with unsupported signatures. assertFalse(isControlServiceMBean(DataInput.class)); } @Test
protected void registerControlService() { getServices().addService(ControlService.class, getControlService()); }
/** * Acts as a service provider for executable elements in the graph, first * looking for a service specific to this job, and then one from the * container. */ @Override public <T> T getService(Class<T> serviceClass) { T service = jobServices.getService(serviceClass); if (service != null) return service; return containerServices.getService(serviceClass); }
@Override public <T> T getService(Class<T> serviceClass) { return services.getService(serviceClass); }
private void updateRegistry() { if (jobs != null) jobs.updateJob(this); }
protected void registerControlService() { getServices().addService(ControlService.class, getControlService()); }
/** * Get the application service. * Callers may use this to register applications to * be executed by this provider. * @return application service. */ public ApplicationService getApplicationService() { return getServices().getService(ApplicationService.class); }
@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
/** * Initializes the invocations. */ public void initialize() { jobServices.addService(ThreadFactory.class, getThreads()); jobServices.addService(ScheduledExecutorService.class, getScheduler()); invokeAction(invocation -> invocation.initialize(job, this)); }
/** * Get the application service. * Callers may use this to register applications to * be executed by this provider. * @return application service. */ public ApplicationService getApplicationService() { return getServices().getService(ApplicationService.class); }
/** * Create an register an application service using the default alias {@link ApplicationService#ALIAS}. * @param provider Provider to create topology instances for registered applications. * @param submitter Submitter for registered applications. * @return Application service instance. */ public static ApplicationService createAndRegister(TopologyProvider provider, DirectSubmitter<Topology, Job> submitter) { AppService service = new AppService(provider, submitter, ALIAS); submitter.getServices().addService(ApplicationService.class, service); return service; }
/** * Create an register an application service using the default alias {@link ApplicationService#ALIAS}. * @param provider Provider to create topology instances for registered applications. * @param submitter Submitter for registered applications. * @return Application service instance. */ public static ApplicationService createAndRegister(TopologyProvider provider, DirectSubmitter<Topology, Job> submitter) { AppService service = new AppService(provider, submitter, ALIAS); submitter.getServices().addService(ApplicationService.class, service); return service; }