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);
}
}
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);
}
}
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;
}
Aggregations