use of io.confluent.ksql.rest.entity.KsqlHostInfoEntity in project ksql by confluentinc.
the class HeartbeatResource method handleHeartbeat.
private void handleHeartbeat(final HeartbeatMessage request) {
final KsqlHostInfoEntity ksqlHostInfoEntity = request.getHostInfo();
final KsqlHostInfo ksqlHostInfo = new KsqlHostInfo(ksqlHostInfoEntity.getHost(), ksqlHostInfoEntity.getPort());
final long timestamp = request.getTimestamp();
heartbeatAgent.receiveHeartbeat(ksqlHostInfo, timestamp);
}
use of io.confluent.ksql.rest.entity.KsqlHostInfoEntity in project ksql by confluentinc.
the class HeartbeatResourceTest method shouldSendHeartbeat.
@Test
public void shouldSendHeartbeat() {
// When:
final HeartbeatMessage request = new HeartbeatMessage(new KsqlHostInfoEntity("localhost", 8080), 1);
final EndpointResponse response = heartbeatResource.registerHeartbeat(request);
// Then:
assertThat(response.getStatus(), is(200));
assertThat(response.getEntity(), instanceOf(HeartbeatResponse.class));
}
use of io.confluent.ksql.rest.entity.KsqlHostInfoEntity in project ksql by confluentinc.
the class PullQueryRoutingFunctionalTest method shouldQueryStandbyWhenActiveDeadStandbyAliveQueryIssuedToRouter_multipleKeys.
@SuppressWarnings("unchecked")
@Test
public void shouldQueryStandbyWhenActiveDeadStandbyAliveQueryIssuedToRouter_multipleKeys() throws Exception {
// Given:
ClusterFormation clusterFormation = findClusterFormation(TEST_APP_0, TEST_APP_1, TEST_APP_2);
waitForClusterToBeDiscovered(clusterFormation.router.getApp(), 3, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.router.getHost(), HighAvailabilityTestUtil.lagsReported(3), USER_CREDS);
// Partition off the active
clusterFormation.active.getShutoffs().shutOffAll();
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.standBy.getHost(), HighAvailabilityTestUtil::remoteServerIsUp, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.active.getHost(), HighAvailabilityTestUtil::remoteServerIsDown, USER_CREDS);
// When:
final List<StreamedRow> rows_0 = makePullQueryRequest(clusterFormation.router.getApp(), sqlMultipleKeys, null, USER_CREDS);
// Then:
assertThat(rows_0, hasSize(HEADER + 2));
KsqlHostInfoEntity host = rows_0.get(1).getSourceHost().get();
assertThat(host.getHost(), is(clusterFormation.standBy.getHost().getHost()));
assertThat(host.getPort(), is(clusterFormation.standBy.getHost().getPort()));
host = rows_0.get(2).getSourceHost().get();
assertThat(host.getHost(), is(clusterFormation.standBy.getHost().getHost()));
assertThat(host.getPort(), is(clusterFormation.standBy.getHost().getPort()));
List<List<?>> values = rows_0.stream().skip(HEADER).map(sr -> {
assertThat(sr.getRow(), is(not(Optional.empty())));
return sr.getRow().get().getColumns();
}).collect(Collectors.toList());
assertThat(values, containsInAnyOrder(ImmutableList.of(KEY, 1), ImmutableList.of(KEY1, 1)));
}
use of io.confluent.ksql.rest.entity.KsqlHostInfoEntity in project ksql by confluentinc.
the class PullQueryRoutingFunctionalTest method shouldQueryStandbyWhenActiveDeadStandbyAliveQueryIssuedToRouter.
@Test
public void shouldQueryStandbyWhenActiveDeadStandbyAliveQueryIssuedToRouter() throws Exception {
// Given:
ClusterFormation clusterFormation = findClusterFormation(TEST_APP_0, TEST_APP_1, TEST_APP_2);
waitForClusterToBeDiscovered(clusterFormation.router.getApp(), 3, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.router.getHost(), HighAvailabilityTestUtil.lagsReported(3), USER_CREDS);
// Partition off the active
clusterFormation.active.getShutoffs().shutOffAll();
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.standBy.getHost(), HighAvailabilityTestUtil::remoteServerIsUp, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.active.getHost(), HighAvailabilityTestUtil::remoteServerIsDown, USER_CREDS);
// When:
final List<StreamedRow> rows_0 = makePullQueryRequest(clusterFormation.router.getApp(), sql, null, USER_CREDS);
// Then:
assertThat(rows_0, hasSize(HEADER + 1));
KsqlHostInfoEntity host = rows_0.get(1).getSourceHost().get();
assertThat(host.getHost(), is(clusterFormation.standBy.getHost().getHost()));
assertThat(host.getPort(), is(clusterFormation.standBy.getHost().getPort()));
assertThat(rows_0.get(1).getRow(), is(not(Optional.empty())));
assertThat(rows_0.get(1).getRow().get().getColumns(), is(ImmutableList.of(KEY, 1)));
}
use of io.confluent.ksql.rest.entity.KsqlHostInfoEntity in project ksql by confluentinc.
the class LagReportingAgentTest method shouldReceiveLags_listAllCurrentPositions.
@Test
public void shouldReceiveLags_listAllCurrentPositions() {
// When:
lagReportingAgent.receiveHostLag(hostLag(HOST_ENTITY1, LAG_MAP1, 100));
lagReportingAgent.receiveHostLag(hostLag(HOST_ENTITY2, LAG_MAP2, 200));
lagReportingAgent.onHostStatusUpdated(HOSTS_ALIVE);
// Then:
ImmutableMap<KsqlHostInfoEntity, HostStoreLags> allLags = lagReportingAgent.getAllLags();
LagInfoEntity lag = allLags.get(HOST_ENTITY1).getStateStoreLags(QUERY_STORE_A).flatMap(s -> s.getLagByPartition(1)).get();
assertEquals(M1_A1_CUR, lag.getCurrentOffsetPosition());
assertEquals(M1_A1_END, lag.getEndOffsetPosition());
assertEquals(M1_A1_LAG, lag.getOffsetLag());
lag = allLags.get(HOST_ENTITY1).getStateStoreLags(QUERY_STORE_A).flatMap(s -> s.getLagByPartition(3)).get();
assertEquals(M1_A3_CUR, lag.getCurrentOffsetPosition());
assertEquals(M1_A3_END, lag.getEndOffsetPosition());
assertEquals(M1_A3_LAG, lag.getOffsetLag());
lag = allLags.get(HOST_ENTITY1).getStateStoreLags(QUERY_STORE_B).flatMap(s -> s.getLagByPartition(4)).get();
assertEquals(M1_B4_CUR, lag.getCurrentOffsetPosition());
assertEquals(M1_B4_END, lag.getEndOffsetPosition());
assertEquals(M1_B4_LAG, lag.getOffsetLag());
lag = allLags.get(HOST_ENTITY2).getStateStoreLags(QUERY_STORE_A).flatMap(s -> s.getLagByPartition(1)).get();
assertEquals(M2_A1_CUR, lag.getCurrentOffsetPosition());
assertEquals(M2_A1_END, lag.getEndOffsetPosition());
assertEquals(M2_A1_LAG, lag.getOffsetLag());
lag = allLags.get(HOST_ENTITY2).getStateStoreLags(QUERY_STORE_B).flatMap(s -> s.getLagByPartition(4)).get();
assertEquals(M2_B4_CUR, lag.getCurrentOffsetPosition());
assertEquals(M2_B4_END, lag.getEndOffsetPosition());
assertEquals(M2_B4_LAG, lag.getOffsetLag());
}
Aggregations