gpt4 book ai didi

pl.allegro.tech.hermes.test.helper.zookeeper.ZookeeperWaiter.untilZookeeperPathIsCreated()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 05:21:31 26 4
gpt4 key购买 nike

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

ZookeeperWaiter.untilZookeeperPathIsCreated介绍

暂无

代码示例

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

public void untilZookeeperPathIsCreated(String... path) {
  untilZookeeperPathIsCreated(stream(path).collect(joining("/")));
}

代码示例来源:origin: pl.allegro.tech.hermes/hermes-test-helper

public void untilZookeeperPathIsCreated(String... path) {
  untilZookeeperPathIsCreated(stream(path).collect(joining("/")));
}

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

@Test
public void shouldIncrementAndRetrieveCounterValue() {
  // given when
  counter.increment("/increment/host/metric", 10);
  wait.untilZookeeperPathIsCreated("/increment/host/metric");
  // then
  assertThat(counter.getValue("/increment", "/metric")).isEqualTo(10);
  assertThat(counter.countOccurrences("/increment", "/metric")).isEqualTo(1);
}

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

@Test
public void shouldIncrementAndRetrieveCounterForGivenPath() {
  // given when
  counter.increment("/increment", 10);
  wait.untilZookeeperPathIsCreated("/increment");
  // then
  assertThat(counter.getValue("/increment")).isEqualTo(10);
}

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

@Test
public void shouldReturnSumOfAllNodeChildrenValues() {
  // given when
  counter.increment("/sum/host1/metric", 10);
  counter.increment("/sum/host2/metric", 5);
  wait.untilZookeeperPathIsCreated("/sum/host1/metric");
  // then
  assertThat(counter.getValue("/sum", "/metric")).isEqualTo(15);
}

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

@Test
  public void shouldResetNodeWhenConnectionIsClosed() {
    // given
    try (CuratorFramework otherClient = newClient()) {
      DistributedEphemeralCounter otherCounter = new DistributedEphemeralCounter(otherClient);

      otherCounter.increment("/ephemeral/host1/metric", 10);
      wait.untilZookeeperPathIsCreated("/ephemeral/host1/metric");
    }

    // when
    counter.increment("/ephemeral/host2/metric", 5);
    wait.untilZookeeperPathIsCreated("/ephemeral/host2/metric");

    // then
    assertThat(counter.getValue("/ephemeral", "/metric")).isEqualTo(5);
  }
}

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

private Subscription forceAssignment(Subscription sub) {
  workTracker.forceAssignment(sub);
  wait.untilZookeeperPathIsCreated(basePath, sub.getQualifiedName().toString(), supervisorId);
  return sub;
}

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

@Test
public void shouldIncrementCounterAtomicallyWhenIncrementedConcurrently() {
  // given
  SharedCounter otherCounter = new SharedCounter(zookeeperClient, 72 * 3600, 1000, 3);
  // when
  counter.increment("/sharedIncrement", 10);
  otherCounter.increment("/sharedIncrement", 15);
  wait.untilZookeeperPathIsCreated("/sharedIncrement");
  // then
  assertThat(counter.getValue("/sharedIncrement")).isEqualTo(25);
}

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

@Test
public void shouldApplyAssignmentChangesByAddingNewNodes() {
  // given
  Subscription s1 = forceAssignment(anySubscription());
  Subscription s2 = forceAssignment(anySubscription());
  SubscriptionAssignmentView view = new SubscriptionAssignmentView(
      ImmutableMap.of(
          s1.getQualifiedName(), ImmutableSet.of(assignment(supervisorId, s1.getQualifiedName()), assignment("otherConsumer", s1.getQualifiedName())),
          s2.getQualifiedName(), ImmutableSet.of(assignment(supervisorId, s2.getQualifiedName()))));
  // when
  workTracker.apply(subscriptionAssignmentRegistry.createSnapshot(), view);
  // then
  wait.untilZookeeperPathIsCreated(basePath, s1.getQualifiedName().toString(), supervisorId);
  wait.untilZookeeperPathIsCreated(basePath, s1.getQualifiedName().toString(), "otherConsumer");
  wait.untilZookeeperPathIsCreated(basePath, s2.getQualifiedName().toString(), supervisorId);
}

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

