gpt4 book ai didi

pl.allegro.tech.hermes.common.broker.ZookeeperBrokerStorage类的使用及代码示例

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

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

ZookeeperBrokerStorage介绍

暂无

代码示例

代码示例来源:origin: allegro/hermes

private BrokerStorage brokersStorage(CuratorFramework curatorFramework, KafkaZkClient kafkaZkClient) {
  return new ZookeeperBrokerStorage(curatorFramework, kafkaZkClient);
}

代码示例来源:origin: allegro/hermes

@Override
public Multimap<Integer, TopicAndPartition> readLeadersForPartitions(Set<TopicAndPartition> topicAndPartitionSet) {
  Multimap<Integer, TopicAndPartition> leadersForPartitions = ArrayListMultimap.create();
  for (TopicAndPartition topicAndPartition : topicAndPartitionSet) {
    try {
      Integer leaderId = readLeaderForPartition(topicAndPartition);
      leadersForPartitions.put(leaderId, topicAndPartition);
    } catch (BrokerNotFoundForPartitionException ex) {
      LOGGER.warn("Broker not found", ex);
    }
  }
  return leadersForPartitions;
}

代码示例来源:origin: allegro/hermes

@Test
public void shouldReadPartitionsIds() throws Exception {
  //given
  String topicName = "readPartitionsIdsTestTopic";
  List<Integer> partitions = Lists.newArrayList(0, 1, 2);
  createPartitionsForTopic(topicName, partitions);
  //when
  List<Integer> partitionsFromBroker = brokerStorage.readPartitionsIds(topicName);
  //then
  assertThat(partitionsFromBroker).isEqualTo(partitions);
}

代码示例来源:origin: allegro/hermes

@Test
public void shouldGetErrorWhileReadingBrokerDetails() {
  // when
  catchException(brokerStorage).readBrokerDetails(5);
  // then
  assertThat((Exception) caughtException()).isInstanceOf(BrokerInfoNotAvailableException.class);
}

代码示例来源:origin: allegro/hermes

@Test
public void shouldNotReadLeadersDueTooNoDataInZk() {
  //when
  Multimap<Integer, TopicAndPartition> leadersForPartitions = brokerStorage.readLeadersForPartitions(
      ImmutableSet.of(new TopicAndPartition("topic1", 2))
  );
  //then
  assertThat(leadersForPartitions.size()).isZero();
}

代码示例来源:origin: allegro/hermes

@Test
public void shouldThrowExceptionWhenReadPartitionsForNotExistingTopic() throws Exception {
  //given
  String nonExistingTopic = "readPartitionIdsNonExistingTopic";
  //when
  catchException(brokerStorage).readPartitionsIds(nonExistingTopic);
  //then
  assertThat((Exception) caughtException())
      .isInstanceOf(PartitionsNotFoundForGivenTopicException.class)
      .hasMessageContaining(nonExistingTopic);
}

代码示例来源:origin: allegro/hermes

@Test
public void shouldReadBrokerDetails() throws Exception {
  //given
  createBrokerDetails(1, "localhost", 9092);
  //when
  BrokerDetails details = brokerStorage.readBrokerDetails(1);
  //then
  assertThat(details.getHost()).isEqualTo("localhost");
  assertThat(details.getPort()).isEqualTo(9092);
}

代码示例来源:origin: allegro/hermes

@Test
public void shouldReadLeadersForPartitions() throws Exception {
  //given
  TopicAndPartition topicAndPartition1 = new TopicAndPartition("topic1", 2);
  TopicAndPartition topicAndPartition2 = new TopicAndPartition("topic2", 4);
  createLeaderForPartition(topicAndPartition1, 0);
  createLeaderForPartition(topicAndPartition2, 3);
  //when
  Multimap<Integer, TopicAndPartition> leadersForPartitions = brokerStorage.readLeadersForPartitions(
      ImmutableSet.of(topicAndPartition1, topicAndPartition2)
  );
  //then
  assertThat(leadersForPartitions.get(0)).contains(topicAndPartition1);
  assertThat(leadersForPartitions.get(3)).contains(topicAndPartition2);
}

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