use of com.sequenceiq.cloudbreak.api.model.Status.AVAILABLE 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.Status.AVAILABLE in project cloudbreak by hortonworks.
the class ClusterDownscaleService method updateMetadata.
public void updateMetadata(Long stackId, Collection<String> hostNames, String hostGroupName) {
StackView stackView = stackService.getByIdView(stackId);
ClusterView clusterView = stackView.getClusterView();
hostNames.forEach(hn -> {
HostGroup hostGroup = hostGroupService.getByClusterIdAndName(clusterView.getId(), hostGroupName);
List<HostMetadata> hostMetaToRemove = hostGroup.getHostMetadata().stream().filter(md -> hostNames.contains(md.getHostName())).collect(Collectors.toList());
hostGroup.getHostMetadata().removeAll(hostMetaToRemove);
hostGroupService.save(hostGroup);
});
LOGGER.info("Start updating metadata");
for (String hostName : hostNames) {
stackService.updateMetaDataStatus(stackView.getId(), hostName, InstanceStatus.DECOMMISSIONED);
}
clusterService.updateClusterStatusByStackId(stackView.getId(), AVAILABLE);
flowMessageService.fireEventAndLog(stackId, Msg.AMBARI_CLUSTER_SCALED_DOWN, AVAILABLE.name());
}
Aggregations