use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackUpdaterTest method skipStackStatusUpdateWhenStatusIsDeleteCompleted.
@Test
public void skipStackStatusUpdateWhenStatusIsDeleteCompleted() {
Stack stack = TestUtil.stack(Status.DELETE_COMPLETED);
DetailedStackStatus newStatus = DetailedStackStatus.AVAILABLE;
when(stackService.getByIdWithTransaction(anyLong())).thenReturn(stack);
Stack modifiedStack = underTest.updateStackStatus(1L, newStatus, "newReason");
assertEquals(Status.DELETE_COMPLETED, modifiedStack.getStatus());
verify(stackService, never()).save(any());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackStartStopService method handleError.
private void handleError(StackView stackView, Exception exception, DetailedStackStatus detailedStackStatus, ResourceEvent resourceEvent, String logMessage) {
LOGGER.debug(logMessage, exception);
Status stackStatus = detailedStackStatus.getStatus();
stackUpdater.updateStackStatus(stackView.getId(), detailedStackStatus, logMessage + exception.getMessage());
flowMessageService.fireEventAndLog(stackView.getId(), stackStatus.name(), resourceEvent, exception.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class ClusterRecoveryService method validateStackStatus.
private RecoveryValidationV4Response validateStackStatus(Stack stack) {
List<StackStatus> statusList = stackStatusService.findAllStackStatusesById(stack.getId());
List<DetailedStackStatus> detailedStackStatusList = statusList.stream().map(StackStatus::getDetailedStackStatus).collect(Collectors.toList());
int lastRecoverySuccess = getLastRecoverySuccess(detailedStackStatusList);
int lastRecoveryFailure = getLastRecoveryFailure(detailedStackStatusList);
int lastUpgradeSuccess = getLastUpgradeSuccess(detailedStackStatusList);
int lastUpgradeFailure = getLastUpgradeFailure(detailedStackStatusList);
String logMessage = Stream.of(createLogEntry(lastUpgradeSuccess, DetailedStackStatus.CLUSTER_UPGRADE_FINISHED), createLogEntry(lastUpgradeFailure, DetailedStackStatus.CLUSTER_UPGRADE_FAILED), createLogEntry(lastRecoverySuccess, DetailedStackStatus.CLUSTER_RECOVERY_FINISHED), createLogEntry(lastRecoveryFailure, DetailedStackStatus.CLUSTER_RECOVERY_FAILED)).flatMap(Optional::stream).collect(Collectors.joining(". "));
LOGGER.debug(logMessage);
int maximumInt = IntStream.of(lastUpgradeFailure, lastRecoveryFailure, lastRecoverySuccess, lastUpgradeSuccess).max().getAsInt();
String reason;
RecoveryStatus status;
if (maximumInt == -1) {
reason = "There has been no failed upgrades for this cluster hence recovery is not permitted.";
status = NON_RECOVERABLE;
} else if (maximumInt == lastRecoveryFailure) {
reason = "Last cluster recovery has failed, recovery can be retried.";
status = RECOVERABLE;
} else if (maximumInt == lastUpgradeFailure) {
reason = "Last cluster upgrade has failed, recovery can be launched to restore the cluster to its pre-upgrade state.";
status = RECOVERABLE;
} else {
reason = "Cluster is not in a recoverable state now, neither uncorrected upgrade or recovery failures are present.";
status = NON_RECOVERABLE;
}
LOGGER.info(reason);
return new RecoveryValidationV4Response(reason, status);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class ClusterCommonService method saveAndFireEventOnClusterStatusChange.
private void saveAndFireEventOnClusterStatusChange(Stack stack, DetailedStackStatus newDetailedStackStatus, ResourceEvent event) {
Status actualStatus = stack.getStatus();
if (!actualStatus.equals(newDetailedStackStatus.getStatus())) {
clusterService.updateClusterStatusByStackId(stack.getId(), newDetailedStackStatus);
cloudbreakEventService.fireCloudbreakEvent(stack.getId(), event.name(), event);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class ClusterStatusUpdater method updateClusterStatus.
private boolean updateClusterStatus(Stack stack, ClusterStatus clusterStatus) {
boolean result = false;
Cluster cluster = stack.getCluster();
Status actualStatus = stack.getStatus();
DetailedStackStatus newDetailedStackStatus = clusterStatus.getDetailedStackStatus();
Status newStatus = newDetailedStackStatus.getStatus();
if (actualStatus != newStatus) {
if (!actualStatus.equals(Status.MAINTENANCE_MODE_ENABLED) || !newStatus.equals(Status.AVAILABLE)) {
LOGGER.debug("Cluster {} status is updated from {} to {}/{}", cluster.getId(), actualStatus, newStatus, newDetailedStackStatus);
clusterService.updateClusterStatusByStackId(stack.getId(), newDetailedStackStatus, clusterStatus.getStatusReason());
result = true;
}
} else {
LOGGER.debug("Cluster {} status hasn't changed: {}", cluster.getId(), actualStatus);
}
return result;
}
Aggregations