Search in sources :

Example 1 with RoutingResult

use of io.confluent.ksql.physical.scalablepush.PushRouting.RoutingResult in project ksql by confluentinc.

the class PushRoutingTest method shouldSucceed_removeRemoteNode.

@Test
public void shouldSucceed_removeRemoteNode() throws ExecutionException, InterruptedException {
    // Given:
    final AtomicReference<Set<KsqlNode>> nodes = new AtomicReference<>(ImmutableSet.of(ksqlNodeLocal, ksqlNodeRemote));
    final PushRouting routing = new PushRouting(sqr -> nodes.get(), 50, true);
    // When:
    final PushConnectionsHandle handle = handlePushRouting(routing);
    context.runOnContext(v -> {
        localPublisher.accept(LOCAL_ROW1);
        localPublisher.accept(LOCAL_ROW2);
        remotePublisher.accept(REMOTE_ROW1);
        remotePublisher.accept(REMOTE_ROW2);
    });
    Set<List<?>> rows = waitOnRows(4);
    final RoutingResult result = handle.get(ksqlNodeRemote).get();
    nodes.set(ImmutableSet.of(ksqlNodeLocal));
    while (handle.get(ksqlNodeRemote).isPresent()) {
        Thread.sleep(100);
        continue;
    }
    handle.close();
    // Then:
    assertThat(rows.contains(LOCAL_ROW1.value().values()), is(true));
    assertThat(rows.contains(LOCAL_ROW2.value().values()), is(true));
    assertThat(rows.contains(REMOTE_ROW1.getRow().get().getColumns()), is(true));
    assertThat(rows.contains(REMOTE_ROW2.getRow().get().getColumns()), is(true));
    assertThat(result.getStatus(), is(RoutingResultStatus.REMOVED));
}
Also used : RoutingResult(io.confluent.ksql.physical.scalablepush.PushRouting.RoutingResult) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashSet(java.util.HashSet) PushConnectionsHandle(io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle) AtomicReference(java.util.concurrent.atomic.AtomicReference) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 PushConnectionsHandle (io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle)1 RoutingResult (io.confluent.ksql.physical.scalablepush.PushRouting.RoutingResult)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.junit.Test)1