Package com.illumon.iris.db.v2.sources
Enum Class LogicalClock
- All Implemented Interfaces:
Serializable,Comparable<LogicalClock>,java.lang.constant.Constable
A logical update clock that has two states, Updating and Idle.
Each time startUpdateCycle() is called, the clock transitions to the Updating state
and the current value is incremented by one.
When completeUpdateCycle() is called, the clock transitions back to Idle.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe state component of a logical timestamp.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionfinal voidIncrement the current step and set the clock state toidle.final LogicalClock.StateGet the current clock state.final longGet the current Step of the clock.final longGet the current value of the clock.final voidensureUpdateCycleCompleted(long updatingCycleValue) After we complete a table refresh, we must ensure that the logical clock is idle.static LogicalClock.StategetState(long value) Get theLogicalClock.Stateof the LogicalClock for a particular clock value.static longgetStep(long value) Get the clock step for the input clock value.final voidReset the clock to its initial state, in order to ensure that unit tests proceed cleanly.final longIncrement the current value and set the clock state toupdating.static LogicalClockReturns the enum constant of this class with the specified name.static LogicalClock[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DEFAULT
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getStep
public static long getStep(long value) Get the clock step for the input clock value. The step increments one time for each completestart-endcycle.- Parameters:
value- The clock value to get the step for- Returns:
- The clock step associated with value
-
getState
Get theLogicalClock.Stateof the LogicalClock for a particular clock value.- Parameters:
value- The clock value- Returns:
- The clock state associated with the input value
-
currentValue
public final long currentValue()Get the current value of the clock. -
currentStep
public final long currentStep()Get the current Step of the clock.- See Also:
-
currentState
Get the current clock state.- See Also:
-
startUpdateCycle
public final long startUpdateCycle()Increment the current value and set the clock state toupdating.- ImplNote:
- The clock must have been
idlebefore this method is called.
-
completeUpdateCycle
public final void completeUpdateCycle()Increment the current step and set the clock state toidle.- ImplNote:
- The clock must have been
updatingbefore this method is called.
-
ensureUpdateCycleCompleted
public final void ensureUpdateCycleCompleted(long updatingCycleValue) After we complete a table refresh, we must ensure that the logical clock is idle.The only valid possibilities are (1) we have completed the cycle, in which case we return; or (2) we have terminated the cycle early and have the same value as at the start of our updating cycle, in which case we complete the cycle.
If our clock is any other value; then it was changed out from under us and we throw an exception.
- Parameters:
updatingCycleValue- the clock value at the end ofstartUpdateCycle()
-
resetForUnitTests
Reset the clock to its initial state, in order to ensure that unit tests proceed cleanly.
-