Search in sources :

Example 1 with ClusterScaleTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent in project cloudbreak by hortonworks.

the class ReactorFlowManager method triggerClusterUpscale.

public void triggerClusterUpscale(Long stackId, HostGroupAdjustmentJson hostGroupAdjustment) {
    String selector = CLUSTER_UPSCALE_TRIGGER_EVENT.event();
    Acceptable event = new ClusterScaleTriggerEvent(selector, stackId, hostGroupAdjustment.getHostGroup(), hostGroupAdjustment.getScalingAdjustment());
    notify(selector, event);
}
Also used : ClusterScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent) Acceptable(com.sequenceiq.cloudbreak.cloud.Acceptable)

Example 2 with ClusterScaleTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent in project cloudbreak by hortonworks.

the class UpscaleFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public Queue<Selectable> createFlowTriggerEventQueue(StackAndClusterUpscaleTriggerEvent event) {
    StackView stackView = stackService.getByIdView(event.getStackId());
    ClusterView clusterView = stackView.getClusterView();
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new StackSyncTriggerEvent(STACK_SYNC_EVENT.event(), event.getStackId(), false, event.accepted()));
    flowEventChain.add(new StackScaleTriggerEvent(ADD_INSTANCES_EVENT.event(), event.getStackId(), event.getInstanceGroup(), event.getAdjustment(), event.getHostNames()));
    if (ScalingType.isClusterUpScale(event.getScalingType()) && clusterView != null) {
        HostGroup hostGroup = hostGroupService.getByClusterIdAndInstanceGroupName(clusterView.getId(), event.getInstanceGroup());
        flowEventChain.add(new ClusterScaleTriggerEvent(CLUSTER_UPSCALE_TRIGGER_EVENT.event(), stackView.getId(), hostGroup.getName(), event.getAdjustment()));
    }
    return flowEventChain;
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) StackScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) ClusterScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent) StackSyncTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackSyncTriggerEvent) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 3 with ClusterScaleTriggerEvent

use of com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent 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

ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)3 Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)2 StackScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent)2 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)2 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 Acceptable (com.sequenceiq.cloudbreak.cloud.Acceptable)1 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)1 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)1 StackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent)1 StackSyncTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackSyncTriggerEvent)1 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)1 ClusterView (com.sequenceiq.cloudbreak.domain.view.ClusterView)1