• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TopicPartitionInfo类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.apache.kafka.common.TopicPartitionInfo的典型用法代码示例。如果您正苦于以下问题:Java TopicPartitionInfo类的具体用法?Java TopicPartitionInfo怎么用?Java TopicPartitionInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TopicPartitionInfo类属于org.apache.kafka.common包,在下文中一共展示了TopicPartitionInfo类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDescribeTopicsResult

点赞 3

import org.apache.kafka.common.TopicPartitionInfo; //导入依赖的package包/类
/**
 *
 * Utility functions
 */

private DescribeTopicsResult getDescribeTopicsResult() {
  TopicPartitionInfo topicPartitionInfo = new TopicPartitionInfo(0, node, Collections
      .singletonList(node), Collections.singletonList(node));
  TopicDescription topicDescription = new TopicDescription(topicName1, false,
                                                           Collections.singletonList
                                                               (topicPartitionInfo));
  DescribeTopicsResult describeTopicsResult = mock(DescribeTopicsResult.class);
  expect(describeTopicsResult.all()).andReturn(KafkaFuture.completedFuture(Collections
                                                                               .singletonMap
                                                                                   (topicName1,
                                                                                    topicDescription
                                                                                   )));
  replay(describeTopicsResult);
  return describeTopicsResult;
}
 

开发者ID:confluentinc,
项目名称:ksql,
代码行数:21,
代码来源:KafkaTopicClientTest.java

示例2: getTopicReplicaInfo

点赞 3

import org.apache.kafka.common.TopicPartitionInfo; //导入依赖的package包/类
private static String getTopicReplicaInfo(List<TopicPartitionInfo> partitions) {
  List<Integer> replicaSizes = new ArrayList<>(partitions.size());

  for (TopicPartitionInfo partition : partitions) {
    replicaSizes.add(partition.replicas().size());
  }

  boolean sameReplicaCount = true;
  for (int i = 1; i < partitions.size(); i++) {
    if (!replicaSizes.get(i).equals(replicaSizes.get(i-1))) {
      sameReplicaCount = false;
      break;
    }
  }

  if (sameReplicaCount) {
    return partitions.size() == 0 ? "0" : String.valueOf(replicaSizes.get(0));
  } else {
    return StringUtil.join(", ", replicaSizes);
  }
}
 

开发者ID:confluentinc,
项目名称:ksql,
代码行数:22,
代码来源:KafkaTopicsList.java

示例3: TopicDescription

点赞 1

import org.apache.kafka.common.TopicPartitionInfo; //导入依赖的package包/类
/**
 * Create an instance with the specified parameters.
 *
 * @param name The topic name
 * @param internal Whether the topic is internal to Kafka
 * @param partitions A list of partitions where the index represents the partition id and the element contains
 *                   leadership and replica information for that partition.
 */
public TopicDescription(String name, boolean internal, List<TopicPartitionInfo> partitions) {
    this.name = name;
    this.internal = internal;
    this.partitions = partitions;
}
 

开发者ID:YMCoding,
项目名称:kafka-0.11.0.0-src-with-comment,
代码行数:14,
代码来源:TopicDescription.java

示例4: partitions

点赞 1

import org.apache.kafka.common.TopicPartitionInfo; //导入依赖的package包/类
/**
 * A list of partitions where the index represents the partition id and the element contains leadership and replica
 * information for that partition.
 */
public List<TopicPartitionInfo> partitions() {
    return partitions;
}
 

开发者ID:YMCoding,
项目名称:kafka-0.11.0.0-src-with-comment,
代码行数:8,
代码来源:TopicDescription.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)