kafka.utils.ZKConfig类的使用及代码示例

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

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

ZKConfig介绍

暂无

代码示例

代码示例来源:origin: confluentinc/ksql

/**
 * Creates and starts a Kafka cluster.
 */
public void start() throws Exception {
 log.debug("Initiating embedded Kafka cluster startup");
 installJaasConfig();
 zookeeper = new ZooKeeperEmbedded();
 brokerConfig.put(SimpleAclAuthorizer.ZkUrlProp(), zookeeper.connectString());
 // Streams runs multiple consumers, so let's give them all a chance to join.
 // (Tests run quicker and with a more stable consumer group):
 brokerConfig.put("group.initial.rebalance.delay.ms", 100);
 broker = new KafkaEmbedded(effectiveBrokerConfigFrom());
 clientConfig.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers());
 authorizer.configure(ImmutableMap.of(ZKConfig.ZkConnectProp(), zookeeperConnect()));
}

代码示例来源:origin: com.cerner.common.kafka/common-kafka-admin

/**
 * Returns an {@link Authorizer} to make {@link Acl} requests
 *
 * @return an {@link Authorizer} to make {@link Acl} requests
 *
 * @throws AdminOperationException
 *      if there is an issue creating the authorizer
 */
public Authorizer getAuthorizer() {
  if (authorizer == null) {
    ZKConfig zkConfig = new ZKConfig(new VerifiableProperties(properties));
    Map<String, Object> authorizerProps = new HashMap<>();
    authorizerProps.put(ZKConfig.ZkConnectProp(), zkConfig.zkConnect());
    authorizerProps.put(ZKConfig.ZkConnectionTimeoutMsProp(), zkConfig.zkConnectionTimeoutMs());
    authorizerProps.put(ZKConfig.ZkSessionTimeoutMsProp(), zkConfig.zkSessionTimeoutMs());
    authorizerProps.put(ZKConfig.ZkSyncTimeMsProp(), zkConfig.zkSyncTimeMs());
    try {
      Authorizer simpleAclAuthorizer = new SimpleAclAuthorizer();
      simpleAclAuthorizer.configure(authorizerProps);
      authorizer = simpleAclAuthorizer;
    } catch (ZkException e) {
      throw new AdminOperationException("Unable to create authorizer", e);
    }
  }
  return authorizer;
}

代码示例来源:origin: com.cerner.common.kafka/common-kafka-admin

private static ZkUtils getZkUtils(Properties properties) {
  if (properties == null)
    throw new IllegalArgumentException("properties cannot be null");
  Tuple2<ZkClient, ZkConnection> tuple;
  try {
    ZKConfig zkConfig = new ZKConfig(new VerifiableProperties(properties));
    tuple = ZkUtils.createZkClientAndConnection(zkConfig.zkConnect(), zkConfig.zkSessionTimeoutMs(),
        zkConfig.zkConnectionTimeoutMs());
  } catch (ZkException e) {
    throw new AdminOperationException("Unable to create admin connection", e);
  }
  boolean isSecure = Boolean.valueOf(properties.getProperty(ZOOKEEPER_SECURE, DEFAULT_ZOOKEEPER_SECURE));
  return new ZkUtils(tuple._1(), tuple._2(), isSecure);
}

代码示例来源:origin: com.cerner.common.kafka/common-kafka-test

/**
 * Returns properties for either a Kafka producer or consumer.
 *
 * @return Combined producer and consumer properties.
 */
public Properties getProps() {
  // Combine producer and consumer properties.
  Properties props = getProducerProps();
  props.putAll(getConsumerProps());
  // Add zookeeper connect which can be used by KafkaAdminClient or other older clients
  props.setProperty(ZKConfig.ZkConnectProp(), brokerConfigs.get(0).zkConnect());
  return props;
}

相关文章

微信公众号

最新文章

更多

ZKConfig类方法