Package com.illumon.iris.db.v2.sources
Enum LogicalClock
- All Implemented Interfaces:
Serializable,Comparable<LogicalClock>,java.lang.constant.Constable
public enum LogicalClock extends Enum<LogicalClock>
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 Classes Modifier and Type Class Description static classLogicalClock.StateThe state component of a logical timestamp. -
Enum Constant Summary
Enum Constants Enum Constant Description DEFAULT -
Method Summary
Modifier and Type Method Description voidcompleteUpdateCycle()Increment the current step and set the clock state toidle.LogicalClock.StatecurrentState()Get the current clock state.longcurrentStep()Get the current Step of the clock.longcurrentValue()Get the current value of the clock.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.voidresetForUnitTests()Reset the clock to its initial state, in order to ensure that unit tests proceed cleanly.longstartUpdateCycle()Increment the current value and set the clock state toupdating.static LogicalClockvalueOf(String name)Returns the enum constant of this type with the specified name.static LogicalClock[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type 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:
getStep(long)
-
currentState
Get the current clock state.- See Also:
getState(long)
-
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.
-