@Test
public void shouldApplyAssignmentChangesCreatingNewNodesInZookeeper() {
  // given
  Subscription s1 = anySubscription();
  SubscriptionAssignmentView view = stateWithSingleAssignment(s1);
  // when
  workTracker.apply(subscriptionAssignmentRegistry.createSnapshot(), view);
  // then
  wait.untilZookeeperPathIsCreated(basePath, s1.getQualifiedName().toString(), supervisorId);
}

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

@Test
public void shouldWriteAndReadMaxRateProperly() throws Exception {
  // given
  ConsumerInstance consumer1 = consumer("consumer1");
  ConsumerInstance consumer2 = consumer("consumer2");
  // when
  maxRateRegistry.update(subscription,
      ImmutableMap.of(
          "consumer1", new MaxRate(350.0),
          "consumer2", new MaxRate(0.5)
      ));
  wait.untilZookeeperPathIsCreated(
      zookeeperPaths.consumersMaxRatePath(cluster, consumer1.getSubscription(), consumer1.getConsumerId()));
  wait.untilZookeeperPathIsCreated(
      zookeeperPaths.consumersMaxRatePath(cluster, consumer2.getSubscription(), consumer2.getConsumerId()));
  // then
  assertEquals(new MaxRate(350.0), maxRateRegistry.getMaxRate(consumer1).get());
  assertEquals(new MaxRate(0.5), maxRateRegistry.getMaxRate(consumer2).get());
}

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

@Test
public void shouldRemoveInactiveConsumerEntries() throws Exception {
  // given
  ConsumerInstance consumer1 = consumer("consumer1");
  ConsumerInstance consumer2 = consumer("consumer2");
  maxRateRegistry.ensureCorrectAssignments(subscription, Sets.newHashSet("consumer1", "consumer2"));
  maxRateRegistry.update(subscription, ImmutableMap.of(
      "consumer1", new MaxRate(350.0),
      "consumer2", new MaxRate(0.5)
  ));
  wait.untilZookeeperPathIsCreated(
      zookeeperPaths.consumersMaxRatePath(cluster, consumer1.getSubscription(), consumer1.getConsumerId()));
  wait.untilZookeeperPathIsCreated(
      zookeeperPaths.consumersMaxRatePath(cluster, consumer2.getSubscription(), consumer2.getConsumerId()));
  // when
  maxRateRegistry.ensureCorrectAssignments(subscription, Sets.newHashSet("consumer1", "consumer3"));
  wait.untilZookeeperPathNotExists(
      zookeeperPaths.consumersRatePath(cluster, consumer2.getSubscription(), consumer2.getConsumerId()));
  // then
  assertEquals(Optional.empty(), maxRateRegistry.getMaxRate(consumer2));
}

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

@Test
public void shouldWriteAndReadRateHistoryProperly() throws Exception {
  // given
  ConsumerInstance consumer = consumer("consumer1");
  RateHistory rateHistory = RateHistory.create(0.5);
  // when
  maxRateRegistry.writeRateHistory(consumer, rateHistory);
  wait.untilZookeeperPathIsCreated(
      zookeeperPaths.consumersRateHistoryPath(cluster, consumer.getSubscription(), consumer.getConsumerId()));
  // then
  assertEquals(rateHistory, maxRateRegistry.getRateHistory(consumer));
}

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

@Test
public void shouldApplyAssignmentChangesByRemovingSubscriptionNode() {
  // given
  Subscription s1 = anySubscription();
  SubscriptionAssignmentView view = stateWithSingleAssignment(s1);
  workTracker.apply(subscriptionAssignmentRegistry.createSnapshot(), view);
  wait.untilZookeeperPathIsCreated(basePath, s1.getQualifiedName().toString(), supervisorId);
  // when
  workTracker.apply(subscriptionAssignmentRegistry.createSnapshot(), stateWithNoAssignments());
  // then
  wait.untilZookeeperPathNotExists(basePath, s1.getQualifiedName().toString());
}

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