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;
}
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;
}
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;
}
Aggregations