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