Search in sources :

Example 26 with Selectable

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

the class FlowChainHandler method restoreFlowChain.

public void restoreFlowChain(String flowChainId) {
    FlowChainLog chainLog = flowChainLogRepository.findFirstByFlowChainIdOrderByCreatedDesc(flowChainId);
    if (chainLog != null) {
        Queue<Selectable> chain = (Queue<Selectable>) JsonReader.jsonToJava(chainLog.getChain());
        flowChains.putFlowChain(flowChainId, chainLog.getParentFlowChainId(), chain);
        if (chainLog.getParentFlowChainId() != null) {
            restoreFlowChain(chainLog.getParentFlowChainId());
        }
    }
}
Also used : Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) FlowChainLog(com.sequenceiq.cloudbreak.domain.FlowChainLog) Queue(java.util.Queue)

Example 27 with Selectable

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

the class EphemeralClusterActions method updateNameserverAction.

@Bean(name = "EPHEMERAL_CLUSTER_UPDATE_STATE")
public Action<?, ?> updateNameserverAction() {
    return new AbstractClusterAction<EphemeralClusterUpdateTriggerEvent>(EphemeralClusterUpdateTriggerEvent.class) {

        @Override
        protected void doExecute(ClusterViewContext context, EphemeralClusterUpdateTriggerEvent payload, Map<Object, Object> variables) {
            ephemeralClusterService.updateClusterStarted(context.getStackId());
            Selectable request = new EphemeralClusterUpdateRequest(context.getStackId());
            sendEvent(context.getFlowId(), request.selector(), request);
        }
    };
}
Also used : EphemeralClusterUpdateRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClusterUpdateRequest) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) EphemeralClusterUpdateTriggerEvent(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.EphemeralClusterUpdateTriggerEvent) 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 28 with Selectable

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

the class ClusterDownscaleActions method decommissionAction.

@Bean(name = "DECOMMISSION_STATE")
public Action<?, ?> decommissionAction() {
    return new AbstractClusterAction<CollectDownscaleCandidatesResult>(CollectDownscaleCandidatesResult.class) {

        @Override
        protected void doExecute(ClusterViewContext context, CollectDownscaleCandidatesResult payload, Map<Object, Object> variables) {
            Selectable request = new DecommissionRequest(context.getStackId(), payload.getHostGroupName(), payload.getHostNames());
            sendEvent(context.getFlowId(), request.selector(), request);
        }
    };
}
Also used : Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) DecommissionRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionRequest) CollectDownscaleCandidatesResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.CollectDownscaleCandidatesResult) 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 29 with Selectable

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

the class WaitingAmbariServerHandler method accept.

@Override
public void accept(Event<WaitForAmbariServerRequest> event) {
    Long stackId = event.getData().getStackId();
    Selectable response;
    try {
        Stack stack = stackService.getById(stackId);
        ambariClusterConnector.waitForServer(stack);
        response = new WaitForAmbariServerSuccess(stackId);
    } catch (Exception e) {
        response = new WaitForAmbariServerFailed(stackId, e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : WaitForAmbariServerSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.WaitForAmbariServerSuccess) WaitForAmbariServerFailed(com.sequenceiq.cloudbreak.reactor.api.event.cluster.WaitForAmbariServerFailed) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 30 with Selectable

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

the class BootstrapMachineHandler method accept.

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

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