incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1555049 - in /sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc: api/execution/HealthCheckExecutor.java core/impl/executor/HealthCheckExecutorImpl.java
Date Fri, 03 Jan 2014 11:18:45 GMT
Author: cziegeler
Date: Fri Jan  3 11:18:44 2014
New Revision: 1555049

URL: http://svn.apache.org/r1555049
Log:
SLING-3278 : Provide a HealthCheckExecutor service. Use ordered result

Modified:
    sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutor.java
    sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java

Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutor.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutor.java?rev=1555049&r1=1555048&r2=1555049&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutor.java
(original)
+++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/api/execution/HealthCheckExecutor.java
Fri Jan  3 11:18:44 2014
@@ -17,7 +17,7 @@
  */
 package org.apache.sling.hc.api.execution;
 
-import java.util.Collection;
+import java.util.List;
 
 import org.apache.sling.hc.api.HealthCheck;
 import org.osgi.framework.ServiceReference;
@@ -35,7 +35,7 @@ public interface HealthCheckExecutor {
     /**
      * Executes all health checks
      *
-     * @return Collection of results. The collection might be empty.
+     * @return List of results. The list might be empty.
      */
-    Collection<HealthCheckExecutionResult> execute(ServiceReference... healthCheckReferences);
+    List<HealthCheckExecutionResult> execute(ServiceReference... healthCheckReferences);
 }
\ No newline at end of file

Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java?rev=1555049&r1=1555048&r2=1555049&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java
(original)
+++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java
Fri Jan  3 11:18:44 2014
@@ -18,7 +18,10 @@
 package org.apache.sling.hc.core.impl.executor;
 
 import java.text.NumberFormat;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -27,7 +30,6 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
-import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.commons.lang.time.StopWatch;
@@ -134,20 +136,32 @@ public class HealthCheckExecutorImpl imp
      * @see org.apache.sling.hc.api.execution.HealthCheckExecutor#execute(org.osgi.framework.ServiceReference[])
      */
     @Override
-    public Collection<HealthCheckExecutionResult> execute(final ServiceReference...
healthCheckReferences) {
+    public List<HealthCheckExecutionResult> execute(final ServiceReference... healthCheckReferences)
{
         logger.debug("Starting executing all checks... ");
 
         final StopWatch stopWatch = new StopWatch();
         stopWatch.start();
 
-        final Collection<HealthCheckExecutionResult> results = new TreeSet<HealthCheckExecutionResult>();
+        final List<HealthCheckExecutionResult> results = new ArrayList<HealthCheckExecutionResult>();
         final List<HealthCheckDescriptor> healthCheckDescriptors = getHealthCheckDescriptors(healthCheckReferences);
 
         createResultsForDescriptors(healthCheckDescriptors, results);
 
         stopWatch.stop();
-        logger.debug("Time consumed for all checks: {}", msHumanReadable(stopWatch.getTime()));
+        if ( logger.isDebugEnabled() ) {
+            logger.debug("Time consumed for all checks: {}", msHumanReadable(stopWatch.getTime()));
+        }
+
+        // sort result
+        Collections.sort(results, new Comparator<HealthCheckExecutionResult>() {
+
+            @Override
+            public int compare(final HealthCheckExecutionResult arg0,
+                    final HealthCheckExecutionResult arg1) {
+                return ((ExecutionResult)arg0).compareTo((ExecutionResult)arg1);
+            }
 
+        });
         return results;
     }
 



Mime
View raw message