summaryrefslogtreecommitdiffstats
path: root/policy-healthcheck/src/main
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-05-09 23:42:38 -0500
committerJorge Hernandez <jh1730@att.com>2017-05-10 00:02:56 -0500
commit0dfbb8790926ad24d1e124ee2acd18d108e358b5 (patch)
treebb50d804f92d530c7bc406710e9e26d73943f16e /policy-healthcheck/src/main
parent99dbede9a263e23a9f526a6a9ad5a7004ad5bec7 (diff)
[POLICY-11] Fact queries with variables + features
GET/PUT/DELETE operations through REST API. Report on optional features (modules) attached to the engine. Added javadoc comments in Healthcheck module. Change-Id: Ic8d2c06779dda4024e94ad39bb316211522e4e4c Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'policy-healthcheck/src/main')
-rw-r--r--policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheck.java70
-rw-r--r--policy-healthcheck/src/main/java/org/openecomp/policy/drools/healthcheck/HealthCheckFeature.java8
2 files changed, 78 insertions, 0 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 2ed2e075..68f9fdb4 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
@@ -11,13 +11,38 @@ import org.openecomp.policy.drools.persistence.SystemPersistence;
import org.openecomp.policy.drools.properties.Startable;
import org.openecomp.policy.drools.system.PolicyEngine;
+/**
+ * Healthcheck
+ */
public interface HealthCheck extends Startable {
+ /**
+ * Healthcheck Report
+ */
public static class Report {
+ /**
+ * Named Entity in the report
+ */
public String name;
+
+ /**
+ * URL queried
+ */
public String url;
+
+ /**
+ * healthy?
+ */
public boolean healthy;
+
+ /**
+ * return code
+ */
public int code;
+
+ /**
+ * Message from remote entity
+ */
public String message;
@Override
@@ -38,6 +63,9 @@ public interface HealthCheck extends Startable {
}
}
+ /**
+ * Report aggregation
+ */
public static class Reports {
public boolean healthy;
public ArrayList<Report> details = new ArrayList<>();
@@ -54,17 +82,41 @@ public interface HealthCheck extends Startable {
}
}
+ /**
+ * perform a healthcheck
+ * @return a report
+ */
public Reports healthCheck();
+ /**
+ * Healthcheck Monitor
+ */
public static final HealthCheck monitor = new HealthCheckMonitor();
}
+/**
+ * Healthcheck Monitor
+ */
class HealthCheckMonitor implements HealthCheck {
+ /**
+ * attached http servers
+ */
protected volatile ArrayList<HttpServletServer> servers = new ArrayList<>();
+
+ /**
+ * attached http clients
+ */
protected volatile ArrayList<HttpClient> clients = new ArrayList<>();
+
+ /**
+ * healthcheck configuration
+ */
protected volatile Properties healthCheckProperties = null;
+ /**
+ * {@inheritDoc}
+ */
public Reports healthCheck() {
Reports reports = new Reports();
reports.healthy = PolicyEngine.manager.isAlive();
@@ -104,6 +156,9 @@ class HealthCheckMonitor implements HealthCheck {
return reports;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean start() throws IllegalStateException {
try {
@@ -125,6 +180,9 @@ class HealthCheckMonitor implements HealthCheck {
return true;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean stop() throws IllegalStateException {
for (HttpServletServer server : servers) {
@@ -146,20 +204,32 @@ class HealthCheckMonitor implements HealthCheck {
return true;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void shutdown() throws IllegalStateException {
this.stop();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public synchronized boolean isAlive() {
return this.healthCheckProperties != null;
}
+ /**
+ * @return list of attached Http Servers
+ */
public ArrayList<HttpServletServer> getServers() {
return this.servers;
}
+ /**
+ * @return list of attached Http Clients
+ */
public ArrayList<HttpClient> getClients() {
return this.clients;
}
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 321d1e73..1d73614a 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
@@ -156,5 +156,13 @@ public class HealthCheckFeature implements PolicyEngineFeatureAPI {
public boolean afterUnlock(PolicyEngine engine) {
return false;
}
+
+ /**
+ * gets the monitor
+ * @return the healthcheck monitor
+ */
+ public HealthCheck getMonitor() {
+ return HealthCheck.monitor;
+ }
}