Search in sources :

Example 11 with Constraint

use of com.sequenceiq.cloudbreak.domain.Constraint in project cloudbreak by hortonworks.

the class TestUtil method hostGroup.

public static HostGroup hostGroup(String name, int count) {
    HostGroup hostGroup = new HostGroup();
    hostGroup.setId(1L);
    hostGroup.setName(name);
    hostGroup.setRecipes(recipes(1));
    hostGroup.setHostMetadata(hostMetadata(hostGroup, count));
    InstanceGroup instanceGroup = instanceGroup(1L, name, InstanceGroupType.CORE, gcpTemplate(1L), count);
    Constraint constraint = new Constraint();
    constraint.setInstanceGroup(instanceGroup);
    constraint.setHostCount(instanceGroup.getNodeCount());
    hostGroup.setConstraint(constraint);
    hostGroup.setCluster(cluster(blueprint(), stack(), 1L));
    hostGroup.setRecoveryMode(RecoveryMode.MANUAL);
    return hostGroup;
}
Also used : Constraint(com.sequenceiq.cloudbreak.domain.Constraint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 12 with Constraint

use of com.sequenceiq.cloudbreak.domain.Constraint in project cloudbreak by hortonworks.

the class DownscaleFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public Queue<Selectable> createFlowTriggerEventQueue(ClusterAndStackDownscaleTriggerEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    ClusterScaleTriggerEvent cste;
    cste = event.getHostNames() == null ? new ClusterDownscaleTriggerEvent(DECOMMISSION_EVENT.event(), event.getStackId(), event.getHostGroupName(), event.getAdjustment(), event.accepted()) : new ClusterDownscaleTriggerEvent(DECOMMISSION_EVENT.event(), event.getStackId(), event.getHostGroupName(), event.getHostNames(), event.accepted());
    flowEventChain.add(cste);
    if (event.getScalingType() == ScalingType.DOWNSCALE_TOGETHER) {
        StackView stackView = stackService.getByIdView(event.getStackId());
        HostGroup hostGroup = hostGroupService.getByClusterIdAndName(stackView.getClusterView().getId(), event.getHostGroupName());
        Constraint hostGroupConstraint = hostGroup.getConstraint();
        String instanceGroupName = Optional.ofNullable(hostGroupConstraint.getInstanceGroup()).map(InstanceGroup::getGroupName).orElse(null);
        StackScaleTriggerEvent sste;
        sste = event.getHostNames() == null ? new StackDownscaleTriggerEvent(STACK_DOWNSCALE_EVENT.event(), event.getStackId(), instanceGroupName, event.getAdjustment()) : new StackDownscaleTriggerEvent(STACK_DOWNSCALE_EVENT.event(), event.getStackId(), instanceGroupName, event.getHostNames());
        flowEventChain.add(sste);
    }
    return flowEventChain;
}
Also used : ClusterDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent) StackScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) Constraint(com.sequenceiq.cloudbreak.domain.Constraint) ClusterScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent) ClusterAndStackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent) StackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) StackView(com.sequenceiq.cloudbreak.domain.view.StackView)

Aggregations

Constraint (com.sequenceiq.cloudbreak.domain.Constraint)12 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)9 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)5 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)3 ConstraintJson (com.sequenceiq.cloudbreak.api.model.ConstraintJson)2 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)2 RecipeRequest (com.sequenceiq.cloudbreak.api.model.RecipeRequest)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)1 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)1 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)1 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)1 ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)1 StackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent)1 StackScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent)1 ConstraintTemplate (com.sequenceiq.cloudbreak.domain.ConstraintTemplate)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)1 Recipe (com.sequenceiq.cloudbreak.domain.Recipe)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)1