diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-08-13 14:13:25 +0200 |
---|---|---|
committer | Fiete Ostkamp <fiete.ostkamp@telekom.de> | 2024-08-13 13:25:58 +0000 |
commit | 412d236404aa0ef9aebec658a1aeca80ab968fcd (patch) | |
tree | bc9f5b38ce50608edea26ddf97185c246fa58323 /aai-resources/src/main/java | |
parent | 43647cd712e6da6b09003845b74d64837bfa8db1 (diff) |
Make echo liveness probe available under /actuator/health for resources
- implement spring's HealthIndicator interface to provide health probe based on AaiGraphChecker
- conditionally enable the probe when aai.actuator.echo.enabled=true
- increase snapshot version to 1.15.6-SNAPSHOT
Issue-ID: AAI-3959
Change-Id: Ie2b49ad1f3145285be844bb11aa8119a16fb68c9
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-resources/src/main/java')
-rw-r--r-- | aai-resources/src/main/java/org/onap/aai/rest/util/EchoHealthIndicator.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/util/EchoHealthIndicator.java b/aai-resources/src/main/java/org/onap/aai/rest/util/EchoHealthIndicator.java new file mode 100644 index 0000000..fd5dbcf --- /dev/null +++ b/aai-resources/src/main/java/org/onap/aai/rest/util/EchoHealthIndicator.java @@ -0,0 +1,50 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2024 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.rest.util; + +import org.onap.aai.tasks.AaiGraphChecker; +import org.onap.aai.tasks.AaiGraphChecker.CheckerType; +import org.springframework.boot.actuate.health.Health; +import org.springframework.boot.actuate.health.HealthIndicator; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; + +import lombok.RequiredArgsConstructor; + +@Component +@RequiredArgsConstructor +@ConditionalOnProperty(name = "aai.actuator.echo.enabled", havingValue = "true") +public class EchoHealthIndicator implements HealthIndicator { + + private final AaiGraphChecker aaiGraphChecker; + + @Override + public Health health() { + return healthy() + ? Health.up().build() + : Health.down().build(); + } + + private boolean healthy() { + return aaiGraphChecker.isAaiGraphDbAvailable(CheckerType.ACTUAL); + } + +} |