This is an automated email from the ASF dual-hosted git repository.
stefanegli pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-scheduler.git
The following commit(s) were added to refs/heads/master by this push:
new 579f7ac SLING-8764 - A metric named
commons.scheduler.oldest.running.job.millis already exists
new 969926c Merge pull request #2 from mibesis/SLING-8764
579f7ac is described below
commit 579f7ac789cb19090cf685187158e51616a87a46
Author: Miroslav Beranič <[email protected]>
AuthorDate: Thu Oct 24 20:44:00 2019 +0200
SLING-8764 - A metric named commons.scheduler.oldest.running.job.millis
already exists
---
.../org/apache/sling/commons/scheduler/impl/GaugesSupport.java | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git
a/src/main/java/org/apache/sling/commons/scheduler/impl/GaugesSupport.java
b/src/main/java/org/apache/sling/commons/scheduler/impl/GaugesSupport.java
index 823fd6a..dd624f4 100644
--- a/src/main/java/org/apache/sling/commons/scheduler/impl/GaugesSupport.java
+++ b/src/main/java/org/apache/sling/commons/scheduler/impl/GaugesSupport.java
@@ -19,6 +19,7 @@ package org.apache.sling.commons.scheduler.impl;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -66,6 +67,8 @@ public class GaugesSupport {
@Reference
private MetricRegistry metricRegistry;
+ private final List<String> registeredGaugeNameList = new LinkedList<>();
+
@SuppressWarnings("rawtypes")
private final class TemporaryGauge implements Gauge {
private final JobExecutionContext jobExecutionContext;
@@ -228,6 +231,7 @@ public class GaugesSupport {
};
logger.debug("createGauge: registering gauge : " + gaugeName);
this.metricRegistry.register(gaugeName, gauge);
+ registeredGaugeNameList.add(gaugeName);
}
private Long getOldestRunningJobMillis(final ConfigHolder configHolder,
@@ -388,6 +392,10 @@ public class GaugesSupport {
logger.debug("unregisterGauges: unregistering temporary gauge for
slow job : " + tempGauge.gaugeName);
tempGauge.unregister();
}
+
+ for (String registeredGaugeName : registeredGaugeNameList) {
+ metricRegistry.remove(registeredGaugeName);
+ }
}
@Deactivate