summaryrefslogtreecommitdiffstats
path: root/policy-healthcheck
diff options
context:
space:
mode:
Diffstat (limited to 'policy-healthcheck')
-rw-r--r--policy-healthcheck/pom.xml4
-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
3 files changed, 26 insertions, 10 deletions
diff --git a/policy-healthcheck/pom.xml b/policy-healthcheck/pom.xml
index 913a944c..ab0e02db 100644
--- a/policy-healthcheck/pom.xml
+++ b/policy-healthcheck/pom.xml
@@ -32,7 +32,7 @@
<artifactId>policy-healthcheck</artifactId>
<name>policy-healthcheck</name>
- <description>Separately loadable module to perform healthchecks of the system</description>
+ <description>Loadable module that performs remote system healthchecks</description>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
@@ -96,7 +96,7 @@
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<scope>provided</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.openecomp.policy.drools-pdp</groupId>
<artifactId>policy-core</artifactId>
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;