From 6ee70eedd709d90ff0ddf7f12d45b03f1c8930b6 Mon Sep 17 00:00:00 2001 From: "Haddox, Anthony (ah0647)" Date: Tue, 12 Nov 2019 19:13:38 +0000 Subject: [CCSDK-1921]Connection Timeout and Info Logging Add connection timeout when creating HTTPUrlConnection. Additionally, add some logging verbosity to the health check RPCs for at-a-glance recognition. Signed-off-by: Haddox, Anthony Issue-ID: CCSDK-1921 Change-Id: I5dcf8c4b4899f121080eedd546e1a1f6fe120a94 --- .../onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java index 119c0b9c7..116afb3a4 100755 --- a/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java +++ b/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java @@ -103,6 +103,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT private static final String FAULTY = "FAULTY"; private static final String VALUE = "value"; private static final String OUTPUT = "output"; + private static final int CONNECTION_TIMEOUT = 5000; // 5 second timeout private String akkaConfig; private String jolokiaClusterPath; private String shardManagerPath; @@ -256,7 +257,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.setStatus("200"); outputBuilder.setHealth(getAdminHealth()); outputBuilder.setServedBy(member); - + log.info(outputBuilder.build().toString()); return Futures.immediateFuture(RpcResultBuilder.status(true).withResult(outputBuilder.build()).build()); } @@ -484,6 +485,10 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.setServedBy(member); RpcResult rpcResult = RpcResultBuilder.status(true).withResult(outputBuilder.build()).build(); + log.info("{}:cluster-health: Site 1 | Healthy ODLs {}", APP_NAME, site1Health); + if(siteConfiguration == SiteConfiguration.GEO) { + log.info("{}:cluster-health: Site 2 | Healthy ODLs {}", APP_NAME, site2Health); + } return Futures.immediateFuture(rpcResult); } @@ -557,6 +562,8 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.getSites().add(builder.build()); builder = getSitesBuilder(site2HealthyODLs, site2Voting, crossSiteAdminHealthy, crossSiteDbHealthy, crossSiteIdentifier); outputBuilder.getSites().add(builder.build()); + log.info("{}:site-health: Site 1 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, siteIdentifier, site1Voting, site1HealthyODLs, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth)); + log.info("{}:site-health: Site 2 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, crossSiteIdentifier, site2Voting, site2HealthyODLs, crossSiteAdminHealthy, crossSiteDbHealthy); } else { // Make calls over to site 1 healthchecks @@ -595,6 +602,8 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT outputBuilder.getSites().add(builder.build()); builder = getSitesBuilder(site2HealthyODLs, site2Voting, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth), siteIdentifier); outputBuilder.getSites().add(builder.build()); + log.info("{}:site-health: Site 1 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, siteIdentifier, site1Voting, site1HealthyODLs, HEALTHY.equals(adminHealth), HEALTHY.equals(databaseHealth)); + log.info("{}:site-health: Site 2 ({}) | hasVotingMembers?: {} | Healthy ODLs: {} | ADM isHealthy?: {} | DB isHealthy?: {}", APP_NAME, crossSiteIdentifier, site2Voting, site2HealthyODLs, crossSiteAdminHealthy, crossSiteDbHealthy); } } @@ -931,6 +940,8 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT connection.addRequestProperty("Authorization", auth); connection.setRequestProperty("Connection", "keep-alive"); connection.setRequestProperty("Proxy-Connection", "keep-alive"); + connection.setConnectTimeout(CONNECTION_TIMEOUT); + connection.setReadTimeout(CONNECTION_TIMEOUT); return connection; } -- cgit 1.2.3-korg