Search in sources :

Example 21 with Cluster

use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.

the class UpdateFailedHandler method onApplicationEvent.

@Override
public void onApplicationEvent(UpdateFailedEvent event) {
    long id = event.getClusterId();
    Cluster cluster = clusterService.find(id);
    MDCBuilder.buildMdcContext(cluster);
    Integer failed = updateFailures.get(id);
    if (failed == null) {
        updateFailures.put(id, 1);
    } else if (RETRY_THRESHOLD - 1 == failed) {
        try {
            CloudbreakClient cloudbreakClient = cloudbreakClientConfiguration.cloudbreakClient();
            StackResponse stackResponse = cloudbreakClient.stackV1Endpoint().get(cluster.getStackId(), new HashSet<>());
            String stackStatus = stackResponse.getStatus().name();
            String clusterStatus = stackResponse.getCluster().getStatus().name();
            if (stackStatus.startsWith(DELETE_STATUSES_PREFIX)) {
                clusterService.removeById(id);
                LOGGER.info("Delete cluster due to failing update attempts and Cloudbreak stack status");
            } else if (stackStatus.equals(AVAILABLE) && clusterStatus.equals(AVAILABLE)) {
                // Ambari server is unreacheable but the stack and cluster statuses are "AVAILABLE"
                reportAmbariServerFailure(cluster, stackResponse, cloudbreakClient);
                suspendCluster(cluster);
            } else {
                suspendCluster(cluster);
            }
        } catch (Exception ex) {
            LOGGER.warn("Cluster status could not be verified by Cloudbreak for remove.", ex);
            suspendCluster(cluster);
        }
        updateFailures.remove(id);
    } else {
        updateFailures.put(id, failed + 1);
    }
}
Also used : CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) Cluster(com.sequenceiq.periscope.domain.Cluster) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) HashSet(java.util.HashSet)

Example 22 with Cluster

use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.

the class AutoScaleClusterCommonService method setState.

public AutoscaleClusterResponse setState(Long clusterId, StateJson stateJson) {
    PeriscopeUser user = authenticatedUserService.getPeriscopeUser();
    MDCBuilder.buildMdcContext(user, clusterId);
    Cluster cluster = clusterService.setState(clusterId, stateJson.getState());
    createHistoryAndNotification(cluster);
    return createClusterJsonResponse(cluster);
}
Also used : PeriscopeUser(com.sequenceiq.periscope.domain.PeriscopeUser) Cluster(com.sequenceiq.periscope.domain.Cluster)

Example 23 with Cluster

use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.

the class AutoScaleClusterCommonService method setAutoscaleState.

public AutoscaleClusterResponse setAutoscaleState(Long clusterId, AutoscaleClusterState autoscaleState) {
    PeriscopeUser user = authenticatedUserService.getPeriscopeUser();
    MDCBuilder.buildMdcContext(user, clusterId);
    Cluster cluster = clusterService.setAutoscaleState(clusterId, autoscaleState.isEnableAutoscaling());
    createHistoryAndNotification(cluster);
    return createClusterJsonResponse(cluster);
}
Also used : PeriscopeUser(com.sequenceiq.periscope.domain.PeriscopeUser) Cluster(com.sequenceiq.periscope.domain.Cluster)

Example 24 with Cluster

use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.

the class AbstractMonitor method execute.

@Override
public void execute(JobExecutionContext context) {
    MDCBuilder.buildMdcContext();
    evalContext(context);
    for (Cluster cluster : getClusters()) {
        EvaluatorExecutor evaluatorExecutor = applicationContext.getBean(getEvaluatorType().getSimpleName(), EvaluatorExecutor.class);
        evaluatorExecutor.setContext(getContext(cluster));
        executorService.submit(evaluatorExecutor);
    }
}
Also used : Cluster(com.sequenceiq.periscope.domain.Cluster) EvaluatorExecutor(com.sequenceiq.periscope.monitor.evaluator.EvaluatorExecutor)

Example 25 with Cluster

use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.

the class AlertService method deleteTimeAlert.

public void deleteTimeAlert(Long clusterId, Long alertId) {
    Cluster cluster = clusterService.findOneById(clusterId);
    timeAlertRepository.findByCluster(alertId, clusterId);
    cluster.setTimeAlerts(removeTimeAlert(cluster, alertId));
    timeAlertRepository.delete(alertId);
    clusterRepository.save(cluster);
}
Also used : Cluster(com.sequenceiq.periscope.domain.Cluster)

Aggregations

Cluster (com.sequenceiq.periscope.domain.Cluster)34 Map (java.util.Map)6 PrometheusAlert (com.sequenceiq.periscope.domain.PrometheusAlert)5 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)4 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)4 MetricAlert (com.sequenceiq.periscope.domain.MetricAlert)4 PeriscopeUser (com.sequenceiq.periscope.domain.PeriscopeUser)4 UpdateFailedEvent (com.sequenceiq.periscope.monitor.event.UpdateFailedEvent)4 TimeAlert (com.sequenceiq.periscope.domain.TimeAlert)3 ScalingEvent (com.sequenceiq.periscope.monitor.event.ScalingEvent)3 Collections (java.util.Collections)3 List (java.util.List)3 Set (java.util.Set)3 Inject (javax.inject.Inject)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Component (org.springframework.stereotype.Component)3 AutoscaleStackResponse (com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse)2 FailureReport (com.sequenceiq.cloudbreak.api.model.FailureReport)2 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)2