Package com.yahoo.concurrent.maintenance
Class Maintainer
- java.lang.Object
-
- com.yahoo.concurrent.maintenance.Maintainer
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.lang.Runnable
public abstract class Maintainer extends java.lang.Object implements java.lang.Runnable, java.lang.AutoCloseable
The base class for maintainers. A maintainer is some job which runs at a fixed rate to perform maintenance tasks.- Author:
- bratseth, mpolden
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.logging.Logger
log
-
Constructor Summary
Constructors Constructor Description Maintainer(java.lang.String name, java.time.Duration interval, java.time.Duration initialDelay, JobControl jobControl, JobMetrics jobMetrics)
Maintainer(java.lang.String name, java.time.Duration interval, java.time.Instant startedAt, JobControl jobControl, JobMetrics jobMetrics, java.util.List<java.lang.String> clusterHostnames)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
protected java.time.Duration
interval()
Returns the interval at which this job is set to runvoid
lockAndMaintain()
Run this while holding the job lockprotected abstract boolean
maintain()
Called once each time this maintenance job should run.java.lang.String
name()
Returns the simple name of this jobvoid
run()
java.lang.String
toString()
-
-
-
Constructor Detail
-
Maintainer
public Maintainer(java.lang.String name, java.time.Duration interval, java.time.Instant startedAt, JobControl jobControl, JobMetrics jobMetrics, java.util.List<java.lang.String> clusterHostnames)
-
Maintainer
public Maintainer(java.lang.String name, java.time.Duration interval, java.time.Duration initialDelay, JobControl jobControl, JobMetrics jobMetrics)
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
maintain
protected abstract boolean maintain()
Called once each time this maintenance job should run. Returns whether the maintenance run was successful
-
interval
protected java.time.Duration interval()
Returns the interval at which this job is set to run
-
lockAndMaintain
public final void lockAndMaintain()
Run this while holding the job lock
-
name
public final java.lang.String name()
Returns the simple name of this job
-
-