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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations