diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml
index df6667c..c60da52 100644
--- a/.github/workflows/build-deploy.yml
+++ b/.github/workflows/build-deploy.yml
@@ -3,12 +3,12 @@ name: Github Package
on:
push:
tags:
- - 'v*.*.*'
+ ["v*.*.*", "v*.*.*-*"]
branches:
- ["release-4.*.*", "release-5.*.*", "release-v2.*.*"]
+ ["release-4.*.*", "release-5.*.*", "release-v2.*.*", "master", "development"]
pull_request:
branches:
- ["release-4.*.*", "release-5.*.*", "release-v2.*.*"]
+ ["release-4.*.*", "release-5.*.*", "release-v2.*.*", "master", "development"]
jobs:
@@ -59,7 +59,7 @@ jobs:
- name: Delete package specific version
uses: smartsquaregmbh/delete-old-packages@v0.4.0
with:
- version: 2.1.0 # This should be same as in the pom.xml file,
+ version: 2.2.1 # This should be same as in the pom.xml file,
# to delete only the pom specified version, not the other older versions
names: |
com.uci.dao
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 844f3a4..fb32b43 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -3,10 +3,10 @@ name: Maven Build
on:
push:
branches:
- ["release-4.*.*", "release-5.*.*", "release-v2.*.*"]
+ ["release-4.*.*", "release-5.*.*", "release-v2.*.*", "master", "development"]
pull_request:
branches:
- ["release-4.*.*", "release-5.*.*", "release-v2.*.*"]
+ ["release-4.*.*", "release-5.*.*", "release-v2.*.*", "master", "development"]
jobs:
build:
diff --git a/pom.xml b/pom.xml
index 3c82a32..b89602c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
dao
dao
jar
- 2.1.0
+ 2.2.1
@@ -21,6 +21,8 @@
1.8
1.8
+ 2.2.1
+ 2.2.1
@@ -99,13 +101,13 @@
com.uci
message-rosa
- 2.1.0
+ ${messagerosa.version}
compile
com.uci
utils
- 2.1.0
+ ${utils.version}
compile
diff --git a/src/main/java/com/uci/dao/service/HealthService.java b/src/main/java/com/uci/dao/service/HealthService.java
index 6ee69ef..e17a686 100644
--- a/src/main/java/com/uci/dao/service/HealthService.java
+++ b/src/main/java/com/uci/dao/service/HealthService.java
@@ -4,12 +4,14 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.uci.dao.repository.XMessageRepository;
import com.uci.utils.UtilHealthService;
import reactor.core.publisher.Mono;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.health.Status;
import org.springframework.stereotype.Service;
@Service
@@ -17,13 +19,27 @@ public class HealthService extends UtilHealthService {
@Autowired
private XMessageRepository xMessageRepository;
+ @Autowired
+ ObjectMapper mapper;
+
/**
* Returns health node
*
* @return Mono
*/
public Mono getCassandraHealthNode() {
- return getIsCassandraHealthy().map(healthy -> new ObjectMapper().createObjectNode().put("healthy", healthy));
+ return Mono.fromCallable(() -> {
+ ObjectNode result = mapper.createObjectNode();
+ try {
+ xMessageRepository.existsByUserId("Test");
+ result.put("status", Status.UP.getCode());
+ return result;
+ } catch(Exception e) {
+ result.put("status", Status.DOWN.getCode());
+ result.put("message", e.getMessage());
+ return result;
+ }
+ });
}
/**
@@ -36,37 +52,18 @@ public Mono getCassandraHealthNode() {
public Mono getAllHealthNode() {
ObjectNode resultNode = new ObjectMapper().createObjectNode();
Mono externalComponentHealth = super.getAllHealthNode();
- Mono cassandraHealth = getCassandraHealthNode().map(result -> {
- ObjectNode objectNode = new ObjectMapper().createObjectNode();
- objectNode.put("name", "cassandra");
- objectNode.set("healthy", result.get("healthy"));
- return objectNode;
- });
- return Mono.zip(externalComponentHealth, cassandraHealth).map(healths -> {
- resultNode.putArray("checks")
- .add(healths.getT1().get("checks"))
- .add(healths.getT2());
- resultNode.put("healthy",
- healths.getT1().get("healthy").booleanValue() &&
- healths.getT2().get("healthy").booleanValue()
+ Mono cassandraHealth = getCassandraHealthNode();
+ return Mono.zip(externalComponentHealth, cassandraHealth).map(results -> {
+ ObjectNode detailsNode = mapper.createObjectNode();
+ detailsNode.set("cassandra", results.getT2());
+ results.getT1().get("details").fields().forEachRemaining(detail -> detailsNode.set(detail.getKey(), detail.getValue()));
+ resultNode.set("details", detailsNode);
+ resultNode.put("status",
+ results.getT1().get("status").textValue().equals(Status.UP.getCode()) &&
+ results.getT2().get("status").textValue().equals(Status.UP.getCode())
+ ? Status.UP.getCode() : Status.DOWN.getCode()
);
return resultNode;
});
}
-
- /**
- * Check if Cassandra connecting or not
- *
- * @return Mono
- */
- private Mono getIsCassandraHealthy() {
- return Mono.fromCallable(() -> {
- try {
- xMessageRepository.existsByUserId("Test");
- return true;
- } catch(Exception e) {
- return false;
- }
- });
- }
}