diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2022-03-01 10:54:33 -0600 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2022-03-01 16:19:18 -0600 |
commit | 515147480c8807219dc4cdff1cd7e178757196ba (patch) | |
tree | 3595a6c86e0757b85e7b820cc7a78a323ad66500 /feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java | |
parent | 4a9a11e170ebcc47ef20f7055184ce66f7994415 (diff) |
Add controllers and remote servers healthchecks
Issue-ID: POLICY-3977
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: I4fd4db29f99989a2ef11b08f66f28535bfd15a36
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java')
-rw-r--r-- | feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java | 103 |
1 files changed, 86 insertions, 17 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 de00df88..06331bcc 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 @@ -1,8 +1,8 @@ /* * ============LICENSE_START======================================================= - * feature-healthcheck + * ONAP * ================================================================================ - * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019, 2021-2022 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. @@ -22,10 +22,11 @@ package org.onap.policy.drools.healthcheck; import java.util.ArrayList; import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; +import lombok.Data; +import lombok.NoArgsConstructor; import org.onap.policy.common.capabilities.Startable; +import org.onap.policy.common.endpoints.http.client.HttpClient; +import org.onap.policy.drools.system.PolicyController; /** * Healthcheck. @@ -35,10 +36,9 @@ public interface HealthCheck extends Startable { /** * Healthcheck Report. */ - @Getter - @Setter - @ToString - public static class Report { + @Data + @NoArgsConstructor + class Report { /** * Named Entity in the report. */ @@ -57,29 +57,98 @@ public interface HealthCheck extends Startable { /** * return code. */ - private int code; + private long code; + + /** + * start time. + */ + private long startTime = System.currentTimeMillis(); + + /** + * end time. + */ + private long endTime; + + /** + * elapsed time. + */ + private long elapsedTime; /** * Message from remote entity. */ private String message; + + + public Report(Report report) { + this.startTime = report.startTime; + this.code = report.code; + this.elapsedTime = report.elapsedTime; + this.endTime = report.endTime; + this.healthy = report.healthy; + this.message = report.message; + this.name = report.name; + this.url = report.url; + } + + public Report setEndTime() { + setEndTime(System.currentTimeMillis()); + setElapsedTime(endTime - startTime); + return this; + } } /** * Report aggregation. */ - @Getter - @Setter - @ToString - public static class Reports { + @Data + class Reports { private boolean healthy; + private final long startTime = System.currentTimeMillis(); + private long endTime; + private long elapsedTime; private List<Report> details = new ArrayList<>(); + + public Reports setEndTime() { + this.endTime = System.currentTimeMillis(); + this.elapsedTime = this.endTime - this.startTime; + return this; + } } /** - * Perform a healthcheck. - * - * @return a report + * Process engine open status. + */ + void open(); + + /** + * System healthcheck. */ Reports healthCheck(); + + /** + * Engine only healthcheck. + */ + Reports engineHealthcheck(); + + /** + * Controllers only healthcheck. + */ + Reports controllerHealthcheck(); + + /** + * Healthcheck on a controller. + */ + Reports controllerHealthcheck(PolicyController controller); + + /** + * HTTP Clients only healthcheck. + */ + Reports clientHealthcheck(); + + /** + * Healthcheck on an HTTP Client. + */ + Reports clientHealthcheck(HttpClient client); + } |