public void untilZookeeperPathIsCreated(String... path) { untilZookeeperPathIsCreated(stream(path).collect(joining("/"))); }
public void untilZookeeperPathNotExists(String... path) { untilZookeeperPathNotExists(stream(path).collect(joining("/"))); }
public void untilZookeeperClientStarted() { this.untilZookeeperClientStarted(zookeeper); }
@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)); }
@BeforeClass public static void beforeZookeeperClass() throws Exception { zookeeperServer = new TestingServer(45678); zookeeperClient = CuratorFrameworkFactory.builder() .connectString(zookeeperServer.getConnectString()) .retryPolicy(new ExponentialBackoffRetry(1000, 3)) .build(); zookeeperClient.start(); wait = new ZookeeperWaiter(zookeeperClient); wait.untilZookeeperClientStarted(); ZooKeeperClient zooKeeperClient = new ZooKeeperClient( zookeeperServer.getConnectString(), 60 * 1000, 15 * 1000, 10, Time.SYSTEM, "zookeeper-test", "zookeeper-test"); zooKeeperClient.waitUntilConnected(); kafkaZkClient = new KafkaZkClient(zooKeeperClient, false, Time.SYSTEM); }
public void untilZookeeperPathIsEmpty(String... path) { untilZookeeperPathIsEmpty(stream(path).collect(joining("/"))); } }
public void untilZookeeperClientStopped() { this.untilZookeeperClientStopped(zookeeper); }
@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()); }
@BeforeClass public static void beforeZookeeperClass() throws Exception { zookeeperServer = new TestingServer(45678); zookeeperClient = CuratorFrameworkFactory.builder() .connectString(zookeeperServer.getConnectString()) .retryPolicy(new ExponentialBackoffRetry(1000, 3)) .build(); zookeeperClient.start(); wait = new ZookeeperWaiter(zookeeperClient); wait.untilZookeeperClientStarted(); ZooKeeperClient zooKeeperClient = new ZooKeeperClient( zookeeperServer.getConnectString(), 60 * 1000, 15 * 1000, 10, Time.SYSTEM, "zookeeper-test", "zookeeper-test"); zooKeeperClient.waitUntilConnected(); kafkaZkClient = new KafkaZkClient(zooKeeperClient, false, Time.SYSTEM); }
public void untilZookeeperPathIsEmpty(String... path) { untilZookeeperPathIsEmpty(stream(path).collect(joining("/"))); } }
public void untilZookeeperClientStopped() { this.untilZookeeperClientStopped(zookeeper); }
public void untilZookeeperPathIsCreated(String... path) { untilZookeeperPathIsCreated(stream(path).collect(joining("/"))); }
public void untilZookeeperPathNotExists(String... path) { untilZookeeperPathNotExists(stream(path).collect(joining("/"))); }
public void untilZookeeperClientStarted() { this.untilZookeeperClientStarted(zookeeper); }
@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); }
private Subscription dropAssignment(Subscription sub) { workTracker.dropAssignment(sub); wait.untilZookeeperPathNotExists(basePath, sub.getQualifiedName().toString(), supervisorId); return sub; } }
protected static CuratorFramework newClient() { CuratorFramework newClient = CuratorFrameworkFactory.builder() .connectString(zookeeperServer.getConnectString()) .retryPolicy(new ExponentialBackoffRetry(1000, 3)) .build(); newClient.start(); wait.untilZookeeperClientStarted(newClient); return newClient; }
@Test public void shouldIncrementAndRetrieveCounterForGivenPath() { // given when counter.increment("/increment", 10); wait.untilZookeeperPathIsCreated("/increment"); // then assertThat(counter.getValue("/increment")).isEqualTo(10); }
@Test public void shouldDropAssignmentAndEmptySubscriptionNode() { // given Subscription sub = forceAssignment(anySubscription()); // when workTracker.dropAssignment(sub); wait.untilZookeeperPathNotExists(basePath, sub.getQualifiedName().toString()); // then assertThat(workTracker.isAssignedTo(sub.getQualifiedName(), supervisorId)).isFalse(); }
protected static CuratorFramework newClient() { CuratorFramework newClient = CuratorFrameworkFactory.builder() .connectString(zookeeperServer.getConnectString()) .retryPolicy(new ExponentialBackoffRetry(1000, 3)) .build(); newClient.start(); wait.untilZookeeperClientStarted(newClient); return newClient; }