@Test public void testCheckClusterStatusDuringStartWhenClusterStopFailed() throws JsonProcessingException { SdxCluster sdxCluster = sdxCluster(); StackV4Response stackV4Response = new StackV4Response(); stackV4Response.setStatusReason("reason"); stackV4Response.setStatus(AVAILABLE); ClusterV4Response clusterV4Response = new ClusterV4Response(); clusterV4Response.setStatus(STOP_FAILED); clusterV4Response.setStatusReason("cluster reason"); stackV4Response.setCluster(clusterV4Response); when(stackV4Endpoint.get(eq(0L), eq(sdxCluster.getClusterName()), eq(Collections.emptySet()), anyString())) .thenReturn(stackV4Response); AttemptResult<StackV4Response> actual = underTest.checkClusterStatusDuringStart(sdxCluster); assertEquals(AttemptState.BREAK, actual.getState()); assertEquals("SDX start failed 'clusterName', cluster is in inconsistency state: STOP_FAILED", actual.getMessage()); }
protected AttemptResult<StackV4Response> checkClusterStatusDuringStart(SdxCluster sdxCluster) throws JsonProcessingException { LOGGER.info("Start polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName()); try { if (PollGroup.CANCELLED.equals(DatalakeInMemoryStateStore.get(sdxCluster.getId()))) { LOGGER.info("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); return AttemptResults.breakFor("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); } else { FlowState flowState = cloudbreakFlowService.getLastKnownFlowState(sdxCluster); if (RUNNING.equals(flowState)) { LOGGER.info("Start polling will continue, cluster has an active flow in Cloudbreak, id: {}", sdxCluster.getId()); return AttemptResults.justContinue(); } else { return getStackResponseAttemptResult(sdxCluster, flowState); } } } catch (NotFoundException e) { LOGGER.debug("Stack not found on CB side " + sdxCluster.getClusterName(), e); return AttemptResults.breakFor("Stack not found on CB side " + sdxCluster.getClusterName()); } }
SdxStartService { protected AttemptResult<StackV4Response> checkClusterStatusDuringStart(SdxCluster sdxCluster) throws JsonProcessingException { LOGGER.info("Start polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName()); try { if (PollGroup.CANCELLED.equals(DatalakeInMemoryStateStore.get(sdxCluster.getId()))) { LOGGER.info("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); return AttemptResults.breakFor("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); } else { FlowState flowState = cloudbreakFlowService.getLastKnownFlowState(sdxCluster); if (RUNNING.equals(flowState)) { LOGGER.info("Start polling will continue, cluster has an active flow in Cloudbreak, id: {}", sdxCluster.getId()); return AttemptResults.justContinue(); } else { return getStackResponseAttemptResult(sdxCluster, flowState); } } } catch (NotFoundException e) { LOGGER.debug("Stack not found on CB side " + sdxCluster.getClusterName(), e); return AttemptResults.breakFor("Stack not found on CB side " + sdxCluster.getClusterName()); } } }
SdxStartService { protected AttemptResult<StackV4Response> checkClusterStatusDuringStart(SdxCluster sdxCluster) throws JsonProcessingException { LOGGER.info("Start polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName()); try { if (PollGroup.CANCELLED.equals(DatalakeInMemoryStateStore.get(sdxCluster.getId()))) { LOGGER.info("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); return AttemptResults.breakFor("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); } else { FlowState flowState = cloudbreakFlowService.getLastKnownFlowState(sdxCluster); if (RUNNING.equals(flowState)) { LOGGER.info("Start polling will continue, cluster has an active flow in Cloudbreak, id: {}", sdxCluster.getId()); return AttemptResults.justContinue(); } else { return getStackResponseAttemptResult(sdxCluster, flowState); } } } catch (NotFoundException e) { LOGGER.debug("Stack not found on CB side " + sdxCluster.getClusterName(), e); return AttemptResults.breakFor("Stack not found on CB side " + sdxCluster.getClusterName()); } }  }
SdxStartService { protected AttemptResult<StackV4Response> checkClusterStatusDuringStart(SdxCluster sdxCluster) throws JsonProcessingException { LOGGER.info("Start polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName()); try { if (PollGroup.CANCELLED.equals(DatalakeInMemoryStateStore.get(sdxCluster.getId()))) { LOGGER.info("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); return AttemptResults.breakFor("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); } else { FlowState flowState = cloudbreakFlowService.getLastKnownFlowState(sdxCluster); if (RUNNING.equals(flowState)) { LOGGER.info("Start polling will continue, cluster has an active flow in Cloudbreak, id: {}", sdxCluster.getId()); return AttemptResults.justContinue(); } else { return getStackResponseAttemptResult(sdxCluster, flowState); } } } catch (NotFoundException e) { LOGGER.debug("Stack not found on CB side " + sdxCluster.getClusterName(), e); return AttemptResults.breakFor("Stack not found on CB side " + sdxCluster.getClusterName()); } }  FlowIdentifier triggerStartIfClusterNotRunning(SdxCluster cluster); void start(Long sdxId); void waitCloudbreakCluster(Long sdxId, PollingConfig pollingConfig); }
SdxStartService { protected AttemptResult<StackV4Response> checkClusterStatusDuringStart(SdxCluster sdxCluster) throws JsonProcessingException { LOGGER.info("Start polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName()); try { if (PollGroup.CANCELLED.equals(DatalakeInMemoryStateStore.get(sdxCluster.getId()))) { LOGGER.info("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); return AttemptResults.breakFor("Start polling cancelled in inmemory store, id: " + sdxCluster.getId()); } else { FlowState flowState = cloudbreakFlowService.getLastKnownFlowState(sdxCluster); if (RUNNING.equals(flowState)) { LOGGER.info("Start polling will continue, cluster has an active flow in Cloudbreak, id: {}", sdxCluster.getId()); return AttemptResults.justContinue(); } else { return getStackResponseAttemptResult(sdxCluster, flowState); } } } catch (NotFoundException e) { LOGGER.debug("Stack not found on CB side " + sdxCluster.getClusterName(), e); return AttemptResults.breakFor("Stack not found on CB side " + sdxCluster.getClusterName()); } }  FlowIdentifier triggerStartIfClusterNotRunning(SdxCluster cluster); void start(Long sdxId); void waitCloudbreakCluster(Long sdxId, PollingConfig pollingConfig);  }