use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.
the class ClusterStatusSyncHandlerTest method testOnApplicationEventWhenCBStackStatusActiveCBClusterStatusInactive.
@Test
public void testOnApplicationEventWhenCBStackStatusActiveCBClusterStatusInactive() {
Cluster cluster = getACluster(ClusterState.SUSPENDED);
when(clusterService.findById(anyLong())).thenReturn(cluster);
StackStatusV4Response stackStatusV4Response = new StackStatusV4Response();
stackStatusV4Response.setStatus(Status.AVAILABLE);
stackStatusV4Response.setClusterStatus(Status.UPDATE_IN_PROGRESS);
when(cloudbreakCommunicator.getStackStatusByCrn(anyString())).thenReturn(stackStatusV4Response);
underTest.onApplicationEvent(new ClusterStatusSyncEvent(AUTOSCALE_CLUSTER_ID));
verify(clusterService, never()).setState(anyLong(), any(ClusterState.class));
verify(cloudbreakCommunicator).getStackStatusByCrn(CLOUDBREAK_STACK_CRN);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response 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());
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response in project cloudbreak by hortonworks.
the class CloudbreakUtil method waitForStatuses.
private static WaitResult waitForStatuses(CloudbreakClient cloudbreakClient, Long workspaceId, String stackName, Map<String, String> desiredStatuses, String accountId) {
WaitResult waitResult = WaitResult.SUCCESSFUL;
Map<String, String> currentStatuses = new HashMap<>();
int retryCount = 0;
do {
LOGGER.info("Waiting for status(es) {}, stack id: {}, current status(es) {} ...", desiredStatuses, stackName, currentStatuses);
sleep();
StackV4Endpoint stackV4Endpoint = cloudbreakClient.stackV4Endpoint();
try {
StackStatusV4Response statusResult = stackV4Endpoint.getStatusByName(workspaceId, stackName, accountId);
for (String statusPath : desiredStatuses.keySet()) {
currentStatuses.put(statusPath, statusResult.getStatus().name());
}
} catch (RuntimeException ignore) {
continue;
}
retryCount++;
} while (!checkStatuses(currentStatuses, desiredStatuses) && !checkFailedStatuses(currentStatuses) && retryCount < MAX_RETRY);
LOGGER.info("Status(es) {} for {} are in desired status(es) {}", desiredStatuses.keySet(), stackName, currentStatuses.values());
if (currentStatuses.values().stream().anyMatch(cs -> cs.contains("FAILED")) || checkNotExpectedDelete(currentStatuses, desiredStatuses)) {
waitResult = WaitResult.FAILED;
}
if (retryCount == MAX_RETRY) {
waitResult = WaitResult.TIMEOUT;
}
return waitResult;
}
Aggregations