use of io.confluent.ksql.rest.entity.HostStoreLags 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());
}
use of io.confluent.ksql.rest.entity.HostStoreLags in project ksql by confluentinc.
the class LagReportingAgentFunctionalTest method allLagsReported.
private static boolean allLagsReported(ClusterStatusResponse response) {
if (response.getClusterStatus().size() == 2) {
HostStoreLags store0 = response.getClusterStatus().get(HOST0).getHostStoreLags();
HostStoreLags store1 = response.getClusterStatus().get(HOST1).getHostStoreLags();
if (arePartitionsCurrent(store0) && arePartitionsCurrent(store1)) {
LOG.info("Found expected lags: {}", response.getClusterStatus().toString());
return true;
}
}
LOG.info("Didn't yet find expected lags: {}", response.getClusterStatus().toString());
return false;
}
use of io.confluent.ksql.rest.entity.HostStoreLags in project ksql by confluentinc.
the class LagReportingAgent method receiveHostLag.
/**
* Stores the host lag received from a remote Ksql server.
* @param lagReportingMessage The host lag information sent directly from the other node.
*/
public void receiveHostLag(final LagReportingMessage lagReportingMessage) {
final HostStoreLags hostStoreLags = lagReportingMessage.getHostStoreLags();
final long updateTimeMs = hostStoreLags.getUpdateTimeMs();
final KsqlHostInfoEntity KsqlHostInfoEntity = lagReportingMessage.getKsqlHost();
final KsqlHostInfo KsqlHostInfo = KsqlHostInfoEntity.toKsqlHost();
LOG.debug("Receive lag at: {} from host: {} lag: {} ", updateTimeMs, KsqlHostInfoEntity, hostStoreLags.getStateStoreLags());
receivedLagInfo.compute(KsqlHostInfo, (hi, previousHostLagInfo) -> previousHostLagInfo != null && previousHostLagInfo.getUpdateTimeMs() > updateTimeMs ? previousHostLagInfo : hostStoreLags);
}
Aggregations