Java Code Examples for de.codecentric.boot.admin.server.domain.values.Registration#getManagementUrl()

The following examples show how to use de.codecentric.boot.admin.server.domain.values.Registration#getManagementUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryIndexEndpointStrategy.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<Endpoints> detectEndpoints(Instance instance) {
    Registration registration = instance.getRegistration();
    String managementUrl = registration.getManagementUrl();
    if (managementUrl == null || Objects.equals(registration.getServiceUrl(), managementUrl)) {
        return Mono.empty();
    }

    return instanceWebClient.instance(instance)
                            .get()
                            .uri(managementUrl)
                            .exchange()
                            .flatMap(response -> {
                                if (response.statusCode().is2xxSuccessful() &&
                                    response.headers()
                                            .contentType()
                                            .map(actuatorMediaType::isCompatibleWith)
                                            .orElse(false)) {
                                    return response.bodyToMono(Response.class);
                                } else {
                                    return response.bodyToMono(Void.class).then(Mono.empty());
                                }
                            })
                            .flatMap(this::convert);
}
 
Example 2
Source File: QueryIndexEndpointStrategy.java    From spring-boot-admin with Apache License 2.0 6 votes vote down vote up
@Override
public Mono<Endpoints> detectEndpoints(Instance instance) {
	Registration registration = instance.getRegistration();
	String managementUrl = registration.getManagementUrl();
	if (managementUrl == null || Objects.equals(registration.getServiceUrl(), managementUrl)) {
		log.debug("Querying actuator-index for instance {} omitted.", instance.getId());
		return Mono.empty();
	}

	return this.instanceWebClient.instance(instance).get().uri(managementUrl).exchange()
			.flatMap(this.convert(instance, managementUrl)).onErrorResume((e) -> {
				log.warn("Querying actuator-index for instance {} on '{}' failed: {}", instance.getId(),
						managementUrl, e.getMessage());
				log.debug("Querying actuator-index for instance {} on '{}' failed.", instance.getId(),
						managementUrl, e);
				return Mono.empty();
			});
}