1 package org.onap.msb.apiroute.health;
3 import org.apache.commons.lang3.StringUtils;
4 import org.onap.msb.apiroute.wrapper.util.HttpClientUtil;
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
8 import com.codahale.metrics.health.HealthCheck;
10 public class OpenRestyHealthCheck extends HealthCheck {
11 private static final Logger LOGGER = LoggerFactory
12 .getLogger(OpenRestyHealthCheck.class);
13 private String CHECK_IP="127.0.0.1";
14 private String CHECK_PORT="80";
15 private String CHECK_URL = "http://"+CHECK_IP+":"+CHECK_PORT+"/api/microservices/v1/apiRoute/discoverInfo";
18 protected Result check() throws Exception {
19 // TODO Auto-generated method stub
21 if(!StringUtils.isBlank(System.getenv("HTTP_OVERWRITE_PORT")))
23 CHECK_PORT=System.getenv("HTTP_OVERWRITE_PORT");
24 CHECK_URL = "http://"+CHECK_IP+":"+CHECK_PORT+"/api/microservices/v1/apiRoute/discoverInfo";
25 LOGGER.info("check openresty URL:"+CHECK_URL);
28 int resultStatus = HttpClientUtil.httpGetStatus(CHECK_URL);
30 if (resultStatus == 200) {
31 return Result.healthy();
34 .unhealthy("check openresty fail:" + resultStatus);