use of com.sequenceiq.cloudbreak.api.model.FailureReport 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.cloudbreak.api.model.FailureReport in project cloudbreak by hortonworks.
the class UpdateFailedHandler method reportAmbariServerFailure.
private void reportAmbariServerFailure(Cluster cluster, StackResponse stackResponse, CloudbreakClient cbClient) {
Optional<InstanceMetaDataJson> pgw = stackResponse.getInstanceGroups().stream().flatMap(ig -> ig.getMetadata().stream()).filter(im -> im.getInstanceType() == InstanceMetadataType.GATEWAY_PRIMARY && im.getInstanceStatus() != InstanceStatus.TERMINATED).findFirst();
if (pgw.isPresent()) {
FailureReport failureReport = new FailureReport();
failureReport.setFailedNodes(Collections.singletonList(pgw.get().getDiscoveryFQDN()));
try {
cbClient.clusterEndpoint().failureReport(cluster.getStackId(), failureReport);
} catch (Exception e) {
LOGGER.warn("Exception during failure report", e);
}
}
}
Aggregations