Search in sources :

Example 1 with ActiveStandbyEntity

use of io.confluent.ksql.rest.entity.ActiveStandbyEntity in project ksql by confluentinc.

the class PullQueryConsistencyFunctionalTest method findClusterFormation.

private ClusterFormation findClusterFormation(TestApp testApp0, TestApp testApp1, TestApp testApp2) {
    ClusterFormation clusterFormation = new ClusterFormation();
    ClusterStatusResponse clusterStatusResponse = HighAvailabilityTestUtil.sendClusterStatusRequest(testApp0.getApp(), USER_CREDS);
    ActiveStandbyEntity entity0 = clusterStatusResponse.getClusterStatus().get(testApp0.getHost()).getActiveStandbyPerQuery().get(queryId);
    ActiveStandbyEntity entity1 = clusterStatusResponse.getClusterStatus().get(testApp1.getHost()).getActiveStandbyPerQuery().get(queryId);
    // find active
    if (!entity0.getActiveStores().isEmpty() && !entity0.getActivePartitions().isEmpty()) {
        clusterFormation.setActive(testApp0);
    } else if (!entity1.getActiveStores().isEmpty() && !entity1.getActivePartitions().isEmpty()) {
        clusterFormation.setActive(testApp1);
    } else {
        clusterFormation.setActive(testApp2);
    }
    // find standby
    if (!entity0.getStandByStores().isEmpty() && !entity0.getStandByPartitions().isEmpty()) {
        clusterFormation.setStandBy(testApp0);
    } else if (!entity1.getStandByStores().isEmpty() && !entity1.getStandByPartitions().isEmpty()) {
        clusterFormation.setStandBy(testApp1);
    } else {
        clusterFormation.setStandBy(testApp2);
    }
    // find router
    if (entity0.getStandByStores().isEmpty() && entity0.getActiveStores().isEmpty()) {
        clusterFormation.setRouter(testApp0);
    } else if (entity1.getStandByStores().isEmpty() && entity1.getActiveStores().isEmpty()) {
        clusterFormation.setRouter(testApp1);
    } else {
        clusterFormation.setRouter(testApp2);
    }
    return clusterFormation;
}
Also used : ClusterStatusResponse(io.confluent.ksql.rest.entity.ClusterStatusResponse) ActiveStandbyEntity(io.confluent.ksql.rest.entity.ActiveStandbyEntity)

Example 2 with ActiveStandbyEntity

use of io.confluent.ksql.rest.entity.ActiveStandbyEntity in project ksql by confluentinc.

the class PullQueryRoutingFunctionalTest method findClusterFormation.

private ClusterFormation findClusterFormation(TestApp testApp0, TestApp testApp1, TestApp testApp2) {
    ClusterFormation clusterFormation = new ClusterFormation();
    ClusterStatusResponse clusterStatusResponse = HighAvailabilityTestUtil.sendClusterStatusRequest(testApp0.getApp(), USER_CREDS);
    ActiveStandbyEntity entity0 = clusterStatusResponse.getClusterStatus().get(testApp0.getHost()).getActiveStandbyPerQuery().get(queryId);
    ActiveStandbyEntity entity1 = clusterStatusResponse.getClusterStatus().get(testApp1.getHost()).getActiveStandbyPerQuery().get(queryId);
    // find active
    if (!entity0.getActiveStores().isEmpty() && !entity0.getActivePartitions().isEmpty()) {
        clusterFormation.setActive(testApp0);
    } else if (!entity1.getActiveStores().isEmpty() && !entity1.getActivePartitions().isEmpty()) {
        clusterFormation.setActive(testApp1);
    } else {
        clusterFormation.setActive(testApp2);
    }
    // find standby
    if (!entity0.getStandByStores().isEmpty() && !entity0.getStandByPartitions().isEmpty()) {
        clusterFormation.setStandBy(testApp0);
    } else if (!entity1.getStandByStores().isEmpty() && !entity1.getStandByPartitions().isEmpty()) {
        clusterFormation.setStandBy(testApp1);
    } else {
        clusterFormation.setStandBy(testApp2);
    }
    // find router
    if (entity0.getStandByStores().isEmpty() && entity0.getActiveStores().isEmpty()) {
        clusterFormation.setRouter(testApp0);
    } else if (entity1.getStandByStores().isEmpty() && entity1.getActiveStores().isEmpty()) {
        clusterFormation.setRouter(testApp1);
    } else {
        clusterFormation.setRouter(testApp2);
    }
    return clusterFormation;
}
Also used : ClusterStatusResponse(io.confluent.ksql.rest.entity.ClusterStatusResponse) ActiveStandbyEntity(io.confluent.ksql.rest.entity.ActiveStandbyEntity)

Example 3 with ActiveStandbyEntity

use of io.confluent.ksql.rest.entity.ActiveStandbyEntity in project ksql by confluentinc.

the class ClusterStatusResource method getActiveStandbyInformation.

private Map<String, ActiveStandbyEntity> getActiveStandbyInformation(final KsqlHostInfo ksqlHostInfo) {
    final Map<String, ActiveStandbyEntity> perQueryMap = new HashMap<>();
    for (PersistentQueryMetadata persistentQueryMetadata : engine.getPersistentQueries()) {
        for (StreamsMetadata streamsMetadata : persistentQueryMetadata.getAllStreamsHostMetadata()) {
            if (!streamsMetadata.hostInfo().equals(asHostInfo(ksqlHostInfo))) {
                continue;
            }
            final QueryIdAndStreamsMetadata queryIdAndStreamsMetadata = new QueryIdAndStreamsMetadata(persistentQueryMetadata.getQueryId().toString(), streamsMetadata);
            perQueryMap.putIfAbsent(queryIdAndStreamsMetadata.queryId, queryIdAndStreamsMetadata.toActiveStandbyEntity());
        }
    }
    return perQueryMap;
}
Also used : HashMap(java.util.HashMap) StreamsMetadata(org.apache.kafka.streams.StreamsMetadata) ActiveStandbyEntity(io.confluent.ksql.rest.entity.ActiveStandbyEntity) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata)

Aggregations

ActiveStandbyEntity (io.confluent.ksql.rest.entity.ActiveStandbyEntity)3 ClusterStatusResponse (io.confluent.ksql.rest.entity.ClusterStatusResponse)2 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)1 HashMap (java.util.HashMap)1 StreamsMetadata (org.apache.kafka.streams.StreamsMetadata)1