use of io.confluent.ksql.execution.streams.materialization.ks.KsLocator.PartitionLocation in project ksql by confluentinc.
the class HARoutingTest method shouldCallRouteQuery_couldNotFindHost.
@Test
public void shouldCallRouteQuery_couldNotFindHost() {
// Given:
location1 = new PartitionLocation(Optional.empty(), 1, ImmutableList.of());
locate(location1, location2, location3, location4);
// When:
final Exception e = assertThrows(MaterializationException.class, () -> haRouting.handlePullQuery(serviceContext, pullPhysicalPlan, statement, routingOptions, logicalSchema, queryId, pullQueryQueue, disconnect, Optional.empty()));
// Then:
assertThat(e.getMessage(), containsString("Unable to execute pull query. " + "[Partition 1 failed to find valid host. Hosts scanned: []]"));
final double fetch_count = getMetricValue("-partition-fetch-count");
final double resubmission_count = getMetricValue("-partition-fetch-resubmission-count");
assertThat(fetch_count, is(0.0));
assertThat(resubmission_count, is(0.0));
}
use of io.confluent.ksql.execution.streams.materialization.ks.KsLocator.PartitionLocation in project ksql by confluentinc.
the class HARoutingTest method shouldNotRouteToFilteredHost.
@Test
public void shouldNotRouteToFilteredHost() throws InterruptedException, ExecutionException {
// Given:
location1 = new PartitionLocation(Optional.empty(), 1, ImmutableList.of(badNode, node1));
when(ksqlClient.makeQueryRequest(any(), any(), any(), any(), any(), any())).then(invocationOnMock -> RestResponse.successful(200, 2));
locate(location1, location2, location3, location4);
// When:
final CompletableFuture<Void> fut = haRouting.handlePullQuery(serviceContext, pullPhysicalPlan, statement, routingOptions, logicalSchema, queryId, pullQueryQueue, disconnect, Optional.empty());
fut.get();
// Then:
verify(ksqlClient, never()).makeQueryRequest(eq(badNode.location()), any(), any(), any(), any(), any());
final double fetch_count = getMetricValue("-partition-fetch-count");
final double resubmission_count = getMetricValue("-partition-fetch-resubmission-count");
assertThat(fetch_count, is(4.0));
assertThat(resubmission_count, is(0.0));
}
use of io.confluent.ksql.execution.streams.materialization.ks.KsLocator.PartitionLocation in project ksql by confluentinc.
the class HARoutingTest method shouldCallRouteQuery_allFilteredWithCause.
@Test
public void shouldCallRouteQuery_allFilteredWithCause() {
// Given:
location1 = new PartitionLocation(Optional.empty(), 1, ImmutableList.of(badNode));
locate(location1, location2, location3, location4);
// When:
final Exception e = assertThrows(MaterializationException.class, () -> haRouting.handlePullQuery(serviceContext, pullPhysicalPlan, statement, routingOptions, logicalSchema, queryId, pullQueryQueue, disconnect, Optional.empty()));
// Then:
assertThat(e.getMessage(), containsString("Hosts scanned: [badnode:8090 was not selected because BAD]]"));
final double fetch_count = getMetricValue("-partition-fetch-count");
final double resubmission_count = getMetricValue("-partition-fetch-resubmission-count");
assertThat(fetch_count, is(0.0));
assertThat(resubmission_count, is(0.0));
}
use of io.confluent.ksql.execution.streams.materialization.ks.KsLocator.PartitionLocation in project ksql by confluentinc.
the class HARoutingTest method setUp.
@Before
public void setUp() {
when(pullPhysicalPlan.getMaterialization()).thenReturn(materialization);
when(pullPhysicalPlan.getMaterialization().locator()).thenReturn(locator);
when(statement.getStatementText()).thenReturn("foo");
when(statement.getSessionConfig()).thenReturn(SessionConfig.of(ksqlConfig, ImmutableMap.of()));
when(node1.isLocal()).thenReturn(true);
when(node2.isLocal()).thenReturn(false);
when(node1.location()).thenReturn(URI.create("http://node1:8088"));
when(node2.location()).thenReturn(URI.create("http://node2:8089"));
when(badNode.location()).thenReturn(URI.create("http://badnode:8090"));
when(node1.getHost()).thenReturn(Host.include(new KsqlHostInfo("node1", 8088)));
when(node2.getHost()).thenReturn(Host.include(new KsqlHostInfo("node2", 8089)));
when(badNode.getHost()).thenReturn(Host.exclude(new KsqlHostInfo("badnode", 8090), "BAD"));
location1 = new PartitionLocation(Optional.empty(), 1, ImmutableList.of(node1, node2));
location2 = new PartitionLocation(Optional.empty(), 2, ImmutableList.of(node2, node1));
location3 = new PartitionLocation(Optional.empty(), 3, ImmutableList.of(node1, node2));
location4 = new PartitionLocation(Optional.empty(), 4, ImmutableList.of(node2, node1));
location5 = new PartitionLocation(Optional.empty(), 4, ImmutableList.of(node2));
// We require at least two threads, one for the orchestrator, and the other for the partitions.
when(ksqlConfig.getInt(KsqlConfig.KSQL_QUERY_PULL_THREAD_POOL_SIZE_CONFIG)).thenReturn(1);
when(ksqlConfig.getInt(KsqlConfig.KSQL_QUERY_PULL_ROUTER_THREAD_POOL_SIZE_CONFIG)).thenReturn(1);
when(serviceContext.getKsqlClient()).thenReturn(ksqlClient);
pullMetrics = new PullQueryExecutorMetrics(KSQL_SERVICE_ID, Collections.emptyMap(), time, new Metrics());
haRouting = new HARouting(routingFilterFactory, Optional.of(pullMetrics), ksqlConfig);
}
Aggregations