summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java
diff options
context:
space:
mode:
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java')
-rw-r--r--vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java24
1 files changed, 5 insertions, 19 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java b/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java
index 2a9e6dda6b6..734c46a2819 100644
--- a/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java
+++ b/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java
@@ -83,19 +83,8 @@ public abstract class Maintainer implements Runnable {
@Override
public final String toString() { return name(); }
- /**
- * Called once each time this maintenance job should run.
- *
- * @return the degree to which the run was successful - a number between 0 (no success), to 1 (complete success).
- * Note that this indicates whether something is wrong, so e.g if the call did nothing because it should do
- * nothing, 1.0 should be returned.
- */
- protected abstract double maintain();
-
- /** Convenience methods to convert attempts and failures into a success factor */
- protected final double asSuccessFactor(int attempts, int failures) {
- return attempts == 0 ? 1.0 : 1 - (double)failures / attempts;
- }
+ /** Called once each time this maintenance job should run. Returns whether the maintenance run was successful */
+ protected abstract boolean maintain();
/** Returns the interval at which this job is set to run */
protected Duration interval() { return interval; }
@@ -104,12 +93,9 @@ public abstract class Maintainer implements Runnable {
public final void lockAndMaintain(boolean force) {
if (!force && !jobControl.isActive(name())) return;
log.log(Level.FINE, () -> "Running " + this.getClass().getSimpleName());
- jobMetrics.starting(name());
- double successFactor = 0;
+ jobMetrics.recordRunOf(name());
try (var lock = jobControl.lockJob(name())) {
- successFactor = maintain();
- if (successFactor > 0.0)
- jobMetrics.recordCompletionOf(name());
+ if (maintain()) jobMetrics.recordCompletionOf(name());
} catch (UncheckedTimeoutException e) {
if (ignoreCollision) {
jobMetrics.recordCompletionOf(name());
@@ -119,7 +105,7 @@ public abstract class Maintainer implements Runnable {
} catch (Throwable e) {
log.log(Level.WARNING, this + " failed. Will retry in " + interval, e);
} finally {
- jobMetrics.completed(name(), successFactor);
+ jobMetrics.forward(name());
}
log.log(Level.FINE, () -> "Finished " + this.getClass().getSimpleName());
}