use of com.sequenceiq.periscope.api.model.AutoscaleClusterResponse in project cloudbreak by hortonworks.
the class ClusterConverter method convert.
@Override
public AutoscaleClusterResponse convert(Cluster source) {
AutoscaleClusterResponse json = new AutoscaleClusterResponse(source.getHost(), source.getPort(), source.getAmbariUser(), source.getStackId(), source.isAutoscalingEnabled(), source.getId(), source.getState().name());
if (!source.getMetricAlerts().isEmpty()) {
List<MetricAlertResponse> metricAlerts = metricAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getMetricAlerts()));
json.setMetricAlerts(metricAlerts);
}
if (!source.getTimeAlerts().isEmpty()) {
List<TimeAlertResponse> timeAlertRequests = timeAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getTimeAlerts()));
json.setTimeAlerts(timeAlertRequests);
}
if (!source.getPrometheusAlerts().isEmpty()) {
List<PrometheusAlertResponse> prometheusAlertRequests = prometheusAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getPrometheusAlerts()));
json.setPrometheusAlerts(prometheusAlertRequests);
}
ScalingConfigurationRequest scalingConfig = new ScalingConfigurationRequest(source.getMinSize(), source.getMaxSize(), source.getCoolDown());
json.setScalingConfiguration(scalingConfig);
return json;
}
use of com.sequenceiq.periscope.api.model.AutoscaleClusterResponse in project cloudbreak by hortonworks.
the class AutoscalingUtil method getPeriscopeClusterId.
static long getPeriscopeClusterId(AutoscaleClient autoscaleClient, String stackId) {
Long clusterId = null;
int retryCount = 0;
AutoScaleClusterV1Endpoint autoScaleClusterV1Endpoint = autoscaleClient.clusterEndpoint();
while (clusterId == null && retryCount < 30) {
LOGGER.info("Waiting for having Prometheus cluster id ...");
CloudbreakUtil.sleep();
List<AutoscaleClusterResponse> autoscaleClusterResponse = autoScaleClusterV1Endpoint.getClusters();
for (AutoscaleClusterResponse elem : autoscaleClusterResponse) {
if (String.valueOf(elem.getStackId()).equals(stackId)) {
clusterId = elem.getId();
}
}
retryCount += 1;
}
Assert.assertNotNull(clusterId);
return clusterId;
}
Aggregations