summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-09-10 15:57:10 +0200
committersebdet <sebastien.determe@intl.att.com>2019-09-10 16:50:30 +0200
commitc85d40b0cc8f40e5d0e17019878df82170f7bb35 (patch)
treea99cefc721df797a485c3ca57b0f85ad3ef4ae3d /src/main/java
parentceaa2fc1fee98ca995e1952f107d098633f01eb7 (diff)
Repair healthcheck
HealthCheck was always returning 200 even if the db was not up and running Issue-ID: CLAMP-494 Change-Id: I85aa427a212c6cde568d3863d1ab1a1a11c71f16 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java15
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopController.java42
2 files changed, 20 insertions, 37 deletions
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java b/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java
index f16791681..39c12c8f5 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java
@@ -34,7 +34,6 @@ import org.onap.clamp.loop.LoopController;
import org.slf4j.event.Level;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
/**
@@ -54,36 +53,28 @@ public class CldsHealthcheckService {
*
* @return CldsHealthCheck class containing healthcheck info
*/
- public ResponseEntity<CldsHealthCheck> gethealthcheck() {
+ public CldsHealthCheck gethealthcheck() {
CldsHealthCheck cldsHealthCheck = new CldsHealthCheck();
Date startTime = new Date();
LoggingUtils util = new LoggingUtils(logger);
LoggingUtils.setRequestContext("CldsService: GET healthcheck", "Clamp-Health-Check");
LoggingUtils.setTimeContext(startTime, new Date());
- boolean healthcheckFailed = false;
try {
loopController.getLoopNames();
cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
cldsHealthCheck.setHealthCheckStatus("UP");
cldsHealthCheck.setDescription("OK");
LoggingUtils.setResponseContext("0", "Get healthcheck success", this.getClass().getName());
+ util.exiting("200", "Healthcheck success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
} catch (Exception e) {
- healthcheckFailed = true;
logger.error("CLAMP application Heath check failed", e);
LoggingUtils.setResponseContext("999", "Get healthcheck failed", this.getClass().getName());
cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
cldsHealthCheck.setHealthCheckStatus("DOWN");
cldsHealthCheck.setDescription("NOT-OK");
- }
- // audit log
- LoggingUtils.setTimeContext(startTime, new Date());
- if (healthcheckFailed) {
util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "Healthcheck failed", Level.INFO,
ONAPLogConstants.ResponseStatus.ERROR);
- return new ResponseEntity<>(cldsHealthCheck, HttpStatus.INTERNAL_SERVER_ERROR);
- } else {
- util.exiting("200", "Healthcheck failed", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
- return new ResponseEntity<>(cldsHealthCheck, HttpStatus.OK);
}
+ return cldsHealthCheck;
}
} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java
index 7d41e489a..72726fa3f 100644
--- a/src/main/java/org/onap/clamp/loop/LoopController.java
+++ b/src/main/java/org/onap/clamp/loop/LoopController.java
@@ -61,40 +61,35 @@ public class LoopController {
/**
* Update the Operational Policy properties.
*
- * @param loopName
- * The loop name
- * @param operationalPoliciesJson
- * The new Operational Policy properties
+ * @param loopName The loop name
+ * @param operationalPoliciesJson The new Operational Policy properties
* @return The updated loop
*/
public Loop updateOperationalPolicies(String loopName, JsonArray operationalPoliciesJson) {
List<OperationalPolicy> operationalPolicies = JsonUtils.GSON.fromJson(operationalPoliciesJson,
- OPERATIONAL_POLICY_TYPE);
+ OPERATIONAL_POLICY_TYPE);
return loopService.updateAndSaveOperationalPolicies(loopName, operationalPolicies);
}
/**
- * Update the whole array of MicroService policies properties
+ * Update the whole array of MicroService policies properties.
*
- * @param loopName
- * The loop name
- * @param microServicePoliciesJson
- * The array of all MicroService policies properties
+ * @param loopName The loop name
+ * @param microServicePoliciesJson The array of all MicroService policies
+ * properties
* @return The updated loop
*/
public Loop updateMicroservicePolicies(String loopName, JsonArray microServicePoliciesJson) {
List<MicroServicePolicy> microservicePolicies = JsonUtils.GSON.fromJson(microServicePoliciesJson,
- MICROSERVICE_POLICY_TYPE);
+ MICROSERVICE_POLICY_TYPE);
return loopService.updateAndSaveMicroservicePolicies(loopName, microservicePolicies);
}
/**
- * Update the global properties
+ * Update the global properties.
*
- * @param loopName
- * The loop name
- * @param globalProperties
- * The updated global properties
+ * @param loopName The loop name
+ * @param globalProperties The updated global properties
* @return The updated loop
*/
public Loop updateGlobalPropertiesJson(String loopName, JsonObject globalProperties) {
@@ -102,12 +97,10 @@ public class LoopController {
}
/**
- * Update one MicroService policy properties
+ * Update one MicroService policy properties.
*
- * @param loopName
- * The loop name
- * @param newMicroservicePolicy
- * The new MicroService policy properties
+ * @param loopName The loop name
+ * @param newMicroservicePolicy The new MicroService policy properties
* @return The updated MicroService policy
*/
public MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
@@ -115,13 +108,12 @@ public class LoopController {
}
/**
- * Get the SVG representation of the loop
+ * Get the SVG representation of the loop.
*
- * @param loopName
- * The loop name
+ * @param loopName The loop name
* @return The SVG representation
*/
- public String getSVGRepresentation(String loopName) {
+ public String getSvgRepresentation(String loopName) {
Loop loop = loopService.getLoop(loopName);
return loop != null ? loop.getSvgRepresentation() : null;
}