summaryrefslogtreecommitdiffstats
path: root/policy-healthcheck/src
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-06-22 17:17:28 -0500
committerJorge Hernandez <jh1730@att.com>2017-06-22 17:17:28 -0500
commit8f61e18ef0457745719f05bd5c186992a7155416 (patch)
tree884f4653f957a88a65ea981727dfe26494fb7c55 /policy-healthcheck/src
parent3cc1a85a832771cb70ed9cbaab9031bc4a114308 (diff)
[POLICY-30] remove problematic layers
add configurability through telemetry API Change-Id: I77ebde12a417d421b98646c32dc74824f4494c2e Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'policy-healthcheck/src')
-rw-r--r--policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java19
-rw-r--r--policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java13
2 files changed, 24 insertions, 8 deletions
diff --git a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java
index 17627a63..b45065e9 100644
--- a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java
+++ b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java
@@ -30,6 +30,8 @@ import org.openecomp.policy.drools.http.server.HttpServletServer;
import org.openecomp.policy.drools.persistence.SystemPersistence;
import org.openecomp.policy.drools.properties.Startable;
import org.openecomp.policy.drools.system.PolicyEngine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Healthcheck
@@ -120,6 +122,11 @@ public interface HealthCheck extends Startable {
class HealthCheckMonitor implements HealthCheck {
/**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(HealthCheckMonitor.class);
+
+ /**
* attached http servers
*/
protected volatile ArrayList<HttpServletServer> servers = new ArrayList<>();
@@ -137,7 +144,7 @@ class HealthCheckMonitor implements HealthCheck {
/**
* {@inheritDoc}
*/
- public Reports healthCheck() {
+ public Reports healthCheck() {
Reports reports = new Reports();
reports.healthy = PolicyEngine.manager.isAlive();
@@ -165,7 +172,7 @@ class HealthCheckMonitor implements HealthCheck {
try {
report.message = HttpClient.getBody(response, String.class);
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot get body from http-client {}", this, client, e);
}
} catch (Exception e) {
report.healthy = false;
@@ -181,6 +188,7 @@ class HealthCheckMonitor implements HealthCheck {
*/
@Override
public boolean start() throws IllegalStateException {
+
try {
this.healthCheckProperties = SystemPersistence.manager.getProperties(HealthCheckFeature.CONFIGURATION_PROPERTIES_NAME);
this.servers = HttpServletServer.factory.build(healthCheckProperties);
@@ -190,7 +198,7 @@ class HealthCheckMonitor implements HealthCheck {
try {
server.start();
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot start http-server {}", this, server, e);
}
}
} catch (Exception e) {
@@ -205,11 +213,12 @@ class HealthCheckMonitor implements HealthCheck {
*/
@Override
public boolean stop() throws IllegalStateException {
+
for (HttpServletServer server : servers) {
try {
server.stop();
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot stop http-server {}", this, server, e);
}
}
@@ -217,7 +226,7 @@ class HealthCheckMonitor implements HealthCheck {
try {
client.stop();
} catch (Exception e) {
- e.printStackTrace();
+ logger.warn("{}: cannot stop http-client {}", this, client, e);
}
}
diff --git a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java
index 63216f6d..0f16d8cf 100644
--- a/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java
+++ b/policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java
@@ -22,11 +22,18 @@ package org.openecomp.policy.drools.healthcheck;
import org.openecomp.policy.drools.features.PolicyEngineFeatureAPI;
import org.openecomp.policy.drools.system.PolicyEngine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This feature provides healthcheck verification of remotely associated RESTful components
*/
-public class HealthCheckFeature implements PolicyEngineFeatureAPI {
+public class HealthCheckFeature implements PolicyEngineFeatureAPI {
+
+ /**
+ * Logger
+ */
+ private static Logger logger = LoggerFactory.getLogger(HealthCheckFeature.class);
/**
* Properties Configuration Name
@@ -43,7 +50,7 @@ public class HealthCheckFeature implements PolicyEngineFeatureAPI {
try {
HealthCheck.monitor.start();
} catch (IllegalStateException e) {
- e.printStackTrace();
+ logger.error("Healthcheck Monitor cannot be started", e);
}
return false;
@@ -54,7 +61,7 @@ public class HealthCheckFeature implements PolicyEngineFeatureAPI {
try {
HealthCheck.monitor.stop();
} catch (IllegalStateException e) {
- e.printStackTrace();
+ logger.error("Healthcheck Monitor cannot be stopped", e);
}
return false;