gpt4 book ai didi

io.pravega.segmentstore.server.host.ZKSegmentContainerManager类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:59:42 27 4
gpt4 key购买 nike

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

ZKSegmentContainerManager介绍

[英]ZK based implementation for SegmentContainerManager.
[中]基于ZK的SegmentContainerManager实现。

代码示例

代码示例来源:origin: pravega/pravega

@Override
public void close() {
  if (closed.compareAndSet(false, true)) {
    close(this.containerMonitor);
    close(this.cluster);
  }
}

代码示例来源:origin: pravega/pravega

@Test
public void testClose() throws Exception {
  @Cleanup
  CuratorFramework zkClient = startClient();
  SegmentContainerRegistry containerRegistry = mock(SegmentContainerRegistry.class);
  ContainerHandle containerHandle1 = mock(ContainerHandle.class);
  when(containerHandle1.getContainerId()).thenReturn(1);
  when(containerRegistry.startContainer(eq(1), any()))
      .thenReturn(CompletableFuture.completedFuture(containerHandle1));
  when(containerRegistry.stopContainer(any(), any())).thenReturn(CompletableFuture.completedFuture(null));
  ZKSegmentContainerManager segManager = createContainerManager(containerRegistry, zkClient);
  segManager.initialize();
  segManager.close();
}

代码示例来源:origin: pravega/pravega

private ZKSegmentContainerManager createContainerManager(SegmentContainerRegistry registry, CuratorFramework zkClient) {
  return new ZKSegmentContainerManager(registry, zkClient, PRAVEGA_SERVICE_ENDPOINT, executorService());
}

代码示例来源:origin: pravega/pravega

@Test
public void testContainerStart() throws Exception {
  @Cleanup
  CuratorFramework zkClient = startClient();
  initializeHostContainerMapping(zkClient);
  SegmentContainerRegistry containerRegistry = mock(SegmentContainerRegistry.class);
  ContainerHandle containerHandle1 = mock(ContainerHandle.class);
  when(containerHandle1.getContainerId()).thenReturn(1);
  when(containerRegistry.startContainer(eq(1), any()))
      .thenReturn(CompletableFuture.completedFuture(containerHandle1));
  @Cleanup
  ZKSegmentContainerManager segManager = createContainerManager(containerRegistry, zkClient);
  segManager.initialize();
  verify(containerRegistry, timeout(30000).atLeastOnce()).startContainer(eq(1), any());
}

代码示例来源:origin: pravega/pravega

private void attachZKSegmentManager(ServiceBuilder builder) {
  builder.withContainerManager(setup ->
      new ZKSegmentContainerManager(setup.getContainerRegistry(),
          this.zkClient,
          new Host(this.serviceConfig.getPublishedIPAddress(),
              this.serviceConfig.getPublishedPort(), null),
          setup.getCoreExecutor()));
}

代码示例来源:origin: pravega/pravega

/**
 * Test if initialization completes.
 *
 * @throws Exception if an error occurred.
 */
@Test
public void testInitializeSucceeds() throws Exception {
  @Cleanup
  CuratorFramework zkClient = startClient();
  @Cleanup
  ZKSegmentContainerManager segManager = createContainerManager(createMockContainerRegistry(), zkClient);
  segManager.initialize();
}

代码示例来源:origin: pravega/pravega

@Override
public void initialize() {
  Exceptions.checkNotClosed(closed.get(), this);
  long traceId = LoggerHelpers.traceEnter(log, "initialize");
  try {
    // Initialize the container monitor.
    this.containerMonitor.initialize();
    // Advertise this segment store to the cluster.
    this.cluster.registerHost(this.host);
    log.info("Initialized.");
    LoggerHelpers.traceLeave(log, "initialize", traceId);
  } catch (Exception ex) {
    // Need to make sure we clean up resources if we failed to initialize.
    log.error("Initialization error. Cleaning up.", ex);
    close();
    throw ex;
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com