use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class InstanceTest method should_update_buildVersion.
@Test
public void should_update_buildVersion() {
Instance instance = Instance.create(InstanceId.of("id"));
assertThat(instance.getBuildVersion()).isNull();
Registration registration = Registration.create("foo-instance", "http://health").metadata("version", "1.0.0").build();
instance = instance.register(registration).withInfo(Info.empty());
assertThat(instance.getBuildVersion()).isEqualTo(BuildVersion.valueOf("1.0.0"));
instance = instance.register(registration.toBuilder().clearMetadata().build());
assertThat(instance.getBuildVersion()).isNull();
instance = instance.withInfo(Info.from(singletonMap("build", singletonMap("version", "2.1.1"))));
assertThat(instance.getBuildVersion()).isEqualTo(BuildVersion.valueOf("2.1.1"));
instance = instance.deregister();
assertThat(instance.getBuildVersion()).isNull();
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class QueryIndexEndpointStrategy method detectEndpoints.
@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).exchangeToMono(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();
});
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class InstanceDiscoveryListener method registerInstance.
protected Mono<InstanceId> registerInstance(ServiceInstance instance) {
try {
Registration registration = converter.convert(instance).toBuilder().source(SOURCE).build();
log.debug("Registering discovered instance {}", registration);
return registry.register(registration);
} catch (Exception ex) {
log.error("Couldn't register instance for discovered instance ({})", toString(instance), ex);
return Mono.empty();
}
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class DefaultServiceInstanceConverterTest method should_convert_with_metadata_having_null_value.
@Test
public void should_convert_with_metadata_having_null_value() {
ServiceInstance service = new DefaultServiceInstance("test-1", "test", "localhost", 80, false);
Map<String, String> metadata = new HashMap<>();
metadata.put("health.path", "ping");
metadata.put("management.scheme", "https");
metadata.put("management.address", "127.0.0.1");
metadata.put("management.port", "1234");
metadata.put("null.value", null);
metadata.put(null, "null.key");
service.getMetadata().putAll(metadata);
Registration registration = new DefaultServiceInstanceConverter().convert(service);
assertThat(registration.getHealthUrl()).isEqualTo("https://127.0.0.1:1234/actuator/ping");
}
use of de.codecentric.boot.admin.server.domain.values.Registration in project spring-boot-admin by codecentric.
the class DefaultServiceInstanceConverterTest method should_convert_service_with_uri_and_metadata.
@Test
public void should_convert_service_with_uri_and_metadata() {
Map<String, String> metadata = new HashMap<>();
metadata.put("health.path", "ping");
metadata.put("management.context-path", "mgmt");
ServiceInstance service = new TestServiceInstance("test", URI.create("http://localhost/test"), metadata);
Registration registration = new DefaultServiceInstanceConverter().convert(service);
assertThat(registration.getName()).isEqualTo("test");
assertThat(registration.getServiceUrl()).isEqualTo("http://localhost/test");
assertThat(registration.getManagementUrl()).isEqualTo("http://localhost/test/mgmt");
assertThat(registration.getHealthUrl()).isEqualTo("http://localhost/test/mgmt/ping");
assertThat(registration.getMetadata()).isEqualTo(metadata);
}
Aggregations