Search in sources :

Example 11 with StackView

use of com.sequenceiq.cloudbreak.domain.view.StackView in project cloudbreak by hortonworks.

the class ClusterTerminationFlowService method finishClusterTerminationNotAllowed.

public void finishClusterTerminationNotAllowed(ClusterViewContext context, ClusterTerminationResult payload) {
    StackView stackView = context.getStack();
    Long stackId = stackView.getId();
    ClusterView clusterView = context.getClusterView();
    flowMessageService.fireEventAndLog(stackId, Msg.CLUSTER_DELETE_FAILED, DELETE_FAILED.name(), "Operation not allowed");
    clusterService.updateClusterStatusByStackId(stackId, AVAILABLE);
    stackUpdater.updateStackStatus(stackId, DetailedStackStatus.AVAILABLE);
    if (clusterView.getEmailNeeded()) {
        sendDeleteFailedMail(clusterView, stackId);
    }
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) StackView(com.sequenceiq.cloudbreak.domain.view.StackView)

Example 12 with StackView

use of com.sequenceiq.cloudbreak.domain.view.StackView in project cloudbreak by hortonworks.

the class ClusterTerminationFlowService method finishClusterTerminationAllowed.

public void finishClusterTerminationAllowed(ClusterViewContext context, ClusterTerminationResult payload) {
    LOGGER.info("Terminate cluster result: {}", payload);
    StackView stackView = context.getStack();
    ClusterView clusterView = context.getClusterView();
    if (clusterView != null) {
        clusterService.cleanupKerberosCredential(clusterView.getId());
        terminationService.finalizeClusterTermination(clusterView.getId());
        clusterService.updateClusterStatusByStackId(stackView.getId(), DELETE_COMPLETED);
        InMemoryStateStore.deleteCluster(clusterView.getId());
        stackUpdater.updateStackStatus(stackView.getId(), DetailedStackStatus.AVAILABLE);
        if (clusterView.getEmailNeeded()) {
            emailSenderService.sendTerminationSuccessEmail(clusterView.getOwner(), clusterView.getEmailTo(), clusterView.getAmbariIp(), clusterView.getName());
            flowMessageService.fireEventAndLog(stackView.getId(), Msg.CLUSTER_EMAIL_SENT, DELETE_COMPLETED.name());
        }
    }
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) StackView(com.sequenceiq.cloudbreak.domain.view.StackView)

Example 13 with StackView

use of com.sequenceiq.cloudbreak.domain.view.StackView 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)

Example 14 with StackView

use of com.sequenceiq.cloudbreak.domain.view.StackView in project cloudbreak by hortonworks.

the class ClusterCreationFlowTriggerCondition method isFlowTriggerable.

@Override
public boolean isFlowTriggerable(Long stackId) {
    StackView stackView = stackService.getByIdView(stackId);
    boolean result = stackView.isAvailable() && stackView.getClusterView() != null && stackView.getClusterView().isRequested();
    if (!result) {
        LOGGER.warn("Cluster creation cannot be triggered, because cluster is not in requested status or stack is not available.");
    }
    return result;
}
Also used : StackView(com.sequenceiq.cloudbreak.domain.view.StackView)

Example 15 with StackView

use of com.sequenceiq.cloudbreak.domain.view.StackView in project cloudbreak by hortonworks.

the class AbstractClusterAction method createFlowContext.

@Override
protected ClusterViewContext createFlowContext(String flowId, StateContext<FlowState, FlowEvent> clusterContext, P payload) {
    StackView stack = stackService.getByIdView(payload.getStackId());
    MDCBuilder.buildMdcContext(stack.getId().toString(), stack.getName(), stack.getOwner(), "CLUSTER");
    return new ClusterViewContext(flowId, stack);
}
Also used : StackView(com.sequenceiq.cloudbreak.domain.view.StackView)

Aggregations

StackView (com.sequenceiq.cloudbreak.domain.view.StackView)18 ClusterView (com.sequenceiq.cloudbreak.domain.view.ClusterView)5 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)4 Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)3 Flow (com.sequenceiq.cloudbreak.core.flow2.Flow)3 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)2 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)2 ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)2 StackScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent)2 StackFailureContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackFailureContext)2 HostGroupService (com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService)2 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)2 List (java.util.List)2 Map (java.util.Map)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 Collectors (java.util.stream.Collectors)2 Sets (com.google.common.collect.Sets)1 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)1 InstanceGroupType (com.sequenceiq.cloudbreak.api.model.InstanceGroupType)1 InstanceMetadataType (com.sequenceiq.cloudbreak.api.model.InstanceMetadataType)1