Package com.yahoo.search.cluster
Class BaseNodeMonitor<T>
java.lang.Object
com.yahoo.search.cluster.BaseNodeMonitor<T>
- Direct Known Subclasses:
TrafficNodeMonitor
A node monitor is responsible for maintaining the state of a monitored node.
It has the following properties:
- A node is taken out of operation if it fails
- A node is put back in operation when it responds correctly again responseAfterFailLimit times unless it has failed failQuarantineLimit. In the latter case it won't be put into operation again before that time period has expired
- Author:
- bratseth
-
Field Summary
Modifier and TypeFieldDescriptionprotected MonitorConfiguration
The configuration of this monitorprotected long
The last time this node failed, in msprotected boolean
Whether this node is quarantined for unstabilityprotected boolean
protected static Logger
protected T
The object representing the monitored nodeprotected long
The last time this node responded (failed or succeeded), in msprotected long
The last time this node responded successfully -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
failed
(ErrorMessage error) Called when this node fails.getNode()
boolean
Returns whether this is monitoring an internal node.boolean
Returns whether this node is currently in a state suitable for receiving traffic (default true)protected long
now()
abstract void
Called when a response is received from this node.protected abstract void
setWorking
(boolean working, String explanation) Thread-safely changes the state of this node if required
-
Field Details
-
log
-
node
The object representing the monitored node -
isWorking
protected boolean isWorking -
isQuarantined
protected boolean isQuarantinedWhether this node is quarantined for unstability -
failedAt
protected long failedAtThe last time this node failed, in ms -
respondedAt
protected long respondedAtThe last time this node responded (failed or succeeded), in ms -
succeededAt
protected long succeededAtThe last time this node responded successfully -
configuration
The configuration of this monitor
-
-
Constructor Details
-
BaseNodeMonitor
public BaseNodeMonitor(boolean internal)
-
-
Method Details
-
getNode
-
isWorking
public boolean isWorking()Returns whether this node is currently in a state suitable for receiving traffic (default true) -
failed
Called when this node fails.- Parameters:
error
- a description of the error
-
responded
public abstract void responded()Called when a response is received from this node. If the node was quarantined and it has been in that state for more than QuarantineTime milliseconds, it is taken out of quarantine. if it is not in quarantine but is not working, it may be set to working if this method is called at least responseAfterFailLimit times -
now
protected long now() -
setWorking
Thread-safely changes the state of this node if required -
isInternal
public boolean isInternal()Returns whether this is monitoring an internal node. Default is false.
-