From 0dfbb8790926ad24d1e124ee2acd18d108e358b5 Mon Sep 17 00:00:00 2001 From: Jorge Hernandez Date: Tue, 9 May 2017 23:42:38 -0500 Subject: [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 --- .../policy/drools/healthcheck/HealthCheck.java | 70 ++++++++++++++++++++++ .../drools/healthcheck/HealthCheckFeature.java | 8 +++ 2 files changed, 78 insertions(+) (limited to 'policy-healthcheck/src') 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 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 servers = new ArrayList<>(); + + /** + * attached http clients + */ protected volatile ArrayList 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 getServers() { return this.servers; } + /** + * @return list of attached Http Clients + */ public ArrayList 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; + } } -- cgit 1.2.3-korg