• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServiceManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.common.util.concurrent.ServiceManager的典型用法代码示例。如果您正苦于以下问题:Java ServiceManager类的具体用法?Java ServiceManager怎么用?Java ServiceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServiceManager类属于com.google.common.util.concurrent包,在下文中一共展示了ServiceManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
 
开发者ID:o,项目名称:metricd,代码行数:21,代码来源:Application.java


示例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();
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:19,代码来源:LocalJobLauncher.java


示例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();
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:21,代码来源:LocalJobLauncher.java


示例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);
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:21,代码来源:StandardGobblinInstanceDriver.java


示例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);;
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:24,代码来源:JobConfigFileMonitorTest.java


示例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();
  });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:27,代码来源:Scanner.java


示例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;
}
 
开发者ID:matttproud,项目名称:groningen,代码行数:17,代码来源:GroningenWorkhorse.java


示例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);
}
 
开发者ID:facebook,项目名称:buck,代码行数:19,代码来源:ProcessTracker.java


示例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);
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:10,代码来源:ServiceManagerProvider.java


示例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));
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-cdc-oracle,代码行数:11,代码来源:QueryServiceTest.java


示例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();
    }
  };
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:37,代码来源:GuavaUtils.java


示例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);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:SchedulerServicesModule.java


示例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);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:SchedulerServicesModule.java


示例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);
}
 
开发者ID:trustedanalytics,项目名称:data-acquisition,代码行数:9,代码来源:SubservicesConfiguration.java


示例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);
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:15,代码来源:SchedulerDaemon.java


示例16: setUp

import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@BeforeClass
public void setUp()
    throws Exception {
  Properties properties = new Properties();
  properties.load(new FileReader("gobblin-test/resource/gobblin.test.properties"));
  properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_DIR_KEY, JOB_CONFIG_FILE_DIR);
  properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_MONITOR_POLLING_INTERVAL_KEY, "1000");
  properties.setProperty(ConfigurationKeys.METRICS_ENABLED_KEY, "false");

  this.jobScheduler = new JobScheduler(properties);
  this.serviceManager = new ServiceManager(Lists.newArrayList(this.jobScheduler));
  this.serviceManager.startAsync();
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:14,代码来源:JobConfigFileMonitorTest.java


示例17: DefaultCultivarStartStopManager

import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@Inject
DefaultCultivarStartStopManager(@Curator final CuratorManagementService curatorManagementService,
        @Cultivar final ServiceManager serviceManager) {
    this.curatorManagementService = curatorManagementService;
    this.serviceManager = serviceManager;

}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:8,代码来源:DefaultCultivarStartStopManager.java


示例18: setUp

import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
@Before
public void setUp() {
    /*
     * Multiple things in AbstractIdleService and ServiceManager are final, necessitating indirect methods of seeing
     * if the service has been started up or shut down.
     */
    Service service = new AbstractIdleService() {
        @Override
        protected void startUp() throws Exception {
            logger.info("startUp");
        }

        @Override
        protected void shutDown() throws Exception {
            logger.info("shutDown");
        }

        @Override
        protected Executor executor() {
            return MoreExecutors.sameThreadExecutor();
        }
    };

    serviceManager = new ServiceManager(ImmutableSet.of(service));

    when(curatorManagementService.startAsync()).thenReturn(curatorManagementService);
    when(curatorManagementService.stopAsync()).thenReturn(curatorManagementService);

    startStopManager = new DefaultCultivarStartStopManager(curatorManagementService, serviceManager);
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:31,代码来源:DefaultCultivarStartStopManagerTest.java


示例19: getServices

import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
private void getServices() {
  final Properties properties = ConfigUtils.configToProperties(this.clusterConfig);
  this.taskExecutor = new TaskExecutor(properties);
  this.taskStateTracker = new GobblinHelixTaskStateTracker(properties);

  final List<Service> services = Lists.newArrayList(this.taskExecutor, this.taskStateTracker);
  this.serviceManager = new ServiceManager(services);
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:9,代码来源:SingleTaskRunner.java


示例20: GobblinTaskRunner

import com.google.common.util.concurrent.ServiceManager; //导入依赖的package包/类
public GobblinTaskRunner(String applicationName, String helixInstanceName, String applicationId,
    String taskRunnerId, Config config, Optional<Path> appWorkDirOptional)
    throws Exception {
  this.helixInstanceName = helixInstanceName;
  this.taskRunnerId = taskRunnerId;
  this.applicationName = applicationName;
  this.applicationId = applicationId;

  Configuration conf = HadoopUtils.newConfiguration();
  this.fs = buildFileSystem(config, conf);

  this.appWorkPath = initAppWorkDir(config, appWorkDirOptional);

  this.config = saveConfigToFile(config);

  initHelixManager();

  this.containerMetrics = buildContainerMetrics();

  this.taskStateModelFactory = registerHelixTaskFactory();

  services.addAll(getServices());
  if (services.isEmpty()) {
    this.serviceManager = null;
  } else {
    this.serviceManager = new ServiceManager(services);
  }

  logger.debug("GobblinTaskRunner: applicationName {}, helixInstanceName {}, applicationId {}, taskRunnerId {}, config {}, appWorkDir {}",
      applicationName, helixInstanceName, applicationId, taskRunnerId, config, appWorkDirOptional);
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:32,代码来源:GobblinTaskRunner.java



注:本文中的com.google.common.util.concurrent.ServiceManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ModelChannelMixer类代码示例发布时间:2022-05-21
下一篇:
Java DefaultMuleMessage类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap