org.apache.samza.zk.ZkUtils.<init>()方法的使用及代码示例

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

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

ZkUtils.<init>介绍

暂无

代码示例

代码示例来源:origin: apache/samza

private ZkUtils getZkUtils() {
 return new ZkUtils(KEY_BUILDER, zkClient, CONNECTION_TIMEOUT_MS,
           SESSION_TIMEOUT_MS, new NoOpMetricsRegistry());
}

代码示例来源:origin: apache/samza

@Test
public void testCloseShouldRetryOnceOnInterruptedException() {
 ZkClient zkClient = Mockito.mock(ZkClient.class);
 ZkUtils zkUtils = new ZkUtils(KEY_BUILDER, zkClient, CONNECTION_TIMEOUT_MS, SESSION_TIMEOUT_MS, new NoOpMetricsRegistry());
 Mockito.doThrow(new ZkInterruptedException(new InterruptedException()))
     .doAnswer(invocation -> null)
     .when(zkClient).close();
 zkUtils.close();
 Mockito.verify(zkClient, Mockito.times(2)).close();
}

代码示例来源:origin: apache/samza

@Test
 public void testCloseShouldTearDownZkConnectionOnInterruptedException() throws Exception {
  CountDownLatch latch = new CountDownLatch(1);
  // Establish connection with the zookeeper server.
  ZkClient zkClient = new ZkClient("127.0.0.1:" + zkServer.getPort());
  ZkUtils zkUtils = new ZkUtils(KEY_BUILDER, zkClient, CONNECTION_TIMEOUT_MS, SESSION_TIMEOUT_MS, new NoOpMetricsRegistry());

  Thread threadToInterrupt = new Thread(() -> {
    try {
     latch.await();
    } catch (InterruptedException e) {
     Thread.currentThread().interrupt();
    }
    zkUtils.close();
   });

  threadToInterrupt.start();

  Field field = ZkClient.class.getDeclaredField("_closed");
  field.setAccessible(true);

  Assert.assertFalse(field.getBoolean(zkClient));

  threadToInterrupt.interrupt();
  threadToInterrupt.join();

  Assert.assertTrue(field.getBoolean(zkClient));
 }
}

代码示例来源:origin: apache/samza

private ZkUtils getZkUtilsWithNewClient() {
  ZkClient zkClient = ZkCoordinationUtilsFactory
    .createZkClient(testZkConnectionString, SESSION_TIMEOUT_MS, CONNECTION_TIMEOUT_MS);
  return new ZkUtils(
    KEY_BUILDER,
    zkClient,
    CONNECTION_TIMEOUT_MS, SESSION_TIMEOUT_MS, new NoOpMetricsRegistry());
 }
}

代码示例来源:origin: apache/samza

private ZkUtils getZkUtilsWithNewClient(String processorId) {
  ZkClient zkClient = ZkCoordinationUtilsFactory
    .createZkClient(testZkConnectionString, SESSION_TIMEOUT_MS, CONNECTION_TIMEOUT_MS);
  return new ZkUtils(KEY_BUILDER, zkClient, CONNECTION_TIMEOUT_MS, SESSION_TIMEOUT_MS, new NoOpMetricsRegistry());
 }
}

代码示例来源:origin: apache/samza

private ZkUtils getZkUtils(Config config, MetricsRegistry metricsRegistry, String coordinatorZkBasePath) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkKeyBuilder keyBuilder = new ZkKeyBuilder(coordinatorZkBasePath);
 ZkClient zkClient = ZkCoordinationUtilsFactory
   .createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 return new ZkUtils(keyBuilder, zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(), metricsRegistry);
}

代码示例来源:origin: org.apache.samza/samza-core

private ZkUtils getZkUtils(Config config, MetricsRegistry metricsRegistry, String coordinatorZkBasePath) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkKeyBuilder keyBuilder = new ZkKeyBuilder(coordinatorZkBasePath);
 ZkClient zkClient = ZkCoordinationUtilsFactory
   .createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 return new ZkUtils(keyBuilder, zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(), metricsRegistry);
}

代码示例来源:origin: org.apache.samza/samza-core_2.12

private ZkUtils getZkUtils(Config config, MetricsRegistry metricsRegistry, String coordinatorZkBasePath) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkKeyBuilder keyBuilder = new ZkKeyBuilder(coordinatorZkBasePath);
 ZkClient zkClient = ZkCoordinationUtilsFactory
   .createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 return new ZkUtils(keyBuilder, zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(), metricsRegistry);
}

代码示例来源:origin: org.apache.samza/samza-core_2.10

private ZkUtils getZkUtils(Config config, MetricsRegistry metricsRegistry, String coordinatorZkBasePath) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkKeyBuilder keyBuilder = new ZkKeyBuilder(coordinatorZkBasePath);
 ZkClient zkClient = ZkCoordinationUtilsFactory
   .createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 return new ZkUtils(keyBuilder, zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(), metricsRegistry);
}

