aboutsummaryrefslogtreecommitdiffstats
path: root/standardization/moher-api/healthstate
diff options
context:
space:
mode:
authorPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2019-06-03 14:20:40 +0200
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>2019-06-12 09:41:01 +0000
commit3d6feef167f8e8eb716312599132c41dd89457cb (patch)
tree0a3b8b8f7371a0d655fff0146dd70080098f5102 /standardization/moher-api/healthstate
parent6c2951519650779c019431f990b22b71feb220dc (diff)
Monitoring API - write framework adapters
Change-Id: Iaba9c4ef6022d01c1f572055316700a3a4dfa8f2 Issue-ID: DCAEGEN2-1589 Signed-off-by: Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
Diffstat (limited to 'standardization/moher-api/healthstate')
-rw-r--r--standardization/moher-api/healthstate/pom.xml19
-rw-r--r--standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/AliveMessage.java29
-rw-r--r--standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/Health.java51
-rw-r--r--standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/HealthProvider.java38
4 files changed, 137 insertions, 0 deletions
diff --git a/standardization/moher-api/healthstate/pom.xml b/standardization/moher-api/healthstate/pom.xml
index d6cf46be..a4036288 100644
--- a/standardization/moher-api/healthstate/pom.xml
+++ b/standardization/moher-api/healthstate/pom.xml
@@ -33,4 +33,23 @@
<artifactId>dcaegen2-sdk-moher-healthstate</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>io.vavr</groupId>
+ <artifactId>vavr
+ </artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>value</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-core</artifactId>
+ </dependency>
+ </dependencies>
</project> \ No newline at end of file
diff --git a/standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/AliveMessage.java b/standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/AliveMessage.java
new file mode 100644
index 00000000..c9a8c226
--- /dev/null
+++ b/standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/AliveMessage.java
@@ -0,0 +1,29 @@
+/*
+ * ============LICENSE_START====================================
+ * DCAEGEN2-SERVICES-SDK
+ * =========================================================
+ * Copyright (C) 2019 Nokia. 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.dcaegen2.services.sdk.standardization.moher.health.api;
+
+public final class AliveMessage {
+
+ public static final String ALIVE_MESSAGE_JSON = "{\"alive\":true}";
+
+ private AliveMessage() {
+ }
+}
diff --git a/standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/Health.java b/standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/Health.java
new file mode 100644
index 00000000..65b11ad1
--- /dev/null
+++ b/standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/Health.java
@@ -0,0 +1,51 @@
+/*
+ * ============LICENSE_START====================================
+ * DCAEGEN2-SERVICES-SDK
+ * =========================================================
+ * Copyright (C) 2019 Nokia. 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.dcaegen2.services.sdk.standardization.moher.health.api;
+
+import org.immutables.gson.Gson;
+import org.immutables.value.Value;
+
+@Value.Immutable
+@Gson.TypeAdapters
+public interface Health {
+
+ @Value.Default
+ default boolean healthy() {
+ return true;
+ }
+
+ @Value.Default
+ default String description() {
+ return "Service is working correctly";
+ }
+
+ static Health createHealthy() {
+ return ImmutableHealth.builder().build();
+ }
+
+ static Health createHealthy(String description) {
+ return ImmutableHealth.builder().description(description).build();
+ }
+
+ static Health createUnhealthy(String description) {
+ return ImmutableHealth.builder().healthy(false).description(description).build();
+ }
+}
diff --git a/standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/HealthProvider.java b/standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/HealthProvider.java
new file mode 100644
index 00000000..b6d770a4
--- /dev/null
+++ b/standardization/moher-api/healthstate/src/main/java/org/onap/dcaegen2/services/sdk/standardization/moher/health/api/HealthProvider.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START====================================
+ * DCAEGEN2-SERVICES-SDK
+ * =========================================================
+ * Copyright (C) 2019 Nokia. 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.dcaegen2.services.sdk.standardization.moher.health.api;
+
+import io.vavr.Function0;
+import java.util.function.Supplier;
+import reactor.core.publisher.Mono;
+
+@FunctionalInterface
+public interface HealthProvider {
+ Mono<Health> currentHealth();
+
+ static HealthProvider fromFunction(Function0<Health> function) {
+ return () -> Mono.fromCallable(function::apply);
+ }
+
+ static HealthProvider fromSupplier(Supplier<Health> function) {
+ return () -> Mono.fromCallable(function::get);
+ }
+}