@Test public void testActiveFlowCheck() { SdxCluster cluster = new SdxCluster(); cluster.setLastCbFlowChainId(FLOW_CHAIN_ID); cluster.setInitiatorUserCrn(USER_CRN); cluster.setClusterName(CLUSTER_NAME); when(flowEndpoint.hasFlowRunningByChainId(eq(FLOW_CHAIN_ID))).thenReturn(createFlowCheckResponse(TRUE)); assertEquals(RUNNING, underTest.getLastKnownFlowState(cluster)); when(flowEndpoint.hasFlowRunningByChainId(eq(FLOW_CHAIN_ID))).thenReturn(createFlowCheckResponse(TRUE)); assertEquals(RUNNING, underTest.getLastKnownFlowState(cluster)); verify(flowEndpoint, times(2)).hasFlowRunningByChainId(eq(FLOW_CHAIN_ID)); }
public FlowState getLastKnownFlowState(SdxCluster sdxCluster) { try { if (sdxCluster.getLastCbFlowChainId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW_CHAIN, sdxCluster.getLastCbFlowChainId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByChainId(sdxCluster.getLastCbFlowChainId()).getHasActiveFlow()); logCbFlowChainStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } else if (sdxCluster.getLastCbFlowId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW, sdxCluster.getLastCbFlowId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByFlowId(sdxCluster.getLastCbFlowId()).getHasActiveFlow()); logCbFlowStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } return FlowState.UNKNOWN; } catch (NotFoundException e) { LOGGER.error("Flow chain id or resource {} not found in CB: {}, so there is no active flow!", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } catch (Exception e) { LOGGER.error("Exception occured during checking if there is a flow for cluster {} in CB: {}", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } }
CloudbreakFlowService { public FlowState getLastKnownFlowState(SdxCluster sdxCluster) { try { if (sdxCluster.getLastCbFlowChainId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW_CHAIN, sdxCluster.getLastCbFlowChainId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByChainId(sdxCluster.getLastCbFlowChainId()).getHasActiveFlow()); logCbFlowChainStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } else if (sdxCluster.getLastCbFlowId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW, sdxCluster.getLastCbFlowId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByFlowId(sdxCluster.getLastCbFlowId()).getHasActiveFlow()); logCbFlowStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } return FlowState.UNKNOWN; } catch (NotFoundException e) { LOGGER.error("Flow chain id or resource {} not found in CB: {}, so there is no active flow!", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } catch (Exception e) { LOGGER.error("Exception occured during checking if there is a flow for cluster {} in CB: {}", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } } }
CloudbreakFlowService { public FlowState getLastKnownFlowState(SdxCluster sdxCluster) { try { if (sdxCluster.getLastCbFlowChainId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW_CHAIN, sdxCluster.getLastCbFlowChainId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByChainId(sdxCluster.getLastCbFlowChainId()).getHasActiveFlow()); logCbFlowChainStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } else if (sdxCluster.getLastCbFlowId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW, sdxCluster.getLastCbFlowId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByFlowId(sdxCluster.getLastCbFlowId()).getHasActiveFlow()); logCbFlowStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } return FlowState.UNKNOWN; } catch (NotFoundException e) { LOGGER.error("Flow chain id or resource {} not found in CB: {}, so there is no active flow!", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } catch (Exception e) { LOGGER.error("Exception occured during checking if there is a flow for cluster {} in CB: {}", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } }  }
CloudbreakFlowService { public FlowState getLastKnownFlowState(SdxCluster sdxCluster) { try { if (sdxCluster.getLastCbFlowChainId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW_CHAIN, sdxCluster.getLastCbFlowChainId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByChainId(sdxCluster.getLastCbFlowChainId()).getHasActiveFlow()); logCbFlowChainStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } else if (sdxCluster.getLastCbFlowId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW, sdxCluster.getLastCbFlowId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByFlowId(sdxCluster.getLastCbFlowId()).getHasActiveFlow()); logCbFlowStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } return FlowState.UNKNOWN; } catch (NotFoundException e) { LOGGER.error("Flow chain id or resource {} not found in CB: {}, so there is no active flow!", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } catch (Exception e) { LOGGER.error("Exception occured during checking if there is a flow for cluster {} in CB: {}", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } }  void getAndSaveLastCloudbreakFlowChainId(SdxCluster sdxCluster); FlowState getLastKnownFlowState(SdxCluster sdxCluster); void saveLastCloudbreakFlowChainId(SdxCluster sdxCluster, FlowIdentifier flowIdentifier); }
CloudbreakFlowService { public FlowState getLastKnownFlowState(SdxCluster sdxCluster) { try { if (sdxCluster.getLastCbFlowChainId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW_CHAIN, sdxCluster.getLastCbFlowChainId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByChainId(sdxCluster.getLastCbFlowChainId()).getHasActiveFlow()); logCbFlowChainStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } else if (sdxCluster.getLastCbFlowId() != null) { LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW, sdxCluster.getLastCbFlowId()); Boolean hasActiveFlow = ThreadBasedUserCrnProvider.doAsInternalActor(() -> flowEndpoint.hasFlowRunningByFlowId(sdxCluster.getLastCbFlowId()).getHasActiveFlow()); logCbFlowStatus(sdxCluster, hasActiveFlow); return getFlowState(hasActiveFlow); } return FlowState.UNKNOWN; } catch (NotFoundException e) { LOGGER.error("Flow chain id or resource {} not found in CB: {}, so there is no active flow!", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } catch (Exception e) { LOGGER.error("Exception occured during checking if there is a flow for cluster {} in CB: {}", sdxCluster.getClusterName(), e.getMessage()); return FlowState.UNKNOWN; } }  void getAndSaveLastCloudbreakFlowChainId(SdxCluster sdxCluster); FlowState getLastKnownFlowState(SdxCluster sdxCluster); void saveLastCloudbreakFlowChainId(SdxCluster sdxCluster, FlowIdentifier flowIdentifier);  }