public static class QuorumCheck.QuorumChecks
extends java.lang.Object
Constructor and Description |
---|
QuorumChecks() |
Modifier and Type | Method and Description |
---|---|
static QuorumCheck |
all()
Checks that all members that should be up are up (i.e.
|
static QuorumCheck |
allAndAtLeastOne()
Checks all members that should be up are up, and that there is at least one such member.
|
static QuorumCheck |
alwaysTrue()
Always "healthy"
|
static QuorumCheck |
atLeastOne()
Requires at least one member that should be up.
|
static QuorumCheck |
atLeastOneUnlessEmpty()
Requires at least one member to be up if the total size is non-zero.
|
static QuorumCheck |
newInstance(int minRequiredSize,
double minRequiredRatio,
boolean allowEmpty) |
static QuorumCheck |
newLinearRange(java.lang.String range)
|
static QuorumCheck |
newLinearRange(java.lang.String range,
java.lang.String name)
Given a JSON representation of a list of points (where a point is a list of 2 numbers),
with the points in increasing x-coordinate value,
this constructs a quorum check which does linear interpolation on those coordinates,
with extensions to either side.
|
static QuorumCheck |
of(java.util.Collection<?> pointsForLinearRange) |
static QuorumCheck |
of(java.lang.Integer constant) |
static QuorumCheck |
of(java.lang.String nameOrRange) |
public static QuorumCheck all()
public static QuorumCheck allAndAtLeastOne()
public static QuorumCheck atLeastOne()
public static QuorumCheck atLeastOneUnlessEmpty()
public static QuorumCheck alwaysTrue()
public static QuorumCheck newInstance(int minRequiredSize, double minRequiredRatio, boolean allowEmpty)
public static QuorumCheck newLinearRange(java.lang.String range)
public static QuorumCheck newLinearRange(java.lang.String range, java.lang.String name)
It sounds complicated but it gives a very easy and powerful way to define quorum checks. For instance:
[[0,0],[1,1]]
says that if 0 items are expected, at least 0 is required;
if 1 is expected, 1 is required; and by extension if 10 are expected, 10 are required.
In other words, this is the same as all()
.
[[0,1],[1,1],[2,2]]
is the same as the previous for x (number expected) greater-than or equal to 1;
but if 0 is expected, 1 is required, and so it fails when 0 are present.
In other words, allAndAtLeastOne()
.
[[5,5],[10,10],[100,70],[200,140]]
has all()
behavior up to 10 expected
(line extended to the left, for less than 5); but then gently tapers off to requiring only 70% at 100
(with 30 of 40 = 75% required at that intermediate point along the line [[10,10],[100,70]]);
and then from 100 onwards it is a straight 70%.
The type of linear regression described in the last example is quite useful in practise, to be stricter for smaller clusters (or possibly more lax for small values in some cases, such as when tolerating dangling references during rebind).
public static QuorumCheck of(java.lang.String nameOrRange)
public static QuorumCheck of(java.util.Collection<?> pointsForLinearRange)
public static QuorumCheck of(java.lang.Integer constant)