Search in sources :

Example 1 with Acceptable

use of com.sequenceiq.cloudbreak.cloud.Acceptable in project cloudbreak by hortonworks.

the class ReactorFlowManager method notify.

private void notify(String selector, Acceptable acceptable) {
    Event<Acceptable> event = eventFactory.createEventWithErrHandler(acceptable);
    reactor.notify(selector, event);
    try {
        Boolean accepted = true;
        if (event.getData().accepted() != null) {
            accepted = event.getData().accepted().await(WAIT_FOR_ACCEPT, TimeUnit.SECONDS);
        }
        if (accepted == null || !accepted) {
            Stack stack = stackService.get(event.getData().getStackId());
            throw new FlowsAlreadyRunningException(String.format("Stack %s has flows under operation, request not allowed.", stack.getName()));
        }
    } catch (InterruptedException e) {
        throw new CloudbreakApiException(e.getMessage());
    }
}
Also used : FlowsAlreadyRunningException(com.sequenceiq.cloudbreak.controller.FlowsAlreadyRunningException) Acceptable(com.sequenceiq.cloudbreak.cloud.Acceptable) CloudbreakApiException(com.sequenceiq.cloudbreak.controller.CloudbreakApiException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 2 with Acceptable

use of com.sequenceiq.cloudbreak.cloud.Acceptable 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 3 with Acceptable

use of com.sequenceiq.cloudbreak.cloud.Acceptable in project cloudbreak by hortonworks.

the class ReactorFlowManager method triggerStackUpscale.

public void triggerStackUpscale(Long stackId, InstanceGroupAdjustmentJson instanceGroupAdjustment, boolean withClusterEvent) {
    String selector = FlowChainTriggers.FULL_UPSCALE_TRIGGER_EVENT;
    Acceptable stackAndClusterUpscaleTriggerEvent = new StackAndClusterUpscaleTriggerEvent(selector, stackId, instanceGroupAdjustment.getInstanceGroup(), instanceGroupAdjustment.getScalingAdjustment(), withClusterEvent ? ScalingType.UPSCALE_TOGETHER : ScalingType.UPSCALE_ONLY_STACK);
    notify(selector, stackAndClusterUpscaleTriggerEvent);
}
Also used : StackAndClusterUpscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent) Acceptable(com.sequenceiq.cloudbreak.cloud.Acceptable)

Example 4 with Acceptable

use of com.sequenceiq.cloudbreak.cloud.Acceptable 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 5 with Acceptable

use of com.sequenceiq.cloudbreak.cloud.Acceptable in project cloudbreak by hortonworks.

the class ReactorFlowManager method triggerClusterDownscale.

public void triggerClusterDownscale(Long stackId, HostGroupAdjustmentJson hostGroupAdjustment) {
    String selector = FlowChainTriggers.FULL_DOWNSCALE_TRIGGER_EVENT;
    ScalingType scalingType = hostGroupAdjustment.getWithStackUpdate() ? ScalingType.DOWNSCALE_TOGETHER : ScalingType.DOWNSCALE_ONLY_CLUSTER;
    Acceptable event = new ClusterAndStackDownscaleTriggerEvent(selector, stackId, hostGroupAdjustment.getHostGroup(), hostGroupAdjustment.getScalingAdjustment(), scalingType);
    notify(selector, event);
}
Also used : ScalingType(com.sequenceiq.cloudbreak.common.type.ScalingType) ClusterAndStackDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent) Acceptable(com.sequenceiq.cloudbreak.cloud.Acceptable)

Aggregations

Acceptable (com.sequenceiq.cloudbreak.cloud.Acceptable)7 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)2 Stack (com.sequenceiq.cloudbreak.domain.Stack)2 ScalingType (com.sequenceiq.cloudbreak.common.type.ScalingType)1 CloudbreakApiException (com.sequenceiq.cloudbreak.controller.CloudbreakApiException)1 FlowsAlreadyRunningException (com.sequenceiq.cloudbreak.controller.FlowsAlreadyRunningException)1 ClusterTerminationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.termination.ClusterTerminationEvent)1 ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)1 StackAndClusterUpscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent)1 StackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent)1 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 Before (org.junit.Before)1 Event (reactor.bus.Event)1 EventBus (reactor.bus.EventBus)1 ThreadPoolExecutorDispatcher (reactor.core.dispatch.ThreadPoolExecutorDispatcher)1 Promise (reactor.rx.Promise)1