use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class ImageService method determineImageFromCatalog.
// CHECKSTYLE:OFF
@Measure(ImageService.class)
public StatedImage determineImageFromCatalog(Long workspaceId, ImageSettingsV4Request imageSettings, String platformString, String variant, Blueprint blueprint, boolean useBaseImage, boolean baseImageEnabled, User user, Predicate<com.sequenceiq.cloudbreak.cloud.model.catalog.Image> imagePredicate) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
ImageCatalogPlatform platform = platformStringTransformer.getPlatformStringForImageCatalog(platformString, variant);
if (imageSettings != null && StringUtils.isNotEmpty(imageSettings.getId())) {
LOGGER.debug("Image id {} is specified for the stack.", imageSettings.getId());
if (imageSettings.getCatalog() == null) {
imageSettings.setCatalog(CDP_DEFAULT_CATALOG_NAME);
}
StatedImage image = imageCatalogService.getImageByCatalogName(workspaceId, imageSettings.getId(), imageSettings.getCatalog());
return checkIfBasePermitted(image, baseImageEnabled);
} else if (useBaseImage && !baseImageEnabled) {
throw new CloudbreakImageCatalogException("Inconsistent request, base images are disabled but custom repo information is submitted!");
}
String clusterVersion = getClusterVersion(blueprint);
Set<String> operatingSystems;
try {
operatingSystems = getSupportedOperatingSystems(workspaceId, imageSettings, clusterVersion, platform);
} catch (Exception ex) {
throw new CloudbreakImageCatalogException(ex);
}
ImageCatalog imageCatalog = getImageCatalogFromRequestOrDefault(workspaceId, imageSettings, user);
ImageFilter imageFilter = new ImageFilter(imageCatalog, Set.of(platform), null, baseImageEnabled, operatingSystems, clusterVersion);
LOGGER.info("Image id is not specified for the stack.");
if (baseImageEnabled && useBaseImage) {
LOGGER.info("Trying to select a base image.");
return imageCatalogService.getLatestBaseImageDefaultPreferred(imageFilter, imagePredicate);
}
LOGGER.info("Trying to select a prewarmed image.");
return imageCatalogService.getImagePrewarmedDefaultPreferred(imageFilter, imagePredicate);
}
use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class TlsSecurityService method generateSecurityKeys.
@Measure(TlsSecurityService.class)
public SecurityConfig generateSecurityKeys(Workspace workspace) {
SecurityConfig securityConfig = new SecurityConfig();
securityConfig.setWorkspace(workspace);
SaltSecurityConfig saltSecurityConfig = new SaltSecurityConfig();
saltSecurityConfig.setWorkspace(workspace);
saltSecurityConfig.setSaltBootPassword(PasswordUtil.generatePassword());
saltSecurityConfig.setSaltPassword(PasswordUtil.generatePassword());
securityConfig.setSaltSecurityConfig(saltSecurityConfig);
setClientKeys(securityConfig, keyPairCache.pop(), keyPairCache.pop());
setSaltBootSignKeypair(saltSecurityConfig, convertKeyPair(keyPairCache.pop()));
setSaltSignKeypair(securityConfig, convertKeyPair(keyPairCache.pop()));
return securityConfig;
}
use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class StackDecorator method decorate.
@Measure(StackDecorator.class)
public Stack decorate(@Nonnull Stack subject, @Nonnull StackV4Request request, User user, Workspace workspace) {
String stackName = request.getName();
DetailedEnvironmentResponse environment = measure(() -> environmentClientService.getByCrn(subject.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn());
Credential credential = measure(() -> prepareCredential(environment), LOGGER, "Credential was prepared under {} ms for stack {}", stackName);
measure(() -> preparePlacement(subject, request, environment), LOGGER, "Placement was prepared under {} ms for stack {}, stackName");
measure(() -> prepareParameters(subject, environment), LOGGER, "Parameters were prepared under {} ms for stack {}", stackName);
measure(() -> prepareDomainIfDefined(subject, credential), LOGGER, "Domain was prepared under {} ms for stack {}", stackName);
subject.setCloudPlatform(credential.cloudPlatform());
if (subject.getInstanceGroups() == null) {
throw new BadRequestException("Instance groups must be specified!");
}
measure(() -> {
PlatformParameters pps = cloudParameterCache.getPlatformParameters().get(Platform.platform(subject.cloudPlatform()));
Boolean mandatoryNetwork = pps.specialParameters().getSpecialParameters().get(PlatformParametersConsts.NETWORK_IS_MANDATORY);
if (BooleanUtils.isTrue(mandatoryNetwork) && subject.getNetwork() == null) {
throw new BadRequestException("Network must be specified!");
}
}, LOGGER, "Network was prepared and validated under {} ms for stack {}", stackName);
measure(() -> prepareOrchestratorIfNotExist(subject, credential), LOGGER, "Orchestrator was prepared under {} ms for stack {}", stackName);
if (subject.getFailurePolicy() != null) {
measure(() -> validatFailurePolicy(subject, subject.getFailurePolicy()), LOGGER, "Failure policy was validated under {} ms for stack {}", stackName);
}
measure(() -> prepareInstanceGroups(subject, request, credential, user, environment), LOGGER, "Instance groups were prepared under {} ms for stack {}", stackName);
measure(() -> validateInstanceGroups(subject), LOGGER, "Validation of gateway instance groups has been finished in {} ms for stack {}", stackName);
measure(() -> {
ValidationResult validationResult = sharedServiceValidator.checkSharedServiceStackRequirements(request, workspace);
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
}, LOGGER, "Validation of shared services requirements has been finished in {} ms for stack {}", stackName);
return subject;
}
use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class DnsRecordService method deleteDnsRecordByFqdn.
@Retryable(value = RetryableFreeIpaClientException.class, maxAttemptsExpression = RetryableFreeIpaClientException.MAX_RETRIES_EXPRESSION, backoff = @Backoff(delayExpression = RetryableFreeIpaClientException.DELAY_EXPRESSION, multiplierExpression = RetryableFreeIpaClientException.MULTIPLIER_EXPRESSION))
@Measure(DnsRecordService.class)
public void deleteDnsRecordByFqdn(String environmentCrn, String accountId, List<String> fqdns) throws FreeIpaClientException {
FreeIpaAndClient freeIpaAndClient = createFreeIpaAndClient(environmentCrn, accountId);
for (DnsZone dnsZone : freeIpaAndClient.getClient().findAllDnsZone()) {
LOGGER.debug("Looking for records in zone [{}]", dnsZone.getIdnsname());
Set<DnsRecord> allDnsRecordsInZone = freeIpaAndClient.getClient().findAllDnsRecordInZone(dnsZone.getIdnsname());
deleteRegularRecords(freeIpaAndClient.getClient(), dnsZone, allDnsRecordsInZone, fqdns, freeIpaAndClient.getFreeIpa().getDomain());
deleteSrvRecords(freeIpaAndClient.getClient(), dnsZone, allDnsRecordsInZone, fqdns);
}
}
use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class SaltConnector method wheel.
@Measure(SaltConnector.class)
@Retryable(value = ClusterProxyWebApplicationException.class, backoff = @Backoff(delay = 1000))
public <T> T wheel(String fun, Collection<String> match, Class<T> clazz) {
Form form = new Form();
form = addAuth(form).param("fun", fun).param("client", "wheel");
if (match != null && !match.isEmpty()) {
form.param("match", String.join(",", match));
}
Response response = endpointInvocation(SaltEndpoint.SALT_RUN.getContextPath(), toJson(form.asMap()).getBytes()).post(Entity.form(form));
T responseEntity = JaxRSUtil.response(response, clazz);
LOGGER.debug("Salt wheel has been executed. fun: {}", fun);
return responseEntity;
}
Aggregations