You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2013/10/19 14:35:45 UTC

svn commit: r1533746 - in /sling/trunk/bundles/extensions/healthcheck/core/src/main: java/org/apache/sling/hc/core/impl/ resources/

Author: cziegeler
Date: Sat Oct 19 12:35:44 2013
New Revision: 1533746

URL: http://svn.apache.org/r1533746
Log:
SLING-3192 : Correct metatype information for health checks

Removed:
    sling/trunk/bundles/extensions/healthcheck/core/src/main/resources/
Modified:
    sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/CompositeHealthCheck.java
    sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAttributeHealthCheck.java
    sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/ScriptableHealthCheck.java

Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/CompositeHealthCheck.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/CompositeHealthCheck.java?rev=1533746&r1=1533745&r2=1533746&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/CompositeHealthCheck.java (original)
+++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/CompositeHealthCheck.java Sat Oct 19 12:35:44 2013
@@ -43,14 +43,24 @@ import org.slf4j.LoggerFactory;
 /** {@link HealthCheck} that executes a number of other HealthChecks,
  *  selected by their tags, and merges their Results.
  */
+
 @Component(
         configurationFactory=true,
         policy=ConfigurationPolicy.REQUIRE,
-        metatype=true)
+        metatype=true,
+        label="Apache Sling Composite Health Check",
+        description="Executes a set of health checks, selected by tags.")
 @Properties({
-    @Property(name=HealthCheck.NAME),
-    @Property(name=HealthCheck.TAGS, unbounded=PropertyUnbounded.ARRAY),
-    @Property(name=HealthCheck.MBEAN_NAME)
+    @Property(name=HealthCheck.NAME,
+              label="Name",
+              description="Name of this healtch check."),
+    @Property(name=HealthCheck.TAGS, unbounded=PropertyUnbounded.ARRAY,
+              label="Tags",
+              description="List of tags for this health check, used to select " +
+                          "subsets of health checks for execution e.g. by a composite health check."),
+    @Property(name=HealthCheck.MBEAN_NAME,
+              label="MBean Name",
+              description="Name of the MBean to create for this health check. If empty, no MBean is registered.")
 })
 @Service(value=HealthCheck.class)
 public class CompositeHealthCheck implements HealthCheck {
@@ -58,7 +68,9 @@ public class CompositeHealthCheck implem
     private final Logger log = LoggerFactory.getLogger(getClass());
     private BundleContext bundleContext;
 
-    @Property(unbounded=PropertyUnbounded.ARRAY)
+    @Property(unbounded=PropertyUnbounded.ARRAY,
+              label="Filter Tags",
+              description="Tags used to select which Health Checks the composite Health Check executes.")
     private static final String PROP_FILTER_TAGS = "filter.tags";
     private String [] filterTags;
 

Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAttributeHealthCheck.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAttributeHealthCheck.java?rev=1533746&r1=1533745&r2=1533746&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAttributeHealthCheck.java (original)
+++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAttributeHealthCheck.java Sat Oct 19 12:35:44 2013
@@ -42,11 +42,20 @@ import org.slf4j.LoggerFactory;
 @Component(
         configurationFactory=true,
         policy=ConfigurationPolicy.REQUIRE,
-        metatype=true)
+        metatype=true,
+        label="Apache Sling JMX Attribute Health Check",
+        description="Checks the value of a single JMX attribute.")
 @Properties({
-    @Property(name=HealthCheck.NAME),
-    @Property(name=HealthCheck.TAGS, unbounded=PropertyUnbounded.ARRAY),
-    @Property(name=HealthCheck.MBEAN_NAME)
+    @Property(name=HealthCheck.NAME,
+            label="Name",
+            description="Name of this healtch check."),
+    @Property(name=HealthCheck.TAGS, unbounded=PropertyUnbounded.ARRAY,
+              label="Tags",
+              description="List of tags for this health check, used to select " +
+                        "subsets of health checks for execution e.g. by a composite health check."),
+    @Property(name=HealthCheck.MBEAN_NAME,
+              label="MBean Name",
+              description="Name of the MBean to create for this health check. If empty, no MBean is registered.")
 })
 @Service(value=HealthCheck.class)
 public class JmxAttributeHealthCheck implements HealthCheck {
@@ -56,22 +65,26 @@ public class JmxAttributeHealthCheck imp
     private String attributeName;
     private String constraint;
 
-    @Property
+    @Property(label="Check MBean Name",
+              description="The name of the MBean to check by this health check.")
     public static final String PROP_OBJECT_NAME = "mbean.name";
 
-    @Property
+    @Property(label="Check Attribute Name",
+            description="The name of the MBean attribute to check by this health check.")
     public static final String PROP_ATTRIBUTE_NAME = "attribute.name";
 
-    @Property
+    @Property(label="Check Attribute Constraint",
+            description="Constraint on the MBean attribute value.")
     public static final String PROP_CONSTRAINT = "attribute.value.constraint";
 
+
     @Activate
-    public void activate(final Map<String, Object> properties) {
+    protected void activate(final Map<String, Object> properties) {
         mbeanName = PropertiesUtil.toString(properties.get(PROP_OBJECT_NAME), "");
         attributeName = PropertiesUtil.toString(properties.get(PROP_ATTRIBUTE_NAME), "");
         constraint = PropertiesUtil.toString(properties.get(PROP_CONSTRAINT), "");
 
-        log.info("Activated with HealthCheck name={}, objectName={}, attribute={}, constraint={}",
+        log.debug("Activated with HealthCheck name={}, objectName={}, attribute={}, constraint={}",
                 new Object[] { properties.get(HealthCheck.NAME), mbeanName, attributeName, constraint });
     }
 
@@ -89,7 +102,7 @@ public class JmxAttributeHealthCheck imp
                 resultLog.debug("{} {} returns {}", mbeanName, attributeName, value);
                 new SimpleConstraintChecker().check(value, constraint, resultLog);
             }
-        } catch(Exception e) {
+        } catch(final Exception e) {
             log.warn("JMX attribute {}/{} check failed: {}", new Object []{ mbeanName, attributeName, e});
             resultLog.healthCheckError("JMX attribute check failed: {}", e);
         }

Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/ScriptableHealthCheck.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/ScriptableHealthCheck.java?rev=1533746&r1=1533745&r2=1533746&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/ScriptableHealthCheck.java (original)
+++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/ScriptableHealthCheck.java Sat Oct 19 12:35:44 2013
@@ -46,11 +46,20 @@ import org.slf4j.LoggerFactory;
 @Component(
         configurationFactory=true,
         policy=ConfigurationPolicy.REQUIRE,
-        metatype=true)
+        metatype=true,
+        label="Apache Sling Scriptable Health Check",
+        description="Uses scripted expressions to verify multiple JMX attributes or other values.")
 @Properties({
-    @Property(name=HealthCheck.NAME),
-    @Property(name=HealthCheck.TAGS, unbounded=PropertyUnbounded.ARRAY),
-    @Property(name=HealthCheck.MBEAN_NAME)
+    @Property(name=HealthCheck.NAME,
+            label="Name",
+            description="Name of this healtch check."),
+    @Property(name=HealthCheck.TAGS, unbounded=PropertyUnbounded.ARRAY,
+              label="Tags",
+              description="List of tags for this health check, used to select " +
+                        "subsets of health checks for execution e.g. by a composite health check."),
+    @Property(name=HealthCheck.MBEAN_NAME,
+              label="MBean Name",
+              description="Name of the MBean to create for this health check. If empty, no MBean is registered.")
 })
 @Service(value=HealthCheck.class)
 public class ScriptableHealthCheck implements HealthCheck {
@@ -61,24 +70,29 @@ public class ScriptableHealthCheck imple
 
     private static final String DEFAULT_LANGUAGE_EXTENSION = "ecma";
 
-    @Property
+    @Property(label="Expression",
+              description="The value of this expression must be \"true\" for this check to be successful.")
     public static final String PROP_EXPRESSION = "expression";
 
-    @Property(value=DEFAULT_LANGUAGE_EXTENSION)
+    @Property(value=DEFAULT_LANGUAGE_EXTENSION,
+              label="Language Extension",
+              description="File extension of the language to use to evaluate the " +
+                      "expression, for example \"ecma\" or \"groovy\", asssuming the corresponding script engine " +
+                      "is available. By default \"ecma\" is used.")
     public static final String PROP_LANGUAGE_EXTENSION = "language.extension";
 
     @Reference
     private ScriptEngineManager scriptEngineManager;
-    
+
     @Reference(
-            cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, 
+            cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE,
             policy=ReferencePolicy.DYNAMIC,
             referenceInterface=BindingsValuesProvider.class,
             target="(context=healthcheck)")
     private final Set<BindingsValuesProvider> bindingsValuesProviders = new HashSet<BindingsValuesProvider>();
 
     @Activate
-    public void activate(ComponentContext ctx) {
+    protected void activate(ComponentContext ctx) {
         expression = PropertiesUtil.toString(ctx.getProperties().get(PROP_EXPRESSION), "");
         languageExtension = PropertiesUtil.toString(ctx.getProperties().get(PROP_LANGUAGE_EXTENSION), DEFAULT_LANGUAGE_EXTENSION);
 
@@ -106,7 +120,7 @@ public class ScriptableHealthCheck imple
                     }
                 }
                 log.debug("All Bindings added: {}", b.keySet());
-                
+
                 final Object value = engine.eval(expression, b);
                 if(value!=null && "true".equals(value.toString().toLowerCase())) {
                     resultLog.debug("Expression [{}] evaluates to true as expected", expression);
@@ -121,14 +135,14 @@ public class ScriptableHealthCheck imple
         }
         return new Result(resultLog);
     }
-    
+
     public void bindBindingsValuesProvider(BindingsValuesProvider bvp) {
         synchronized (bindingsValuesProviders) {
             bindingsValuesProviders.add(bvp);
         }
         log.debug("{} registered: {}", bvp, bindingsValuesProviders);
     }
-    
+
     public void unbindBindingsValuesProvider(BindingsValuesProvider bvp) {
         synchronized (bindingsValuesProviders) {
             bindingsValuesProviders.remove(bvp);