public void untilZookeeperPathNotExists(String... path) { untilZookeeperPathNotExists(stream(path).collect(joining("/"))); }
public void untilZookeeperPathNotExists(String... path) { untilZookeeperPathNotExists(stream(path).collect(joining("/"))); }
private Subscription dropAssignment(Subscription sub) { workTracker.dropAssignment(sub); wait.untilZookeeperPathNotExists(basePath, sub.getQualifiedName().toString(), supervisorId); return sub; } }
@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(); }
@Test public void shouldApplyAssignmentChangesByRemovingInvalidNodes() { // given Subscription s1 = forceAssignment(anySubscription()); // when workTracker.apply(subscriptionAssignmentRegistry.createSnapshot(), stateWithNoAssignments()); // then wait.untilZookeeperPathNotExists(basePath, s1.getQualifiedName().toString(), supervisorId); }
@Test public void shouldApplyAssignmentChangesByRemovingInvalidSubscriptionNode() { // given Subscription s1 = dropAssignment(forceAssignment(anySubscription())); // when workTracker.apply(subscriptionAssignmentRegistry.createSnapshot(), stateWithNoAssignments()); // then wait.untilZookeeperPathNotExists(basePath, s1.getQualifiedName().toString()); }
@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)); }
@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()); }