X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Fclds%2Fservice%2FCldsHealthcheckService.java;h=3fceace55c5f83e38401afac81c87ff23b186216;hb=cac17e887b4df189fc9123097e1442d0b6c421b8;hp=c25e6e7acd5f9730b1493a55892f92d0a0db700c;hpb=116703e35d4426dfd644246e17a40d4cab5cf641;p=clamp.git 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 c25e6e7a..3fceace5 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsHealthcheckService.java @@ -19,21 +19,19 @@ * ============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 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.util.ONAPLogConstants; +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.http.ResponseEntity; import org.springframework.stereotype.Component; /** @@ -44,44 +42,40 @@ import org.springframework.stereotype.Component; 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 */ - public ResponseEntity 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 { - cldsDao.doHealthCheck(); + loopController.getLoopNames(); 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) { - healthcheckFailed = true; 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"); + util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Healthcheck failed", Level.INFO, + OnapLogConstants.ResponseStatus.ERROR); } - // 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 +}