代码示例来源:origin: org.apache.samza/samza-core_2.11

private ZkUtils getZkUtils(Config config, MetricsRegistry metricsRegistry, String coordinatorZkBasePath) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkKeyBuilder keyBuilder = new ZkKeyBuilder(coordinatorZkBasePath);
 ZkClient zkClient = ZkCoordinationUtilsFactory
   .createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 return new ZkUtils(keyBuilder, zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(), metricsRegistry);
}

代码示例来源:origin: apache/samza

@Test
public void testGetProcessorsIDs() {
 Assert.assertEquals(0, zkUtils.getSortedActiveProcessorsIDs().size());
 zkUtils.registerProcessorAndGetId(new ProcessorData("host1", "1"));
 List<String> l = zkUtils.getSortedActiveProcessorsIDs();
 Assert.assertEquals(1, l.size());
 new ZkUtils(KEY_BUILDER, zkClient, CONNECTION_TIMEOUT_MS, SESSION_TIMEOUT_MS, new NoOpMetricsRegistry()).registerProcessorAndGetId(
   new ProcessorData("host2", "2"));
 l = zkUtils.getSortedActiveProcessorsIDs();
 Assert.assertEquals(2, l.size());
 Assert.assertEquals(" ID1 didn't match", "1", l.get(0));
 Assert.assertEquals(" ID2 didn't match", "2", l.get(1));
}

代码示例来源:origin: org.apache.samza/samza-core_2.11

public CoordinationUtils getCoordinationUtils(String groupId, String participantId, Config config) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkClient zkClient =
   createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 ZkUtils zkUtils = new ZkUtils(new ZkKeyBuilder(groupId), zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(),
   new NoOpMetricsRegistry());
 return new ZkCoordinationUtils(participantId, zkConfig, zkUtils);
}

代码示例来源:origin: apache/samza

@Before
public void testSetup() {
 ZkClient zkClient = new ZkClient(testZkConnectionString, ZkConfig.DEFAULT_SESSION_TIMEOUT_MS, ZkConfig.DEFAULT_CONNECTION_TIMEOUT_MS);
 this.zkUtils = new ZkUtils(new ZkKeyBuilder("group1"), zkClient, ZkConfig.DEFAULT_CONNECTION_TIMEOUT_MS, ZkConfig.DEFAULT_SESSION_TIMEOUT_MS, new NoOpMetricsRegistry());
 ZkClient zkClient1 = new ZkClient(testZkConnectionString, ZkConfig.DEFAULT_SESSION_TIMEOUT_MS, ZkConfig.DEFAULT_CONNECTION_TIMEOUT_MS);
 this.zkUtils1 = new ZkUtils(new ZkKeyBuilder("group1"), zkClient1, ZkConfig.DEFAULT_CONNECTION_TIMEOUT_MS, ZkConfig.DEFAULT_SESSION_TIMEOUT_MS, new NoOpMetricsRegistry());
}

代码示例来源:origin: apache/samza

public CoordinationUtils getCoordinationUtils(String groupId, String participantId, Config config) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkClient zkClient =
   createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 ZkUtils zkUtils = new ZkUtils(new ZkKeyBuilder(groupId), zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(),
   new NoOpMetricsRegistry());
 return new ZkCoordinationUtils(participantId, zkConfig, zkUtils);
}

代码示例来源:origin: org.apache.samza/samza-core

public CoordinationUtils getCoordinationUtils(String groupId, String participantId, Config config) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkClient zkClient =
   createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 ZkUtils zkUtils = new ZkUtils(new ZkKeyBuilder(groupId), zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(),
   new NoOpMetricsRegistry());
 return new ZkCoordinationUtils(participantId, zkConfig, zkUtils);
}

代码示例来源:origin: org.apache.samza/samza-core_2.10

public CoordinationUtils getCoordinationUtils(String groupId, String participantId, Config config) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkClient zkClient =
   createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 ZkUtils zkUtils = new ZkUtils(new ZkKeyBuilder(groupId), zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(),
   new NoOpMetricsRegistry());
 return new ZkCoordinationUtils(participantId, zkConfig, zkUtils);
}

代码示例来源:origin: org.apache.samza/samza-core_2.12

public CoordinationUtils getCoordinationUtils(String groupId, String participantId, Config config) {
 ZkConfig zkConfig = new ZkConfig(config);
 ZkClient zkClient =
   createZkClient(zkConfig.getZkConnect(), zkConfig.getZkSessionTimeoutMs(), zkConfig.getZkConnectionTimeoutMs());
 ZkUtils zkUtils = new ZkUtils(new ZkKeyBuilder(groupId), zkClient, zkConfig.getZkConnectionTimeoutMs(), zkConfig.getZkSessionTimeoutMs(),
   new NoOpMetricsRegistry());
 return new ZkCoordinationUtils(participantId, zkConfig, zkUtils);
}

相关文章