You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gh...@apache.org on 2020/07/10 14:54:30 UTC
[felix-dev] branch master updated (7f4d31b -> ee6485a)
This is an automated email from the ASF dual-hosted git repository.
ghenzler pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git.
from 7f4d31b Use var args directly.
new 12cba0b Use <any> instead of * in toString() to avoid confusion
new 27b4871 FELIX-6300 force autoDisableFilter=true for avoid404DuringStartup=true
new ee6485a FELIX-6250 Dynamic mode and option for logging
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../hc/api/execution/HealthCheckSelector.java | 4 +-
.../core/impl/filter/ServiceUnavailableFilter.java | 12 +-
.../hc/core/impl/monitor/HealthCheckMonitor.java | 360 ++++++++++-----------
.../felix/hc/core/impl/monitor/HealthState.java | 249 ++++++++++++++
.../core/impl/monitor/HealthCheckMonitorTest.java | 40 +--
5 files changed, 450 insertions(+), 215 deletions(-)
create mode 100644 healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/monitor/HealthState.java
[felix-dev] 03/03: FELIX-6250 Dynamic mode and option for logging
Posted by gh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ghenzler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
commit ee6485a0f003ff0e322d83e12f22b88597305c0a
Author: georg.henzler <ge...@netcentric.biz>
AuthorDate: Fri Jul 10 16:54:06 2020 +0200
FELIX-6250 Dynamic mode and option for logging
* Dynamic mode allows to monitor all checks as given by tags
individually
* Logging can be configured
---
.../hc/core/impl/monitor/HealthCheckMonitor.java | 360 ++++++++++-----------
.../felix/hc/core/impl/monitor/HealthState.java | 249 ++++++++++++++
.../core/impl/monitor/HealthCheckMonitorTest.java | 40 +--
3 files changed, 440 insertions(+), 209 deletions(-)
diff --git a/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/monitor/HealthCheckMonitor.java b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/monitor/HealthCheckMonitor.java
index c6bf00f..3dc6903 100644
--- a/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/monitor/HealthCheckMonitor.java
+++ b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/monitor/HealthCheckMonitor.java
@@ -17,32 +17,37 @@
*/
package org.apache.felix.hc.core.impl.monitor;
-import java.text.SimpleDateFormat;
+import static java.util.stream.Collectors.toList;
+
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Hashtable;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
-import org.apache.felix.hc.api.Result;
+import org.apache.felix.hc.api.HealthCheck;
+import org.apache.felix.hc.api.Result.Status;
import org.apache.felix.hc.api.condition.Healthy;
import org.apache.felix.hc.api.condition.SystemReady;
import org.apache.felix.hc.api.condition.Unhealthy;
import org.apache.felix.hc.api.execution.HealthCheckExecutionResult;
-import org.apache.felix.hc.api.execution.HealthCheckExecutor;
import org.apache.felix.hc.api.execution.HealthCheckSelector;
import org.apache.felix.hc.core.impl.executor.CombinedExecutionResult;
+import org.apache.felix.hc.core.impl.executor.ExtendedHealthCheckExecutor;
import org.apache.felix.hc.core.impl.executor.HealthCheckExecutorThreadPool;
import org.apache.felix.hc.core.impl.scheduling.AsyncIntervalJob;
import org.apache.felix.hc.core.impl.scheduling.AsyncJob;
import org.apache.felix.hc.core.impl.scheduling.CronJobFactory;
+import org.apache.felix.hc.core.impl.servlet.ResultTxtVerboseSerializer;
+import org.apache.felix.hc.core.impl.util.HealthCheckFilter;
import org.apache.felix.hc.core.impl.util.lang.StringUtils;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentConstants;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
@@ -50,7 +55,6 @@ import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
@@ -74,24 +78,7 @@ import org.slf4j.LoggerFactory;
public class HealthCheckMonitor implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(HealthCheckMonitor.class);
- public static final String TAG_SYSTEMREADY = "systemready";
-
- public static final String EVENT_TOPIC_PREFIX = "org/apache/felix/health";
- public static final String EVENT_TOPIC_SUFFIX_STATUS_CHANGED = "STATUS_CHANGED";
- public static final String EVENT_TOPIC_SUFFIX_STATUS_UPDATED = "UPDATED";
-
- public static final String EVENT_PROP_EXECUTION_RESULT = "executionResult";
- public static final String EVENT_PROP_STATUS = "status";
- public static final String EVENT_PROP_PREVIOUS_STATUS = "previousStatus";
-
- static final Healthy MARKER_SERVICE_HEALTHY = new Healthy() {
- };
- static final Unhealthy MARKER_SERVICE_UNHEALTHY = new Unhealthy() {
- };
- static final SystemReady MARKER_SERVICE_SYSTEMREADY = new SystemReady() {
- };
-
- public enum SendEventsConfig {
+ public enum ChangeType {
NONE, STATUS_CHANGES, ALL
}
@@ -120,19 +107,28 @@ public class HealthCheckMonitor implements Runnable {
boolean treatWarnAsHealthy() default true;
@AttributeDefinition(name = "Send Events", description = "Send OSGi events for the case a status has changed or for all executions or for none.")
- SendEventsConfig sendEvents() default SendEventsConfig.STATUS_CHANGES;
+ ChangeType sendEvents() default ChangeType.STATUS_CHANGES;
+ @AttributeDefinition(name = "Log results", description = "Log the result to the regular log file.")
+ ChangeType logResults() default ChangeType.NONE;
+
+ @AttributeDefinition(name = "Dynamic Mode", description = "In dynamic mode all checks for names/tags are monitored individually (this means events are sent/services registered for name only, never for given tags). This mode allows to use '*' in tags to query for all health checks in system. It is also possible to query for all except certain tags by using '-', e.g. by configuring the values '*', '-tag1' and '-tag2' for tags.")
+ boolean isDynamic() default false;
+
@AttributeDefinition
String webconsole_configurationFactory_nameHint() default "Health Monitor for '{tags}'/'{names}', {intervalInSec}sec/{cronExpression}, Marker Service Healthy:{registerHealthyMarkerService} Unhealthy:{registerUnhealthyMarkerService}, Send Events {sendEvents}";
}
@Reference
- HealthCheckExecutor executor;
+ ExtendedHealthCheckExecutor executor;
@Reference
HealthCheckExecutorThreadPool healthCheckExecutorThreadPool;
@Reference
+ ResultTxtVerboseSerializer resultTxtVerboseSerializer;
+
+ @Reference
CronJobFactory cronJobFactory;
@Reference
@@ -142,7 +138,7 @@ public class HealthCheckMonitor implements Runnable {
AsyncJob monitorJob = null;
List<String> tags;
List<String> names;
- List<HealthState> healthStates = new ArrayList<>();
+ Map<Object,HealthState> healthStates = new ConcurrentHashMap<>();
private long intervalInSec;
private String cronExpression;
@@ -152,30 +148,32 @@ public class HealthCheckMonitor implements Runnable {
private boolean treatWarnAsHealthy;
- private SendEventsConfig sendEventsConfig;
+ private ChangeType sendEvents;
+ private ChangeType logResults;
private BundleContext bundleContext;
private String monitorId;
+
+ private boolean isDynamic;
+ private ServiceListener healthCheckServiceListener = null;
@Activate
- protected final void activate(BundleContext bundleContext, Config config, ComponentContext componentContext)
- throws InvalidSyntaxException {
+ protected final void activate(BundleContext bundleContext, Config config, ComponentContext componentContext) throws InvalidSyntaxException {
this.bundleContext = bundleContext;
- this.tags = Arrays.asList(config.tags());
- this.tags.stream().filter(StringUtils::isNotBlank).forEach(tag -> healthStates.add(new HealthState(tag, true)));
-
- this.names = Arrays.asList(config.names());
- this.names.stream().filter(StringUtils::isNotBlank)
- .forEach(name -> healthStates.add(new HealthState(name, false)));
-
+ this.tags = Arrays.stream(config.tags()).filter(StringUtils::isNotBlank).collect(toList());
+ this.names = Arrays.stream(config.names()).filter(StringUtils::isNotBlank).collect(toList());
+ this.isDynamic = config.isDynamic();
+ initHealthStates();
+
this.registerHealthyMarkerService = config.registerHealthyMarkerService();
this.registerUnhealthyMarkerService = config.registerUnhealthyMarkerService();
this.treatWarnAsHealthy = config.treatWarnAsHealthy();
- this.sendEventsConfig = config.sendEvents();
+ this.sendEvents = config.sendEvents();
+ this.logResults = config.logResults();
this.intervalInSec = config.intervalInSec();
this.cronExpression = config.cronExpression();
@@ -189,7 +187,26 @@ public class HealthCheckMonitor implements Runnable {
throw new IllegalArgumentException("Either cronExpression or intervalInSec needs to be set");
}
monitorJob.schedule();
- LOG.info("HealthCheckMonitor active for tags {} and names {}", this.tags, this.names);
+ LOG.info("HealthCheckMonitor active for tags {} and names {} (isDynamic={})", this.tags, this.names, this.isDynamic);
+ }
+
+ private void initHealthStates() throws InvalidSyntaxException {
+ if(!this.isDynamic) {
+ this.tags.stream().filter(StringUtils::isNotBlank).forEach(tag -> {
+ if(tag.contains("*") || tag.startsWith("-")) {
+ throw new IllegalArgumentException("Health check monitor is configured to isDyamic=false but tags contain query items like '*' or '-': "+String.join(",", this.tags));
+ }
+ healthStates.put(tag, new HealthState(this, tag, true));
+ });
+ this.names.stream().filter(StringUtils::isNotBlank).forEach(name -> {
+ healthStates.put(name, new HealthState(this, name, false));
+ });
+ } else {
+ updateHealthStatesMap();
+ healthCheckServiceListener = new HealthCheckServiceListener();
+ bundleContext.addServiceListener(healthCheckServiceListener, HealthCheckFilter.HC_FILTER_OBJECT_CLASS);
+ }
+
}
private String getMonitorId(Object compId) {
@@ -204,179 +221,144 @@ public class HealthCheckMonitor implements Runnable {
@Deactivate
protected final void deactivate() {
- healthStates.stream().forEach(HealthState::cleanUp);
+ if(healthCheckServiceListener != null) {
+ bundleContext.removeServiceListener(healthCheckServiceListener);
+ }
+ healthStates.values().stream().forEach(HealthState::cleanUp);
healthStates.clear();
monitorJob.unschedule();
LOG.info("HealthCheckMonitor deactivated for tags {} and names {}", this.tags, this.names);
}
- public void run() {
- String threadNameToRestore = Thread.currentThread().getName();
- try {
- Thread.currentThread().setName(monitorId);
-
- // run in tags/names in parallel
- healthStates.parallelStream().forEach(this::runFor);
-
- LOG.trace("HealthCheckMonitor: updated results for tags {} and names {}", this.tags, this.names);
- } catch (Exception e) {
- LOG.error("Exception HealthCheckMonitor run(): " + e, e);
- } finally {
- Thread.currentThread().setName(threadNameToRestore);
+ public void updateHealthStatesMap() {
+ HealthCheckFilter filter = new HealthCheckFilter(bundleContext);
+ HealthCheckSelector selector = HealthCheckSelector.tags(tags.toArray(new String[tags.size()])).withNames(names.toArray(new String[names.size()]));
+ ServiceReference<HealthCheck>[] refs = filter.getHealthCheckServiceReferences(selector, true);
+ LOG.debug("Found {} health check service refs", refs.length);
+ List<Object> oldServiceIds = new ArrayList<>(healthStates.keySet()); // start with all keys
+ for (ServiceReference<HealthCheck> ref : refs) {
+ Long serviceId = (Long) ref.getProperty(Constants.SERVICE_ID);
+ if(healthStates.containsKey(serviceId)) {
+ // HC state exists, keep
+ oldServiceIds.remove(serviceId);
+ } else {
+ // add HC state
+ HealthState healthState = new HealthState(this, ref);
+ LOG.debug("Monitoring health state: {}", healthState);
+ healthStates.put(serviceId, healthState);
+ }
}
- }
-
- public void runFor(HealthState healthState) {
- String threadNameToRestore = Thread.currentThread().getName();
- try {
- Thread.currentThread().setName(monitorId);
- HealthCheckSelector selector = healthState.isTag ? HealthCheckSelector.tags(healthState.tagOrName)
- : HealthCheckSelector.names(healthState.tagOrName);
- List<HealthCheckExecutionResult> executionResults = executor.execute(selector);
-
- HealthCheckExecutionResult result = executionResults.size() == 1 ? executionResults.get(0)
- : new CombinedExecutionResult(executionResults, Result.Status.TEMPORARILY_UNAVAILABLE);
- LOG.trace("Result of '{}' => {}", healthState.tagOrName, result.getHealthCheckResult().getStatus());
-
- healthState.update(result);
- } finally {
- Thread.currentThread().setName(threadNameToRestore);
+ // Remove obsolete HC states
+ for (Object oldServiceId : oldServiceIds) {
+ HealthState removed = healthStates.remove(oldServiceId);
+ removed.cleanUp();
+ LOG.debug("Removed monitoring for health state: {}", removed);
}
}
-
- class HealthState {
+ public void run() {
+ runWithThreadNameContext(() -> {
+ try {
- private String tagOrName;
- private boolean isTag;
- private String propertyName;
+ // run in tags/names in parallel
+ healthStates.values().parallelStream().forEach(healthState ->
+ runWithThreadNameContext(healthState::update)
+ );
+
- private ServiceRegistration<?> healthyRegistration = null;
- private ServiceRegistration<Unhealthy> unhealthyRegistration = null;
+ if(logResults != ChangeType.NONE) {
+ logResults();
+ }
+
- private Result.Status status = null;
- private boolean isHealthy = false;
- private boolean statusChanged = false;
+ LOG.trace("HealthCheckMonitor: updated {} health states for tags {} and names {}", healthStates.size(), this.tags, this.names);
+ } catch (Exception e) {
+ LOG.error("Exception HealthCheckMonitor run(): " + e, e);
+ }
+ });
+ }
- HealthState(String tagOrName, boolean isTag) {
- this.tagOrName = tagOrName;
- this.isTag = isTag;
- this.propertyName = isTag ? "tag" : "name";
- }
+ private void logResults() {
- @Override
- public String toString() {
- return "[HealthState tagOrName=" + tagOrName + ", isTag=" + isTag + ", status=" + status + ", isHealthy="
- + isHealthy + ", statusChanged=" + statusChanged + "]";
+ List<HealthCheckExecutionResult> executionResults = healthStates.values().stream()
+ .filter(healthState -> { return healthState.hasChanged() || logResults == ChangeType.ALL; })
+ .flatMap( healthState -> {
+ HealthCheckExecutionResult executionResult = healthState.getExecutionResult();
+ List<HealthCheckExecutionResult> execResults;
+ if (executionResult instanceof CombinedExecutionResult) {
+ execResults = ((CombinedExecutionResult) executionResult).getExecutionResults();
+ } else {
+ execResults = Arrays.asList(executionResult);
+ }
+ return execResults.stream();
+ })
+ .sorted()
+ .collect(toList());
+
+ if(executionResults.isEmpty()) {
+ return;
}
-
- synchronized void update(HealthCheckExecutionResult executionResult) {
- Result.Status previousStatus = status;
- status = executionResult.getHealthCheckResult().getStatus();
-
- isHealthy = (status == Result.Status.OK || (treatWarnAsHealthy && status == Result.Status.WARN));
- statusChanged = previousStatus != status;
- LOG.trace(" {}: isHealthy={} statusChanged={}", tagOrName, isHealthy, statusChanged);
-
- registerMarkerServices();
- sendEvents(executionResult, previousStatus);
+
+ CombinedExecutionResult combinedResultForLogging = new CombinedExecutionResult(executionResults);
+ Status hcStatus = combinedResultForLogging.getHealthCheckResult().getStatus();
+ if(!LOG.isInfoEnabled() && hcStatus == Status.OK) {
+ return;
}
- private void registerMarkerServices() {
- if (registerHealthyMarkerService) {
- if (isHealthy && healthyRegistration == null) {
- registerHealthyService();
- } else if (!isHealthy && healthyRegistration != null) {
- unregisterHealthyService();
- }
- }
- if (registerUnhealthyMarkerService) {
- if (!isHealthy && unhealthyRegistration == null) {
- registerUnhealthyService();
- } else if (isHealthy && unhealthyRegistration != null) {
- unregisterUnhealthyService();
- }
- }
+ String logMsg = resultTxtVerboseSerializer.serialize(combinedResultForLogging.getHealthCheckResult(), combinedResultForLogging.getExecutionResults(), false);
+ String firstLineMsg = (logResults == ChangeType.STATUS_CHANGES) ? "Status Changes:" : "";
+ if(hcStatus == Status.OK) {
+ LOG.info(firstLineMsg+"\n"+logMsg);
+ } else {
+ LOG.warn(firstLineMsg+"\n"+logMsg);
}
- private void registerHealthyService() {
- if (healthyRegistration == null) {
- LOG.debug("HealthCheckMonitor: registerHealthyService() {} ", tagOrName);
- Dictionary<String, String> registrationProps = new Hashtable<>();
- registrationProps.put(propertyName, tagOrName);
- registrationProps.put("activated", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
-
- if (TAG_SYSTEMREADY.equals(tagOrName)) {
- LOG.debug("HealthCheckMonitor: SYSTEM READY");
- healthyRegistration = bundleContext.registerService(
- new String[] { SystemReady.class.getName(), Healthy.class.getName() },
- MARKER_SERVICE_SYSTEMREADY, registrationProps);
- } else {
- healthyRegistration = bundleContext.registerService(Healthy.class, MARKER_SERVICE_HEALTHY,
- registrationProps);
- }
- LOG.debug("HealthCheckMonitor: Healthy service for {} '{}' registered", propertyName, tagOrName);
- }
+ }
+
+ private void runWithThreadNameContext(Runnable r) {
+ String threadNameToRestore = Thread.currentThread().getName();
+ try {
+ Thread.currentThread().setName(monitorId);
+ r.run();
+ } finally {
+ Thread.currentThread().setName(threadNameToRestore);
}
+ }
- private void unregisterHealthyService() {
- if (healthyRegistration != null) {
- healthyRegistration.unregister();
- healthyRegistration = null;
- LOG.debug("HealthCheckMonitor: Healthy service for {} '{}' unregistered", propertyName, tagOrName);
- }
- }
- private void registerUnhealthyService() {
- if (unhealthyRegistration == null) {
- Dictionary<String, String> registrationProps = new Hashtable<>();
- registrationProps.put("tag", tagOrName);
- registrationProps.put("activated", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
- unhealthyRegistration = bundleContext.registerService(Unhealthy.class, MARKER_SERVICE_UNHEALTHY,
- registrationProps);
- LOG.debug("HealthCheckMonitor: Unhealthy service for {} '{}' registered", propertyName, tagOrName);
- }
- }
+ ExtendedHealthCheckExecutor getExecutor() {
+ return executor;
+ }
- private void unregisterUnhealthyService() {
- if (unhealthyRegistration != null) {
- unhealthyRegistration.unregister();
- unhealthyRegistration = null;
- LOG.debug("HealthCheckMonitor: Unhealthy service for {} '{}' unregistered", propertyName, tagOrName);
- }
- }
+ EventAdmin getEventAdmin() {
+ return eventAdmin;
+ }
- private void sendEvents(HealthCheckExecutionResult executionResult, Result.Status previousStatus) {
- if ((sendEventsConfig == SendEventsConfig.STATUS_CHANGES && statusChanged) || sendEventsConfig == SendEventsConfig.ALL) {
-
- String eventSuffix = statusChanged ? EVENT_TOPIC_SUFFIX_STATUS_CHANGED : EVENT_TOPIC_SUFFIX_STATUS_UPDATED;
- String logMsg = "Posted event for topic '{}': " + (statusChanged ? "Status change from {} to {}" : "Result updated (status {})");
+ boolean isRegisterHealthyMarkerService() {
+ return registerHealthyMarkerService;
+ }
- Map<String, Object> properties = new HashMap<>();
- properties.put(EVENT_PROP_STATUS, status);
- if (previousStatus != null) {
- properties.put(EVENT_PROP_PREVIOUS_STATUS, previousStatus);
- }
- properties.put(EVENT_PROP_EXECUTION_RESULT, executionResult);
- String topic = String.join("/", EVENT_TOPIC_PREFIX, propertyName, tagOrName.replaceAll("\\s+", "_"), eventSuffix);
- eventAdmin.postEvent(new Event(topic, properties));
- LOG.debug(logMsg, topic, previousStatus, status);
- if (!(executionResult instanceof CombinedExecutionResult)) {
- String componentName = (String) executionResult.getHealthCheckMetadata().getServiceReference()
- .getProperty(ComponentConstants.COMPONENT_NAME);
- if (StringUtils.isNotBlank(componentName)) {
- String topicClass = String.join("/", EVENT_TOPIC_PREFIX, "component", componentName.replace(".", "/"), eventSuffix);
- eventAdmin.postEvent(new Event(topicClass, properties));
- LOG.debug(logMsg, topicClass, previousStatus, status);
- }
- }
- }
- }
+ boolean isRegisterUnhealthyMarkerService() {
+ return registerUnhealthyMarkerService;
+ }
- synchronized void cleanUp() {
- unregisterHealthyService();
- unregisterUnhealthyService();
- }
+ ChangeType getSendEvents() {
+ return sendEvents;
+ }
+
+ BundleContext getBundleContext() {
+ return bundleContext;
+ }
+ boolean isTreatWarnAsHealthy() {
+ return treatWarnAsHealthy;
}
+
+ private final class HealthCheckServiceListener implements ServiceListener {
+ @Override
+ public void serviceChanged(ServiceEvent event) {
+ updateHealthStatesMap();
+ }
+ }
+
}
diff --git a/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/monitor/HealthState.java b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/monitor/HealthState.java
new file mode 100644
index 0000000..ed5d33f
--- /dev/null
+++ b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/monitor/HealthState.java
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.felix.hc.core.impl.monitor;
+
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+
+import org.apache.felix.hc.api.HealthCheck;
+import org.apache.felix.hc.api.Result;
+import org.apache.felix.hc.api.Result.Status;
+import org.apache.felix.hc.api.condition.Healthy;
+import org.apache.felix.hc.api.condition.SystemReady;
+import org.apache.felix.hc.api.condition.Unhealthy;
+import org.apache.felix.hc.api.execution.HealthCheckExecutionResult;
+import org.apache.felix.hc.api.execution.HealthCheckMetadata;
+import org.apache.felix.hc.api.execution.HealthCheckSelector;
+import org.apache.felix.hc.core.impl.executor.CombinedExecutionResult;
+import org.apache.felix.hc.core.impl.monitor.HealthCheckMonitor.ChangeType;
+import org.apache.felix.hc.core.impl.util.lang.StringUtils;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentConstants;
+import org.osgi.service.event.Event;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class HealthState {
+ private static final Logger LOG = LoggerFactory.getLogger(HealthState.class);
+
+ public static final String TAG_SYSTEMREADY = "systemready";
+
+ public static final String EVENT_TOPIC_PREFIX = "org/apache/felix/health";
+ public static final String EVENT_TOPIC_SUFFIX_STATUS_CHANGED = "STATUS_CHANGED";
+ public static final String EVENT_TOPIC_SUFFIX_STATUS_UPDATED = "UPDATED";
+
+ public static final String EVENT_PROP_EXECUTION_RESULT = "executionResult";
+ public static final String EVENT_PROP_STATUS = "status";
+ public static final String EVENT_PROP_PREVIOUS_STATUS = "previousStatus";
+
+ static final Healthy MARKER_SERVICE_HEALTHY = new Healthy() {
+ };
+ static final Unhealthy MARKER_SERVICE_UNHEALTHY = new Unhealthy() {
+ };
+ static final SystemReady MARKER_SERVICE_SYSTEMREADY = new SystemReady() {
+ };
+
+ private final HealthCheckMonitor monitor;
+
+ private final String tagOrName;
+ private final ServiceReference<HealthCheck> healthCheckRef;
+ private final boolean isTag;
+ private final String propertyName;
+
+ private ServiceRegistration<?> healthyRegistration = null;
+ private ServiceRegistration<Unhealthy> unhealthyRegistration = null;
+
+ private HealthCheckExecutionResult executionResult;
+ private Result.Status status = null;
+ private boolean isHealthy = false;
+ private boolean statusChanged = false;
+ private boolean isLive = true;
+
+ HealthState(HealthCheckMonitor healthCheckMonitor, ServiceReference<HealthCheck> ref) {
+ this.monitor = healthCheckMonitor;
+ HealthCheckMetadata metadata = new HealthCheckMetadata(ref);
+ this.tagOrName = metadata.getTitle(); // using title here to ensure it is never null, usually title is nc.name
+ this.healthCheckRef = ref;
+ this.isTag = false;
+ this.propertyName = this.isTag ? "tag" : "name";
+ }
+
+ HealthState(HealthCheckMonitor healthCheckMonitor, String tagOrName, boolean isTag) {
+ this.monitor = healthCheckMonitor;
+ this.tagOrName = tagOrName;
+ this.healthCheckRef = null;
+ this.isTag = isTag;
+ this.propertyName = isTag ? "tag" : "name";
+ }
+
+ @Override
+ public String toString() {
+ return "[HealthState tagOrName=" + tagOrName + (healthCheckRef!=null?" (service ref)":"") + ", isTag=" + isTag + ", status=" + status + ", isHealthy="
+ + isHealthy + ", statusChanged=" + statusChanged + "]";
+ }
+
+ public boolean hasChanged() {
+ return statusChanged;
+ }
+
+ HealthCheckExecutionResult getExecutionResult() {
+ return executionResult;
+ }
+
+ public void update() {
+
+ List<HealthCheckExecutionResult> executionResults;
+ if(healthCheckRef != null) {
+ executionResults = Arrays.asList(monitor.getExecutor().execute(healthCheckRef));
+ } else {
+ HealthCheckSelector selector = isTag ? HealthCheckSelector.tags(tagOrName) : HealthCheckSelector.names(tagOrName);
+ executionResults = monitor.getExecutor().execute(selector);
+ }
+
+ HealthCheckExecutionResult result = executionResults.size() == 1 ? executionResults.get(0)
+ : new CombinedExecutionResult(executionResults, Result.Status.TEMPORARILY_UNAVAILABLE);
+ LOG.trace("Result of '{}' => {}", tagOrName, result.getHealthCheckResult().getStatus());
+
+ update(result);
+
+ }
+
+ synchronized void update(HealthCheckExecutionResult executionResult) {
+ if(!isLive) {
+ LOG.trace("Not live anymore, skipping result update for {}", this);
+ return;
+ }
+ this.executionResult = executionResult;
+ Result.Status previousStatus = status;
+ status = executionResult.getHealthCheckResult().getStatus();
+
+ isHealthy = (status == Result.Status.OK || (monitor.isTreatWarnAsHealthy() && status == Result.Status.WARN));
+ statusChanged = previousStatus != status;
+ LOG.trace(" {}: isHealthy={} statusChanged={}", tagOrName, isHealthy, statusChanged);
+
+ registerMarkerServices();
+ sendEvents(executionResult, previousStatus);
+ }
+
+ private void registerMarkerServices() {
+ if (monitor.isRegisterHealthyMarkerService()) {
+ if (isHealthy && healthyRegistration == null) {
+ registerHealthyService();
+ } else if (!isHealthy && healthyRegistration != null) {
+ unregisterHealthyService();
+ }
+ }
+ if (monitor.isRegisterUnhealthyMarkerService()) {
+ if (!isHealthy && unhealthyRegistration == null) {
+ registerUnhealthyService();
+ } else if (isHealthy && unhealthyRegistration != null) {
+ unregisterUnhealthyService();
+ }
+ }
+ }
+
+ private void registerHealthyService() {
+ if (healthyRegistration == null) {
+ LOG.debug("HealthCheckMonitor: registerHealthyService() {} ", tagOrName);
+ Dictionary<String, String> registrationProps = new Hashtable<>();
+ registrationProps.put(propertyName, tagOrName);
+ registrationProps.put("activated", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+
+ if (TAG_SYSTEMREADY.equals(tagOrName)) {
+ LOG.debug("HealthCheckMonitor: SYSTEM READY");
+ healthyRegistration = monitor.getBundleContext().registerService(
+ new String[] { SystemReady.class.getName(), Healthy.class.getName() },
+ MARKER_SERVICE_SYSTEMREADY, registrationProps);
+ } else {
+ healthyRegistration = monitor.getBundleContext().registerService(Healthy.class, MARKER_SERVICE_HEALTHY,
+ registrationProps);
+ }
+ LOG.debug("HealthCheckMonitor: Healthy service for {} '{}' registered", propertyName, tagOrName);
+ }
+ }
+
+ private void unregisterHealthyService() {
+ if (healthyRegistration != null) {
+ healthyRegistration.unregister();
+ healthyRegistration = null;
+ LOG.debug("HealthCheckMonitor: Healthy service for {} '{}' unregistered", propertyName, tagOrName);
+ }
+ }
+
+ private void registerUnhealthyService() {
+ if (unhealthyRegistration == null) {
+ Dictionary<String, String> registrationProps = new Hashtable<>();
+ registrationProps.put("tag", tagOrName);
+ registrationProps.put("activated", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+ unhealthyRegistration = monitor.getBundleContext().registerService(Unhealthy.class, MARKER_SERVICE_UNHEALTHY,
+ registrationProps);
+ LOG.debug("HealthCheckMonitor: Unhealthy service for {} '{}' registered", propertyName, tagOrName);
+ }
+ }
+
+ private void unregisterUnhealthyService() {
+ if (unhealthyRegistration != null) {
+ unhealthyRegistration.unregister();
+ unhealthyRegistration = null;
+ LOG.debug("HealthCheckMonitor: Unhealthy service for {} '{}' unregistered", propertyName, tagOrName);
+ }
+ }
+
+ private void sendEvents(HealthCheckExecutionResult executionResult, Result.Status previousStatus) {
+ ChangeType sendEventsConfig = monitor.getSendEvents();
+ if ((sendEventsConfig == ChangeType.STATUS_CHANGES && statusChanged) || sendEventsConfig == ChangeType.ALL) {
+
+ String eventSuffix = statusChanged ? EVENT_TOPIC_SUFFIX_STATUS_CHANGED : EVENT_TOPIC_SUFFIX_STATUS_UPDATED;
+ String logMsg = "Posted event for topic '{}': " + (statusChanged ? "Status change from {} to {}" : "Result updated (status {})");
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(EVENT_PROP_STATUS, status);
+ if (previousStatus != null) {
+ properties.put(EVENT_PROP_PREVIOUS_STATUS, previousStatus);
+ }
+ properties.put(EVENT_PROP_EXECUTION_RESULT, executionResult);
+ String topic = String.join("/", EVENT_TOPIC_PREFIX, propertyName, tagOrName.replaceAll("[^A-Za-z0-9-_]+", "_"), eventSuffix);
+ monitor.getEventAdmin().postEvent(new Event(topic, properties));
+ LOG.debug(logMsg, topic, previousStatus, status);
+ if (!(executionResult instanceof CombinedExecutionResult)) {
+ String componentName = (String) executionResult.getHealthCheckMetadata().getServiceReference()
+ .getProperty(ComponentConstants.COMPONENT_NAME);
+ if (StringUtils.isNotBlank(componentName)) {
+ String topicClass = String.join("/", EVENT_TOPIC_PREFIX, "component", componentName.replace(".", "/"), eventSuffix);
+ monitor.getEventAdmin().postEvent(new Event(topicClass, properties));
+ LOG.debug(logMsg, topicClass, previousStatus, status);
+ }
+ }
+ }
+ }
+
+ synchronized void cleanUp() {
+ unregisterHealthyService();
+ unregisterUnhealthyService();
+ isLive = false;
+ }
+
+}
diff --git a/healthcheck/core/src/test/java/org/apache/felix/hc/core/impl/monitor/HealthCheckMonitorTest.java b/healthcheck/core/src/test/java/org/apache/felix/hc/core/impl/monitor/HealthCheckMonitorTest.java
index 3426cf6..2d9502d 100644
--- a/healthcheck/core/src/test/java/org/apache/felix/hc/core/impl/monitor/HealthCheckMonitorTest.java
+++ b/healthcheck/core/src/test/java/org/apache/felix/hc/core/impl/monitor/HealthCheckMonitorTest.java
@@ -38,10 +38,10 @@ import org.apache.felix.hc.api.HealthCheck;
import org.apache.felix.hc.api.Result;
import org.apache.felix.hc.api.condition.Healthy;
import org.apache.felix.hc.api.condition.Unhealthy;
-import org.apache.felix.hc.api.execution.HealthCheckExecutor;
import org.apache.felix.hc.api.execution.HealthCheckMetadata;
import org.apache.felix.hc.api.execution.HealthCheckSelector;
import org.apache.felix.hc.core.impl.executor.ExecutionResult;
+import org.apache.felix.hc.core.impl.executor.ExtendedHealthCheckExecutor;
import org.apache.felix.hc.core.impl.executor.HealthCheckExecutorThreadPool;
import org.apache.felix.hc.core.impl.scheduling.AsyncIntervalJob;
import org.junit.Before;
@@ -83,7 +83,7 @@ public class HealthCheckMonitorTest {
private HealthCheckExecutorThreadPool healthCheckExecutorThreadPool;
@Mock
- private HealthCheckExecutor healthCheckExecutor;
+ private ExtendedHealthCheckExecutor healthCheckExecutor;
@Mock
private HealthCheckMetadata healthCheckMetadata;
@@ -134,7 +134,7 @@ public class HealthCheckMonitorTest {
assertEquals("[HealthCheckMonitor tags=[test-tag]/names=[], intervalInSec=1000/cron=]", healthCheckMonitor.toString());
assertEquals(1, healthCheckMonitor.healthStates.size());
- assertEquals("[HealthState tagOrName=test-tag, isTag=true, status=null, isHealthy=false, statusChanged=false]", healthCheckMonitor.healthStates.get(0).toString());
+ assertEquals("[HealthState tagOrName=test-tag, isTag=true, status=null, isHealthy=false, statusChanged=false]", healthCheckMonitor.healthStates.get(TEST_TAG).toString());
healthCheckMonitor.deactivate();
assertEquals(0, healthCheckMonitor.healthStates.size());
@@ -156,8 +156,8 @@ public class HealthCheckMonitorTest {
verify(healthCheckExecutor).execute(HealthCheckSelector.tags(TEST_TAG));
- verify(bundleContext).registerService(eq(Healthy.class), eq(HealthCheckMonitor.MARKER_SERVICE_HEALTHY), any());
- verify(bundleContext, never()).registerService(eq(Unhealthy.class), eq(HealthCheckMonitor.MARKER_SERVICE_UNHEALTHY), any());
+ verify(bundleContext).registerService(eq(Healthy.class), eq(HealthState.MARKER_SERVICE_HEALTHY), any());
+ verify(bundleContext, never()).registerService(eq(Unhealthy.class), eq(HealthState.MARKER_SERVICE_UNHEALTHY), any());
verifyNoInteractions(healthyRegistration, unhealthyRegistration);
resetMarkerServicesContext();
@@ -170,8 +170,8 @@ public class HealthCheckMonitorTest {
setHcResult(Result.Status.TEMPORARILY_UNAVAILABLE);
healthCheckMonitor.run();
- verify(bundleContext, never()).registerService(eq(Healthy.class), eq(HealthCheckMonitor.MARKER_SERVICE_HEALTHY), any());
- verify(bundleContext).registerService(eq(Unhealthy.class), eq(HealthCheckMonitor.MARKER_SERVICE_UNHEALTHY), any());
+ verify(bundleContext, never()).registerService(eq(Healthy.class), eq(HealthState.MARKER_SERVICE_HEALTHY), any());
+ verify(bundleContext).registerService(eq(Unhealthy.class), eq(HealthState.MARKER_SERVICE_UNHEALTHY), any());
verify(healthyRegistration).unregister();
verifyNoInteractions(unhealthyRegistration);
@@ -179,22 +179,22 @@ public class HealthCheckMonitorTest {
resetMarkerServicesContext();
setHcResult(Result.Status.WARN); // WARN is healthy by default config
healthCheckMonitor.run();
- verify(bundleContext).registerService(eq(Healthy.class), eq(HealthCheckMonitor.MARKER_SERVICE_HEALTHY), any());
- verify(bundleContext, never()).registerService(eq(Unhealthy.class), eq(HealthCheckMonitor.MARKER_SERVICE_UNHEALTHY), any());
+ verify(bundleContext).registerService(eq(Healthy.class), eq(HealthState.MARKER_SERVICE_HEALTHY), any());
+ verify(bundleContext, never()).registerService(eq(Unhealthy.class), eq(HealthState.MARKER_SERVICE_UNHEALTHY), any());
verify(unhealthyRegistration).unregister();
verifyNoInteractions(healthyRegistration);
}
private void resetMarkerServicesContext() {
reset(bundleContext, healthyRegistration, unhealthyRegistration);
- when(bundleContext.registerService(eq(Healthy.class), eq(HealthCheckMonitor.MARKER_SERVICE_HEALTHY), any())).thenReturn((ServiceRegistration<Healthy>) healthyRegistration);
- when(bundleContext.registerService(eq(Unhealthy.class), eq(HealthCheckMonitor.MARKER_SERVICE_UNHEALTHY), any())).thenReturn(unhealthyRegistration);
+ when(bundleContext.registerService(eq(Healthy.class), eq(HealthState.MARKER_SERVICE_HEALTHY), any())).thenReturn((ServiceRegistration<Healthy>) healthyRegistration);
+ when(bundleContext.registerService(eq(Unhealthy.class), eq(HealthState.MARKER_SERVICE_UNHEALTHY), any())).thenReturn(unhealthyRegistration);
}
@Test
public void testRunSendEventsStatusChanges() throws InvalidSyntaxException {
- when(config.sendEvents()).thenReturn(HealthCheckMonitor.SendEventsConfig.STATUS_CHANGES);
+ when(config.sendEvents()).thenReturn(HealthCheckMonitor.ChangeType.STATUS_CHANGES);
when(healthCheckServiceRef.getProperty(ComponentConstants.COMPONENT_NAME)).thenReturn("org.apache.felix.TestHealthCheck");
healthCheckMonitor.activate(bundleContext, config, componentContext);
@@ -209,7 +209,7 @@ public class HealthCheckMonitorTest {
List<Event> postedEvents = postedEventsCaptor1.getAllValues();
assertEquals(2, postedEvents.size());
assertEquals("org/apache/felix/health/tag/test-tag/STATUS_CHANGED", postedEvents.get(0).getTopic());
- assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthCheckMonitor.EVENT_PROP_STATUS));
+ assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthState.EVENT_PROP_STATUS));
assertEquals("org/apache/felix/health/component/org/apache/felix/TestHealthCheck/STATUS_CHANGED", postedEvents.get(1).getTopic());
reset(eventAdmin);
@@ -226,8 +226,8 @@ public class HealthCheckMonitorTest {
postedEvents = postedEventsCaptor2.getAllValues();
assertEquals(2, postedEvents.size());
assertEquals("org/apache/felix/health/tag/test-tag/STATUS_CHANGED", postedEvents.get(0).getTopic());
- assertEquals(Result.Status.CRITICAL, postedEvents.get(0).getProperty(HealthCheckMonitor.EVENT_PROP_STATUS));
- assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthCheckMonitor.EVENT_PROP_PREVIOUS_STATUS));
+ assertEquals(Result.Status.CRITICAL, postedEvents.get(0).getProperty(HealthState.EVENT_PROP_STATUS));
+ assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthState.EVENT_PROP_PREVIOUS_STATUS));
assertEquals("org/apache/felix/health/component/org/apache/felix/TestHealthCheck/STATUS_CHANGED", postedEvents.get(1).getTopic());
reset(eventAdmin);
@@ -241,11 +241,11 @@ public class HealthCheckMonitorTest {
@Test
public void testRunSendEventsAll() throws InvalidSyntaxException {
- when(config.sendEvents()).thenReturn(HealthCheckMonitor.SendEventsConfig.ALL);
+ when(config.sendEvents()).thenReturn(HealthCheckMonitor.ChangeType.ALL);
when(healthCheckServiceRef.getProperty(ComponentConstants.COMPONENT_NAME)).thenReturn("org.apache.felix.TestHealthCheck");
healthCheckMonitor.activate(bundleContext, config, componentContext);
-
+
setHcResult(Result.Status.OK);
healthCheckMonitor.run();
@@ -256,7 +256,7 @@ public class HealthCheckMonitorTest {
List<Event> postedEvents = postedEventsCaptor1.getAllValues();
assertEquals(2, postedEvents.size());
assertEquals("org/apache/felix/health/tag/test-tag/STATUS_CHANGED", postedEvents.get(0).getTopic());
- assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthCheckMonitor.EVENT_PROP_STATUS));
+ assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthState.EVENT_PROP_STATUS));
assertEquals("org/apache/felix/health/component/org/apache/felix/TestHealthCheck/STATUS_CHANGED", postedEvents.get(1).getTopic());
reset(eventAdmin);
@@ -267,8 +267,8 @@ public class HealthCheckMonitorTest {
postedEvents = postedEventsCaptor2.getAllValues();
assertEquals(2, postedEvents.size());
assertEquals("org/apache/felix/health/tag/test-tag/UPDATED", postedEvents.get(0).getTopic());
- assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthCheckMonitor.EVENT_PROP_STATUS));
- assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthCheckMonitor.EVENT_PROP_PREVIOUS_STATUS));
+ assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthState.EVENT_PROP_STATUS));
+ assertEquals(Result.Status.OK, postedEvents.get(0).getProperty(HealthState.EVENT_PROP_PREVIOUS_STATUS));
assertEquals("org/apache/felix/health/component/org/apache/felix/TestHealthCheck/UPDATED", postedEvents.get(1).getTopic());
}
[felix-dev] 02/03: FELIX-6300 force autoDisableFilter=true for
avoid404DuringStartup=true
Posted by gh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ghenzler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
commit 27b487177775fccf3fe9d254a244cfa824774c4f
Author: georg.henzler <ge...@netcentric.biz>
AuthorDate: Fri Jul 10 16:45:15 2020 +0200
FELIX-6300 force autoDisableFilter=true for avoid404DuringStartup=true
autoDisableFilter=false together with avoid404DuringStartup=true has the
strange effect that the 404 context that is created remains as leftover,
hence forcing autoDisableFilter=true is importnat here
---
.../felix/hc/core/impl/filter/ServiceUnavailableFilter.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/filter/ServiceUnavailableFilter.java b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/filter/ServiceUnavailableFilter.java
index def5af8..3027e75 100644
--- a/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/filter/ServiceUnavailableFilter.java
+++ b/healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/filter/ServiceUnavailableFilter.java
@@ -117,12 +117,12 @@ public class ServiceUnavailableFilter implements Filter {
@AttributeDefinition(name = "503 Response Text", description = "Response text for 503 responses. Value can be either the content directly or in the format '"+CLASSPATH_PREFIX+"<symbolic-bundle-id>:/path/to/file.html'. The response content type is auto-detected to either text/html or text/plain.")
String responseTextFor503() default RESPONSE_TEXT_DEFAULT;
- @AttributeDefinition(name = "Auto-disable filter", description = "If true, will automatically disable the filter once the filter continued the filter chain without 503 for the first time. Useful for server startup scenarios.")
- boolean autoDisableFilter() default false;
-
@AttributeDefinition(name = "Avoid 404", description = "If true, will automatically register a dummy servlet to ensure this filter becomes effective. Useful for server startup scenarios.")
boolean avoid404DuringStartup() default true;
+ @AttributeDefinition(name = "Auto-disable filter", description = "If true, will automatically disable the filter once the filter continued the filter chain without 503 for the first time. Useful for server startup scenarios. Becomes automatically active if avoid404DuringStartup is configured to true.")
+ boolean autoDisableFilter() default false;
+
@AttributeDefinition(name = "Filter Service Ranking", description = "The service.ranking for the filter as respected by http whiteboard.")
int service_ranking() default Integer.MAX_VALUE;
@@ -166,6 +166,10 @@ public class ServiceUnavailableFilter implements Filter {
this.includeExecutionResultInResponse = config.includeExecutionResult();
this.autoDisableFilter = config.autoDisableFilter();
this.avoid404DuringStartup = config.avoid404DuringStartup();
+ if(avoid404DuringStartup && !autoDisableFilter) {
+ LOG.debug("For avoid404DuringStartup set to true, avoid404DuringStartup is forced to true as well");
+ autoDisableFilter = true;
+ }
registerHealthCheckServiceListener();
@@ -376,7 +380,7 @@ public class ServiceUnavailableFilter implements Filter {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- send503((HttpServletResponse) resp, "Response from dynamic startup servlet");
+ send503((HttpServletResponse) resp, "Starting...");
}
}, servletProps);
[felix-dev] 01/03: Use instead of * in toString() to avoid
confusion
Posted by gh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ghenzler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
commit 12cba0b40868239b96656b3ae3fb06a8596ee655
Author: georg.henzler <ge...@netcentric.biz>
AuthorDate: Fri Jul 10 16:42:39 2020 +0200
Use <any> instead of * in toString() to avoid confusion
(* can be used to select any health checks)
---
.../java/org/apache/felix/hc/api/execution/HealthCheckSelector.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/healthcheck/api/src/main/java/org/apache/felix/hc/api/execution/HealthCheckSelector.java b/healthcheck/api/src/main/java/org/apache/felix/hc/api/execution/HealthCheckSelector.java
index 0e0fdca..75e5aee 100644
--- a/healthcheck/api/src/main/java/org/apache/felix/hc/api/execution/HealthCheckSelector.java
+++ b/healthcheck/api/src/main/java/org/apache/felix/hc/api/execution/HealthCheckSelector.java
@@ -91,8 +91,8 @@ public final class HealthCheckSelector {
@Override
public String toString() {
return "HealthCheckSelector{" +
- "tags=" + (tags == null ? "*" : Arrays.toString(tags)) +
- ", names=" + (names == null ? "*" : Arrays.toString(names)) +
+ "tags=" + (tags == null ? "<any>" : Arrays.toString(tags)) +
+ ", names=" + (names == null ? "<any>" : Arrays.toString(names)) +
'}';
}