Search in sources :

Example 1 with OperationFlowsView

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

the class OperationService method getOperationProgressByResourceCrn.

public OperationView getOperationProgressByResourceCrn(String resourceCrn, boolean detailed) {
    OperationView stackOperationView = new OperationView();
    try {
        OperationResource operationResource = OperationResource.fromCrn(Crn.safeFromString(resourceCrn));
        Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(resourceCrn);
        if (operationFlowsViewOpt.isPresent()) {
            OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
            OperationType operationType = operationFlowsView.getOperationType();
            if (OperationType.PROVISION.equals(operationType)) {
                stackOperationView = handleProvisionOperation(resourceCrn, operationResource, operationFlowsView, detailed);
            } else {
                stackOperationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource);
            }
        }
    } catch (Exception e) {
        LOGGER.debug(String.format("Could not fetch remote database details for stack with crn %s", resourceCrn), e);
    }
    return stackOperationView;
}
Also used : OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationFlowsView(com.sequenceiq.flow.api.model.operation.OperationFlowsView) OperationType(com.sequenceiq.flow.api.model.operation.OperationType) OperationResource(com.sequenceiq.flow.api.model.operation.OperationResource)

Example 2 with OperationFlowsView

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

the class OperationService method getOperationProgressByResourceCrn.

public OperationView getOperationProgressByResourceCrn(String resourceCrn, boolean detailed) {
    OperationView response = new OperationView();
    Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(resourceCrn);
    if (operationFlowsViewOpt.isPresent()) {
        return operationDetailsPopulator.createOperationView(operationFlowsViewOpt.get(), OperationResource.REMOTEDB);
    }
    return response;
}
Also used : OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationFlowsView(com.sequenceiq.flow.api.model.operation.OperationFlowsView)

Example 3 with OperationFlowsView

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

the class OperationDetailsPopulatorTest method testCreateOperationViewWithFailedState.

@Test
public void testCreateOperationViewWithFailedState() {
    // GIVEN
    Map<String, FlowProgressResponse> flowProgressResponseMap = new HashMap<>();
    flowProgressResponseMap.put(DUMMY_CLASS, createFlowProgressResponse("FAILED", true).get());
    OperationFlowsView operationFlowsView = createOperationFlowsView(flowProgressResponseMap);
    // WHEN
    OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
    // THEN
    assertEquals(MAX_PROGRESS, operationView.getProgress());
    assertEquals(OperationProgressStatus.FAILED, operationView.getProgressStatus());
}
Also used : FlowProgressResponse(com.sequenceiq.flow.api.model.FlowProgressResponse) HashMap(java.util.HashMap) OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationFlowsView(com.sequenceiq.flow.api.model.operation.OperationFlowsView) Test(org.junit.jupiter.api.Test)

Example 4 with OperationFlowsView

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

the class OperationDetailsPopulatorTest method testCreateOperationViewWithPendingState.

@Test
public void testCreateOperationViewWithPendingState() {
    // GIVEN
    Map<String, FlowProgressResponse> flowProgressResponseMap = new HashMap<>();
    flowProgressResponseMap.put(DUMMY_CLASS, createFlowProgressResponse("SUCCESSFUL", false).get());
    OperationFlowsView operationFlowsView = createOperationFlowsView(flowProgressResponseMap);
    // WHEN
    OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
    // THEN
    assertEquals(IN_PROGRESS_FROM_HISTORY, operationView.getProgress());
    assertEquals(OperationProgressStatus.RUNNING, operationView.getProgressStatus());
}
Also used : FlowProgressResponse(com.sequenceiq.flow.api.model.FlowProgressResponse) HashMap(java.util.HashMap) OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationFlowsView(com.sequenceiq.flow.api.model.operation.OperationFlowsView) Test(org.junit.jupiter.api.Test)

Example 5 with OperationFlowsView

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

the class FlowOperationService method getOperationProgressByEnvironmentCrn.

public OperationView getOperationProgressByEnvironmentCrn(String environmentCrn, boolean detailed) {
    OperationView operationView = new OperationView();
    Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(environmentCrn);
    if (operationFlowsViewOpt.isPresent()) {
        OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
        OperationResource operationResource = OperationResource.FREEIPA;
        com.sequenceiq.flow.api.model.operation.OperationType operationType = operationFlowsView.getOperationType();
        if (com.sequenceiq.flow.api.model.operation.OperationType.PROVISION.equals(operationType)) {
            operationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource, List.of(StackProvisionFlowConfig.class, FreeIpaProvisionFlowConfig.class));
        } else {
            operationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource);
        }
    }
    return operationView;
}
Also used : OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationFlowsView(com.sequenceiq.flow.api.model.operation.OperationFlowsView) OperationResource(com.sequenceiq.flow.api.model.operation.OperationResource)

Aggregations

OperationFlowsView (com.sequenceiq.flow.api.model.operation.OperationFlowsView)10 OperationView (com.sequenceiq.flow.api.model.operation.OperationView)9 FlowProgressResponse (com.sequenceiq.flow.api.model.FlowProgressResponse)4 OperationType (com.sequenceiq.flow.api.model.operation.OperationType)4 HashMap (java.util.HashMap)4 Test (org.junit.jupiter.api.Test)4 OperationResource (com.sequenceiq.flow.api.model.operation.OperationResource)2 Splitter (com.google.common.base.Splitter)1 EvictingQueue (com.google.common.collect.EvictingQueue)1 PayloadContext (com.sequenceiq.cloudbreak.common.event.PayloadContext)1 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)1 FlowProgressResponseConverter (com.sequenceiq.flow.converter.FlowProgressResponseConverter)1 PayloadContextProvider (com.sequenceiq.flow.core.PayloadContextProvider)1 FlowStat (com.sequenceiq.flow.core.cache.FlowStat)1 FlowLog (com.sequenceiq.flow.domain.FlowLog)1 FlowOperationStats (com.sequenceiq.flow.domain.FlowOperationStats)1 FlowOperationStatsRepository (com.sequenceiq.flow.repository.FlowOperationStatsRepository)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1