Search in sources :

Example 1 with ClusterView

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

the class ClusterStartService method handleClusterStartFailure.

public void handleClusterStartFailure(StackView stackView, String errorReason) {
    ClusterView clusterView = stackView.getClusterView();
    clusterService.updateClusterStatusByStackId(stackView.getId(), Status.START_FAILED);
    stackUpdater.updateStackStatus(stackView.getId(), DetailedStackStatus.AVAILABLE, "Cluster could not be started: " + errorReason);
    flowMessageService.fireEventAndLog(stackView.getId(), Msg.AMBARI_CLUSTER_START_FAILED, Status.START_FAILED.name(), errorReason);
    if (clusterView.getEmailNeeded()) {
        emailSenderService.sendStartFailureEmail(stackView.getClusterView().getOwner(), clusterView.getEmailTo(), stackUtil.extractAmbariIp(stackView), clusterView.getName());
        flowMessageService.fireEventAndLog(stackView.getId(), Msg.AMBARI_CLUSTER_NOTIFICATION_EMAIL, Status.START_FAILED.name());
    }
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView)

Example 2 with ClusterView

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

the class UpscaleFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public Queue<Selectable> createFlowTriggerEventQueue(StackAndClusterUpscaleTriggerEvent event) {
    StackView stackView = stackService.getByIdView(event.getStackId());
    ClusterView clusterView = stackView.getClusterView();
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new StackSyncTriggerEvent(STACK_SYNC_EVENT.event(), event.getStackId(), false, event.accepted()));
    flowEventChain.add(new StackScaleTriggerEvent(ADD_INSTANCES_EVENT.event(), event.getStackId(), event.getInstanceGroup(), event.getAdjustment(), event.getHostNames()));
    if (ScalingType.isClusterUpScale(event.getScalingType()) && clusterView != null) {
        HostGroup hostGroup = hostGroupService.getByClusterIdAndInstanceGroupName(clusterView.getId(), event.getInstanceGroup());
        flowEventChain.add(new ClusterScaleTriggerEvent(CLUSTER_UPSCALE_TRIGGER_EVENT.event(), stackView.getId(), hostGroup.getName(), event.getAdjustment()));
    }
    return flowEventChain;
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) StackScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) ClusterScaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent) StackSyncTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackSyncTriggerEvent) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 3 with ClusterView

use of com.sequenceiq.cloudbreak.domain.view.ClusterView 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 4 with ClusterView

use of com.sequenceiq.cloudbreak.domain.view.ClusterView 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 5 with ClusterView

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

the class ClusterDownscaleService method updateMetadata.

public void updateMetadata(Long stackId, Collection<String> hostNames, String hostGroupName) {
    StackView stackView = stackService.getByIdView(stackId);
    ClusterView clusterView = stackView.getClusterView();
    hostNames.forEach(hn -> {
        HostGroup hostGroup = hostGroupService.getByClusterIdAndName(clusterView.getId(), hostGroupName);
        List<HostMetadata> hostMetaToRemove = hostGroup.getHostMetadata().stream().filter(md -> hostNames.contains(md.getHostName())).collect(Collectors.toList());
        hostGroup.getHostMetadata().removeAll(hostMetaToRemove);
        hostGroupService.save(hostGroup);
    });
    LOGGER.info("Start updating metadata");
    for (String hostName : hostNames) {
        stackService.updateMetaDataStatus(stackView.getId(), hostName, InstanceStatus.DECOMMISSIONED);
    }
    clusterService.updateClusterStatusByStackId(stackView.getId(), AVAILABLE);
    flowMessageService.fireEventAndLog(stackId, Msg.AMBARI_CLUSTER_SCALED_DOWN, AVAILABLE.name());
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) UPDATE_FAILED(com.sequenceiq.cloudbreak.api.model.Status.UPDATE_FAILED) LoggerFactory(org.slf4j.LoggerFactory) Msg(com.sequenceiq.cloudbreak.core.flow2.stack.Msg) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) CloudbreakMessagesService(com.sequenceiq.cloudbreak.service.messages.CloudbreakMessagesService) Inject(javax.inject.Inject) Status(com.sequenceiq.cloudbreak.api.model.Status) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata) Service(org.springframework.stereotype.Service) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Logger(org.slf4j.Logger) AVAILABLE(com.sequenceiq.cloudbreak.api.model.Status.AVAILABLE) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) Collection(java.util.Collection) Set(java.util.Set) FlowMessageService(com.sequenceiq.cloudbreak.core.flow2.stack.FlowMessageService) NotEnoughNodeException(com.sequenceiq.cloudbreak.service.cluster.NotEnoughNodeException) Collectors(java.util.stream.Collectors) StackUpdater(com.sequenceiq.cloudbreak.repository.StackUpdater) List(java.util.List) ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) CollectionUtils(org.springframework.util.CollectionUtils) InstanceStatus(com.sequenceiq.cloudbreak.api.model.InstanceStatus) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) CloudbreakEventService(com.sequenceiq.cloudbreak.service.events.CloudbreakEventService) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Aggregations

ClusterView (com.sequenceiq.cloudbreak.domain.view.ClusterView)7 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)5 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)2 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)1 InstanceStatus (com.sequenceiq.cloudbreak.api.model.InstanceStatus)1 Status (com.sequenceiq.cloudbreak.api.model.Status)1 AVAILABLE (com.sequenceiq.cloudbreak.api.model.Status.AVAILABLE)1 UPDATE_FAILED (com.sequenceiq.cloudbreak.api.model.Status.UPDATE_FAILED)1 Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)1 ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)1 StackScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackScaleTriggerEvent)1 StackSyncTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackSyncTriggerEvent)1 FlowMessageService (com.sequenceiq.cloudbreak.core.flow2.stack.FlowMessageService)1 Msg (com.sequenceiq.cloudbreak.core.flow2.stack.Msg)1 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)1 StackUpdater (com.sequenceiq.cloudbreak.repository.StackUpdater)1 ClusterService (com.sequenceiq.cloudbreak.service.cluster.ClusterService)1 NotEnoughNodeException (com.sequenceiq.cloudbreak.service.cluster.NotEnoughNodeException)1 CloudbreakEventService (com.sequenceiq.cloudbreak.service.events.CloudbreakEventService)1 HostGroupService (com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService)1