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);
}
}
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());
}
}
}
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;
}
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;
}
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);
}
Aggregations