本文整理汇总了Java中com.google.common.util.concurrent.ServiceManager类的典型用法代码示例。如果您正苦于以下问题:Java ServiceManager类的具体用法?Java ServiceManager怎么用?Java ServiceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceManager类属于com.google.common.util.concurrent包,在下文中一共展示了ServiceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
public static void main(String[] args) {
LOGGER.info("{} {} starting", NAME, VERSION);
Configuration configuration = new Configuration();
try {
configuration = DataBindingUtils.readConfiguration(new File("config.yml"));
} catch (IOException e) {
LOGGER.error("Unable to read configuration, exiting.");
LOGGER.error(e.getMessage());
System.exit(1);
}
final ServiceFactory configurationAwareServiceFactory = new ServiceFactory(configuration);
configurationAwareServiceFactory.initializePlugins();
final ServiceManager serviceManager = new ServiceManager(configurationAwareServiceFactory.getServices());
LOGGER.info("Starting services");
serviceManager.startAsync();
}
示例2: LocalJobLauncher
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
public LocalJobLauncher(Properties jobProps) throws Exception {
super(jobProps);
TimingEvent jobLocalSetupTimer = this.eventSubmitter.getTimingEvent(TimingEventNames.RunJobTimings.JOB_LOCAL_SETUP);
this.taskExecutor = new TaskExecutor(jobProps);
this.taskStateTracker = new LocalTaskStateTracker(jobProps, this.taskExecutor);
this.serviceManager = new ServiceManager(Lists.newArrayList(
// The order matters due to dependencies between services
this.taskExecutor, this.taskStateTracker));
// Start all dependent services
this.serviceManager.startAsync().awaitHealthy(5, TimeUnit.SECONDS);
startCancellationExecutor();
jobLocalSetupTimer.stop();
}
示例3: LocalJobLauncher
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
public LocalJobLauncher(Properties jobProps, SharedResourcesBroker<GobblinScopeTypes> instanceBroker) throws Exception {
super(jobProps, ImmutableList.<Tag<?>> of(), instanceBroker);
log.debug("Local job launched with properties: {}", jobProps);
TimingEvent jobLocalSetupTimer = this.eventSubmitter.getTimingEvent(TimingEvent.RunJobTimings.JOB_LOCAL_SETUP);
this.taskExecutor = new TaskExecutor(jobProps);
this.taskStateTracker =
new LocalTaskStateTracker(jobProps, this.jobContext.getJobState(), this.taskExecutor, this.eventBus);
this.serviceManager = new ServiceManager(Lists.newArrayList(
// The order matters due to dependencies between services
this.taskExecutor, this.taskStateTracker));
// Start all dependent services
this.serviceManager.startAsync().awaitHealthy(5, TimeUnit.SECONDS);
startCancellationExecutor();
jobLocalSetupTimer.stop();
}
示例4: StandardGobblinInstanceDriver
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
protected StandardGobblinInstanceDriver(String instanceName, Configurable sysConfig,
JobCatalog jobCatalog,
JobSpecScheduler jobScheduler, JobExecutionLauncher jobLauncher,
Optional<MetricContext> instanceMetricContext,
Optional<Logger> log,
List<GobblinInstancePluginFactory> plugins,
SharedResourcesBroker<GobblinScopeTypes> instanceBroker) {
super(instanceName, sysConfig, jobCatalog, jobScheduler, jobLauncher, instanceMetricContext, log, instanceBroker);
List<Service> componentServices = new ArrayList<>();
checkComponentService(getJobCatalog(), componentServices);
checkComponentService(getJobScheduler(), componentServices);
checkComponentService(getJobLauncher(), componentServices);
_plugins = createPlugins(plugins, componentServices);
if (componentServices.size() > 0) {
_subservices = new ServiceManager(componentServices);
}
}
示例5: setUp
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@BeforeClass
public void setUp() throws Exception {
this.jobConfigDir =
Files.createTempDirectory(String.format("gobblin-test_%s_job-conf", this.getClass().getSimpleName()))
.toString();
FileUtils.forceDeleteOnExit(new File(this.jobConfigDir));
FileUtils.copyDirectory(new File(JOB_CONFIG_FILE_DIR), new File(jobConfigDir));
Properties properties = new Properties();
try (Reader schedulerPropsReader = new FileReader("gobblin-test/resource/gobblin.test.properties")) {
properties.load(schedulerPropsReader);
}
properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_DIR_KEY, jobConfigDir);
properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY, jobConfigDir);
properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_MONITOR_POLLING_INTERVAL_KEY, "1000");
properties.setProperty(ConfigurationKeys.METRICS_ENABLED_KEY, "false");
SchedulerService quartzService = new SchedulerService(new Properties());
this.jobScheduler = new JobScheduler(properties, quartzService);
this.serviceManager = new ServiceManager(Lists.newArrayList(quartzService, this.jobScheduler));
this.serviceManager.startAsync().awaitHealthy(10, TimeUnit.SECONDS);;
}
示例6: guavaServices
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
private static void guavaServices(final Env env, final Binder binder,
final Set<Class<Service>> serviceTypes) {
Consumer<Class> guavaService = klass -> {
binder.bind(klass).asEagerSingleton();
serviceTypes.add(klass);
};
serviceTypes.forEach(guavaService);
// lazy service manager
AtomicReference<ServiceManager> sm = new AtomicReference<>();
Provider<ServiceManager> smProvider = () -> sm.get();
binder.bind(ServiceManager.class).toProvider(smProvider);
// ask Guice for services, create ServiceManager and start services
env.onStart(r -> {
List<Service> services = serviceTypes.stream()
.map(r::require)
.collect(Collectors.toList());
sm.set(new ServiceManager(services));
sm.get().startAsync().awaitHealthy();
});
// stop services
env.onStop(() -> {
sm.get().stopAsync().awaitStopped();
});
}
示例7: GroningenWorkhorse
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@Inject
private GroningenWorkhorse(final Provider<Pipeline> pipelineProvider,
final PipelineIdGenerator pipelineIdGenerator,
final ServiceManager backgroundServices,
final SystemAdapter systemAdapter,
final Settings settings,
final PipelineManager pipelineManager,
final ProtoBufConfigManagerFactory protoBufConfigManagerFactory,
final Build build) {
this.backgroundServices = backgroundServices;
this.systemAdapter = systemAdapter;
this.pipelineManager = pipelineManager;
this.settings = settings;
this.protoBufConfigManagerFactory = protoBufConfigManagerFactory;
this.build = build;
}
示例8: ProcessTracker
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@VisibleForTesting
ProcessTracker(
BuckEventBus buckEventBus,
InvocationInfo invocationInfo,
ProcessHelper processHelper,
ProcessRegistry processRegistry,
boolean isDaemon,
boolean deepEnabled) {
this.eventBus = buckEventBus;
this.invocationInfo = invocationInfo;
this.serviceManager = new ServiceManager(ImmutableList.of(this));
this.processHelper = processHelper;
this.processRegistry = processRegistry;
this.isDaemon = isDaemon;
this.deepEnabled = deepEnabled;
serviceManager.startAsync();
this.processRegistry.subscribe(processRegisterCallback);
}
示例9: get
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@Override
public ServiceManager get() {
final ImmutableSet<Service> allServices = ImmutableSet.<Service>builder()
.addAll(services)
.addAll(configuration.getServices())
.build();
return new ServiceManager(allServices);
}
示例10: setup
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@BeforeEach
public void setup(
@OracleSettings Map<String, String> settings
) throws Exception {
this.config = new OracleSourceConnectorConfig(settings);
this.offsetStorageReader = mock(OffsetStorageReader.class);
this.changeWriter = mock(ChangeWriter.class);
this.queryService = new QueryService(this.config, this.offsetStorageReader, this.changeWriter);
this.serviceManager = new ServiceManager(Arrays.asList(this.queryService));
}
示例11: serviceManager
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
/**
* Create a new {@link ServiceManagerIface} that wraps a {@link ServiceManager}.
*
* @param delegate Service manager to delegate to.
* @return A wrapper.
*/
public static ServiceManagerIface serviceManager(final ServiceManager delegate) {
return new ServiceManagerIface() {
@Override
public ServiceManagerIface startAsync() {
delegate.startAsync();
return this;
}
@Override
public void awaitHealthy() {
delegate.awaitHealthy();
}
@Override
public ServiceManagerIface stopAsync() {
delegate.stopAsync();
return this;
}
@Override
public void awaitStopped(long timeout, TimeUnit unit) throws TimeoutException {
delegate.awaitStopped(timeout, unit);
}
@Override
public ImmutableMultimap<State, Service> servicesByState() {
return delegate.servicesByState();
}
};
}
示例12: provideAppStartupServiceManager
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@Provides
@Singleton
@AppStartup
ServiceManagerIface provideAppStartupServiceManager(
@AppStartup Set<Service> services,
LifecycleShutdownListener listener) {
ServiceManager manager = new ServiceManager(services);
manager.addListener(listener);
return GuavaUtils.serviceManager(manager);
}
示例13: provideSchedulerActiveServiceManager
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@Provides
@Singleton
@SchedulerActive
ServiceManagerIface provideSchedulerActiveServiceManager(
@SchedulerActive Set<Service> services,
LifecycleShutdownListener listener) {
ServiceManager manager = new ServiceManager(services);
manager.addListener(listener);
return GuavaUtils.serviceManager(manager);
}
示例14: serviceManager
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@Bean(initMethod = "startAsync", destroyMethod = "stopAsync")
public ServiceManager serviceManager() {
List<PoolingThreadedService> services = new ArrayList<>();
services.addAll(requestParsingServices());
services.addAll(downloadingServices());
services.addAll(metaparsingServices());
return new ServiceManager(services);
}
示例15: SchedulerDaemon
import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
public SchedulerDaemon(Properties defaultProperties, Properties customProperties)
throws Exception {
Properties properties = new Properties();
properties.putAll(defaultProperties);
properties.putAll(customProperties);
List<Service> services = Lists.<Service>newArrayList(new JobScheduler(properties));
boolean jobExecInfoServerEnabled = Boolean
.valueOf(properties.getProperty(ConfigurationKeys.JOB_EXECINFO_SERVER_ENABLED_KEY, Boolean.FALSE.toString()));
if (jobExecInfoServerEnabled) {
services.add(new JobExecutionInfoServer(properties));
}
this.serviceManager = new ServiceManager(services);
}