Search in sources :

Example 1 with AutoscaleClusterHistoryResponse

use of com.sequenceiq.periscope.api.model.AutoscaleClusterHistoryResponse in project cloudbreak by hortonworks.

the class CloudbreakUtil method waitForAutoScalingEvent.

public static WaitResult waitForAutoScalingEvent(AutoscaleClient autoscaleClient, Long clusterId, Long currentTime) {
    WaitResult waitResult = WaitResult.SUCCESSFUL;
    Boolean exitCriteria = FALSE;
    int retryCount = 0;
    do {
        LOGGER.info("Waiting for auto scaling event is success ...");
        sleep();
        HistoryEndpoint historyEndpoint = autoscaleClient.historyEndpoint();
        List<AutoscaleClusterHistoryResponse> autoscaleClusterHistoryResponse = historyEndpoint.getHistory(clusterId);
        for (AutoscaleClusterHistoryResponse elem : autoscaleClusterHistoryResponse) {
            if ((elem.getTimestamp() > currentTime) && "SUCCESS".equals(elem.getScalingStatus().toString())) {
                exitCriteria = Boolean.TRUE;
            }
        }
        retryCount++;
    } while (!exitCriteria && retryCount < MAX_RETRY);
    LOGGER.info("Auto scaling event happened successfully");
    if (retryCount == MAX_RETRY) {
        waitResult = WaitResult.TIMEOUT;
    }
    return waitResult;
}
Also used : AutoscaleClusterHistoryResponse(com.sequenceiq.periscope.api.model.AutoscaleClusterHistoryResponse) HistoryEndpoint(com.sequenceiq.periscope.api.endpoint.v1.HistoryEndpoint) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) StackEndpoint(com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint) HistoryEndpoint(com.sequenceiq.periscope.api.endpoint.v1.HistoryEndpoint) EventEndpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint)

Example 2 with AutoscaleClusterHistoryResponse

use of com.sequenceiq.periscope.api.model.AutoscaleClusterHistoryResponse in project cloudbreak by hortonworks.

the class HistoryConverter method convert.

@Override
public AutoscaleClusterHistoryResponse convert(History source) {
    AutoscaleClusterHistoryResponse json = new AutoscaleClusterHistoryResponse();
    json.setId(source.getId());
    json.setAdjustment(source.getAdjustment());
    json.setAdjustmentType(source.getAdjustmentType());
    json.setAlertType(source.getAlertType());
    json.setCbStackId(source.getCbStackId());
    json.setClusterId(source.getClusterId());
    json.setHostGroup(source.getHostGroup());
    json.setOriginalNodeCount(source.getOriginalNodeCount());
    json.setProperties(source.getProperties());
    json.setScalingStatus(source.getScalingStatus());
    json.setTimestamp(source.getTimestamp());
    json.setStatusReason(source.getStatusReason());
    return json;
}
Also used : AutoscaleClusterHistoryResponse(com.sequenceiq.periscope.api.model.AutoscaleClusterHistoryResponse)

Aggregations

AutoscaleClusterHistoryResponse (com.sequenceiq.periscope.api.model.AutoscaleClusterHistoryResponse)2 StackEndpoint (com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint)1 EventEndpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint)1 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)1 HistoryEndpoint (com.sequenceiq.periscope.api.endpoint.v1.HistoryEndpoint)1