Search in sources :

Example 16 with PushConnectionsHandle

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

the class PushRoutingTest method shouldFail_LocaleNodeException.

@Test
public void shouldFail_LocaleNodeException() 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 -> {
        remotePublisher.accept(REMOTE_ROW1);
        remotePublisher.accept(REMOTE_ROW2);
        localPublisher.error(new RuntimeException("Random local error"));
    });
    final Throwable throwable = waitOnException(handle);
    handle.close();
    // Then:
    assertThat(throwable.getMessage(), containsString("Random local error"));
}
Also used : 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) Test(org.junit.Test)

Example 17 with PushConnectionsHandle

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

the class PushRoutingTest method shouldSucceed_gapDetectedLocal_noRetry.

@Test
public void shouldSucceed_gapDetectedLocal_noRetry() throws ExecutionException, InterruptedException {
    // Given:
    final AtomicReference<Set<KsqlNode>> nodes = new AtomicReference<>(ImmutableSet.of(ksqlNodeLocal, ksqlNodeRemote));
    final PushRouting routing = new PushRouting(sqr -> nodes.get(), 50, false);
    // When:
    final PushConnectionsHandle handle = handlePushRouting(routing);
    context.runOnContext(v -> {
        localPublisher.accept(LOCAL_ROW1);
        localPublisher.accept(LOCAL_CONTINUATION_TOKEN1);
        localPublisher.accept(LOCAL_ROW2);
        localPublisher.accept(LOCAL_CONTINUATION_TOKEN_GAP);
    });
    Set<List<?>> rows = waitOnRows(2);
    waitOnNodeStatus(handle, ksqlNodeLocal, RoutingResultStatus.OFFSET_GAP_FOUND);
    handle.close();
    // Then:
    assertThat(rows.contains(LOCAL_ROW1.value().values()), is(true));
    assertThat(rows.contains(LOCAL_ROW2.value().values()), is(true));
    assertThat(handle.get(ksqlNodeLocal).get().getStatus(), is(RoutingResultStatus.OFFSET_GAP_FOUND));
}
Also used : 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)

Example 18 with PushConnectionsHandle

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

the class PushRoutingTest method shouldSucceed_justForwarded.

@Test
public void shouldSucceed_justForwarded() throws ExecutionException, InterruptedException {
    // Given:
    when(pushRoutingOptions.getHasBeenForwarded()).thenReturn(true);
    final PushRouting routing = new PushRouting();
    // When:
    final PushConnectionsHandle handle = handlePushRouting(routing);
    context.runOnContext(v -> {
        localPublisher.accept(LOCAL_ROW1);
        localPublisher.accept(LOCAL_ROW2);
    });
    // Then:
    verify(simpleKsqlClient, never()).makeQueryRequestStreamed(any(), any(), any(), any());
    Set<List<?>> rows = waitOnRows(2);
    handle.close();
    assertThat(rows.contains(LOCAL_ROW1.value().values()), is(true));
    assertThat(rows.contains(LOCAL_ROW2.value().values()), is(true));
}
Also used : PushConnectionsHandle(io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Aggregations

PushConnectionsHandle (io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle)18 Test (org.junit.Test)18 ImmutableList (com.google.common.collect.ImmutableList)14 List (java.util.List)14 ImmutableSet (com.google.common.collect.ImmutableSet)11 HashSet (java.util.HashSet)11 Set (java.util.Set)11 AtomicReference (java.util.concurrent.atomic.AtomicReference)11 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 PushOffsetRange (io.confluent.ksql.util.PushOffsetRange)3 TransientQueryQueue (io.confluent.ksql.query.TransientQueryQueue)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 QueryRow (io.confluent.ksql.physical.common.QueryRow)1 RoutingResult (io.confluent.ksql.physical.scalablepush.PushRouting.RoutingResult)1 BufferedPublisher (io.confluent.ksql.reactive.BufferedPublisher)1