Search in sources :

Example 6 with Host

use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.

the class MaximumLagFilterTest method filter_shouldNotIncludeAboveThreshold.

@Test
public void filter_shouldNotIncludeAboveThreshold() {
    // The max end offset is 15, so the lag for HOST is 12
    // Given:
    when(routingOptions.getMaxOffsetLagAllowed()).thenReturn(11L);
    // When:
    filter = MaximumLagFilter.create(Optional.of(lagReportingAgent), routingOptions, HOSTS, APPLICATION_ID, STATE_STORE, PARTITION).get();
    // Then:
    final Host host = filter.filter(HOST1);
    assertFalse(host.isSelected());
    assertEquals(host.getReasonNotSelected(), "Host excluded because lag 12 exceeds maximum allowed lag 11.");
}
Also used : Host(io.confluent.ksql.execution.streams.RoutingFilter.Host) Test(org.junit.Test)

Example 7 with Host

use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.

the class LivenessFilterTest method shouldFilterActiveAlive.

@Test
public void shouldFilterActiveAlive() {
    // Given:
    allHostsStatus = ImmutableMap.of(activeHost, HOST_ALIVE, standByHost1, HOST_DEAD, standByHost2, HOST_DEAD);
    when(heartbeatAgent.getHostsStatus()).thenReturn(allHostsStatus);
    // When:
    final Host filterActive = livenessFilter.filter(activeHost);
    final Host filterStandby1 = livenessFilter.filter(standByHost1);
    final Host filterStandby2 = livenessFilter.filter(standByHost2);
    // Then:
    assertThat(filterActive.isSelected(), is(true));
    assertThat(filterStandby1.isSelected(), is(false));
    assertThat(filterStandby1.getReasonNotSelected(), is("Host is not alive as of time 0"));
    assertThat(filterStandby2.isSelected(), is(false));
    assertThat(filterStandby2.getReasonNotSelected(), is("Host is not alive as of time 0"));
}
Also used : Host(io.confluent.ksql.execution.streams.RoutingFilter.Host) Test(org.junit.Test)

Example 8 with Host

use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.

the class LivenessFilterTest method shouldFilterStandbyAlive.

@Test
public void shouldFilterStandbyAlive() {
    // Given:
    allHostsStatus = ImmutableMap.of(activeHost, HOST_DEAD, standByHost1, HOST_ALIVE, standByHost2, HOST_DEAD);
    when(heartbeatAgent.getHostsStatus()).thenReturn(allHostsStatus);
    // When:
    final Host filterActive = livenessFilter.filter(activeHost);
    final Host filterStandby1 = livenessFilter.filter(standByHost1);
    final Host filterStandby2 = livenessFilter.filter(standByHost2);
    // Then:
    assertThat(filterActive.isSelected(), is(false));
    assertThat(filterActive.getReasonNotSelected(), is("Host is not alive as of time 0"));
    assertThat(filterStandby1.isSelected(), is(true));
    assertThat(filterStandby2.isSelected(), is(false));
    assertThat(filterActive.getReasonNotSelected(), is("Host is not alive as of time 0"));
}
Also used : Host(io.confluent.ksql.execution.streams.RoutingFilter.Host) Test(org.junit.Test)

Example 9 with Host

use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.

the class ActiveHostFilterTest method shouldFilterActive.

@Test
public void shouldFilterActive() {
    // Given:
    // When:
    final Host filterActive = activeHostFilter.filter(activeHost);
    final Host filterStandby = activeHostFilter.filter(standByHost);
    // Then:
    assertThat(filterActive.isSelected(), is(true));
    assertThat(filterStandby.isSelected(), is(false));
    assertThat(filterStandby.getReasonNotSelected(), is("Host is not the active host for this partition."));
}
Also used : Host(io.confluent.ksql.execution.streams.RoutingFilter.Host) Test(org.junit.Test)

Example 10 with Host

use of io.confluent.ksql.execution.streams.RoutingFilter.Host in project ksql by confluentinc.

the class MaximumLagFilterTest method filter_shouldIncludeBelowThreshold.

@Test
public void filter_shouldIncludeBelowThreshold() {
    // The max end offset is 15, so the lag for HOST is 12
    // Given:
    when(routingOptions.getMaxOffsetLagAllowed()).thenReturn(13L);
    // When:
    filter = MaximumLagFilter.create(Optional.of(lagReportingAgent), routingOptions, HOSTS, APPLICATION_ID, STATE_STORE, PARTITION).get();
    // Then:
    final Host host = filter.filter(HOST1);
    assertTrue(host.isSelected());
    assertEquals(host.getReasonNotSelected(), "");
}
Also used : Host(io.confluent.ksql.execution.streams.RoutingFilter.Host) Test(org.junit.Test)

Aggregations

Host (io.confluent.ksql.execution.streams.RoutingFilter.Host)10 Test (org.junit.Test)8 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Preconditions (com.google.common.base.Preconditions)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 RoutingFilterFactory (io.confluent.ksql.execution.streams.RoutingFilter.RoutingFilterFactory)2 RoutingOptions (io.confluent.ksql.execution.streams.RoutingOptions)2 KsqlNode (io.confluent.ksql.execution.streams.materialization.Locator.KsqlNode)2 KsqlPartitionLocation (io.confluent.ksql.execution.streams.materialization.Locator.KsqlPartitionLocation)2 MaterializationException (io.confluent.ksql.execution.streams.materialization.MaterializationException)2 NotUpToBoundException (io.confluent.ksql.execution.streams.materialization.ks.NotUpToBoundException)2 PullQueryExecutorMetrics (io.confluent.ksql.internal.PullQueryExecutorMetrics)2 Query (io.confluent.ksql.parser.tree.Query)2 PullPhysicalPlanType (io.confluent.ksql.physical.pull.PullPhysicalPlan.PullPhysicalPlanType)2 PullQueryQueue (io.confluent.ksql.query.PullQueryQueue)2 QueryId (io.confluent.ksql.query.QueryId)2 RestResponse (io.confluent.ksql.rest.client.RestResponse)2 StreamedRow (io.confluent.ksql.rest.entity.StreamedRow)2