Search in sources :

Example 26 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class ClusterUpscaleService method stopComponents.

public void stopComponents(Long stackId, Map<String, String> components, String hostname) throws CloudbreakException {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    LOGGER.info("Start stop components in ambari on host {}", hostname);
    getClusterConnector(stack).stopComponents(components, hostname);
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 27 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class UpgradeDatalakeFlowEventChainFactory method addUpgradeValidationToChain.

private void addUpgradeValidationToChain(ClusterUpgradeTriggerEvent event, Queue<Selectable> flowEventChain) {
    if (upgradeValidationEnabled) {
        Stack stack = stackService.getById(event.getResourceId());
        boolean lockComponents = lockedComponentService.isComponentsLocked(stack, event.getImageId());
        flowEventChain.add(new ClusterUpgradeValidationTriggerEvent(event.getResourceId(), event.accepted(), event.getImageId(), lockComponents));
    }
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ClusterUpgradeValidationTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeValidationTriggerEvent)

Example 28 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class PillarConfigUpdateService method doConfigUpdate.

public void doConfigUpdate(Long stackId) {
    stackUpdater.updateStackStatus(stackId, DetailedStackStatus.BOOTSTRAPPING_MACHINES);
    flowMessageService.fireEventAndLog(stackId, UPDATE_IN_PROGRESS.name(), CLUSTER_PILLAR_CONFIG_UPDATE_STARTED);
    Stack stack = stackService.getByIdWithClusterInTransaction(stackId);
    Long clusterId = stack.getCluster().getId();
    Cluster cluster = clusterService.findOneWithLists(clusterId).orElseThrow(NotFoundException.notFound("Cluster", clusterId));
    clusterHostServiceRunner.updateClusterConfigs(stack, cluster);
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 29 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class ClusterDownscaleService method updateMetadataStatusToFailed.

public void updateMetadataStatusToFailed(DecommissionResult payload) {
    if (payload.getErrorPhase() != null) {
        Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
        for (String hostName : payload.getHostNames()) {
            instanceMetaDataService.findByHostname(stack.getId(), hostName).ifPresent(instanceMetaData -> {
                instanceMetaDataService.updateInstanceStatus(instanceMetaData, InstanceStatus.DECOMMISSION_FAILED, payload.getStatusReason());
            });
        }
        String errorDetailes = String.format("The following hosts are '%s': %s", InstanceStatus.DECOMMISSION_FAILED, String.join(", ", payload.getHostNames()));
        flowMessageService.fireEventAndLog(payload.getResourceId(), UPDATE_FAILED.name(), CLUSTER_SCALING_FAILED, "removed from", errorDetailes);
    }
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 30 with Stack

use of com.sequenceiq.cloudbreak.domain.stack.Stack in project cloudbreak by hortonworks.

the class StopStartDownscaleActions method decommissionViaCmFailedAction.

@Bean(name = "STOPSTART_DOWNSCALE_DECOMMISSION_VIA_CM_FAILED_STATE")
public Action<?, ?> decommissionViaCmFailedAction() {
    return new AbstractStopStartDownscaleActions<>(StopStartDownscaleDecommissionViaCMResult.class) {

        @Override
        protected void doExecute(StopStartDownscaleContext context, StopStartDownscaleDecommissionViaCMResult payload, Map<Object, Object> variables) throws Exception {
            LOGGER.warn("Failure during the decommissionViaCm step");
            // TODO CB-14929. Should the nodes be put into an ORCHESTRATOR_FAILED state? What are the manual recovery steps from this state.
            Set<String> hostnames = getHostNamesForPrivateIds(payload.getRequest().getInstanceIdsToDecommission(), context.getStack());
            stopStartDownscaleFlowService.decommissionViaCmFailed(payload.getResourceId(), hostnames);
            sendEvent(context, STOPSTART_DOWNSCALE_FAILURE_EVENT.event(), new StackFailureEvent(payload.getResourceId(), payload.getErrorDetails()));
        }

        private Set<String> getHostNamesForPrivateIds(Set<Long> hostIdsToRemove, Stack stack) {
            return hostIdsToRemove.stream().map(privateId -> {
                Optional<InstanceMetaData> instanceMetadata = stackService.getInstanceMetadata(stack.getInstanceMetaDataAsList(), privateId);
                return instanceMetadata.map(InstanceMetaData::getDiscoveryFQDN).orElse(null);
            }).filter(StringUtils::isNotEmpty).collect(Collectors.toSet());
        }
    };
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StopStartDownscaleDecommissionViaCMResult(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.StopStartDownscaleDecommissionViaCMResult) Set(java.util.Set) HashSet(java.util.HashSet) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) Map(java.util.Map) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Bean(org.springframework.context.annotation.Bean)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1041 Test (org.junit.jupiter.api.Test)326 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)255 Test (org.junit.Test)208 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)158 Map (java.util.Map)114 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)113 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)112 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)111 List (java.util.List)101 Set (java.util.Set)101 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)100 Collectors (java.util.stream.Collectors)84 Optional (java.util.Optional)83 HashSet (java.util.HashSet)82 Inject (javax.inject.Inject)80 Logger (org.slf4j.Logger)78 LoggerFactory (org.slf4j.LoggerFactory)78 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)69 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)67