This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-annotations.git
commit fd6d98c8cd79999c42bd187ee9e08b8a44d0ec51 Author: Georg Henzler <[email protected]> AuthorDate: Thu Jun 8 20:42:33 2017 +0000 SLING-6855 Introducing property hc.warningsStickForMinutes that makes warn HC results sticky for the given minutes git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1798123 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 4 +-- .../sling/hc/annotations/SlingHealthCheck.java | 8 +++++ .../hc/annotations/SlingHealthCheckProcessor.java | 38 +++++++++++++++++++--- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 6012892..4ad2d11 100644 --- a/pom.xml +++ b/pom.xml @@ -63,8 +63,8 @@ </dependency> <dependency> <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.hc.core</artifactId> - <version>1.2.4</version> + <artifactId>org.apache.sling.hc.api</artifactId> + <version>1.0.0</version> <scope>provided</scope> </dependency> </dependencies> diff --git a/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheck.java b/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheck.java index 4e3bf28..dba4e66 100644 --- a/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheck.java +++ b/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheck.java @@ -55,6 +55,14 @@ public @interface SlingHealthCheck { */ long resultCacheTtlInMs() default -1; + /** + * If given, warning results (that is WARN, CRITICAL or HEALTH_CHECK_ERROR) from the past executions + * will be taken into account as well for the given minutes (use Integer.MAX_VALUE for indefinitely). + * Useful for unhealthy system states that disappear but might leave the system at an inconsistent + * state (e.g. an event queue overflow). + */ + long warningsStickForMinutes() default -1; + // handling of service and component properties (optional) /** Whether to generate a default SCR component tag. If set to false, a {@link org.apache.felix.scr.annotations.Component} annotation can be added manually diff --git a/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheckProcessor.java b/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheckProcessor.java index 060135e..51eed20 100644 --- a/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheckProcessor.java +++ b/src/main/java/org/apache/sling/hc/annotations/SlingHealthCheckProcessor.java @@ -86,11 +86,39 @@ public class SlingHealthCheckProcessor implements AnnotationProcessor { } // generate HC PropertyDescriptions - generatePropertyDescriptor(cad, classDescription, metatype, "name", HealthCheck.NAME, PropertyType.String, "Name", "Name of the Health Check", false); - generatePropertyDescriptor(cad, classDescription, metatype, "tags", HealthCheck.TAGS, PropertyType.String, "Tags", "List of tags", true); - generatePropertyDescriptor(cad, classDescription, metatype, "mbeanName", HealthCheck.MBEAN_NAME, PropertyType.String, "MBean", "MBean name (leave empty for not using JMX)", false); - generatePropertyDescriptor(cad, classDescription, metatype, "asyncCronExpression", HealthCheck.ASYNC_CRON_EXPRESSION, PropertyType.String, "Cron expression", "Cron expression for asynchronous execution (leave empty for synchronous execution)", false); - generatePropertyDescriptor(cad, classDescription, metatype, "resultCacheTtlInMs", "hc.resultCacheTtlInMs" /* use constant once API is released */, PropertyType.Long , "Result Cache TTL", "TTL for results. The value -1 (default) uses the global configuration in health check executor. Redeployment of a HC always invalidates its cached result.", false); + generatePropertyDescriptor(cad, classDescription, metatype, "name", HealthCheck.NAME, PropertyType.String, + "Name", "Name of the Health Check", false); + generatePropertyDescriptor(cad, classDescription, metatype, "tags", HealthCheck.TAGS, PropertyType.String, + "Tags", "List of tags", true); + generatePropertyDescriptor(cad, classDescription, metatype, "mbeanName", HealthCheck.MBEAN_NAME, PropertyType.String, + "MBean", "MBean name (leave empty for not using JMX)", false); + generatePropertyDescriptor(cad, classDescription, metatype, "asyncCronExpression", HealthCheck.ASYNC_CRON_EXPRESSION, PropertyType.String, + "Cron expression", "Cron expression for asynchronous execution (leave empty for synchronous execution)", false); + + String resultCacheTtlInMsPropName = "resultCacheTtlInMs"; + if (cad.getValue(resultCacheTtlInMsPropName) != null) { + generatePropertyDescriptor(cad, classDescription, metatype, resultCacheTtlInMsPropName, HealthCheck.RESULT_CACHE_TTL_IN_MS, PropertyType.Long, + "Result Cache TTL", + "TTL for results. The value -1 (default) uses the global configuration in health check executor. " + + "Redeployment of a HC always invalidates its cached result.", + false); + } + + String warningsStickForMinutesPropName = "warningsStickForMinutes"; + if (cad.getValue(warningsStickForMinutesPropName) != null) { + generatePropertyDescriptor(cad, classDescription, metatype, warningsStickForMinutesPropName, + "hc.warningsStickForMinutes" /* use constant once API is released */, + PropertyType.Long, "Sticky Warnings", + "If given, warning results (that is WARN, CRITICAL or HEALTH_CHECK_ERROR) from the past executions will be " + + "taken into account as well for the given minutes (use Integer.MAX_VALUE for indefinitely). " + + "By default this is disabled (value -1).", + false); + } + } + + private boolean isLongDefaultValue(final ClassAnnotation cad, String propName) { + Object value = cad.getValue(propName); + return value == null || ((Long) value) == -1; } /** Generates a property descriptor of type {@link PropertyType} */ -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
