use of com.sequenceiq.cloudbreak.service.cluster.ambari.AmbariOperationFailedException in project cloudbreak by hortonworks.
the class AmbariOperationsStartCheckerTask method checkStatus.
@Override
public boolean checkStatus(AmbariOperations t) {
Map<String, Integer> installRequests = t.getRequests();
for (Entry<String, Integer> request : installRequests.entrySet()) {
AmbariClient ambariClient = t.getAmbariClient();
BigDecimal installProgress = Optional.ofNullable(ambariClient.getRequestProgress(request.getValue())).orElse(PENDING);
LOGGER.info("Ambari operation start: '{}', Progress: {}", request.getKey(), installProgress);
if (FAILED.compareTo(installProgress) == 0) {
boolean failed = true;
for (int i = 0; i < MAX_RETRY; i++) {
if (ambariClient.getRequestProgress(request.getValue()).compareTo(FAILED) != 0) {
failed = false;
break;
}
}
if (failed) {
Map<String, ?> requests = (Map<String, ?>) ambariClient.getRequestStatus(request.getValue()).get("Requests");
String context = (String) requests.get("request_context");
String status = (String) requests.get("request_status");
throw new AmbariOperationFailedException(String.format("Ambari operation start failed: [component:'%s', requestID: '%s', context: '%s', status: '%s']", request.getKey(), request.getValue(), context, status));
}
}
if (PENDING.compareTo(installProgress) == 0) {
return false;
}
}
return true;
}
use of com.sequenceiq.cloudbreak.service.cluster.ambari.AmbariOperationFailedException in project cloudbreak by hortonworks.
the class AmbariOperationsStatusCheckerTask method checkStatus.
@Override
public boolean checkStatus(AmbariOperations t) {
Map<String, Integer> installRequests = t.getRequests();
boolean allFinished = true;
for (Entry<String, Integer> request : installRequests.entrySet()) {
AmbariClient ambariClient = t.getAmbariClient();
BigDecimal installProgress = Optional.ofNullable(ambariClient.getRequestProgress(request.getValue())).orElse(PENDING);
LOGGER.info("Ambari operation: '{}', Progress: {}", request.getKey(), installProgress);
notificationSender.send(getAmbariProgressNotification(installProgress.longValue(), t.getStack(), t.getAmbariOperationType()));
if (FAILED.compareTo(installProgress) == 0) {
boolean failed = true;
for (int i = 0; i < MAX_RETRY; i++) {
if (ambariClient.getRequestProgress(request.getValue()).compareTo(FAILED) != 0) {
failed = false;
break;
}
}
if (failed) {
notificationSender.send(getAmbariProgressNotification(Long.parseLong("100"), t.getStack(), t.getAmbariOperationType()));
throw new AmbariOperationFailedException(String.format("Ambari operation failed: [component: '%s', requestID: '%s']", request.getKey(), request.getValue()));
}
}
allFinished = allFinished && COMPLETED.compareTo(installProgress) == 0;
}
return allFinished;
}
Aggregations