/** * 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; }
/** * 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); }
public DirectProvider() { this.services = new ServiceContainer(); getServices().addService(ControlService.class, new JsonControlService()); }
/** * Returns a new {@link MetricsSetup} for configuring metrics. * * @param services ServiceContainer to use to add services to * @param registry the registry to use for the application * @return a {@link MetricsSetup} instance */ public static MetricsSetup withRegistry(ServiceContainer services, MetricRegistry registry) { final MetricsSetup setup = new MetricsSetup(registry); services.addService(MetricRegistry.class, registry); services.addCleaner(setup.new MetricOpletCleaner()); return setup; }
@Override protected Graph createGraph() { return new DirectGraph(this.getClass().getSimpleName(), new ServiceContainer()); }
/** * Perform the necessary registrations. * <P> * <UL> * <LI>register the StreamScopeRegistry service</LI> * <LI>register a cleaner to remove job oplet StreamScope registrations</LI> * <LI>register a StreamScopeRegistryMXBean with the registered ControlService</LI> * </UL> * </P> * @param services ServiceContainer to register with. */ private void registerPvt(ServiceContainer services) { services.addService(StreamScopeRegistry.class, rgy); services.addCleaner( (jobId, opletId) -> { rgy.unregister(jobId, opletId); if (rgyBean != null) rgyBean.unregister(jobId, opletId); }); registerRegistryBean(services); }
/** * Initializes the invocations. */ public void initialize() { jobServices.addService(ThreadFactory.class, getThreads()); jobServices.addService(ScheduledExecutorService.class, getScheduler()); invokeAction(invocation -> invocation.initialize(job, this)); }
/** * 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); }
public DirectProvider() { this.services = new ServiceContainer(); getServices().addService(ControlService.class, new JsonControlService()); }
/** * 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; }
/** * 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; }
/** * 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); }
/** * Initializes the invocations. */ public void initialize() { jobServices.addService(ThreadFactory.class, getThreads()); jobServices.addService(ScheduledExecutorService.class, getScheduler()); invokeAction(invocation -> invocation.initialize(job, this)); }
private void validateSubmitter() { ControlService controlService = submitter.getServices().getService(ControlService.class); if (controlService == null) { throw new IllegalArgumentException("Could not access service " + ControlService.class.getName()); } ApplicationService appService = submitter.getServices().getService(ApplicationService.class); if (appService == null) { throw new IllegalArgumentException("Could not access service " + ApplicationService.class.getName()); } JobRegistryService jobRegistryService = submitter.getServices().getService(JobRegistryService.class); if (jobRegistryService == null) { throw new IllegalArgumentException("Could not access service " + JobRegistryService.class.getName()); } } }
protected void registerPublishSubscribeService() { getServices().addService(PublishSubscribeService.class, new ProviderPubSub()); }
private void validateSubmitter() { ControlService controlService = submitter.getServices().getService(ControlService.class); if (controlService == null) { throw new IllegalArgumentException("Could not access service " + ControlService.class.getName()); } ApplicationService appService = submitter.getServices().getService(ApplicationService.class); if (appService == null) { throw new IllegalArgumentException("Could not access service " + ApplicationService.class.getName()); } JobRegistryService jobRegistryService = submitter.getServices().getService(JobRegistryService.class); if (jobRegistryService == null) { throw new IllegalArgumentException("Could not access service " + JobRegistryService.class.getName()); } } }
protected void registerPublishSubscribeService() { getServices().addService(PublishSubscribeService.class, new ProviderPubSub()); }
/** * 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); }
protected void registerControlService() { getServices().addService(ControlService.class, getControlService()); }