Search in sources :

Example 1 with StackScaleTriggerEvent

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

the class StackUpscaleActions method addInstances.

@Bean(name = "ADD_INSTANCES_STATE")
public Action<?, ?> addInstances() {
    return new AbstractStackUpscaleAction<StackScaleTriggerEvent>(StackScaleTriggerEvent.class) {

        @Override
        protected void prepareExecution(StackScaleTriggerEvent payload, Map<Object, Object> variables) {
            variables.put(INSTANCEGROUPNAME, payload.getInstanceGroup());
            variables.put(ADJUSTMENT, payload.getAdjustment());
            variables.put(HOSTNAMES, payload.getHostNames());
        }

        @Override
        protected void doExecute(StackScalingFlowContext context, StackScaleTriggerEvent payload, Map<Object, Object> variables) {
            stackUpscaleService.startAddInstances(context.getStack(), payload.getAdjustment());
            sendEvent(context);
        }

        @Override
        protected Selectable createRequest(StackScalingFlowContext context) {
            LOGGER.debug("Assembling upscale stack event for stack: {}", context.getStack());
            InstanceGroup group = context.getStack().getInstanceGroupByInstanceGroupName(context.getInstanceGroupName());
            group.setNodeCount(group.getNodeCount() + context.getAdjustment());
            CloudStack cloudStack = cloudStackConverter.convert(context.getStack());
            instanceMetadataService.saveInstanceRequests(context.getStack(), cloudStack.getGroups());
            List<CloudResource> resources = cloudResourceConverter.convert(context.getStack().getResources());
            return new UpscaleStackRequest<UpscaleStackResult>(context.getCloudContext(), context.getCloudCredential(), cloudStack, resources);
        }
    };
}
Also used : StackScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent) UpscaleStackRequest(com.sequenceiq.cloudbreak.cloud.event.resource.UpscaleStackRequest) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Map(java.util.Map) StackScalingFlowContext(com.sequenceiq.cloudbreak.core.flow2.stack.downscale.StackScalingFlowContext) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Bean(org.springframework.context.annotation.Bean)

Example 2 with StackScaleTriggerEvent

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

the class ReactorFlowManager method triggerStackDownscale.

public void triggerStackDownscale(Long stackId, InstanceGroupAdjustmentJson instanceGroupAdjustment) {
    String selector = STACK_DOWNSCALE_EVENT.event();
    Acceptable stackScaleTriggerEvent = new StackDownscaleTriggerEvent(selector, stackId, instanceGroupAdjustment.getInstanceGroup(), instanceGroupAdjustment.getScalingAdjustment());
    notify(selector, stackScaleTriggerEvent);
}
Also used : ClusterAndStackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent) StackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent) Acceptable(com.sequenceiq.cloudbreak.cloud.Acceptable)

Example 3 with StackScaleTriggerEvent

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

the class AbstractStackDownscaleAction method extractInstanceGroupName.

private String extractInstanceGroupName(P payload, Map<Object, Object> variables) {
    if (payload instanceof StackScaleTriggerEvent) {
        StackScaleTriggerEvent ssc = (StackScaleTriggerEvent) payload;
        variables.put(INSTANCEGROUPNAME, ssc.getInstanceGroup());
        return ssc.getInstanceGroup();
    }
    return getInstanceGroupName(variables);
}
Also used : StackScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent)

Example 4 with StackScaleTriggerEvent

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

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

StackScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent)4 Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)2 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)2 ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)2 StackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent)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 UpscaleStackRequest (com.sequenceiq.cloudbreak.cloud.event.resource.UpscaleStackRequest)1 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)1 StackSyncTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackSyncTriggerEvent)1 StackScalingFlowContext (com.sequenceiq.cloudbreak.core.flow2.stack.downscale.StackScalingFlowContext)1 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)1 ClusterView (com.sequenceiq.cloudbreak.domain.view.ClusterView)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1