incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1512243 - in /sling/branches/SLING-2987-healthcheck-redesign: core/src/main/java/org/apache/sling/hc/api/ core/src/main/java/org/apache/sling/hc/impl/ core/src/main/java/org/apache/sling/hc/impl/healthchecks/ core/src/main/resources/OSGI-I...
Date Fri, 09 Aug 2013 10:42:24 GMT
Author: bdelacretaz
Date: Fri Aug  9 10:42:24 2013
New Revision: 1512243

URL: http://svn.apache.org/r1512243
Log:
SLING-2987 - optionally use a different (shorter) name for the MBeans that we create

Modified:
    sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/api/Constants.java
    sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckMBean.java
    sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckWebconsolePlugin.java
    sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/DefaultLoginsHealthCheck.java
    sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/JmxAttributeHealthCheck.java
    sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/ScriptableHealthCheck.java
    sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/SlingRequestStatusHealthCheck.java
    sling/branches/SLING-2987-healthcheck-redesign/core/src/main/resources/OSGI-INF/metatype/metatype.properties
    sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.JmxAttributeHealthCheck-1.json
    sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.ScriptableHealthCheck-2.json

Modified: sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/api/Constants.java
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/api/Constants.java?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/api/Constants.java
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/api/Constants.java
Fri Aug  9 10:42:24 2013
@@ -21,8 +21,8 @@ public interface Constants {
     /** info property name: the name of a health check */
     String HC_NAME = "hc.name";
     
-    /** info property name: description of a health check */
-    String HC_DESCRIPTION = "hc.description";
+    /** info property name: name of the MBean to create for this Health Check */
+    String HC_MBEAN_NAME = "hc.mbean.name";
     
     /** info property name: the tags of a health check */
     String HC_TAGS = "hc.tags";

Modified: sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckMBean.java
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckMBean.java?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckMBean.java
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckMBean.java
Fri Aug  9 10:42:24 2013
@@ -84,14 +84,25 @@ public class HealthCheckMBean implements
     }
 
     public HealthCheckMBean(HealthCheck hc) {
-        String name = hc.getInfo() == null ? null : hc.getInfo().get(Constants.HC_NAME);
-        if(name == null) {
+        String name = null;
+        if(hc.getInfo() != null) {
+            name = hc.getInfo().get(Constants.HC_MBEAN_NAME);
+            if(empty(name)) {
+                name = hc.getInfo().get(Constants.HC_NAME);
+            }
+        }
+                
+        if(empty(name)) {
             name = hc.toString();
         }
         beanName = name;
         healthCheck = hc;
     }
     
+    private static boolean empty(String str) {
+        return str == null || str.trim().length() == 0;
+    }
+    
     @Override
     public Object getAttribute(String attribute)
             throws AttributeNotFoundException, MBeanException, ReflectionException {

Modified: sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckWebconsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckWebconsolePlugin.java?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckWebconsolePlugin.java
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/HealthCheckWebconsolePlugin.java
Fri Aug  9 10:42:24 2013
@@ -164,10 +164,6 @@ public class HealthCheckWebconsolePlugin
         if(result == null) {
             result = hc.toString();
         }
-        final String description = hc.getInfo().get(Constants.HC_DESCRIPTION);
-        if(description != null) {
-            result += ": " + description;
-        }
         return result;
     }
     

Modified: sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/DefaultLoginsHealthCheck.java
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/DefaultLoginsHealthCheck.java?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/DefaultLoginsHealthCheck.java
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/DefaultLoginsHealthCheck.java
Fri Aug  9 10:42:24 2013
@@ -69,6 +69,9 @@ public class DefaultLoginsHealthCheck im
     @Property
     public static final String PROP_NAME = Constants.HC_NAME;
     
+    @Property
+    public static final String PROP_MBEAN_NAME = Constants.HC_MBEAN_NAME;
+    
     @Reference
     private SlingRepository repository;
     
@@ -79,6 +82,7 @@ public class DefaultLoginsHealthCheck im
         
         info.put(PROP_USERNAME, username);
         info.put(Constants.HC_NAME, PropertiesUtil.toString(ctx.getProperties().get(Constants.HC_NAME),
""));
+        info.put(Constants.HC_MBEAN_NAME, PropertiesUtil.toString(ctx.getProperties().get(Constants.HC_MBEAN_NAME),
""));
         info.put(Constants.HC_TAGS, 
                 Arrays.asList(PropertiesUtil.toStringArray(ctx.getProperties().get(Constants.HC_TAGS),
new String[] {})).toString());
         

Modified: sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/JmxAttributeHealthCheck.java
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/JmxAttributeHealthCheck.java?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/JmxAttributeHealthCheck.java
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/JmxAttributeHealthCheck.java
Fri Aug  9 10:42:24 2013
@@ -70,6 +70,9 @@ public class JmxAttributeHealthCheck imp
     @Property
     public static final String PROP_NAME = Constants.HC_NAME;
     
+    @Property
+    public static final String PROP_MBEAN_NAME = Constants.HC_MBEAN_NAME;
+    
     @Activate
     public void activate(ComponentContext ctx) {
         mbeanName = PropertiesUtil.toString(ctx.getProperties().get(PROP_OBJECT_NAME), "");
@@ -80,6 +83,7 @@ public class JmxAttributeHealthCheck imp
         info.put(PROP_ATTRIBUTE_NAME, attributeName);
         info.put(PROP_CONSTRAINT, constraint);
         info.put(Constants.HC_NAME, PropertiesUtil.toString(ctx.getProperties().get(Constants.HC_NAME),
""));
+        info.put(Constants.HC_MBEAN_NAME, PropertiesUtil.toString(ctx.getProperties().get(Constants.HC_MBEAN_NAME),
""));
         info.put(Constants.HC_TAGS, 
                 Arrays.asList(PropertiesUtil.toStringArray(ctx.getProperties().get(Constants.HC_TAGS),
new String[] {})).toString());
         

Modified: sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/ScriptableHealthCheck.java
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/ScriptableHealthCheck.java?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/ScriptableHealthCheck.java
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/ScriptableHealthCheck.java
Fri Aug  9 10:42:24 2013
@@ -70,6 +70,9 @@ public class ScriptableHealthCheck imple
     @Property
     public static final String PROP_NAME = Constants.HC_NAME;
     
+    @Property
+    public static final String PROP_MBEAN_NAME = Constants.HC_MBEAN_NAME;
+    
     @Reference
     private ScriptEngineManager scriptEngineManager;
     
@@ -82,6 +85,7 @@ public class ScriptableHealthCheck imple
         info.put(PROP_EXPRESSION, expression);
         info.put(PROP_LANGUAGE_EXTENSION, languageExtension);
         info.put(Constants.HC_NAME, PropertiesUtil.toString(ctx.getProperties().get(Constants.HC_NAME),
""));
+        info.put(Constants.HC_MBEAN_NAME, PropertiesUtil.toString(ctx.getProperties().get(Constants.HC_MBEAN_NAME),
""));
         info.put(Constants.HC_TAGS, 
                 Arrays.asList(PropertiesUtil.toStringArray(ctx.getProperties().get(Constants.HC_TAGS),
new String[] {})).toString());
         

Modified: sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/SlingRequestStatusHealthCheck.java
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/SlingRequestStatusHealthCheck.java?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/SlingRequestStatusHealthCheck.java
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/core/src/main/java/org/apache/sling/hc/impl/healthchecks/SlingRequestStatusHealthCheck.java
Fri Aug  9 10:42:24 2013
@@ -83,6 +83,9 @@ public class SlingRequestStatusHealthChe
     @Property
     public static final String PROP_NAME = Constants.HC_NAME;
     
+    @Property
+    public static final String PROP_MBEAN_NAME = Constants.HC_MBEAN_NAME;
+    
     @Reference
     private SlingRequestProcessor requestProcessor;
     
@@ -94,6 +97,7 @@ public class SlingRequestStatusHealthChe
         paths = PropertiesUtil.toStringArray(ctx.getProperties().get(PROP_PATH), new String
[] {});
         
         info.put(Constants.HC_NAME, PropertiesUtil.toString(ctx.getProperties().get(Constants.HC_NAME),
""));
+        info.put(Constants.HC_MBEAN_NAME, PropertiesUtil.toString(ctx.getProperties().get(Constants.HC_MBEAN_NAME),
""));
         info.put(Constants.HC_TAGS, 
                 Arrays.asList(PropertiesUtil.toStringArray(ctx.getProperties().get(Constants.HC_TAGS),
new String[] {})).toString());
         

Modified: sling/branches/SLING-2987-healthcheck-redesign/core/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/core/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/core/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/core/src/main/resources/OSGI-INF/metatype/metatype.properties
Fri Aug  9 10:42:24 2013
@@ -45,6 +45,9 @@ attribute.name.description = The name of
 attribute.value.constraint.name = Attribute value constraint
 attribute.value.constraint.description = Constraint on the MBean attribute value.
 
+hc.mbean.name.name = MBean name
+hc.mbean.name.description = Name of the MBean to create for this Health Check.
+
 hc.tags.name = Health Check tags
 hc.tags.description = List of tags for this Health Check service, used to select \
     subsets of Health Check services for execution.

Modified: sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.JmxAttributeHealthCheck-1.json
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.JmxAttributeHealthCheck-1.json?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.JmxAttributeHealthCheck-1.json
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.JmxAttributeHealthCheck-1.json
Fri Aug  9 10:42:24 2013
@@ -3,6 +3,7 @@
     "mbean.name" : "java.lang:type=ClassLoading", 
     "attribute.name" : "LoadedClassCount", 
     "attribute.value.constraint" : "between 5000 and 50000", 
-    "hc.name" : "LoadedClassCount is in range", 
+    "hc.name" : "LoadedClassCount is in range",
+    "hc.mbean.name" : "JMX LoadedClassCount", 
     "hc.tags" : [jvm, classloading, jmx] 
 }

Modified: sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.ScriptableHealthCheck-2.json
URL: http://svn.apache.org/viewvc/sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.ScriptableHealthCheck-2.json?rev=1512243&r1=1512242&r2=1512243&view=diff
==============================================================================
--- sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.ScriptableHealthCheck-2.json
(original)
+++ sling/branches/SLING-2987-healthcheck-redesign/samples/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.ScriptableHealthCheck-2.json
Fri Aug  9 10:42:24 2013
@@ -2,6 +2,7 @@
     "jcr:primaryType" : "sling:OsgiConfig",
     "expression" : "osgi.inactiveBundlesCount() == 0 ",
     "hc.name" : "No inactive bundles", 
+    "hc.mbean.name" : "InactiveBundlesCheck", 
     "language.extension" : "ecma", 
     "hc.tags" : [bundles, script] 
 }



Mime
View raw message