use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class ProvisionerService method waitCloudbreakClusterDeletion.
public void waitCloudbreakClusterDeletion(Long id, PollingConfig pollingConfig) {
SdxCluster sdxCluster = sdxService.getById(id);
AtomicInteger deleteFailedCount = new AtomicInteger(1);
Polling.waitPeriodly(pollingConfig.getSleepTime(), pollingConfig.getSleepTimeUnit()).stopIfException(pollingConfig.getStopPollingIfExceptionOccurred()).stopAfterDelay(pollingConfig.getDuration(), pollingConfig.getDurationTimeUnit()).run(() -> {
LOGGER.info("Deletion polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName());
try {
StackV4Response stackV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.get(0L, sdxCluster.getClusterName(), Collections.emptySet(), sdxCluster.getAccountId()));
LOGGER.info("Stack status of SDX {} by response from cloudbreak: {}", sdxCluster.getClusterName(), stackV4Response.getStatus().name());
LOGGER.debug("Response from cloudbreak: {}", JsonUtil.writeValueAsString(stackV4Response));
ClusterV4Response cluster = stackV4Response.getCluster();
if (cluster != null) {
if (StatusKind.PROGRESS.equals(cluster.getStatus().getStatusKind())) {
return AttemptResults.justContinue();
}
if (Status.DELETE_FAILED.equals(cluster.getStatus())) {
// if it is implemented, please remove this
if (deleteFailedCount.getAndIncrement() >= DELETE_FAILED_RETRY_COUNT) {
LOGGER.error("Cluster deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getCluster().getStatusReason());
return AttemptResults.breakFor("Data Lake deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getCluster().getStatusReason());
} else {
return AttemptResults.justContinue();
}
}
}
if (Status.DELETE_FAILED.equals(stackV4Response.getStatus())) {
// if it is implemented, please remove this
if (deleteFailedCount.getAndIncrement() >= DELETE_FAILED_RETRY_COUNT) {
LOGGER.error("Stack deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getStatusReason());
return AttemptResults.breakFor("Data Lake deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getStatusReason());
} else {
return AttemptResults.justContinue();
}
} else {
return AttemptResults.justContinue();
}
} catch (NotFoundException e) {
return AttemptResults.finishWith(null);
}
});
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.STACK_DELETED, "Datalake stack deleted", sdxCluster);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class SdxClusterStatusCheckerJob method isNodeFailure.
private boolean isNodeFailure(StackStatusV4Response stack) {
Status stackStatus = stack.getStatus();
Status clusterStatus = stack.getClusterStatus();
return stackStatus == Status.NODE_FAILURE || (stackStatus == Status.AVAILABLE && clusterStatus == Status.NODE_FAILURE);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class ClusterDeleteHandlerTest method getStackResponse.
private StackStatusV4Response getStackResponse(Status clusterStatus) {
StackStatusV4Response stackResponse = new StackStatusV4Response();
stackResponse.setStatus(clusterStatus);
stackResponse.setClusterStatus(clusterStatus);
return stackResponse;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class MetricTest method getStackResponse.
private StackV4Response getStackResponse(Status stackStatus, Status clusterStatus) {
StackV4Response stackResponse = new StackV4Response();
stackResponse.setStatus(stackStatus);
stackResponse.setCluster(new ClusterV4Response());
stackResponse.getCluster().setStatus(clusterStatus);
return stackResponse;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class ClusterDeleteHandler method onApplicationEvent.
@Override
public void onApplicationEvent(ClusterDeleteEvent event) {
Cluster cluster = clusterService.findById(event.getClusterId());
if (cluster == null) {
return;
}
LoggingUtils.buildMdcContext(cluster);
StackStatusV4Response statusResponse = cloudbreakCommunicator.getStackStatusByCrn(cluster.getStackCrn());
if (DELETE_COMPLETED.equals(statusResponse.getStatus())) {
beforeDeleteCleanup(cluster);
clusterService.removeById(event.getClusterId());
LOGGER.info("Deleted cluster: {}, CB Stack status: {}", cluster.getStackCrn(), statusResponse.getStatus());
}
}
Aggregations