Replace output with static constant 83/87183/1
authorHaddox, Anthony <ah0647@att.com>
Tue, 7 May 2019 18:52:12 +0000 (11:52 -0700)
committerHaddox, Anthony <ah0647@att.com>
Tue, 7 May 2019 18:52:12 +0000 (11:52 -0700)
Replacing "output" with static constant OUTPUT.
This also resolves an issue with cross site health
check not being able to parse the health check.

Change-Id: Ie4d3b30b241620d00365d58db7797a5052f60827
Signed-off-by: Haddox, Anthony <ah0647@att.com>
Issue-ID: CCSDK-1312

grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java

index 39bc161..f10055a 100755 (executable)
@@ -48,7 +48,6 @@ import javax.annotation.Nonnull;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 
-import org.onap.ccsdk.sli.core.dblib.DBLibConnection;
 import org.onap.ccsdk.sli.core.dblib.DbLibService;
 import org.onap.ccsdk.sli.plugins.grtoolkit.data.ClusterActor;
 import org.onap.ccsdk.sli.plugins.grtoolkit.data.MemberBuilder;
@@ -103,6 +102,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT
     private static final String HEALTHY = "HEALTHY";
     private static final String FAULTY = "FAULTY";
     private static final String VALUE = "value";
+    private static final String OUTPUT = "output";
     private String akkaConfig;
     private String jolokiaClusterPath;
     private String shardManagerPath;
@@ -540,12 +540,13 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT
                             if(!performedCrossSiteHealthCheck) {
                                 try {
                                     String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST);
-                                    crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id");
+                                    crossSiteIdentifier = new JSONObject(content).getJSONObject(OUTPUT).getString("id");
                                     crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health");
                                     crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health");
                                     performedCrossSiteHealthCheck = true;
                                 } catch(Exception e) {
-                                    log.info("Cannot get site identifier from {}", clusterActor.getNode());
+                                    log.info("Cannot get cross site health from {}", clusterActor.getNode());
+                                    log.info("siteIdentifier: {} | dbHealth: {} | adminHealth: {}", crossSiteIdentifier, crossSiteDbHealthy, crossSiteAdminHealthy);
                                     log.error("Site Health Error", e);
                                 }
                             }
@@ -570,12 +571,13 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT
                             if(!performedCrossSiteHealthCheck) {
                                 try {
                                     String content = getRequestContent(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:site-identifier", HttpMethod.POST);
-                                    crossSiteIdentifier = new JSONObject(content).getJSONObject("output").getString("id");
+                                    crossSiteIdentifier = new JSONObject(content).getJSONObject(OUTPUT).getString("id");
                                     crossSiteDbHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:database-health");
                                     crossSiteAdminHealthy = crossSiteHealthRequest(httpProtocol + clusterActor.getNode() + ":" + port + "/restconf/operations/gr-toolkit:admin-health");
                                     performedCrossSiteHealthCheck = true;
                                 } catch(Exception e) {
-                                    log.info("Cannot get site identifier from {}", clusterActor.getNode());
+                                    log.info("Cannot get cross site health from {}", clusterActor.getNode());
+                                    log.info("siteIdentifier: {} | dbHealth: {} | adminHealth: {}", crossSiteIdentifier, crossSiteDbHealthy, crossSiteAdminHealthy);
                                     log.error("Site Health Error", e);
                                 }
                             }
@@ -815,7 +817,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT
         String content = getRequestContent(path, HttpMethod.POST);
         try {
             JSONObject responseJson = new JSONObject(content);
-            JSONObject responseValue = responseJson.getJSONObject(VALUE);
+            JSONObject responseValue = responseJson.getJSONObject(OUTPUT);
             return HEALTHY.equals(responseValue.getString("health"));
         } catch(JSONException e) {
             log.error("Error parsing JSON", e);