Search in sources :

Example 6 with StackView

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

the class StackCreationActions method stackCreationFailureAction.

@Bean(name = "STACK_CREATION_FAILED_STATE")
public Action<?, ?> stackCreationFailureAction() {
    return new AbstractStackFailureAction<StackCreationState, StackCreationEvent>() {

        @Override
        protected StackFailureContext createFlowContext(String flowId, StateContext<StackCreationState, StackCreationEvent> stateContext, StackFailureEvent payload) {
            Flow flow = getFlow(flowId);
            StackView stackView = stackService.getByIdView(payload.getStackId());
            MDCBuilder.buildMdcContext(stackView);
            flow.setFlowFailed(payload.getException());
            return new StackFailureContext(flowId, stackView);
        }

        @Override
        protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) {
            stackCreationService.handleStackCreationFailure(context.getStackView(), payload.getException());
            metricService.incrementMetricCounter(MetricType.STACK_CREATION_FAILED, context.getStackView());
            sendEvent(context);
        }

        @Override
        protected Selectable createRequest(StackFailureContext context) {
            return new StackEvent(StackCreationEvent.STACKCREATION_FAILURE_HANDLED_EVENT.event(), context.getStackView().getId());
        }
    };
}
Also used : AbstractStackFailureAction(com.sequenceiq.cloudbreak.core.flow2.stack.AbstractStackFailureAction) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StateContext(org.springframework.statemachine.StateContext) StackFailureContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackFailureContext) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Map(java.util.Map) Flow(com.sequenceiq.cloudbreak.core.flow2.Flow) Bean(org.springframework.context.annotation.Bean)

Example 7 with StackView

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

the class AbstractClusterUpgradeAction method createFlowContext.

@Override
protected ClusterViewContext createFlowContext(String flowId, StateContext<ClusterUpgradeState, ClusterUpgradeEvent> stateContext, 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) ClusterViewContext(com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)

Example 8 with StackView

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

the class StackCommonService method put.

public Response put(Long id, UpdateStackJson updateRequest) {
    StackView stack = stackService.getByIdView(id);
    MDCBuilder.buildMdcContext(stack);
    if (updateRequest.getStatus() != null) {
        stackService.updateStatus(id, updateRequest.getStatus(), updateRequest.getWithClusterEvent());
    } else {
        Integer scalingAdjustment = updateRequest.getInstanceGroupAdjustment().getScalingAdjustment();
        validateAccountPreferences(id, scalingAdjustment);
        stackService.updateNodeCount(id, updateRequest.getInstanceGroupAdjustment(), updateRequest.getWithClusterEvent());
    }
    return Response.status(Status.NO_CONTENT).build();
}
Also used : StackView(com.sequenceiq.cloudbreak.domain.view.StackView)

Example 9 with StackView

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

the class AbstractStackFailureAction method createFlowContext.

@Override
protected StackFailureContext createFlowContext(String flowId, StateContext<S, E> stateContext, StackFailureEvent payload) {
    Flow flow = getFlow(flowId);
    StackView stack = stackService.getByIdView(payload.getStackId());
    MDCBuilder.buildMdcContext(stack);
    flow.setFlowFailed(payload.getException());
    return new StackFailureContext(flowId, stack);
}
Also used : StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Flow(com.sequenceiq.cloudbreak.core.flow2.Flow)

Example 10 with StackView

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

the class InstanceTerminationFlowTriggerCondition method isFlowTriggerable.

@Override
public boolean isFlowTriggerable(Long stackId) {
    StackView stack = stackService.getByIdView(stackId);
    boolean result = !stack.isDeleteInProgress();
    if (result) {
        LOGGER.info("Couldn't start instance termination flow because the stack has been terminating.");
    }
    return result;
}
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