Code Review
/
clamp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix audit, metric and error logs as per logging specification
[clamp.git]
/
src
/
main
/
java
/
org
/
onap
/
clamp
/
clds
/
service
/
CldsHealthcheckService.java
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
a017d54
..
3fceace
100644
(file)
--- a/
src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java
+++ b/
src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java
@@
-19,19
+19,19
@@
* ============LICENSE_END============================================
* ===================================================================
*/
* ============LICENSE_END============================================
* ===================================================================
*/
-package org.onap.clamp.clds.service;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+package org.onap.clamp.clds.service;
import java.util.Date;
import java.util.Date;
-
-import org.onap.clamp.clds.dao.CldsDao;
import org.onap.clamp.clds.model.CldsHealthCheck;
import org.onap.clamp.clds.util.LoggingUtils;
import org.onap.clamp.clds.model.CldsHealthCheck;
import org.onap.clamp.clds.util.LoggingUtils;
+import org.onap.clamp.clds.util.OnapLogConstants;
+import org.onap.clamp.loop.LoopController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.event.Level;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
/**
import org.springframework.stereotype.Component;
/**
@@
-42,41
+42,40
@@
import org.springframework.stereotype.Component;
public class CldsHealthcheckService {
@Autowired
public class CldsHealthcheckService {
@Autowired
- private
CldsDao cldsDao
;
+ private
LoopController loopController
;
- protected static final
EELFLogger logger = EELFManager.getInstance()
.getLogger(CldsHealthcheckService.class);
+ protected static final
Logger logger = LoggerFactory
.getLogger(CldsHealthcheckService.class);
/**
* REST service that retrieves clds healthcheck information.
*
* @return CldsHealthCheck class containing healthcheck info
*/
/**
* REST service that retrieves clds healthcheck information.
*
* @return CldsHealthCheck class containing healthcheck info
*/
- public
ResponseEntity<CldsHealthCheck>
gethealthcheck() {
+ public
CldsHealthCheck
gethealthcheck() {
CldsHealthCheck cldsHealthCheck = new CldsHealthCheck();
Date startTime = new Date();
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());
LoggingUtils.setRequestContext("CldsService: GET healthcheck", "Clamp-Health-Check");
LoggingUtils.setTimeContext(startTime, new Date());
- boolean healthcheckFailed = false;
try {
try {
-
cldsDao.doHealthCheck
();
+
loopController.getLoopNames
();
cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
cldsHealthCheck.setHealthCheckStatus("UP");
cldsHealthCheck.setDescription("OK");
cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
cldsHealthCheck.setHealthCheckStatus("UP");
cldsHealthCheck.setDescription("OK");
- LoggingUtils.setResponseContext("0", "Get healthcheck success", this.getClass().getName());
+ LoggingUtils.setResponseContext("0", "Get healthcheck success",
+ this.getClass().getName());
+ util.exiting(HttpStatus.OK.value(), "Healthcheck success", Level.INFO,
+ OnapLogConstants.ResponseStatus.COMPLETE);
} catch (Exception e) {
} catch (Exception e) {
- healthcheckFailed = true;
logger.error("CLAMP application Heath check failed", e);
logger.error("CLAMP application Heath check failed", e);
- LoggingUtils.setResponseContext("999", "Get healthcheck failed", this.getClass().getName());
+ LoggingUtils.setResponseContext("999", "Get healthcheck failed",
+ this.getClass().getName());
cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
cldsHealthCheck.setHealthCheckStatus("DOWN");
cldsHealthCheck.setDescription("NOT-OK");
cldsHealthCheck.setHealthCheckComponent("CLDS-APP");
cldsHealthCheck.setHealthCheckStatus("DOWN");
cldsHealthCheck.setDescription("NOT-OK");
+ util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Healthcheck failed", Level.INFO,
+ OnapLogConstants.ResponseStatus.ERROR);
}
}
- // audit log
- LoggingUtils.setTimeContext(startTime, new Date());
- if(healthcheckFailed) {
- return new ResponseEntity<>(cldsHealthCheck, HttpStatus.INTERNAL_SERVER_ERROR);
- } else {
- return new ResponseEntity<>(cldsHealthCheck, HttpStatus.OK);
- }
+ return cldsHealthCheck;
}
}
-}
\ No newline at end of file
+}