use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class StackTerminationService method handleStackTerminationError.
public void handleStackTerminationError(StackView stackView, Exception errorDetails, boolean forced) {
Long stackId = stackView.getId();
String stackUpdateMessage;
ResourceEvent resourceEvent;
DetailedStackStatus status;
if (!forced) {
stackUpdateMessage = "Termination failed: " + errorDetails.getMessage();
status = DetailedStackStatus.DELETE_FAILED;
resourceEvent = STACK_INFRASTRUCTURE_DELETE_FAILED;
stackUpdater.updateStackStatus(stackId, status, stackUpdateMessage);
LOGGER.debug("Error during stack termination flow: ", errorDetails);
} else {
clusterService.updateClusterStatusByStackId(stackId, DetailedStackStatus.CLUSTER_DELETE_COMPLETED);
terminationService.finalizeTermination(stackId, true);
stackUpdateMessage = "Stack was force terminated.";
status = DetailedStackStatus.DELETE_COMPLETED;
resourceEvent = STACK_FORCED_DELETE_COMPLETED;
}
flowMessageService.fireEventAndLog(stackId, status.name(), resourceEvent, stackUpdateMessage);
metricService.incrementMetricCounter(MetricType.STACK_TERMINATION_FAILED, stackView, errorDetails);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class ClusterCommonService method put.
public FlowIdentifier put(String crn, UpdateClusterV4Request updateJson) {
Stack stack = stackService.getByCrnWithLists(crn);
Long stackId = stack.getId();
MDCBuilder.buildMdcContext(stack);
UserNamePasswordV4Request userNamePasswordJson = updateJson.getUserNamePassword();
FlowIdentifier flowIdentifier;
if (userNamePasswordJson != null) {
flowIdentifier = clusterManagerUserNamePasswordChange(stack, userNamePasswordJson);
} else if (updateJson.getStatus() != null) {
LOGGER.debug("Cluster status update request received. Stack id: {}, status: {} ", stackId, updateJson.getStatus());
flowIdentifier = clusterOperationService.updateStatus(stackId, updateJson.getStatus());
} else if (updateJson.getBlueprintName() != null && updateJson.getHostgroups() != null && stack.getCluster().isCreateFailed()) {
LOGGER.debug("Cluster rebuild request received. Stack id: {}", stackId);
try {
flowIdentifier = recreateCluster(stack, updateJson);
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
} else if (updateJson.getHostGroupAdjustment() != null) {
environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.upscalable());
flowIdentifier = clusterHostgroupAdjustmentChange(stackId, updateJson, stack);
} else {
LOGGER.info("Invalid cluster update request received. Stack id: {}", stackId);
throw new BadRequestException("Invalid update cluster request!");
}
return flowIdentifier;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class StackUpdater method doUpdateStackStatus.
private Stack doUpdateStackStatus(Long stackId, Status newStatus, DetailedStackStatus newDetailedStatus, String statusReason) {
Stack stack = stackService.getByIdWithTransaction(stackId);
StackStatus actualStackStatus = stack.getStackStatus();
LOGGER.info("Update stack status from: {}/{} to: {}/{} stack: {} reason: {}", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus(), newStatus, newDetailedStatus, stackId, statusReason);
if (actualStackStatus.getStatus().equals(newStatus)) {
LOGGER.debug("New status is the same as previous status {}/{}, skip status update.", actualStackStatus.getStatus(), actualStackStatus.getDetailedStackStatus());
return stack;
} else if (!stack.isDeleteCompleted()) {
stack.setStackStatus(new StackStatus(stack, newStatus, statusReason, newDetailedStatus));
Cluster cluster = stack.getCluster();
if (newStatus.isRemovableStatus()) {
InMemoryStateStore.deleteStack(stackId);
if (cluster != null) {
InMemoryStateStore.deleteCluster(cluster.getId());
}
} else {
InMemoryStateStore.putStack(stackId, statusToPollGroupConverter.convert(newStatus));
if (cluster != null) {
InMemoryStateStore.putCluster(cluster.getId(), statusToPollGroupConverter.convert(newStatus));
}
}
stack = stackService.save(stack);
saveDeprecatedClusterStatus(statusReason, stack, newStatus);
usageLoggingUtil.logClusterStatusChangeUsageEvent(actualStackStatus.getStatus(), newStatus, cluster);
} else {
LOGGER.info("Stack is in DELETE_COMPLETED status, cannot update status.");
}
return stack;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class ClusterStatusUpdater method updateClusterStatus.
private void updateClusterStatus(Stack stack, ClusterStatusResult clusterStatusResult) {
Status statusInEvent = stack.getStatus();
ClusterStatus clusterStatus = clusterStatusResult.getClusterStatus();
String statusReason = clusterStatusResult.getStatusReason();
if (isUpdateEnabled(clusterStatus)) {
if (updateClusterStatus(stack, clusterStatus)) {
statusInEvent = clusterStatus.getDetailedStackStatus().getStatus();
statusReason = clusterStatus.getStatusReason();
} else {
statusReason = "The cluster's state is up to date.";
}
}
cloudbreakEventService.fireCloudbreakEvent(stack.getId(), statusInEvent.name(), CLUSTER_AMBARI_CLUSTER_SYNCHRONIZED, Collections.singletonList(statusReason));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class ClusterStatusSyncHandlerTest method getStackResponse.
private StackStatusV4Response getStackResponse(Status clusterStatus) {
StackStatusV4Response stackResponse = new StackStatusV4Response();
stackResponse.setStatus(clusterStatus);
stackResponse.setClusterStatus(clusterStatus);
return stackResponse;
}
Aggregations