Search in sources :

Example 26 with Cluster

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

the class AlertService method deletePrometheusAlert.

public void deletePrometheusAlert(Long clusterId, Long alertId) {
    PrometheusAlert alert = prometheusAlertRepository.findByCluster(alertId, clusterId);
    Cluster cluster = clusterRepository.findById(clusterId);
    consulKeyValueService.deleteAlert(cluster, alert);
    Set<PrometheusAlert> alerts = cluster.getPrometheusAlerts().stream().filter(a -> a.getId() != alertId).collect(Collectors.toSet());
    cluster.setPrometheusAlerts(alerts);
    prometheusAlertRepository.delete(alertId);
    clusterRepository.save(cluster);
    LOGGER.info("Prometheus alert '{}' has been deleted for cluster 'ID:{}'", alert.getName(), cluster.getId());
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) MetricAlertRepository(com.sequenceiq.periscope.repository.MetricAlertRepository) Service(org.springframework.stereotype.Service) Map(java.util.Map) MDCBuilder(com.sequenceiq.periscope.log.MDCBuilder) AlertRuleDefinitionEntry(com.sequenceiq.periscope.api.model.AlertRuleDefinitionEntry) PrometheusAlert(com.sequenceiq.periscope.domain.PrometheusAlert) ClusterRepository(com.sequenceiq.periscope.repository.ClusterRepository) Logger(org.slf4j.Logger) Cluster(com.sequenceiq.periscope.domain.Cluster) Set(java.util.Set) Collectors(java.util.stream.Collectors) TimeAlertRepository(com.sequenceiq.periscope.repository.TimeAlertRepository) List(java.util.List) FreeMarkerTemplateUtils.processTemplateIntoString(org.springframework.ui.freemarker.FreeMarkerTemplateUtils.processTemplateIntoString) AmbariClientProvider(com.sequenceiq.periscope.utils.AmbariClientProvider) Configuration(freemarker.template.Configuration) Entry(java.util.Map.Entry) MetricAlert(com.sequenceiq.periscope.domain.MetricAlert) CommonService(com.sequenceiq.ambari.client.services.CommonService) BaseAlert(com.sequenceiq.periscope.domain.BaseAlert) TimeAlert(com.sequenceiq.periscope.domain.TimeAlert) PrometheusAlertRepository(com.sequenceiq.periscope.repository.PrometheusAlertRepository) Collections(java.util.Collections) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) PrometheusAlert(com.sequenceiq.periscope.domain.PrometheusAlert) Cluster(com.sequenceiq.periscope.domain.Cluster)

Example 27 with Cluster

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

the class AlertService method deleteMetricAlert.

public void deleteMetricAlert(Long clusterId, Long alertId) {
    metricAlertRepository.findByCluster(alertId, clusterId);
    Cluster cluster = clusterRepository.findById(clusterId);
    cluster.setMetricAlerts(removeMetricAlert(cluster, alertId));
    metricAlertRepository.delete(alertId);
    clusterRepository.save(cluster);
}
Also used : Cluster(com.sequenceiq.periscope.domain.Cluster)

Example 28 with Cluster

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

the class AlertService method createTimeAlert.

public TimeAlert createTimeAlert(Long clusterId, TimeAlert alert) {
    Cluster cluster = clusterService.findOneById(clusterId);
    alert.setCluster(cluster);
    alert = (TimeAlert) save(alert);
    cluster.addTimeAlert(alert);
    clusterRepository.save(cluster);
    return alert;
}
Also used : Cluster(com.sequenceiq.periscope.domain.Cluster)

Example 29 with Cluster

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

the class ClusterService method updateScalingConfiguration.

public Cluster updateScalingConfiguration(Long clusterId, ScalingConfigurationRequest scalingConfiguration) {
    Cluster cluster = findOneById(clusterId);
    cluster.setMinSize(scalingConfiguration.getMinSize());
    cluster.setMaxSize(scalingConfiguration.getMaxSize());
    cluster.setCoolDown(scalingConfiguration.getCoolDown());
    return save(cluster);
}
Also used : Cluster(com.sequenceiq.periscope.domain.Cluster)

Example 30 with Cluster

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

the class ClusterService method getScalingConfiguration.

public ScalingConfigurationRequest getScalingConfiguration(Long clusterId) {
    Cluster cluster = findOneById(clusterId);
    ScalingConfigurationRequest configuration = new ScalingConfigurationRequest();
    configuration.setCoolDown(cluster.getCoolDown());
    configuration.setMaxSize(cluster.getMaxSize());
    configuration.setMinSize(cluster.getMinSize());
    return configuration;
}
Also used : ScalingConfigurationRequest(com.sequenceiq.periscope.api.model.ScalingConfigurationRequest) 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