Search in sources :

Example 6 with KsqlQueryStatus

use of io.confluent.ksql.util.KsqlConstants.KsqlQueryStatus in project ksql by confluentinc.

the class ListQueriesExecutor method mergeExtended.

private static Map<QueryId, QueryDescription> mergeExtended(final Map<QueryId, QueryDescription> allResults, final Pair<Map<HostInfo, KsqlEntity>, Set<HostInfo>> remoteResults) {
    final List<QueryDescription> remoteQueryDescriptions = remoteResults.getLeft().values().stream().map(QueryDescriptionList.class::cast).map(QueryDescriptionList::getQueryDescriptions).flatMap(List::stream).collect(Collectors.toList());
    for (QueryDescription q : remoteQueryDescriptions) {
        final QueryId queryId = q.getId();
        // and the streams metadata task set
        if (allResults.containsKey(queryId)) {
            for (Map.Entry<KsqlHostInfoEntity, KsqlQueryStatus> entry : q.getKsqlHostQueryStatus().entrySet()) {
                allResults.get(queryId).updateKsqlHostQueryStatus(entry.getKey(), entry.getValue());
            }
            allResults.get(queryId).updateTaskMetadata(q.getTasksMetadata());
        } else {
            allResults.put(queryId, q);
        }
    }
    final Set<HostInfo> unresponsiveRemoteHosts = remoteResults.getRight();
    for (HostInfo hostInfo : unresponsiveRemoteHosts) {
        for (QueryDescription queryDescription : allResults.values()) {
            queryDescription.updateKsqlHostQueryStatus(new KsqlHostInfoEntity(hostInfo.host(), hostInfo.port()), KsqlQueryStatus.UNRESPONSIVE);
        }
    }
    return allResults;
}
Also used : QueryId(io.confluent.ksql.query.QueryId) QueryDescriptionList(io.confluent.ksql.rest.entity.QueryDescriptionList) KsqlHostInfoEntity(io.confluent.ksql.rest.entity.KsqlHostInfoEntity) QueryDescription(io.confluent.ksql.rest.entity.QueryDescription) Map(java.util.Map) HostInfo(org.apache.kafka.streams.state.HostInfo) KsqlQueryStatus(io.confluent.ksql.util.KsqlConstants.KsqlQueryStatus)

Aggregations

KsqlQueryStatus (io.confluent.ksql.util.KsqlConstants.KsqlQueryStatus)6 ListQueries (io.confluent.ksql.parser.tree.ListQueries)5 KsqlHostInfoEntity (io.confluent.ksql.rest.entity.KsqlHostInfoEntity)5 QueryDescriptionList (io.confluent.ksql.rest.entity.QueryDescriptionList)5 KsqlEngine (io.confluent.ksql.engine.KsqlEngine)4 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)4 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)4 Test (org.junit.Test)4 QueryDescription (io.confluent.ksql.rest.entity.QueryDescription)3 HashMap (java.util.HashMap)3 QueryId (io.confluent.ksql.query.QueryId)2 Map (java.util.Map)2 HostInfo (org.apache.kafka.streams.state.HostInfo)2 KsqlRestClientException (io.confluent.ksql.rest.client.exception.KsqlRestClientException)1 KsqlErrorMessage (io.confluent.ksql.rest.entity.KsqlErrorMessage)1 Queries (io.confluent.ksql.rest.entity.Queries)1 RunningQuery (io.confluent.ksql.rest.entity.RunningQuery)1 StreamsTaskMetadata (io.confluent.ksql.rest.entity.StreamsTaskMetadata)1