use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.
the class ComputeResourceService method stopStart.
private List<CloudVmInstanceStatus> stopStart(ResourceBuilderContext context, AuthenticatedContext auth, Iterable<CloudResource> resources, Iterable<CloudInstance> instances) {
List<CloudVmInstanceStatus> results = new ArrayList<>();
Collection<Future<ResourceRequestResult<List<CloudVmInstanceStatus>>>> futures = new ArrayList<>();
Platform platform = auth.getCloudContext().getPlatform();
List<ComputeResourceBuilder> builders = resourceBuilders.compute(platform);
if (!context.isBuild()) {
Collections.reverse(builders);
}
for (ComputeResourceBuilder builder : builders) {
List<CloudResource> resourceList = getResources(builder.resourceType(), resources);
for (CloudResource cloudResource : resourceList) {
CloudInstance instance = getCloudInstance(cloudResource, instances);
if (instance != null) {
ResourceStopStartThread thread = createThread(ResourceStopStartThread.NAME, context, auth, cloudResource, instance, builder);
Future<ResourceRequestResult<List<CloudVmInstanceStatus>>> future = resourceBuilderExecutor.submit(thread);
futures.add(future);
if (isRequestFull(futures.size(), context)) {
results.addAll(flatVmList(waitForRequests(futures).get(FutureResult.SUCCESS)));
}
} else {
break;
}
}
}
results.addAll(flatVmList(waitForRequests(futures).get(FutureResult.SUCCESS)));
return results;
}
use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.
the class ComputeResourceService method deleteResources.
public List<CloudResourceStatus> deleteResources(ResourceBuilderContext context, AuthenticatedContext auth, Iterable<CloudResource> resources, boolean cancellable) {
List<CloudResourceStatus> results = new ArrayList<>();
Collection<Future<ResourceRequestResult<List<CloudResourceStatus>>>> futures = new ArrayList<>();
Platform platform = auth.getCloudContext().getPlatform();
List<ComputeResourceBuilder> builders = resourceBuilders.compute(platform);
int numberOfBuilders = builders.size();
for (int i = numberOfBuilders - 1; i >= 0; i--) {
ComputeResourceBuilder builder = builders.get(i);
List<CloudResource> resourceList = getResources(builder.resourceType(), resources);
for (CloudResource cloudResource : resourceList) {
ResourceDeleteThread thread = createThread(ResourceDeleteThread.NAME, context, auth, cloudResource, builder, cancellable);
Future<ResourceRequestResult<List<CloudResourceStatus>>> future = resourceBuilderExecutor.submit(thread);
futures.add(future);
if (isRequestFull(futures.size(), context)) {
results.addAll(flatList(waitForRequests(futures).get(FutureResult.SUCCESS)));
}
}
// wait for builder type to finish before starting the next one
results.addAll(flatList(waitForRequests(futures).get(FutureResult.SUCCESS)));
}
return results;
}
use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.
the class CloudPlatformConnectors method cloudPlatformConnectors.
@PostConstruct
public void cloudPlatformConnectors() {
platformToVariants = HashMultimap.create();
for (CloudConnector connector : cloudConnectors) {
map.put(new CloudPlatformVariant(connector.platform(), connector.variant()), connector);
platformToVariants.put(connector.platform(), connector.variant());
}
Map<Platform, Variant> environmentDefaults = extractEnvironmentDefaultVariants();
setupDefaultVariants(platformToVariants, environmentDefaults);
LOGGER.debug(map.toString());
LOGGER.debug(defaultVariants.toString());
}
use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.
the class PlatformParametersHandler method accept.
@Override
public void accept(Event<PlatformParametersRequest> platformParameterRequestEvent) {
LOGGER.info("Received event: {}", platformParameterRequestEvent);
PlatformParametersRequest request = platformParameterRequestEvent.getData();
Map<Platform, PlatformParameters> platformParameters = new HashMap<>();
try {
for (Entry<Platform, Collection<Variant>> connector : cloudPlatformConnectors.getPlatformVariants().getPlatformToVariants().entrySet()) {
platformParameters.put(connector.getKey(), cloudPlatformConnectors.getDefault(connector.getKey()).parameters());
}
PlatformParametersResult platformParameterResult = new PlatformParametersResult(request, platformParameters);
request.getResult().onNext(platformParameterResult);
LOGGER.info("Query platform parameters finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new PlatformParametersResult(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.
the class CloudResourceAdvisor method createForBlueprint.
public PlatformRecommendation createForBlueprint(String blueprintName, Long blueprintId, PlatformResourceRequest resourceRequest, IdentityUser cbUser) {
String cloudPlatform = resourceRequest.getCloudPlatform();
String region = resourceRequest.getRegion();
String availabilityZone = resourceRequest.getAvailabilityZone();
Map<String, VmType> vmTypesByHostGroup = new HashMap<>();
Map<String, Boolean> hostGroupContainsMasterComp = new HashMap<>();
LOGGER.info("Advising resources for blueprintId: {}, blueprintName: {}, provider: {} and region: {}.", blueprintId, blueprintName, cloudPlatform, region);
String blueprintText = getBlueprint(blueprintName, blueprintId, cbUser).getBlueprintText();
Map<String, Set<String>> componentsByHostGroup = blueprintProcessorFactory.get(blueprintText).getComponentsByHostGroup();
componentsByHostGroup.forEach((hGName, components) -> hostGroupContainsMasterComp.put(hGName, isThereMasterComponents(components)));
CloudVmTypes vmTypes = cloudParameterService.getVmTypesV2(resourceRequest.getCredential(), resourceRequest.getRegion(), resourceRequest.getPlatformVariant(), resourceRequest.getFilters());
VmType defaultVmType = getDefaultVmType(availabilityZone, vmTypes);
if (defaultVmType != null) {
componentsByHostGroup.keySet().forEach(comp -> vmTypesByHostGroup.put(comp, defaultVmType));
}
VmRecommendations recommendations = cloudParameterService.getRecommendation(cloudPlatform);
Set<VmType> availableVmTypes = vmTypes.getCloudVmResponses().get(availabilityZone);
if (availableVmTypes == null) {
availableVmTypes = Collections.emptySet();
}
if (recommendations != null) {
Map<String, VmType> masterVmTypes = getVmTypesForComponentType(true, recommendations.getMaster(), hostGroupContainsMasterComp, availableVmTypes);
vmTypesByHostGroup.putAll(masterVmTypes);
Map<String, VmType> workerVmTypes = getVmTypesForComponentType(false, recommendations.getWorker(), hostGroupContainsMasterComp, availableVmTypes);
vmTypesByHostGroup.putAll(workerVmTypes);
}
PlatformDisks platformDisks = cloudParameterService.getDiskTypes();
Platform platform = platform(cloudPlatform);
DiskTypes diskTypes = new DiskTypes(platformDisks.getDiskTypes().get(platform), platformDisks.getDefaultDisks().get(platform), platformDisks.getDiskMappings().get(platform), platformDisks.getDiskDisplayNames().get(platform));
return new PlatformRecommendation(vmTypesByHostGroup, availableVmTypes, diskTypes);
}
Aggregations