Search in sources :

Example 21 with FlowCheckResponse

use of com.sequenceiq.flow.api.model.FlowCheckResponse in project cloudbreak by hortonworks.

the class FlowService method getFlowState.

public FlowCheckResponse getFlowState(String flowId) {
    List<FlowLog> allByFlowIdOrderByCreatedDesc = flowLogDBService.findAllByFlowIdOrderByCreatedDesc(flowId);
    FlowCheckResponse flowCheckResponse = new FlowCheckResponse();
    flowCheckResponse.setFlowId(flowId);
    flowCheckResponse.setHasActiveFlow(!completed("Flow", flowId, List.of(), allByFlowIdOrderByCreatedDesc));
    flowCheckResponse.setLatestFlowFinalizedAndFailed(isFlowInFailedState(allByFlowIdOrderByCreatedDesc, failHandledEvents));
    return flowCheckResponse;
}
Also used : FlowCheckResponse(com.sequenceiq.flow.api.model.FlowCheckResponse) FlowLog(com.sequenceiq.flow.domain.FlowLog)

Example 22 with FlowCheckResponse

use of com.sequenceiq.flow.api.model.FlowCheckResponse in project cloudbreak by hortonworks.

the class FlowService method getFlowChainStateSafe.

public FlowCheckResponse getFlowChainStateSafe(List<Long> resourceIdList, String chainId) {
    FlowCheckResponse flowCheckResponse = new FlowCheckResponse();
    flowCheckResponse.setFlowChainId(chainId);
    List<FlowChainLog> flowChains = flowChainLogService.findByFlowChainIdOrderByCreatedDesc(chainId);
    if (!flowChains.isEmpty()) {
        LOGGER.info("Checking if there is an active flow based on flow chain id {}", chainId);
        List<FlowChainLog> relatedChains = getRelatedFlowChainLogs(flowChains);
        Set<String> relatedChainIds = relatedChains.stream().map(FlowChainLog::getFlowChainId).collect(toSet());
        Set<String> relatedFlowIds = flowLogDBService.getFlowIdsByChainIds(relatedChainIds);
        List<FlowLog> relatedFlowLogs = flowLogDBService.getFlowLogsByFlowIdsCreatedDesc(relatedFlowIds);
        validateResourceId(relatedFlowLogs, resourceIdList);
        flowCheckResponse.setHasActiveFlow(!completed("Flow chain", chainId, relatedChains, relatedFlowLogs));
        flowCheckResponse.setLatestFlowFinalizedAndFailed(isFlowInFailedState(relatedFlowLogs, failHandledEvents));
        return flowCheckResponse;
    } else {
        flowCheckResponse.setHasActiveFlow(Boolean.FALSE);
        return flowCheckResponse;
    }
}
Also used : FlowCheckResponse(com.sequenceiq.flow.api.model.FlowCheckResponse) FlowLog(com.sequenceiq.flow.domain.FlowLog) FlowChainLog(com.sequenceiq.flow.domain.FlowChainLog)

Example 23 with FlowCheckResponse

use of com.sequenceiq.flow.api.model.FlowCheckResponse in project cloudbreak by hortonworks.

the class FlowService method getFlowChainState.

public FlowCheckResponse getFlowChainState(String chainId) {
    FlowCheckResponse flowCheckResponse = new FlowCheckResponse();
    flowCheckResponse.setFlowChainId(chainId);
    List<FlowChainLog> flowChains = flowChainLogService.findByFlowChainIdOrderByCreatedDesc(chainId);
    if (!flowChains.isEmpty()) {
        LOGGER.info("Checking if there is an active flow based on flow chain id {}", chainId);
        List<FlowChainLog> relatedChains = getRelatedFlowChainLogs(flowChains);
        Set<String> relatedChainIds = relatedChains.stream().map(FlowChainLog::getFlowChainId).collect(toSet());
        Set<String> relatedFlowIds = flowLogDBService.getFlowIdsByChainIds(relatedChainIds);
        List<FlowLog> relatedFlowLogs = flowLogDBService.getFlowLogsByFlowIdsCreatedDesc(relatedFlowIds);
        flowCheckResponse.setHasActiveFlow(!completed("Flow chain", chainId, relatedChains, relatedFlowLogs));
        flowCheckResponse.setLatestFlowFinalizedAndFailed(isFlowInFailedState(relatedFlowLogs, failHandledEvents));
        return flowCheckResponse;
    } else {
        flowCheckResponse.setHasActiveFlow(Boolean.FALSE);
        return flowCheckResponse;
    }
}
Also used : FlowCheckResponse(com.sequenceiq.flow.api.model.FlowCheckResponse) FlowLog(com.sequenceiq.flow.domain.FlowLog) FlowChainLog(com.sequenceiq.flow.domain.FlowChainLog)

Aggregations

FlowCheckResponse (com.sequenceiq.flow.api.model.FlowCheckResponse)23 Test (org.junit.Test)10 FlowLog (com.sequenceiq.flow.domain.FlowLog)3 FlowChainLog (com.sequenceiq.flow.domain.FlowChainLog)2 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 FlowPublicEndpoint (com.sequenceiq.flow.api.FlowPublicEndpoint)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 NotFoundException (javax.ws.rs.NotFoundException)1 Test (org.junit.jupiter.api.Test)1