Author: ghenzler
Date: Fri Jan 4 11:41:38 2019
New Revision: 1850353
URL: http://svn.apache.org/viewvc?rev=1850353&view=rev
Log:
FELIX-6011 Introduce tag "default" to be used if no tags are passed to health
check executor
Modified:
felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImpl.java
felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImplConfiguration.java
felix/trunk/healthcheck/webconsoleplugin/src/main/java/org/apache/felix/hc/webconsole/impl/HealthCheckWebconsolePlugin.java
Modified:
felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImpl.java?rev=1850353&r1=1850352&r2=1850353&view=diff
==============================================================================
---
felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImpl.java
(original)
+++
felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImpl.java
Fri Jan 4 11:41:38 2019
@@ -38,6 +38,7 @@ import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.apache.felix.hc.api.HealthCheck;
@@ -81,6 +82,8 @@ public class HealthCheckExecutorImpl imp
private long resultCacheTtlInMs;
+ private String[] defaultTags;
+
private HealthCheckResultCache healthCheckResultCache = new
HealthCheckResultCache();
private final Map<HealthCheckMetadata, HealthCheckFuture>
stillRunningFutures = new HashMap<HealthCheckMetadata, HealthCheckFuture>();
@@ -136,6 +139,8 @@ public class HealthCheckExecutorImpl imp
if (this.resultCacheTtlInMs <= 0L) {
this.resultCacheTtlInMs = RESULT_CACHE_TTL_DEFAULT_MS;
}
+
+ this.defaultTags = configuration.defaultTags();
}
@@ -156,10 +161,13 @@ public class HealthCheckExecutorImpl imp
public List<HealthCheckExecutionResult> execute(HealthCheckSelector
selector, HealthCheckExecutionOptions options) {
logger.debug("Starting executing checks for filter selector {} and
execution options {}", selector, options);
+ if(ArrayUtils.isEmpty(selector.tags())) {
+ logger.debug("Using default tags");
+ selector.withTags(defaultTags);
+ }
final HealthCheckFilter filter = new
HealthCheckFilter(this.bundleContext);
try {
- final ServiceReference<HealthCheck>[] healthCheckReferences =
filter.getHealthCheckServiceReferences(selector,
- options.isCombineTagsWithOr());
+ final ServiceReference<HealthCheck>[] healthCheckReferences =
filter.getHealthCheckServiceReferences(selector, options.isCombineTagsWithOr());
return this.execute(healthCheckReferences, options);
} finally {
Modified:
felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImplConfiguration.java
URL:
http://svn.apache.org/viewvc/felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImplConfiguration.java?rev=1850353&r1=1850352&r2=1850353&view=diff
==============================================================================
---
felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImplConfiguration.java
(original)
+++
felix/trunk/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/HealthCheckExecutorImplConfiguration.java
Fri Jan 4 11:41:38 2019
@@ -37,4 +37,7 @@ import org.osgi.service.metatype.annotat
@AttributeDefinition(name = "Results Cache TTL in Ms", description =
"Result Cache time to live - results will be cached for the given time")
long resultCacheTtlInMs() default RESULT_CACHE_TTL_DEFAULT_MS;
+
+ @AttributeDefinition(name = "Default Tags", description = "Default tags to
be executed if no tags are explicitly supplied")
+ String[] defaultTags() default {"default"};
}
Modified:
felix/trunk/healthcheck/webconsoleplugin/src/main/java/org/apache/felix/hc/webconsole/impl/HealthCheckWebconsolePlugin.java
URL:
http://svn.apache.org/viewvc/felix/trunk/healthcheck/webconsoleplugin/src/main/java/org/apache/felix/hc/webconsole/impl/HealthCheckWebconsolePlugin.java?rev=1850353&r1=1850352&r2=1850353&view=diff
==============================================================================
---
felix/trunk/healthcheck/webconsoleplugin/src/main/java/org/apache/felix/hc/webconsole/impl/HealthCheckWebconsolePlugin.java
(original)
+++
felix/trunk/healthcheck/webconsoleplugin/src/main/java/org/apache/felix/hc/webconsole/impl/HealthCheckWebconsolePlugin.java
Fri Jan 4 11:41:38 2019
@@ -33,6 +33,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang3.StringUtils;
import org.apache.felix.hc.api.Result;
import org.apache.felix.hc.api.ResultLog;
import org.apache.felix.hc.api.execution.HealthCheckExecutionOptions;
@@ -125,7 +126,8 @@ public class HealthCheckWebconsolePlugin
// override not set in UI
}
- Collection<HealthCheckExecutionResult> results =
healthCheckExecutor.execute(HealthCheckSelector.tags(tags.split(",")), options);
+ HealthCheckSelector selector = StringUtils.isNotBlank(tags) ?
HealthCheckSelector.tags(tags.split(",")) : HealthCheckSelector.empty();
+ Collection<HealthCheckExecutionResult> results =
healthCheckExecutor.execute(selector, options);
pw.println("<table class='content healthcheck' cellpadding='0'
cellspacing='0' width='100%'>");
int total = 0;