class SdxStopService {

    protected AttemptResult<StackV4Response> checkClusterStatusDuringStop(SdxCluster sdxCluster) throws JsonProcessingException {
        LOGGER.info("Stop polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName());
        try {
            if (PollGroup.CANCELLED.equals(DatalakeInMemoryStateStore.get(sdxCluster.getId()))) {
                LOGGER.info("Stop polling cancelled in inmemory store, id: " + sdxCluster.getId());
                return AttemptResults.breakFor("Stop polling cancelled in inmemory store, id: " + sdxCluster.getId());
            } else {
                FlowState flowState = cloudbreakFlowService.getLastKnownFlowState(sdxCluster);
                if (RUNNING.equals(flowState)) {
                    LOGGER.info("Stop 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());
        }
    }

}