Search in sources :

Example 51 with Stack

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

the class ClusterContainerRunner method addClusterContainers.

public Map<String, List<Container>> addClusterContainers(Long stackId, String hostGroupName, Integer scalingAdjustment) throws CloudbreakException {
    try {
        Stack stack = stackRepository.findOneWithLists(stackId);
        String cloudPlatform = StringUtils.isNotEmpty(stack.cloudPlatform()) ? stack.cloudPlatform() : NONE;
        return addClusterContainers(stack, cloudPlatform, hostGroupName, scalingAdjustment);
    } catch (CloudbreakOrchestratorCancelledException e) {
        throw new CancellationException(e.getMessage());
    } catch (CloudbreakOrchestratorException e) {
        throw new CloudbreakException(e);
    }
}
Also used : CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 52 with Stack

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

the class ClusterBootstrapper method bootstrapMachines.

public void bootstrapMachines(Long stackId) throws CloudbreakException {
    Stack stack = stackRepository.findOneWithLists(stackId);
    String stackOrchestratorType = stack.getOrchestrator().getType();
    OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stackOrchestratorType);
    if (orchestratorType.hostOrchestrator()) {
        bootstrapOnHost(stack);
    } else if (orchestratorType.containerOrchestrator()) {
        LOGGER.info("Skipping bootstrap of the machines because the stack's orchestrator type is '{}'.", stackOrchestratorType);
    } else {
        LOGGER.error("Orchestrator not found: {}", stackOrchestratorType);
        throw new CloudbreakException("HostOrchestrator not found: " + stackOrchestratorType);
    }
}
Also used : CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) OrchestratorType(com.sequenceiq.cloudbreak.common.model.OrchestratorType) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 53 with Stack

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

the class StackRequestToStackConverter method convert.

@Override
public Stack convert(StackRequest source) {
    Stack stack = new Stack();
    stack.setName(source.getName());
    stack.setDisplayName(source.getName());
    stack.setRegion(getRegion(source));
    setPlatform(source);
    stack.setCloudPlatform(source.getCloudPlatform());
    Map<String, String> sourceTags = source.getApplicationTags();
    stack.setTags(getTags(mergeTags(sourceTags, source.getUserDefinedTags(), getDefaultTags(source))));
    if (sourceTags != null && sourceTags.get("datalakeId") != null) {
        stack.setDatalakeId(Long.valueOf(String.valueOf(sourceTags.get("datalakeId"))));
    }
    StackAuthentication stackAuthentication = conversionService.convert(source.getStackAuthentication(), StackAuthentication.class);
    stack.setStackAuthentication(stackAuthentication);
    validateStackAuthentication(source);
    stack.setOwner(source.getOwner());
    stack.setAvailabilityZone(source.getAvailabilityZone());
    stack.setOnFailureActionAction(source.getOnFailureAction());
    stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.PROVISION_REQUESTED.getStatus(), "", DetailedStackStatus.PROVISION_REQUESTED));
    stack.setFailurePolicy(getConversionService().convert(source.getFailurePolicy(), FailurePolicy.class));
    stack.setCreated(Calendar.getInstance().getTimeInMillis());
    stack.setPlatformVariant(source.getPlatformVariant());
    stack.setOrchestrator(getConversionService().convert(source.getOrchestrator(), Orchestrator.class));
    if (source.getCredential() != null) {
        stack.setCredential(getConversionService().convert(source.getCredential(), Credential.class));
    }
    Set<InstanceGroup> instanceGroups = convertInstanceGroups(source, stack);
    stack.setInstanceGroups(instanceGroups);
    if (source.getNetwork() != null) {
        stack.setNetwork(getConversionService().convert(source.getNetwork(), Network.class));
    }
    stack.setCustomDomain(source.getCustomDomain());
    stack.setCustomHostname(source.getCustomHostname());
    stack.setClusterNameAsSubdomain(source.isClusterNameAsSubdomain());
    stack.setHostgroupNameAsHostname(source.isHostgroupNameAsHostname());
    stack.setUuid(UUID.randomUUID().toString());
    return stack;
}
Also used : StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) Credential(com.sequenceiq.cloudbreak.domain.Credential) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) Network(com.sequenceiq.cloudbreak.domain.Network) FailurePolicy(com.sequenceiq.cloudbreak.domain.FailurePolicy) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 54 with Stack

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

the class StackService method getJsonById.

@Transactional(TxType.NEVER)
public StackResponse getJsonById(Long id, Collection<String> entry) {
    Stack stack = getByIdWithLists(id);
    authorizationService.hasReadPermission(stack);
    StackResponse stackResponse = conversionService.convert(stack, StackResponse.class);
    stackResponse = stackResponseDecorator.decorate(stackResponse, stack, entry);
    return stackResponse;
}
Also used : AutoscaleStackResponse(com.sequenceiq.cloudbreak.api.model.AutoscaleStackResponse) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) Stack(com.sequenceiq.cloudbreak.domain.Stack) Transactional(javax.transaction.Transactional)

Example 55 with Stack

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

the class StackService method updateNodeCount.

public void updateNodeCount(Long stackId, InstanceGroupAdjustmentJson instanceGroupAdjustmentJson, boolean withClusterEvent) {
    Stack stack = get(stackId);
    validateStackStatus(stack);
    validateInstanceGroup(stack, instanceGroupAdjustmentJson.getInstanceGroup());
    validateScalingAdjustment(instanceGroupAdjustmentJson, stack);
    if (withClusterEvent) {
        validateClusterStatus(stack);
        validateHostGroupAdjustment(instanceGroupAdjustmentJson, stack, instanceGroupAdjustmentJson.getScalingAdjustment());
    }
    if (instanceGroupAdjustmentJson.getScalingAdjustment() > 0) {
        stackUpdater.updateStackStatus(stackId, DetailedStackStatus.UPSCALE_REQUESTED);
        flowManager.triggerStackUpscale(stack.getId(), instanceGroupAdjustmentJson, withClusterEvent);
    } else {
        stackUpdater.updateStackStatus(stackId, DetailedStackStatus.DOWNSCALE_REQUESTED);
        flowManager.triggerStackDownscale(stack.getId(), instanceGroupAdjustmentJson);
    }
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.Stack)207 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)74 Test (org.junit.Test)70 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)32 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)30 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)26 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)23 ArrayList (java.util.ArrayList)20 List (java.util.List)20 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)18 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)18 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)18 HashMap (java.util.HashMap)18 HashSet (java.util.HashSet)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Map (java.util.Map)17 Matchers.anyString (org.mockito.Matchers.anyString)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)15 Set (java.util.Set)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14