Search in sources :

Example 1 with AutoscaleStackResponse

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

the class ClusterCreationEvaluator method run.

@Override
public void run() {
    AutoscaleStackResponse stack = context.getStack();
    Optional<Cluster> clusterOptional = context.getClusterOptional();
    try {
        createOrUpdateCluster(stack, clusterOptional);
    } catch (AmbariHealtCheckException ahf) {
        LOGGER.warn(String.format("Ambari health check failed for Cloudbreak stack: %s(ID:%s)", stack.getStackId(), stack.getName()), ahf);
    } catch (TlsConfigurationException ex) {
        LOGGER.warn(String.format("Could not prepare TLS configuration for Cloudbreak stack: %s(ID:%s)", stack.getStackId(), stack.getName()), ex);
    } catch (Exception ex) {
        LOGGER.warn(String.format("Could not create cluster for Cloudbreak stack: %s(ID:%s)", stack.getStackId(), stack.getName()), ex);
    }
}
Also used : TlsConfigurationException(com.sequenceiq.periscope.service.security.TlsConfigurationException) AutoscaleStackResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse) Cluster(com.sequenceiq.periscope.domain.Cluster) TlsConfigurationException(com.sequenceiq.periscope.service.security.TlsConfigurationException)

Example 2 with AutoscaleStackResponse

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

the class ClusterMonitor method execute.

@Override
public void execute(JobExecutionContext context) {
    evalContext(context);
    try {
        CloudbreakClient cloudbreakClient = applicationContext.getBean(CloudbreakClientConfiguration.class).cloudbreakClient();
        ClusterService clusterService = applicationContext.getBean(ClusterService.class);
        List<Cluster> clusters = clusterService.findAll();
        Set<AutoscaleStackResponse> allStacks = cloudbreakClient.stackV1Endpoint().getAllForAutoscale();
        for (AutoscaleStackResponse stack : allStacks) {
            Status clusterStatus = stack.getClusterStatus();
            if (clusterStatus != null && AVAILABLE.equals(clusterStatus)) {
                String ambariIp = stack.getAmbariServerIp();
                Optional<Cluster> clusterOptional = clusters.stream().filter(c -> c.getStackId() != null && c.getStackId().equals(stack.getStackId())).findFirst();
                if (ambariIp != null) {
                    ClusterCreationEvaluator clusterCreationEvaluator = applicationContext.getBean(ClusterCreationEvaluator.class);
                    clusterCreationEvaluator.setContext(new ClusterCreationEvaluatorContext(stack, clusterOptional));
                    executorService.submit(clusterCreationEvaluator);
                } else {
                    LOGGER.info("Could not find Ambari for stack: {}(ID:{})", stack.getName(), stack.getStackId());
                }
            } else {
                LOGGER.info("Do not create or update cluster while the Cloudbreak cluster {}(ID:{}) is in '{}' state instead of 'AVAILABLE'!", stack.getName(), stack.getStackId(), stack.getClusterStatus());
            }
        }
    } catch (Exception ex) {
        LOGGER.error("New clusters could not be synchronized from Cloudbreak.", ex);
    }
}
Also used : Status(com.sequenceiq.cloudbreak.api.model.Status) JobExecutionContext(org.quartz.JobExecutionContext) EvaluatorContext(com.sequenceiq.periscope.monitor.evaluator.EvaluatorContext) Logger(org.slf4j.Logger) Cluster(com.sequenceiq.periscope.domain.Cluster) AVAILABLE(com.sequenceiq.cloudbreak.api.model.Status.AVAILABLE) LoggerFactory(org.slf4j.LoggerFactory) AutoscaleStackResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse) Set(java.util.Set) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) ApplicationContext(org.springframework.context.ApplicationContext) ClusterCreationEvaluator(com.sequenceiq.periscope.monitor.evaluator.ClusterCreationEvaluator) Status(com.sequenceiq.cloudbreak.api.model.Status) List(java.util.List) Component(org.springframework.stereotype.Component) JobDataMap(org.quartz.JobDataMap) ClusterCreationEvaluatorContext(com.sequenceiq.periscope.model.ClusterCreationEvaluatorContext) Map(java.util.Map) Optional(java.util.Optional) Collections(java.util.Collections) ExecutorService(java.util.concurrent.ExecutorService) CloudbreakClientConfiguration(com.sequenceiq.periscope.service.configuration.CloudbreakClientConfiguration) ClusterService(com.sequenceiq.periscope.service.ClusterService) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) ClusterCreationEvaluatorContext(com.sequenceiq.periscope.model.ClusterCreationEvaluatorContext) Cluster(com.sequenceiq.periscope.domain.Cluster) CloudbreakClientConfiguration(com.sequenceiq.periscope.service.configuration.CloudbreakClientConfiguration) ClusterService(com.sequenceiq.periscope.service.ClusterService) AutoscaleStackResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse) ClusterCreationEvaluator(com.sequenceiq.periscope.monitor.evaluator.ClusterCreationEvaluator)

Example 3 with AutoscaleStackResponse

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

the class StackToAutoscaleStackResponseJsonConverter method convert.

@Override
public AutoscaleStackResponse convert(Stack source) {
    AutoscaleStackResponse result = new AutoscaleStackResponse();
    result.setStackId(source.getId());
    result.setName(source.getName());
    result.setOwner(source.getOwner());
    result.setAccount(source.getOwner());
    result.setGatewayPort(source.getGatewayPort());
    result.setCreated(source.getCreated());
    result.setStatus(source.getStatus());
    if (source.getCluster() != null) {
        Cluster cluster = source.getCluster();
        String gatewayIp = gatewayConfigService.getPrimaryGatewayIp(source);
        result.setAmbariServerIp(gatewayIp);
        result.setUserName(cluster.getUserName());
        result.setPassword(cluster.getPassword());
        result.setClusterStatus(cluster.getStatus());
    }
    return result;
}
Also used : AutoscaleStackResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse) Cluster(com.sequenceiq.cloudbreak.domain.Cluster)

Aggregations

AutoscaleStackResponse (com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse)3 Cluster (com.sequenceiq.periscope.domain.Cluster)2 Status (com.sequenceiq.cloudbreak.api.model.Status)1 AVAILABLE (com.sequenceiq.cloudbreak.api.model.Status.AVAILABLE)1 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 ClusterCreationEvaluatorContext (com.sequenceiq.periscope.model.ClusterCreationEvaluatorContext)1 ClusterCreationEvaluator (com.sequenceiq.periscope.monitor.evaluator.ClusterCreationEvaluator)1 EvaluatorContext (com.sequenceiq.periscope.monitor.evaluator.EvaluatorContext)1 ClusterService (com.sequenceiq.periscope.service.ClusterService)1 CloudbreakClientConfiguration (com.sequenceiq.periscope.service.configuration.CloudbreakClientConfiguration)1 TlsConfigurationException (com.sequenceiq.periscope.service.security.TlsConfigurationException)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 ExecutorService (java.util.concurrent.ExecutorService)1 JobDataMap (org.quartz.JobDataMap)1 JobExecutionContext (org.quartz.JobExecutionContext)1