com.github.zkclient.ZkClient.<init>()方法的使用及代码示例

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

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

ZkClient.<init>介绍

[英]Create a client with special implementation
[中]创建具有特殊实现的客户机

代码示例

代码示例来源:origin: adyliu/jafka

static void tryCleanupZookeeper(String zkConnect, String groupId) {
    try {
      String dir = "/consumers/" + groupId;
      ZkClient zk = new ZkClient(zkConnect, 30 * 1000, 30 * 1000);
      zk.deleteRecursive(dir);
      zk.close();
    } catch (ZkInterruptedException e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: adyliu/jafka

private void connectZk() {
  logger.debug("Connecting to zookeeper instance at " + config.getZkConnect());
  this.zkClient = new ZkClient(config.getZkConnect(), config.getZkSessionTimeoutMs(),
      config.getZkConnectionTimeoutMs());
  logger.debug("Connected to zookeeper at " + config.getZkConnect());
}

代码示例来源:origin: adyliu/jafka

public void startup() {
  logger.info("connecting to zookeeper: " + config.getZkConnect());
  zkClient = new ZkClient(config.getZkConnect(), config.getZkSessionTimeoutMs(),
      config.getZkConnectionTimeoutMs());
  zkClient.subscribeStateChanges(this);
}

代码示例来源:origin: adyliu/jafka

public ZookeeperTopicEventWatcher(ConsumerConfig consumerConfig, TopicEventHandler<String> eventHandler, ServerStartable serverStartable) {
  super();
  this.eventHandler = eventHandler;
  this.serverStartable = serverStartable;
  //
  this.zkClient = new ZkClient(consumerConfig.getZkConnect(), //
      consumerConfig.getZkSessionTimeoutMs(), //
      consumerConfig.getZkConnectionTimeoutMs());
  startWatchingTopicEvents();
}

代码示例来源:origin: adyliu/jafka

public ZKBrokerPartitionInfo(ZKConfig zkConfig, Callback callback) {
  this.zkConfig = zkConfig;
  this.callback = callback;
  //
  this.zkClient = new ZkClient(zkConfig.getZkConnect(), //
      zkConfig.getZkSessionTimeoutMs(), //
      zkConfig.getZkConnectionTimeoutMs());
  //
  this.allBrokers = getZKBrokerInfo();
  this.topicBrokerPartitions = getZKTopicPartitionInfo(this.allBrokers);
  //use just the brokerTopicsListener for all watchers
  this.brokerTopicsListener = new BrokerTopicsListener(this.topicBrokerPartitions, this.allBrokers);
  //register listener for change of topics to keep topicsBrokerPartitions updated
  zkClient.subscribeChildChanges(ZkUtils.BrokerTopicsPath, brokerTopicsListener);
  //register listener for change of brokers for each topic to keep topicsBrokerPartitions updated
  for (String topic : this.topicBrokerPartitions.keySet()) {
    zkClient.subscribeChildChanges(ZkUtils.BrokerTopicsPath + "/" + topic, this.brokerTopicsListener);
  }
  // register listener for new broker
  zkClient.subscribeChildChanges(ZkUtils.BrokerIdsPath, this.brokerTopicsListener);
  //
  // register listener for session expired event
  zkClient.subscribeStateChanges(new ZKSessionExpirationListener());
}

代码示例来源:origin: com.github.adyliu/zkclient

@PostConstruct
public void start() {
  startZkServer();
  _zkClient = new ZkClient("localhost:" + _port, 10000);
}

代码示例来源:origin: adyliu/zkclient

@PostConstruct
public void start() {
  startZkServer();
  _zkClient = new ZkClient("localhost:" + _port, 10000);
}

相关文章