Search in sources :

Example 6 with FlowTriggerConditionResult

use of com.sequenceiq.flow.core.FlowTriggerConditionResult in project cloudbreak by hortonworks.

the class StackLoadBalancerUpdateTriggerCondition method isFlowTriggerable.

@Override
public FlowTriggerConditionResult isFlowTriggerable(Long stackId) {
    FlowTriggerConditionResult result = FlowTriggerConditionResult.OK;
    Stack stack = stackService.getByIdWithTransaction(stackId);
    DetailedEnvironmentResponse environment = environmentClientService.getByCrn(stack.getEnvironmentCrn());
    Set<InstanceGroup> instanceGroups = instanceGroupService.findByStackId(stack.getId());
    stack.setInstanceGroups(instanceGroups);
    if (!loadBalancerConfigService.isLoadBalancerCreationConfigured(stack, environment)) {
        String msg = "Load balancer update could not be configured because load balancers are not enabled for the stack. " + "Check that correct entitlements are enabled and the environment has valid network settings. Ending flow.";
        LOGGER.debug(msg);
        result = new FlowTriggerConditionResult(msg);
    }
    return result;
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) FlowTriggerConditionResult(com.sequenceiq.flow.core.FlowTriggerConditionResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 7 with FlowTriggerConditionResult

use of com.sequenceiq.flow.core.FlowTriggerConditionResult in project cloudbreak by hortonworks.

the class ClusterStartFlowTriggerCondition method isFlowTriggerable.

@Override
public FlowTriggerConditionResult isFlowTriggerable(Long stackId) {
    FlowTriggerConditionResult result = FlowTriggerConditionResult.OK;
    StackView stackView = stackService.getViewByIdWithoutAuth(stackId);
    ClusterView clusterView = stackView.getClusterView();
    if (clusterView == null || !stackView.isStartInProgress()) {
        String msg = String.format("Cluster start cannot be triggered, because cluster %s.", clusterView == null ? "is null" : "not in startRequested status");
        LOGGER.info(msg);
        result = new FlowTriggerConditionResult(msg);
    }
    return result;
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) FlowTriggerConditionResult(com.sequenceiq.flow.core.FlowTriggerConditionResult)

Example 8 with FlowTriggerConditionResult

use of com.sequenceiq.flow.core.FlowTriggerConditionResult in project cloudbreak by hortonworks.

the class FlowComponentTest method startFlowChainWhenSecondFlowTriggerConditionFailsItShouldFail.

@Test
public void startFlowChainWhenSecondFlowTriggerConditionFailsItShouldFail() throws InterruptedException {
    reset(sleepTriggerCondition);
    when(sleepTriggerCondition.isFlowTriggerable(anyLong())).thenReturn(FlowTriggerConditionResult.OK).thenReturn(new FlowTriggerConditionResult("Error"));
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    SleepChainTriggerEvent sleepChainTriggerEvent = new SleepChainTriggerEvent(resourceId, Lists.newArrayList(new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL), new SleepConfig(SLEEP_TIME, SleepStartEvent.NEVER_FAIL)));
    FlowAcceptResult acceptResult = startSleepFlowChain(sleepChainTriggerEvent);
    assertRunningInFlowChain(acceptResult);
    waitFlowChainToFail(SLEEP_TIME.multipliedBy(WAIT_FACTOR), acceptResult);
}
Also used : FlowAcceptResult(com.sequenceiq.flow.core.model.FlowAcceptResult) SleepChainTriggerEvent(com.sequenceiq.flow.component.sleep.event.SleepChainTriggerEvent) NestedSleepChainTriggerEvent(com.sequenceiq.flow.component.sleep.event.NestedSleepChainTriggerEvent) FlowTriggerConditionResult(com.sequenceiq.flow.core.FlowTriggerConditionResult) SleepConfig(com.sequenceiq.flow.component.sleep.event.SleepConfig) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with FlowTriggerConditionResult

use of com.sequenceiq.flow.core.FlowTriggerConditionResult in project cloudbreak by hortonworks.

the class CcmUpgradeFlowTriggerCondition method isFlowTriggerable.

@Override
public FlowTriggerConditionResult isFlowTriggerable(Long stackId) {
    FlowTriggerConditionResult result = FlowTriggerConditionResult.OK;
    Stack stack = stackService.getByIdWithTransaction(stackId);
    boolean resourcesIsInTriggerableState = stack.isAvailable() && stack.getCluster() != null;
    if (!resourcesIsInTriggerableState) {
        String msg = "Cluster Connectivity Manager upgrade could not be triggered, because the cluster's state is not available.";
        LOGGER.info(msg);
        result = new FlowTriggerConditionResult(msg);
    }
    return result;
}
Also used : FlowTriggerConditionResult(com.sequenceiq.flow.core.FlowTriggerConditionResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 10 with FlowTriggerConditionResult

use of com.sequenceiq.flow.core.FlowTriggerConditionResult in project cloudbreak by hortonworks.

the class StackStopFlowTriggerCondition method isFlowTriggerable.

@Override
public FlowTriggerConditionResult isFlowTriggerable(Long stackId) {
    FlowTriggerConditionResult result = FlowTriggerConditionResult.OK;
    Stack stack = stackService.getStackById(stackId);
    if (!stackStopService.isStopPossible(stack)) {
        String msg = "Stopping stack is not possible because stack is not in stop requested state.";
        LOGGER.debug(msg);
        result = new FlowTriggerConditionResult(msg);
    }
    return result;
}
Also used : FlowTriggerConditionResult(com.sequenceiq.flow.core.FlowTriggerConditionResult) Stack(com.sequenceiq.freeipa.entity.Stack)

Aggregations

FlowTriggerConditionResult (com.sequenceiq.flow.core.FlowTriggerConditionResult)10 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)1 ClusterView (com.sequenceiq.cloudbreak.domain.view.ClusterView)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1 NestedSleepChainTriggerEvent (com.sequenceiq.flow.component.sleep.event.NestedSleepChainTriggerEvent)1 SleepChainTriggerEvent (com.sequenceiq.flow.component.sleep.event.SleepChainTriggerEvent)1 SleepConfig (com.sequenceiq.flow.component.sleep.event.SleepConfig)1 FlowAcceptResult (com.sequenceiq.flow.core.model.FlowAcceptResult)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 Test (org.junit.jupiter.api.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1