Class ClockBackwardsException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
me.ahoo.cosid.CosIdException
me.ahoo.cosid.snowflake.exception.ClockBackwardsException
- All Implemented Interfaces:
Serializable
Exception thrown when system clock moves backwards.
Indicates that the current system time is less than the last timestamp used for ID generation, which could cause ID duplication.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionClockBackwardsException(long lastTimestamp, long currentTimestamp) Creates a new exception. -
Method Summary
Modifier and TypeMethodDescriptionlongGets the current timestamp.longGets the last timestamp.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ClockBackwardsException
public ClockBackwardsException(long lastTimestamp, long currentTimestamp) Creates a new exception.- Parameters:
lastTimestamp- the last generated timestampcurrentTimestamp- the current system timestamp
-
-
Method Details
-
getLastTimestamp
public long getLastTimestamp()Gets the last timestamp.- Returns:
- the last timestamp
-
getCurrentTimestamp
public long getCurrentTimestamp()Gets the current timestamp.- Returns:
- the current timestamp
-