use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.
the class SdxClusterStatusCheckerJobTest method setUp.
@BeforeEach
void setUp() {
underTest.setLocalId(SDX_ID.toString());
underTest.setRemoteResourceCrn(STACK_ID.toString());
sdxCluster = new SdxCluster();
sdxCluster.setClusterName("data-lake-cluster");
when(sdxClusterRepository.findById(SDX_ID)).thenReturn(Optional.of(sdxCluster));
stack = new StackStatusV4Response();
when(cloudbreakInternalCrnClient.withInternalCrn()).thenReturn(cloudbreakServiceCrnEndpoints);
when(cloudbreakServiceCrnEndpoints.autoscaleEndpoint()).thenReturn(autoscaleV4Endpoint);
when(autoscaleV4Endpoint.getStatusByCrn(STACK_ID.toString())).thenReturn(stack);
status = new SdxStatusEntity();
status.setDatalake(sdxCluster);
when(sdxStatusService.getActualStatusForSdx(sdxCluster)).thenReturn(status);
jobDataMap = new JobDataMap();
when(jobExecutionContext.getMergedJobDataMap()).thenReturn(jobDataMap);
when(flowLogService.isOtherFlowRunning(any())).thenReturn(false);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.
the class CloudbreakPollerTest method statusResponse.
private StackStatusV4Response statusResponse(Status stackStatus, String stackStatusReason) {
StackStatusV4Response statusV4Response = new StackStatusV4Response();
statusV4Response.setStatus(stackStatus);
statusV4Response.setStatusReason(stackStatusReason);
return statusV4Response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.
the class CloudbreakPoller method getStackResponseAttemptResult.
private AttemptResult<StackStatusV4Response> getStackResponseAttemptResult(String process, SdxCluster sdxCluster, FlowState flowState, Set<Status> targetStatuses, Set<Status> failedStatuses) {
StackStatusV4Response statusResponse = getStackAndClusterStatusWithInternalActor(sdxCluster);
LOGGER.info("Response from cloudbreak: {}", statusResponse);
if (FAILED.equals(flowState)) {
String message = sdxStatusService.getShortStatusMessage(statusResponse);
LOGGER.info("{} flow finished, but failed. {}", process, message);
return failedPolling(process, sdxCluster, message);
} else if (oneOf(statusResponse.getStatus(), targetStatuses) && oneOf(statusResponse.getClusterStatus(), targetStatuses)) {
return AttemptResults.finishWith(statusResponse);
} else if (oneOf(statusResponse.getStatus(), failedStatuses)) {
LOGGER.info("{} failed. Stack is in {} status.", process, statusResponse.getStatus());
return failedPolling(process, sdxCluster, statusResponse.getStatusReason());
} else if (oneOf(statusResponse.getClusterStatus(), failedStatuses)) {
LOGGER.info("{} failed. Cluster is in {} status.", process, statusResponse.getClusterStatus());
return failedPolling(process, sdxCluster, statusResponse.getClusterStatusReason());
} else if (FINISHED.equals(flowState)) {
String message = sdxStatusService.getShortStatusMessage(statusResponse);
LOGGER.info("{} flow finished, but stack or cluster is not available. {}", process, message);
return failedPolling(process, sdxCluster, message);
} else {
return AttemptResults.justContinue();
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.
the class ClusterStatusSyncHandler method onApplicationEvent.
@Override
public void onApplicationEvent(ClusterStatusSyncEvent event) {
long autoscaleClusterId = event.getClusterId();
Cluster cluster = clusterService.findById(autoscaleClusterId);
if (cluster == null) {
return;
}
LoggingUtils.buildMdcContext(cluster);
StackStatusV4Response statusResponse = cloudbreakCommunicator.getStackStatusByCrn(cluster.getStackCrn());
boolean clusterAvailable;
if (Boolean.TRUE.equals(cluster.isStopStartScalingEnabled())) {
clusterAvailable = Optional.ofNullable(statusResponse.getStatus()).map(Status::isAvailable).orElse(false);
// TODO CB-15146: This may need to change depending on the final form of how we check which operations are to be allowed
// when there are some STOPPED instances
} else {
clusterAvailable = Optional.ofNullable(statusResponse.getStatus()).map(Status::isAvailable).orElse(false) && Optional.ofNullable(statusResponse.getClusterStatus()).map(Status::isAvailable).orElse(false);
}
LOGGER.info("Computed clusterAvailable: {}", clusterAvailable);
LOGGER.info("Analysing CBCluster Status '{}' for Cluster '{}. Available(Determined)={}' ", statusResponse, cluster.getStackCrn(), clusterAvailable);
updateClusterState(cluster, statusResponse, clusterAvailable);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.
the class StackToStatusConverter method convert.
public StackStatusV4Response convert(Stack source) {
StackStatusV4Response response = new StackStatusV4Response();
response.setId(source.getId());
response.setStatus(source.getStatus());
response.setStatusReason(source.getStatusReason());
Optional<Cluster> cluster = Optional.ofNullable(source.getCluster());
cluster.ifPresent(c -> response.setClusterStatus(source.getStatus()));
cluster.ifPresent(c -> response.setClusterStatusReason(source.getStatusReason()));
response.setCrn(source.getResourceCrn());
return response;
}
Aggregations