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