use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class SaltConnector method members.
@Measure(SaltConnector.class)
@Retryable(value = ClusterProxyWebApplicationException.class, backoff = @Backoff(delay = 1000))
public Map<String, String> members(List<String> privateIps) throws CloudbreakOrchestratorFailedException {
Map<String, List<String>> clients = singletonMap("clients", privateIps);
Response response = postSignedJsonSaltRequest(BOOT_HOSTNAME_ENDPOINT, clients);
GenericResponses responses = JaxRSUtil.response(response, GenericResponses.class);
List<GenericResponse> failedResponses = responses.getResponses().stream().filter(genericResponse -> !ACCEPTED_STATUSES.contains(genericResponse.getStatusCode())).collect(Collectors.toList());
if (!failedResponses.isEmpty()) {
failedResponseErrorLog(failedResponses);
String nodeErrors = failedResponses.stream().map(gr -> gr.getAddress() + ": " + gr.getErrorText()).collect(Collectors.joining(","));
throw new CloudbreakOrchestratorFailedException("Hostname resolution failed for nodes: " + nodeErrors);
}
return responses.getResponses().stream().collect(Collectors.toMap(GenericResponse::getAddress, GenericResponse::getStatus));
}
use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class SaltConnector method run.
@Measure(SaltConnector.class)
@Retryable(value = ClusterProxyWebApplicationException.class, backoff = @Backoff(delay = 1000))
public <T> T run(Target<String> target, String fun, SaltClientType clientType, Class<T> clazz, Long timeout, String... arg) {
Form form = new Form();
form = addAuth(form).param("fun", fun).param("client", clientType.getType());
if (target != null) {
form = form.param("tgt", target.getTarget()).param("tgt_type", target.getType());
}
if (timeout != null) {
form = form.param("t", timeout.toString());
}
if ("state.show_sls".equals(fun)) {
form.param("full_return", "True");
}
if (arg != null) {
if (clientType.equals(SaltClientType.LOCAL) || clientType.equals(SaltClientType.LOCAL_ASYNC)) {
for (String a : arg) {
form.param("arg", a);
}
} else {
for (int i = 0; i < arg.length - 1; i += 2) {
form.param(arg[i], arg[i + 1]);
}
}
}
Response response = endpointInvocation(SaltEndpoint.SALT_RUN.getContextPath(), toJson(form.asMap()).getBytes()).post(Entity.form(form));
T responseEntity = JaxRSUtil.response(response, clazz);
try {
LOGGER.debug("Salt run has been executed. fun: [{}], parsed response: [{}]", fun, anonymize(JsonUtil.writeValueAsString(responseEntity)));
} catch (JsonProcessingException e) {
LOGGER.error("Can not read response from salt", e);
}
return responseEntity;
}
use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class SaltConnector method action.
@Measure(SaltConnector.class)
@Retryable(value = ClusterProxyWebApplicationException.class, backoff = @Backoff(delay = 1000))
public GenericResponses action(SaltAction saltAction) {
Response response = postSignedJsonSaltRequest(SaltEndpoint.BOOT_ACTION_DISTRIBUTE, saltAction);
GenericResponses responseEntity = JaxRSUtil.response(response, GenericResponses.class);
LOGGER.debug("SaltBoot. SaltAction response: {}", responseEntity);
return responseEntity;
}
use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class SaltConnector method health.
@Measure(SaltConnector.class)
@Retryable(value = ClusterProxyWebApplicationException.class, backoff = @Backoff(delay = 1000))
public GenericResponse health() {
LOGGER.debug("Sending request to salt endpoint {}", SaltEndpoint.BOOT_HEALTH.getContextPath());
Response response = saltTarget.path(SaltEndpoint.BOOT_HEALTH.getContextPath()).request().get();
GenericResponse responseEntity = JaxRSUtil.response(response, GenericResponse.class);
LOGGER.debug("SaltBoot. Health response: {}", responseEntity);
return responseEntity;
}
use of com.sequenceiq.cloudbreak.aspect.Measure in project cloudbreak by hortonworks.
the class ImageService method create.
@Measure(ImageService.class)
public Set<Component> create(Stack stack, StatedImage imgFromCatalog) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
String region = stack.getRegion();
String cloudPlatform = stack.getCloudPlatform();
ImageCatalogPlatform platformString = platformStringTransformer.getPlatformStringForImageCatalog(cloudPlatform, stack.getPlatformVariant());
LOGGER.debug("Determined image from catalog: {}", imgFromCatalog);
String imageName = determineImageName(cloudPlatform, platformString, region, imgFromCatalog.getImage());
LOGGER.debug("Selected VM image for CloudPlatform '{}' and region '{}' is: {} from: {} image catalog", platformString, region, imageName, imgFromCatalog.getImageCatalogUrl());
Set<Component> components = getComponents(stack, Map.of(), imgFromCatalog, EnumSet.of(IMAGE, CDH_PRODUCT_DETAILS, CM_REPO_DETAILS));
componentConfigProviderService.store(components);
return components;
}
Aggregations