Search in sources :

Example 1 with AutoscaleClusterResponse

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;
}
Also used : AutoscaleClusterResponse(com.sequenceiq.periscope.api.model.AutoscaleClusterResponse) ScalingConfigurationRequest(com.sequenceiq.periscope.api.model.ScalingConfigurationRequest) TimeAlertResponse(com.sequenceiq.periscope.api.model.TimeAlertResponse) PrometheusAlertResponse(com.sequenceiq.periscope.api.model.PrometheusAlertResponse) MetricAlertResponse(com.sequenceiq.periscope.api.model.MetricAlertResponse)

Example 2 with AutoscaleClusterResponse

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;
}
Also used : AutoscaleClusterResponse(com.sequenceiq.periscope.api.model.AutoscaleClusterResponse) AutoScaleClusterV1Endpoint(com.sequenceiq.periscope.api.endpoint.v1.AutoScaleClusterV1Endpoint) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) ConfigurationEndpoint(com.sequenceiq.periscope.api.endpoint.v1.ConfigurationEndpoint) AlertEndpoint(com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint) PolicyEndpoint(com.sequenceiq.periscope.api.endpoint.v1.PolicyEndpoint) AutoScaleClusterV1Endpoint(com.sequenceiq.periscope.api.endpoint.v1.AutoScaleClusterV1Endpoint)

Aggregations

AutoscaleClusterResponse (com.sequenceiq.periscope.api.model.AutoscaleClusterResponse)2 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)1 AlertEndpoint (com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint)1 AutoScaleClusterV1Endpoint (com.sequenceiq.periscope.api.endpoint.v1.AutoScaleClusterV1Endpoint)1 ConfigurationEndpoint (com.sequenceiq.periscope.api.endpoint.v1.ConfigurationEndpoint)1 PolicyEndpoint (com.sequenceiq.periscope.api.endpoint.v1.PolicyEndpoint)1 MetricAlertResponse (com.sequenceiq.periscope.api.model.MetricAlertResponse)1 PrometheusAlertResponse (com.sequenceiq.periscope.api.model.PrometheusAlertResponse)1 ScalingConfigurationRequest (com.sequenceiq.periscope.api.model.ScalingConfigurationRequest)1 TimeAlertResponse (com.sequenceiq.periscope.api.model.TimeAlertResponse)1