Package com.yahoo.concurrent.maintenance
Class Maintainer
java.lang.Object
com.yahoo.concurrent.maintenance.Maintainer
- All Implemented Interfaces:
Runnable
The base class for maintainers. A maintainer is some job which runs at a fixed rate to perform maintenance tasks.
- Author:
- bratseth, mpolden, jonmv
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMaintainer(String name, Duration interval, Clock clock, JobControl jobControl, JobMetrics jobMetrics, List<String> clusterHostnames, boolean ignoreCollision) Maintainer(String name, Duration interval, Clock clock, JobControl jobControl, JobMetrics jobMetrics, List<String> clusterHostnames, boolean ignoreCollision, double successFactorBaseline, boolean acquireLock) -
Method Summary
Modifier and TypeMethodDescriptionprotected final doubleasSuccessFactorDeviation(int attempts, int failures) Convenience methods to convert attempts and failures into a success factor deviation from the baseline, and returnvoidWaits for shutdown to complete, callingshutdown()if this hasn't been done already.final voiddoMaintain(boolean force) Run this while holding the job lock, as necessaryprotected Durationinterval()Returns the interval at which this job is set to runprotected abstract doublemaintain()Called once each time this maintenance job should run.final Stringname()Returns the simple name of this jobvoidrun()voidshutdown()Starts shutdown of this, typically by shutting down executors.final booleanReturns whether this is being shut downfinal StringtoString()
-
Field Details
-
log
-
-
Constructor Details
-
Maintainer
public Maintainer(String name, Duration interval, Clock clock, JobControl jobControl, JobMetrics jobMetrics, List<String> clusterHostnames, boolean ignoreCollision, double successFactorBaseline, boolean acquireLock) -
Maintainer
public Maintainer(String name, Duration interval, Clock clock, JobControl jobControl, JobMetrics jobMetrics, List<String> clusterHostnames, boolean ignoreCollision)
-
-
Method Details
-
run
public void run() -
shutdown
public void shutdown()Starts shutdown of this, typically by shutting down executors.awaitShutdown()waits for shutdown to complete. -
awaitShutdown
public void awaitShutdown()Waits for shutdown to complete, callingshutdown()if this hasn't been done already. -
shuttingDown
public final boolean shuttingDown()Returns whether this is being shut down -
toString
-
maintain
protected abstract double maintain()Called once each time this maintenance job should run.- Returns:
- the degree to which the run successFactor deviated from the successFactorBaseline - a number between -1 (no success), to 0 (complete success) measured against the successFactorBaseline, or higher if the success factor is higher than the successFactorBaseline. The default successFactorBaseline is 1.0. If a maintainer is expected to fail sometimes, the successFactorBaseline should be set to a lower value. Note that this indicates whether something is wrong, so e.g. if the call did nothing because it should do nothing, 0.0 should be returned.
-
asSuccessFactorDeviation
protected final double asSuccessFactorDeviation(int attempts, int failures) Convenience methods to convert attempts and failures into a success factor deviation from the baseline, and return -
interval
Returns the interval at which this job is set to run -
doMaintain
public final void doMaintain(boolean force) Run this while holding the job lock, as necessary -
name
Returns the simple name of this job
-