use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.
the class AutoScaleClusterCommonService method getClusters.
public List<AutoscaleClusterResponse> getClusters() {
PeriscopeUser user = authenticatedUserService.getPeriscopeUser();
MDCBuilder.buildUserMdcContext(user);
List<Cluster> clusters = clusterService.findAllByUser(user);
return clusterConverter.convertAllToJson(clusters);
}
use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.
the class AutoScaleClusterCommonService method setCluster.
private AutoscaleClusterResponse setCluster(PeriscopeUser user, AutoscaleClusterRequest json, Long clusterId) {
Ambari ambari = ambariConverter.convert(json);
Long stackId = json.getStackId();
boolean access = clusterSecurityService.hasAccess(user, ambari, stackId);
if (!access) {
String host = ambari.getHost();
LOGGER.info("Illegal access to Ambari cluster '{}' from user '{}'", host, user.getEmail());
throw new AccessDeniedException(String.format("Accessing Ambari cluster '%s' is not allowed", host));
} else {
Cluster cluster = clusterRequestConverter.convert(json);
if (!hasAmbariConnectionDetailsSpecified(json)) {
AmbariStack ambariStack = new AmbariStack(ambari, stackId, null);
cluster = clusterService.create(cluster, user, ambariStack, PENDING);
} else {
AmbariStack resolvedAmbari = clusterSecurityService.tryResolve(ambari);
cluster = clusterId == null ? clusterService.create(cluster, user, resolvedAmbari, RUNNING) : clusterService.update(clusterId, resolvedAmbari, cluster.isAutoscalingEnabled());
}
createHistoryAndNotification(cluster);
return createClusterJsonResponse(cluster);
}
}
use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.
the class ScalingHandler method onApplicationEvent.
@Override
public void onApplicationEvent(ScalingEvent event) {
BaseAlert alert = event.getAlert();
Cluster cluster = clusterService.find(alert.getCluster().getId());
MDCBuilder.buildMdcContext(cluster);
scale(cluster, alert.getScalingPolicy());
}
use of com.sequenceiq.periscope.domain.Cluster in project cloudbreak by hortonworks.
the class AmbariAgentHealthEvaluator method run.
@Override
public void run() {
Cluster cluster = clusterService.find(clusterId);
MDCBuilder.buildMdcContext(cluster);
LOGGER.info("Checking '{}' alerts.", AMBARI_AGENT_HEARTBEAT);
try {
AmbariClient ambariClient = ambariClientProvider.createAmbariClient(cluster);
List<Map<String, Object>> alertHistory = ambariClient.getAlert(AMBARI_AGENT_HEARTBEAT_DEF_NAME);
if (!alertHistory.isEmpty()) {
List<String> hostNamesToRecover = new ArrayList<>();
for (Map<String, Object> history : alertHistory) {
String currentState = (String) history.get(ALERT_STATE);
if (isAlertStateMet(currentState)) {
String hostName = (String) history.get(HOST_NAME);
hostNamesToRecover.add(hostName);
LOGGER.info("Alert: {} is in '{}' state for host '{}'.", AMBARI_AGENT_HEARTBEAT, currentState, hostName);
}
}
if (!hostNamesToRecover.isEmpty()) {
hostNamesToRecover.forEach(hn -> LOGGER.info("Host to recover: {}", hn));
CloudbreakClient cbClient = cloudbreakClientConfiguration.cloudbreakClient();
FailureReport failureReport = new FailureReport();
failureReport.setFailedNodes(hostNamesToRecover);
cbClient.clusterEndpoint().failureReport(cluster.getStackId(), failureReport);
}
}
} catch (Exception e) {
LOGGER.warn(String.format("Failed to retrieve '%s' alerts.", AMBARI_AGENT_HEARTBEAT), e);
publishEvent(new UpdateFailedEvent(clusterId));
}
}
use of com.sequenceiq.periscope.domain.Cluster 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);
}
}
Aggregations