Search in sources :

Example 16 with StackView

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

Example 17 with StackView

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

the class ClusterStartFlowTriggerCondition method isFlowTriggerable.

@Override
public boolean isFlowTriggerable(Long stackId) {
    StackView stackView = stackService.getByIdView(stackId);
    ClusterView clusterView = stackView.getClusterView();
    boolean result = clusterView != null && clusterView.isStartRequested();
    if (!result) {
        LOGGER.warn("Cluster start cannot be triggered, because cluster {}", clusterView == null ? "is null" : "not in startRequested status");
    }
    return result;
}
Also used : ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) StackView(com.sequenceiq.cloudbreak.domain.view.StackView)

Example 18 with StackView

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

the class AbstractClusterSyncAction method createFlowContext.

@Override
protected ClusterSyncContext createFlowContext(String flowId, StateContext<ClusterSyncState, ClusterSyncEvent> stateContext, P payload) {
    StackView stack = stackService.getByIdView(payload.getStackId());
    MDCBuilder.buildMdcContext(stack.getId().toString(), stack.getName(), stack.getOwner(), "CLUSTER");
    return new ClusterSyncContext(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