Search in sources :

Example 6 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class EphemeralClusterUpdateHandler method accept.

@Override
public void accept(Event<EphemeralClusterUpdateRequest> event) {
    EphemeralClusterUpdateRequest request = event.getData();
    Selectable response;
    try {
        clusterServiceRunner.updateSaltState(request.getStackId());
        response = new EphemeralClusterUpdateSuccess(request.getStackId());
    } catch (Exception e) {
        response = new EphemeralClusterUpdateFailed(request.getStackId(), e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : EphemeralClusterUpdateRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClusterUpdateRequest) EphemeralClusterUpdateSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClusterUpdateSuccess) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) EphemeralClusterUpdateFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClusterUpdateFailed)

Example 7 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class StackDownscaleActions method stackDownscaleAction.

@Bean(name = "DOWNSCALE_STATE")
public Action<?, ?> stackDownscaleAction() {
    return new AbstractStackDownscaleAction<DownscaleStackCollectResourcesResult>(DownscaleStackCollectResourcesResult.class) {

        @Override
        protected void doExecute(StackScalingFlowContext context, DownscaleStackCollectResourcesResult payload, Map<Object, Object> variables) {
            Selectable request = new DownscaleStackRequest(context.getCloudContext(), context.getCloudCredential(), context.getCloudStack(), (List<CloudResource>) variables.get(RESOURCES), (List<CloudInstance>) variables.get(INSTANCES), payload.getResourcesToScale());
            sendEvent(context.getFlowId(), request);
        }
    };
}
Also used : Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) DownscaleStackCollectResourcesResult(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesResult) DownscaleStackRequest(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackRequest) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 8 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class ChangePrimaryGatewayActions method repairGatewayAction.

@Bean(name = "CHANGE_PRIMARY_GATEWAY_STATE")
public Action<?, ?> repairGatewayAction() {
    return new AbstractClusterAction<ChangePrimaryGatewayTriggerEvent>(ChangePrimaryGatewayTriggerEvent.class) {

        @Override
        protected void doExecute(ClusterViewContext context, ChangePrimaryGatewayTriggerEvent payload, Map<Object, Object> variables) {
            changePrimaryGatewayService.changePrimaryGatewayStarted(context.getStackId());
            Selectable request = new ChangePrimaryGatewayRequest(context.getStackId());
            sendEvent(context.getFlowId(), request.selector(), request);
        }
    };
}
Also used : ChangePrimaryGatewayTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayTriggerEvent) ChangePrimaryGatewayRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayRequest) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) AbstractClusterAction(com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction) Map(java.util.Map) ClusterViewContext(com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext) Bean(org.springframework.context.annotation.Bean)

Example 9 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class ClusterDownscaleActions method collectCandidatesAction.

@Bean(name = "COLLECT_CANDIDATES_STATE")
public Action<?, ?> collectCandidatesAction() {
    return new AbstractClusterAction<ClusterDownscaleTriggerEvent>(ClusterDownscaleTriggerEvent.class) {

        @Override
        protected void doExecute(ClusterViewContext context, ClusterDownscaleTriggerEvent payload, Map<Object, Object> variables) {
            clusterDownscaleService.clusterDownscaleStarted(context.getStackId(), payload.getHostGroupName(), payload.getAdjustment(), payload.getHostNames());
            Selectable request = new CollectDownscaleCandidatesRequest(context.getStackId(), payload.getHostGroupName(), payload.getAdjustment(), payload.getHostNames());
            sendEvent(context.getFlowId(), request.selector(), request);
        }
    };
}
Also used : ClusterDownscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) CollectDownscaleCandidatesRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesRequest) AbstractClusterAction(com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction) Map(java.util.Map) ClusterViewContext(com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext) Bean(org.springframework.context.annotation.Bean)

Example 10 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class FlowChains method triggerNextFlow.

public void triggerNextFlow(String flowChainId) {
    Queue<Selectable> queue = flowChainMap.get(flowChainId);
    if (queue != null) {
        Selectable selectable = queue.poll();
        if (selectable != null) {
            sendEvent(flowChainId, selectable);
        } else {
            removeFlowChain(flowChainId);
            triggerParentFlowChain(flowChainId);
        }
        flowLogService.saveChain(flowChainId, flowChainParentMap.get(flowChainId), queue);
    }
}
Also used : Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable)

Aggregations

Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)35 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)10 Map (java.util.Map)10 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)10 Bean (org.springframework.context.annotation.Bean)9 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)5 Stack (com.sequenceiq.cloudbreak.domain.Stack)5 AbstractClusterAction (com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction)4 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)4 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)3 StackScalingFlowContext (com.sequenceiq.cloudbreak.core.flow2.stack.downscale.StackScalingFlowContext)3 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)3 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)3 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)2 ClusterTerminationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.termination.ClusterTerminationEvent)2 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)2 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)2 ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)2 StackAndClusterUpscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent)2