com.palominolabs.benchpress.config.ZookeeperConfig.getWorkerServiceName()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中com.palominolabs.benchpress.config.ZookeeperConfig.getWorkerServiceName()方法的一些代码示例,展示了ZookeeperConfig.getWorkerServiceName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperConfig.getWorkerServiceName()方法的具体详情如下:
包路径:com.palominolabs.benchpress.config.ZookeeperConfig
类名称:ZookeeperConfig
方法名:getWorkerServiceName

ZookeeperConfig.getWorkerServiceName介绍

暂无

代码示例

代码示例来源:origin: palominolabs/benchpress

@Provides
@Singleton
public ServiceProvider<WorkerMetadata> getServiceProvider(ServiceDiscovery<WorkerMetadata> serviceDiscovery,
    ZookeeperConfig zookeeperConfig) {
  return serviceDiscovery.serviceProviderBuilder()
      .serviceName(zookeeperConfig.getWorkerServiceName())
      .build();
}

代码示例来源:origin: palominolabs/benchpress

private void assertNoWorkersAdvertised() throws Exception {
  Collection<ServiceInstance<WorkerMetadata>> instances =
      serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
  assertEquals(0, instances.size());
}

代码示例来源:origin: palominolabs/benchpress

private ServiceInstance<WorkerMetadata> getServiceInstance() throws Exception {
  WorkerMetadata workerMetadata = new WorkerMetadata(workerId, listenAddress, listenPort);
  return ServiceInstance.<WorkerMetadata>builder()
      .name(zookeeperConfig.getWorkerServiceName())
      .address(listenAddress)
      .port(listenPort)
      .id(workerId.toString())
      .payload(workerMetadata)
      .build();
}

代码示例来源:origin: palominolabs/benchpress

private void assertWorkerAdvertised(WorkerMetadata workerMetadata) throws Exception {
  Collection<ServiceInstance<WorkerMetadata>> instances =
      serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
  assertEquals(1, instances.size());
  assertEquals(workerMetadata.getWorkerId(), instances.iterator().next().getPayload().getWorkerId());
}

代码示例来源:origin: palominolabs/benchpress

@Test
  public void testDeAdvertiseAvailability() throws Exception {
    workerAdvertiser.initListenInfo("127.0.0.1", 12345);
    workerAdvertiser.advertiseAvailability();
    Collection<ServiceInstance<WorkerMetadata>> instances =
      serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
    assertEquals(1, instances.size());

    workerAdvertiser.deAdvertiseAvailability();
    instances = serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
    assertEquals(0, instances.size());
  }
}

代码示例来源:origin: palominolabs/benchpress

/**
 * @return the metadata loaded from ZK
 */
private WorkerMetadata advertiseWorker() throws Exception {
  workerAdvertiser.initListenInfo(host, port);
  workerAdvertiser.advertiseAvailability();
  Collection<ServiceInstance<WorkerMetadata>> instances =
      serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
  assertEquals(1, instances.size());
  WorkerMetadata workerMetadata = instances.iterator().next().getPayload();
  assertEquals(workerAdvertiser.getWorkerId(), workerMetadata.getWorkerId());
  return workerMetadata;
}

代码示例来源:origin: palominolabs/benchpress

@Test
public void testAdvertiseAvailability() throws Exception {
  workerAdvertiser.initListenInfo("127.0.0.1", 12345);
  workerAdvertiser.advertiseAvailability();
  Collection<ServiceInstance<WorkerMetadata>> instances =
    serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
  assertEquals(1, instances.size());
  WorkerMetadata workerMetadata = instances.iterator().next().getPayload();
  assertEquals(workerAdvertiser.getWorkerId(), workerMetadata.getWorkerId());
}

相关文章