X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fcontroller%2FHealthCheckController.java;h=0acfabfe9bb9b3ded8a57cfb04b46a5c3ab8ed39;hb=e27e8a75ca9d92b6694b109f3e5d3c79ce673473;hp=cecbd9bdf89c47d0da380fe5c9a38dd8505897ae;hpb=a70761c096192e38800bf38d6c7f61f52bf72007;p=portal.git diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java index cecbd9bd..0acfabfe 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -45,8 +47,7 @@ import javax.servlet.http.HttpServletResponse; import org.slf4j.MDC; import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.onap.music.main.MusicUtil; import org.onap.portalapp.controller.EPUnRestrictedBaseController; @@ -118,12 +119,12 @@ public class HealthCheckController extends EPUnRestrictedBaseController { private final String statusDown = "DOWN"; private final String statusOk = "OK"; - @RequestMapping(value = { "/portalApi/healthCheck" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/healthCheck" }, produces = "application/json") public HealthStatus healthCheck(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(500, ""); // Return the status as 500 if it suspended due to manual fail over - if (HealthMonitor.isSuspended) { + if (HealthMonitor.isSuspended()) { healthStatus.body = "Suspended"; response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); MDC.put(EPCommonSystemProperties.RESPONSE_CODE, @@ -171,16 +172,15 @@ public class HealthCheckController extends EPUnRestrictedBaseController { // dbInfo.dbClusterStatus = statusOk; // } - if (!HealthMonitor.isDatabasePermissionsOk()) { + if (!HealthMonitor.isDbPermissionsOk()) { dbInfo.dbPermissions = "Problem, check the logs for more details"; EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError); } else { dbInfo.dbPermissions = statusOk; } statusCollection.add(dbInfo); - - org.onap.portalapp.music.util.MusicUtil MusicUtilSDK = new org.onap.portalapp.music.util.MusicUtil(); - if(MusicUtilSDK.isMusicEnable()){ + + if(org.onap.portalapp.music.util.MusicUtil.isMusicEnable()){ HealthStatusInfo CassandraStatusInfo = new HealthStatusInfo("Music-Cassandra"); //CassandraStatusInfo.hostName = EcompPortalUtils.getMyHostName(); CassandraStatusInfo.ipAddress = MusicUtil.getMyCassaHost(); @@ -193,16 +193,17 @@ public class HealthCheckController extends EPUnRestrictedBaseController { } statusCollection.add(CassandraStatusInfo); - HealthStatusInfo zookeeperStatusInfo = new HealthStatusInfo("Music-zookeeper"); - //zookeeperStatusInfo.hostName = EcompPortalUtils.getMyHostName(); - zookeeperStatusInfo.ipAddress = MusicUtil.getMyZkHost(); - if (!HealthMonitor.isZookeeperStatusOk()) { - overallStatus = false; - zookeeperStatusInfo.healthCheckStatus = statusDown; - zookeeperStatusInfo.description = "Check the logs for more details"; - EPLogUtil.logEcompError(logger, EPAppMessagesEnum.MusicHealthCheckZookeeperError); - } - statusCollection.add(zookeeperStatusInfo); + /* + * HealthStatusInfo zookeeperStatusInfo = new + * HealthStatusInfo("Music-zookeeper"); --zookeeperStatusInfo.hostName = + * EcompPortalUtils.getMyHostName(); zookeeperStatusInfo.ipAddress = + * MusicUtil.getMyZkHost(); if (!HealthMonitor.isZookeeperStatusOk()) { + * overallStatus = false; zookeeperStatusInfo.healthCheckStatus = statusDown; + * zookeeperStatusInfo.description = "Check the logs for more details"; + * EPLogUtil.logEcompError(logger, + * EPAppMessagesEnum.MusicHealthCheckZookeeperError); } + * statusCollection.add(zookeeperStatusInfo); + */ } String json = ""; @@ -229,12 +230,12 @@ public class HealthCheckController extends EPUnRestrictedBaseController { return healthStatus; } - @RequestMapping(value = { - "/portalApi/healthCheckSuspend" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/healthCheckSuspend" }, produces = "application/json") public HealthStatus healthCheckSuspend(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(500, "Suspended for manual failover mechanism"); - HealthMonitor.isSuspended = true; + HealthMonitor.setSuspended(true); healthStatus.statusCode = 200; EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/healthCheckSuspend", "GET result =", @@ -243,19 +244,19 @@ public class HealthCheckController extends EPUnRestrictedBaseController { return healthStatus; } - @RequestMapping(value = { - "/portalApi/healthCheckResume" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/healthCheckResume" }, produces = "application/json") public HealthStatus healthCheckResume(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(500, "Resumed from manual failover mechanism"); - HealthMonitor.isSuspended = false; + HealthMonitor.setSuspended(false); healthStatus.statusCode = 200; EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/healthCheckResume", "GET result =", response.getStatus()); return healthStatus; } - @RequestMapping(value = { "/portalApi/ping" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/ping" }, produces = "application/json") public HealthStatus ping(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(200, "OK"); EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/ping", "GET result =", response.getStatus());