use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackUpdater method doUpdateStackStatus.
private Stack doUpdateStackStatus(Stack stack, DetailedStackStatus newDetailedStatus, String rawNewStatusReason) {
Status newStatus = newDetailedStatus.getStatus();
StackStatus stackStatus = stack.getStackStatus();
if (!Status.DELETE_COMPLETED.equals(stackStatus.getStatus())) {
rawNewStatusReason = serviceStatusRawMessageTransformer.transformMessage(rawNewStatusReason, stack.getTunnel());
String transformedStatusReason = stackStatusMessageTransformator.transformMessage(rawNewStatusReason);
if (isStatusChanged(stack, newDetailedStatus, transformedStatusReason, newStatus)) {
stack = handleStatusChange(stack, newDetailedStatus, transformedStatusReason, newStatus, stackStatus);
} else {
LOGGER.debug("Statuses are the same, it will not update");
updateInMemoryStoreIfStackIsMissing(stack, newStatus);
}
}
return stack;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class FreeipaChecker method getStatus.
public SyncResult getStatus(Stack stack, Set<InstanceMetaData> checkableInstances) {
try {
if (checkableInstances.isEmpty()) {
throw new UnsupportedOperationException("There are no instances of FreeIPA to check the status of");
}
// Exclude terminated but include deleted
Set<InstanceMetaData> notTermiatedStackInstances = stack.getAllInstanceMetaDataList().stream().filter(Predicate.not(InstanceMetaData::isTerminated)).collect(Collectors.toSet());
Pair<Map<InstanceMetaData, DetailedStackStatus>, String> statusCheckPair = checkStatus(stack, checkableInstances);
List<DetailedStackStatus> responses = new ArrayList<>(statusCheckPair.getFirst().values());
DetailedStackStatus status;
if (areAllStatusTheSame(responses) && !hasMissingStatus(responses, notTermiatedStackInstances)) {
status = responses.get(0);
} else {
status = DetailedStackStatus.UNHEALTHY;
}
return new SyncResult("FreeIpa is " + status + ", " + statusCheckPair.getSecond(), status, statusCheckPair.getFirst());
} catch (Exception e) {
LOGGER.info("Error occurred during status fetch: " + e.getMessage(), e);
return new SyncResult("FreeIpa is unreachable, because error occurred: " + e.getMessage(), DetailedStackStatus.UNREACHABLE, null);
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class FreeipaChecker method checkStatus.
private Pair<Map<InstanceMetaData, DetailedStackStatus>, String> checkStatus(Stack stack, Set<InstanceMetaData> checkableInstances) throws Exception {
return checkedMeasure(() -> {
Map<InstanceMetaData, DetailedStackStatus> statuses = new HashMap<>();
List<RPCResponse<Boolean>> responses = new LinkedList<>();
LOGGER.info("Checking FreeIPA status for instance IDs {}", checkableInstances.stream().map(InstanceMetaData::getInstanceId).collect(Collectors.toList()));
for (InstanceMetaData instanceMetaData : checkableInstances) {
try {
RPCResponse<Boolean> response = checkedMeasure(() -> freeIpaInstanceHealthDetailsService.checkFreeIpaHealth(stack, instanceMetaData), LOGGER, ":::Auto sync::: FreeIPA health check ran in {}ms");
responses.add(response);
DetailedStackStatus newDetailedStackStatus;
if (response.getResult()) {
newDetailedStackStatus = DetailedStackStatus.AVAILABLE;
} else {
newDetailedStackStatus = DetailedStackStatus.UNHEALTHY;
}
LOGGER.info("FreeIpa health check reported {} for {}", newDetailedStackStatus, instanceMetaData);
statuses.put(instanceMetaData, newDetailedStackStatus);
} catch (Exception e) {
LOGGER.info("FreeIpaClientException occurred during status fetch for {}: {}", instanceMetaData, e.getMessage(), e);
statuses.put(instanceMetaData, DetailedStackStatus.UNREACHABLE);
}
}
String message = getMessages(responses);
return Pair.of(statuses, message);
}, LOGGER, ":::Auto sync::: freeipa server status is checked in {}ms");
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackUpdater method saveStackNewStatus.
private Stack saveStackNewStatus(Stack stack, DetailedStackStatus newDetailedStatus, String newStatusReason, Status newStatus, StackStatus stackStatus) {
LOGGER.debug("Updated: status from {} to {} - detailed status from {} to {} - reason from {} to {}", stackStatus.getStatus(), newStatus, stackStatus.getDetailedStackStatus(), newDetailedStatus, stackStatus.getStatusReason(), newStatusReason);
stack.setStackStatus(new StackStatus(stack, newStatus, newStatusReason, newDetailedStatus));
stack = stackService.save(stack);
return stack;
}
Aggregations