Search in sources :

Example 1 with ClusterState

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

the class ClusterService method update.

public Cluster update(Long clusterId, AmbariStack stack, boolean withPermissionCheck, ClusterState clusterState, boolean enableAutoscaling) {
    Cluster cluster = withPermissionCheck ? findOneById(clusterId) : find(clusterId);
    ClusterState newState = clusterState != null ? clusterState : cluster.getState();
    cluster.setState(newState);
    cluster.setAutoscalingEnabled(enableAutoscaling);
    cluster.update(stack);
    SecurityConfig sSecConf = stack.getSecurityConfig();
    if (sSecConf != null) {
        SecurityConfig updatedConfig = sSecConf;
        SecurityConfig securityConfig = securityConfigRepository.findByClusterId(clusterId);
        if (securityConfig != null) {
            securityConfig.update(updatedConfig);
            securityConfigRepository.save(securityConfig);
        } else {
            SecurityConfig sc = new SecurityConfig(sSecConf.getClientKey(), sSecConf.getClientCert(), sSecConf.getServerCert());
            sc.setCluster(cluster);
            sc = securityConfigRepository.save(sc);
            cluster.setSecurityConfig(sc);
        }
    }
    cluster = save(cluster);
    addPrometheusAlertsToConsul(cluster);
    return cluster;
}
Also used : ClusterState(com.sequenceiq.periscope.api.model.ClusterState) SecurityConfig(com.sequenceiq.periscope.domain.SecurityConfig) Cluster(com.sequenceiq.periscope.domain.Cluster)

Aggregations

ClusterState (com.sequenceiq.periscope.api.model.ClusterState)1 Cluster (com.sequenceiq.periscope.domain.Cluster)1 SecurityConfig (com.sequenceiq.periscope.domain.SecurityConfig)1