Search in sources :

Example 11 with FlowLogResponse

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

the class SdxUpgradeValidationResultProviderTest method createLastFlowLog.

private FlowLogResponse createLastFlowLog() {
    FlowLogResponse flowLogResponse = new FlowLogResponse();
    flowLogResponse.setFlowId(FLOW_ID);
    return flowLogResponse;
}
Also used : FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse)

Example 12 with FlowLogResponse

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

the class CloudbreakFlowServiceTest method testSaveFlowIdWhenNoFlowIdentifierIsPresent.

@Test
public void testSaveFlowIdWhenNoFlowIdentifierIsPresent() {
    SdxCluster cluster = new SdxCluster();
    cluster.setLastCbFlowChainId(FLOW_CHAIN_ID);
    cluster.setInitiatorUserCrn(USER_CRN);
    cluster.setClusterName(CLUSTER_NAME);
    FlowLogResponse response = new FlowLogResponse();
    response.setStateStatus(StateStatus.SUCCESSFUL);
    response.setFinalized(true);
    response.setFlowId(FLOW_ID);
    when(flowEndpoint.getLastFlowByResourceName(any(), anyString())).thenReturn(response);
    when(sdxClusterRepository.save(any())).thenReturn(cluster);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    underTest.saveLastCloudbreakFlowChainId(cluster, null);
    verify(flowEndpoint).getLastFlowByResourceName(any(), anyString());
    verify(sdxClusterRepository).save(clusterCaptor.capture());
    assertEquals(FLOW_ID, clusterCaptor.getValue().getLastCbFlowId());
    assertNull(clusterCaptor.getValue().getLastCbFlowChainId());
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse) Test(org.junit.jupiter.api.Test)

Example 13 with FlowLogResponse

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

the class LoadBalancerPollerServiceTest method setupSuccessFlowLogResponse.

private FlowLogResponse setupSuccessFlowLogResponse() {
    FlowLogResponse flowLogResponse = new FlowLogResponse();
    flowLogResponse.setCurrentState(LOAD_BALANCER_UPDATE_FINISHED_STATE);
    return flowLogResponse;
}
Also used : FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse)

Example 14 with FlowLogResponse

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

the class CloudbreakFlowService method trySaveLastCbFlowIdOrFlowChainId.

private void trySaveLastCbFlowIdOrFlowChainId(SdxCluster sdxCluster) {
    try {
        FlowLogResponse lastFlowByResourceName = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> flowEndpoint.getLastFlowByResourceName(sdxCluster.getAccountId(), sdxCluster.getClusterName()));
        logFlowLogResponse(lastFlowByResourceName);
        if (StringUtils.isNotBlank(lastFlowByResourceName.getFlowChainId())) {
            setFlowChainIdAndResetFlowId(sdxCluster, lastFlowByResourceName.getFlowChainId());
        } else if (StringUtils.isNotBlank(lastFlowByResourceName.getFlowId())) {
            setFlowIdAndResetFlowChainId(sdxCluster, lastFlowByResourceName.getFlowId());
        } else {
            resetFlowIdAndFlowChainId(sdxCluster);
        }
    } catch (Exception ex) {
        LOGGER.info("Not found flow id for cluster: {}. Reset laast flow id to null.", sdxCluster.getClusterName());
        resetFlowIdAndFlowChainId(sdxCluster);
    }
    sdxClusterRepository.save(sdxCluster);
}
Also used : FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse) NotFoundException(javax.ws.rs.NotFoundException)

Example 15 with FlowLogResponse

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

the class FlowLogConverter method convert.

public FlowLogResponse convert(FlowLog source) {
    FlowLogResponse flowLogResponse = new FlowLogResponse();
    flowLogResponse.setCreated(source.getCreated());
    flowLogResponse.setCurrentState(source.getCurrentState());
    flowLogResponse.setFinalized(source.getFinalized());
    flowLogResponse.setFlowChainId(source.getFlowChainId());
    flowLogResponse.setFlowId(source.getFlowId());
    flowLogResponse.setFlowTriggerUserCrn(source.getFlowTriggerUserCrn());
    flowLogResponse.setResourceId(source.getResourceId());
    flowLogResponse.setNextEvent(source.getNextEvent());
    flowLogResponse.setNodeId(source.getCloudbreakNodeId());
    if (source.getStateStatus() != null) {
        flowLogResponse.setStateStatus(StateStatus.valueOf(source.getStateStatus().name()));
    }
    return flowLogResponse;
}
Also used : FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse)

Aggregations

FlowLogResponse (com.sequenceiq.flow.api.model.FlowLogResponse)15 Test (org.junit.jupiter.api.Test)6 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 NotFoundException (javax.ws.rs.NotFoundException)1 Before (org.junit.Before)1