use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.
the class UpdateFailedHandler method onApplicationEvent.
@Override
public void onApplicationEvent(UpdateFailedEvent event) {
long id = event.getClusterId();
Cluster cluster = clusterService.find(id);
MDCBuilder.buildMdcContext(cluster);
Integer failed = updateFailures.get(id);
if (failed == null) {
updateFailures.put(id, 1);
} else if (RETRY_THRESHOLD - 1 == failed) {
try {
CloudbreakClient cloudbreakClient = cloudbreakClientConfiguration.cloudbreakClient();
StackResponse stackResponse = cloudbreakClient.stackV1Endpoint().get(cluster.getStackId(), new HashSet<>());
String stackStatus = stackResponse.getStatus().name();
String clusterStatus = stackResponse.getCluster().getStatus().name();
if (stackStatus.startsWith(DELETE_STATUSES_PREFIX)) {
clusterService.removeById(id);
LOGGER.info("Delete cluster due to failing update attempts and Cloudbreak stack status");
} else if (stackStatus.equals(AVAILABLE) && clusterStatus.equals(AVAILABLE)) {
// Ambari server is unreacheable but the stack and cluster statuses are "AVAILABLE"
reportAmbariServerFailure(cluster, stackResponse, cloudbreakClient);
suspendCluster(cluster);
} else {
suspendCluster(cluster);
}
} catch (Exception ex) {
LOGGER.warn("Cluster status could not be verified by Cloudbreak for remove.", ex);
suspendCluster(cluster);
}
updateFailures.remove(id);
} else {
updateFailures.put(id, failed + 1);
}
}
use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.
the class AutoScaleClusterCommonService method setState.
public AutoscaleClusterResponse setState(Long clusterId, StateJson stateJson) {
PeriscopeUser user = authenticatedUserService.getPeriscopeUser();
MDCBuilder.buildMdcContext(user, clusterId);
Cluster cluster = clusterService.setState(clusterId, stateJson.getState());
createHistoryAndNotification(cluster);
return createClusterJsonResponse(cluster);
}
use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.
the class AutoScaleClusterCommonService method setAutoscaleState.
public AutoscaleClusterResponse setAutoscaleState(Long clusterId, AutoscaleClusterState autoscaleState) {
PeriscopeUser user = authenticatedUserService.getPeriscopeUser();
MDCBuilder.buildMdcContext(user, clusterId);
Cluster cluster = clusterService.setAutoscaleState(clusterId, autoscaleState.isEnableAutoscaling());
createHistoryAndNotification(cluster);
return createClusterJsonResponse(cluster);
}
use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.
the class AbstractMonitor method execute.
@Override
public void execute(JobExecutionContext context) {
MDCBuilder.buildMdcContext();
evalContext(context);
for (Cluster cluster : getClusters()) {
EvaluatorExecutor evaluatorExecutor = applicationContext.getBean(getEvaluatorType().getSimpleName(), EvaluatorExecutor.class);
evaluatorExecutor.setContext(getContext(cluster));
executorService.submit(evaluatorExecutor);
}
}
use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.
the class AlertService method deleteTimeAlert.
public void deleteTimeAlert(Long clusterId, Long alertId) {
Cluster cluster = clusterService.findOneById(clusterId);
timeAlertRepository.findByCluster(alertId, clusterId);
cluster.setTimeAlerts(removeTimeAlert(cluster, alertId));
timeAlertRepository.delete(alertId);
clusterRepository.save(cluster);
}
Aggregations