Record Class HlcTimestamp
java.lang.Object
java.lang.Record
ai.badmonkey.agentspaces.common.hlc.HlcTimestamp
- Record Components:
physical- wall-clock component, epoch millisecondslogical- logical counter within the same physical millisecondnode- identifier of the issuing node; nevernull
- All Implemented Interfaces:
Comparable<HlcTimestamp>
public record HlcTimestamp(long physical, int logical, String node)
extends Record
implements Comparable<HlcTimestamp>
A hybrid logical clock (HLC) timestamp: a physical wall-clock component in epoch
milliseconds, a logical counter that disambiguates events within the same
millisecond, and the identifier of the node that issued the timestamp.
Timestamps order totally: first by physical time, then by logical counter, then
by node identifier. The node component makes the ordering deterministic across the
whole fleet, which the LEASE_RACE arbitration in the spec (ยง7.4) relies on.
The canonical string form is physical:logical:node, and that form is
used for serialization.
-
Constructor Summary
ConstructorsConstructorDescriptionHlcTimestamp(long physical, int logical, String node) Creates an instance of aHlcTimestamprecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(HlcTimestamp other) encoded()Returns the canonicalphysical:logical:nodeform.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intlogical()Returns the value of thelogicalrecord component.node()Returns the value of thenoderecord component.static HlcTimestampParses the canonicalphysical:logical:nodeform.longphysical()Returns the value of thephysicalrecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
HlcTimestamp
-
-
Method Details
-
parse
Parses the canonicalphysical:logical:nodeform.- Parameters:
encoded- the canonical string form- Returns:
- the parsed timestamp
- Throws:
IllegalArgumentException- if the input does not match the canonical form
-
encoded
Returns the canonicalphysical:logical:nodeform. -
compareTo
- Specified by:
compareToin interfaceComparable<HlcTimestamp>
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
physical
-
logical
-
node
-