Divide the MSB source codes into two repos
[msb/apigateway.git] / apiroute / apiroute-service / src / main / java / org / onap / msb / apiroute / health / ApiRouteHealthCheck.java
@@ -1,5 +1,5 @@
 /**
- * Copyright 2016 ZTE Corporation.
+ * Copyright 2016 ZTE, Inc. and others.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.openo.msb.health;
+package org.onap.msb.apiroute.health;
+
+import org.onap.msb.apiroute.api.DiscoverInfo;
+import org.onap.msb.apiroute.wrapper.util.ConfigUtil;
+import org.onap.msb.apiroute.wrapper.util.HttpClientUtil;
+import org.onap.msb.apiroute.wrapper.util.RouteUtil;
 
 import com.codahale.metrics.health.HealthCheck;
 
 public class ApiRouteHealthCheck extends HealthCheck {
-    private final String template;
 
-    public ApiRouteHealthCheck(String template) {
-        this.template = template;
+
+    public ApiRouteHealthCheck() {
     }
 
     @Override
     protected Result check() throws Exception {
-        final String saying = String.format(template, "TEST");
-        if (!saying.contains("TEST")) {
-            return Result.unhealthy("template doesn't include a name");
-        }
+      DiscoverInfo discoverInfo=ConfigUtil.getInstance().getDiscoverInfo();
+      
+      String checkUrl =
+          (new StringBuilder().append("http://").append(discoverInfo.toString())
+              .append(RouteUtil.MSB_CHECK_URL)).toString();
+
+      int resultStatus = HttpClientUtil.httpGetStatus(checkUrl);
+      
+      if(resultStatus==200){
         return Result.healthy();
+      }
+      else{
+        return Result.unhealthy("check consul fail:[status]"+resultStatus);
+      }
+      
+
     }
 }
\ No newline at end of file