use of io.confluent.ksql.rest.entity.HostStatusEntity in project ksql by confluentinc.
the class HighAvailabilityTestUtil method getOffsets.
// Gets (current, end) offsets for the given host. Makes the simplified assumption that there's
// just one state store.
public static Pair<Long, Long> getOffsets(final KsqlHostInfoEntity server, final Map<KsqlHostInfoEntity, HostStatusEntity> clusterStatus) {
HostStatusEntity hostStatusEntity = clusterStatus.get(server);
long end = hostStatusEntity.getHostStoreLags().getStateStoreLags().values().stream().flatMap(stateStoreLags -> stateStoreLags.getLagByPartition().values().stream()).mapToLong(LagInfoEntity::getEndOffsetPosition).max().orElse(0);
long current = hostStatusEntity.getHostStoreLags().getStateStoreLags().values().stream().flatMap(stateStoreLags -> stateStoreLags.getLagByPartition().values().stream()).mapToLong(LagInfoEntity::getCurrentOffsetPosition).max().orElse(0);
return Pair.of(current, end);
}
use of io.confluent.ksql.rest.entity.HostStatusEntity in project ksql by confluentinc.
the class HighAvailabilityTestUtil method waitForStreamsMetadataToInitialize.
static void waitForStreamsMetadataToInitialize(final TestKsqlRestApp restApp, List<KsqlHostInfoEntity> hosts, final Optional<BasicCredentials> credentials) {
while (true) {
ClusterStatusResponse clusterStatusResponse = HighAvailabilityTestUtil.sendClusterStatusRequest(restApp, credentials);
List<KsqlHostInfoEntity> initialized = hosts.stream().filter(hostInfo -> Optional.ofNullable(clusterStatusResponse.getClusterStatus().get(hostInfo)).map(hostStatusEntity -> hostStatusEntity.getActiveStandbyPerQuery().isEmpty()).isPresent()).collect(Collectors.toList());
if (initialized.size() == hosts.size())
break;
}
try {
Thread.sleep(200);
} catch (final Exception e) {
// Meh
}
}
Aggregations