summaryrefslogtreecommitdiffstats
path: root/feature-healthcheck
diff options
context:
space:
mode:
Diffstat (limited to 'feature-healthcheck')
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java34
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckFeature.java91
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java40
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java18
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java3
5 files changed, 98 insertions, 88 deletions
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
index f4cb1cc6..d35b7371 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
@@ -35,41 +35,41 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Healthcheck
+ * Healthcheck.
*/
public interface HealthCheck extends Startable {
/**
- * Healthcheck Monitor
+ * Healthcheck Monitor.
*/
public static final HealthCheck monitor = new HealthCheckMonitor();
/**
- * Healthcheck Report
+ * Healthcheck Report.
*/
public static class Report {
/**
- * Named Entity in the report
+ * Named Entity in the report.
*/
private String name;
/**
- * URL queried
+ * URL queried.
*/
private String url;
/**
- * healthy?
+ * healthy.
*/
private boolean healthy;
/**
- * return code
+ * return code.
*/
private int code;
/**
- * Message from remote entity
+ * Message from remote entity.
*/
private String message;
@@ -132,7 +132,7 @@ public interface HealthCheck extends Startable {
}
/**
- * Report aggregation
+ * Report aggregation.
*/
public static class Reports {
private boolean healthy;
@@ -167,7 +167,7 @@ public interface HealthCheck extends Startable {
}
/**
- * perform a healthcheck
+ * Perform a healthcheck.
*
* @return a report
*/
@@ -176,27 +176,27 @@ public interface HealthCheck extends Startable {
/**
- * Healthcheck Monitor
+ * Healthcheck Monitor.
*/
class HealthCheckMonitor implements HealthCheck {
/**
- * Logger
+ * Logger.
*/
private static Logger logger = LoggerFactory.getLogger(HealthCheckMonitor.class);
/**
- * attached http servers
+ * attached http servers.
*/
protected volatile List<HttpServletServer> servers = new ArrayList<>();
/**
- * attached http clients
+ * attached http clients.
*/
protected volatile List<HttpClient> clients = new ArrayList<>();
/**
- * healthcheck configuration
+ * healthcheck configuration.
*/
protected volatile Properties healthCheckProperties = null;
@@ -306,6 +306,8 @@ class HealthCheckMonitor implements HealthCheck {
}
/**
+ * Get servers.
+ *
* @return list of attached Http Servers
*/
public List<HttpServletServer> getServers() {
@@ -313,6 +315,8 @@ class HealthCheckMonitor implements HealthCheck {
}
/**
+ * Get clients.
+ *
* @return list of attached Http Clients
*/
public List<HttpClient> getClients() {
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckFeature.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckFeature.java
index 34c1fe3a..3a79a55c 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckFeature.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheckFeature.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-healthcheck
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,53 +26,54 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This feature provides healthcheck verification of remotely associated RESTful components
+ * This feature provides healthcheck verification of remotely associated RESTful components.
*/
-public class HealthCheckFeature implements PolicyEngineFeatureAPI {
-
- /**
- * Logger
- */
- private static Logger logger = LoggerFactory.getLogger(HealthCheckFeature.class);
-
- /**
- * Properties Configuration Name
- */
- public static final String CONFIGURATION_PROPERTIES_NAME = "feature-healthcheck";
+public class HealthCheckFeature implements PolicyEngineFeatureAPI {
- @Override
- public int getSequenceNumber() {
- return 1000;
- }
+ /**
+ * Logger.
+ */
+ private static Logger logger = LoggerFactory.getLogger(HealthCheckFeature.class);
- @Override
- public boolean afterStart(PolicyEngine engine) {
- try {
- HealthCheck.monitor.start();
- } catch (IllegalStateException e) {
- logger.error("Healthcheck Monitor cannot be started", e);
- }
-
- return false;
- }
+ /**
+ * Properties Configuration Name.
+ */
+ public static final String CONFIGURATION_PROPERTIES_NAME = "feature-healthcheck";
- @Override
- public boolean afterShutdown(PolicyEngine engine) {
- try {
- HealthCheck.monitor.stop();
- } catch (IllegalStateException e) {
- logger.error("Healthcheck Monitor cannot be stopped", e);
- }
-
- return false;
- }
-
- /**
- * gets the monitor
- * @return the healthcheck monitor
- */
- public HealthCheck getMonitor() {
- return HealthCheck.monitor;
- }
+ @Override
+ public int getSequenceNumber() {
+ return 1000;
+ }
+
+ @Override
+ public boolean afterStart(PolicyEngine engine) {
+ try {
+ HealthCheck.monitor.start();
+ } catch (IllegalStateException e) {
+ logger.error("Healthcheck Monitor cannot be started", e);
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean afterShutdown(PolicyEngine engine) {
+ try {
+ HealthCheck.monitor.stop();
+ } catch (IllegalStateException e) {
+ logger.error("Healthcheck Monitor cannot be stopped", e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Gets the monitor.
+ *
+ * @return the healthcheck monitor
+ */
+ public HealthCheck getMonitor() {
+ return HealthCheck.monitor;
+ }
}
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
index 3f51ba46..734a75e0 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-healthcheck
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.drools.healthcheck;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.Info;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@@ -27,12 +34,6 @@ import javax.ws.rs.core.Response;
import org.onap.policy.drools.healthcheck.HealthCheck.Reports;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.SwaggerDefinition;
-import io.swagger.annotations.Tag;
-
@Path("/")
@Api
@Produces(MediaType.APPLICATION_JSON)
@@ -50,28 +51,29 @@ import io.swagger.annotations.Tag;
}
)
public class RestHealthCheck {
-
+
@GET
@Path("healthcheck")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
- value="Perform a system healthcheck",
- notes="Provides healthy status of the PDP-D plus the components defined in its configuration by using a REST interface",
- response=Reports.class
- )
+ value = "Perform a system healthcheck",
+ notes = "Provides healthy status of the PDP-D plus the components defined in its "
+ + "configuration by using a REST interface",
+ response = Reports.class
+ )
public Response healthcheck() {
- return Response.status(Response.Status.OK).entity(HealthCheck.monitor.healthCheck()).build();
+ return Response.status(Response.Status.OK).entity(HealthCheck.monitor.healthCheck()).build();
}
-
+
@GET
@Path("healthcheck/configuration")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
- value="Configuration",
- notes="Provides the Healthcheck server configuration and monitored REST clients",
- response=HealthCheck.class
- )
+ value = "Configuration",
+ notes = "Provides the Healthcheck server configuration and monitored REST clients",
+ response = HealthCheck.class
+ )
public HealthCheck configuration() {
- return HealthCheck.monitor;
+ return HealthCheck.monitor;
}
}
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
index 578ce5d5..8ae73435 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-healthcheck
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
package org.onap.policy.drools.healthcheck;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -45,7 +44,7 @@ import org.slf4j.LoggerFactory;
public class HealthCheckFeatureTest {
/**
- * Healthcheck Configuration File
+ * Healthcheck Configuration File.
*/
private static final String HEALTH_CHECK_PROPERTIES_FILE = "feature-healthcheck.properties";
@@ -57,13 +56,15 @@ public class HealthCheckFeatureTest {
/**
- * logger
+ * logger.
*/
private static Logger logger = LoggerFactory.getLogger(HealthCheckFeatureTest.class);
private static Properties httpProperties = new Properties();
-
+ /**
+ * Set up.
+ */
@BeforeClass
public static void setup() {
@@ -105,6 +106,9 @@ public class HealthCheckFeatureTest {
}
+ /**
+ * Tear down.
+ */
@AfterClass
public static void tearDown() {
logger.info("-- tearDown() --");
@@ -135,7 +139,7 @@ public class HealthCheckFeatureTest {
/**
- * setup up config directory
+ * setup up config directory.
*/
protected static void configDirSetup() {
@@ -161,7 +165,7 @@ public class HealthCheckFeatureTest {
}
/**
- * cleanup up config directory
+ * cleanup up config directory.
*/
protected static void configDirCleanup() {
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java
index 5b3b82b3..8bdad5b6 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-healthcheck
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
package org.onap.policy.drools.healthcheck;
-
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;