use of com.sequenceiq.flow.api.model.FlowCheckResponse in project cloudbreak by hortonworks.
the class FlowServiceTest method testRunningFlowChainWhenHasEventInQueue.
@Test
public void testRunningFlowChainWhenHasEventInQueue() {
setUpFlowChain(flowChainLog(), true, List.of(flowLog(FlowConstants.FINISHED_STATE, NO_NEXT_EVENT, 2), flowLog(FlowConstants.INIT_STATE, NEXT_EVENT, 1)));
FlowCheckResponse flowCheckResponse = underTest.getFlowChainState(FLOW_CHAIN_ID);
assertTrue(flowCheckResponse.getHasActiveFlow());
assertEquals(FLOW_CHAIN_ID, flowCheckResponse.getFlowChainId());
}
use of com.sequenceiq.flow.api.model.FlowCheckResponse in project cloudbreak by hortonworks.
the class FlowServiceTest method testRunningFlowChainWithoutFinishedState.
@Test
public void testRunningFlowChainWithoutFinishedState() {
setUpFlowChain(flowChainLog(), false, List.of(flowLog(INTERMEDIATE_STATE, NEXT_EVENT, 2), flowLog(FlowConstants.INIT_STATE, NEXT_EVENT, 1)));
FlowCheckResponse flowCheckResponse = underTest.getFlowChainState(FLOW_CHAIN_ID);
assertTrue(flowCheckResponse.getHasActiveFlow());
assertEquals(FLOW_CHAIN_ID, flowCheckResponse.getFlowChainId());
}
use of com.sequenceiq.flow.api.model.FlowCheckResponse in project cloudbreak by hortonworks.
the class CloudbreakFlowServiceTest method testFlowCheckBasedOnFlowId.
@Test
public void testFlowCheckBasedOnFlowId() {
when(flowCheckResponseToFlowStatusConverter.convert(any())).thenCallRealMethod();
SdxCluster cluster = new SdxCluster();
cluster.setLastCbFlowId(FLOW_ID);
cluster.setInitiatorUserCrn(USER_CRN);
cluster.setClusterName(CLUSTER_NAME);
FlowCheckResponse flowCheckResponse = new FlowCheckResponse();
flowCheckResponse.setHasActiveFlow(TRUE);
when(flowEndpoint.hasFlowRunningByFlowId(anyString())).thenReturn(flowCheckResponse);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
assertEquals(FlowState.RUNNING, underTest.getLastKnownFlowState(cluster));
verify(flowEndpoint).hasFlowRunningByFlowId(FLOW_ID);
}
use of com.sequenceiq.flow.api.model.FlowCheckResponse in project cloudbreak by hortonworks.
the class CloudbreakFlowService method getLastKnownFlowStateByFlowId.
public FlowState getLastKnownFlowStateByFlowId(String flowId) {
LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW, flowId);
FlowCheckResponse flowCheckResponse = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> flowEndpoint.hasFlowRunningByFlowId(flowId));
logCbFlowStatus(flowId, flowCheckResponse.getHasActiveFlow());
return flowCheckResponseToFlowStateConverter.convert(flowCheckResponse);
}
use of com.sequenceiq.flow.api.model.FlowCheckResponse in project cloudbreak by hortonworks.
the class CloudbreakFlowService method getLastKnownFlowState.
public FlowState getLastKnownFlowState(SdxCluster sdxCluster) {
try {
if (sdxCluster.getLastCbFlowChainId() != null) {
LOGGER.info("Checking cloudbreak {} {}", FlowType.FLOW_CHAIN, sdxCluster.getLastCbFlowChainId());
FlowCheckResponse flowCheckResponse = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> flowEndpoint.hasFlowRunningByChainId(sdxCluster.getLastCbFlowChainId()));
logCbFlowChainStatus(sdxCluster.getLastCbFlowChainId(), flowCheckResponse.getHasActiveFlow());
return flowCheckResponseToFlowStateConverter.convert(flowCheckResponse);
} else if (sdxCluster.getLastCbFlowId() != null) {
return getLastKnownFlowStateByFlowId(sdxCluster.getLastCbFlowId());
}
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;
}
}
Aggregations