Class TimestampGenerator
java.lang.Object
org.apache.hadoop.yarn.server.timelineservice.storage.common.TimestampGenerator
Utility class that allows HBase coprocessors to interact with unique
timestamps.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the current wall clock time in milliseconds, multiplied by the required precision.static longgetSupplementedTimestamp(long incomingTS, String appId) Returns a timestamp multiplied with TS_MULTIPLIER and last few digits of application id.static longgetTruncatedTimestamp(long incomingTS) truncates the last few digits of the timestamp which were supplemented by the TimestampGenerator#getSupplementedTimestamp function.longReturns a timestamp value unique within the scope of thisTimestampGeneratorinstance.
-
Field Details
-
TS_MULTIPLIER
public static final long TS_MULTIPLIER- See Also:
-
-
Constructor Details
-
TimestampGenerator
public TimestampGenerator()
-
-
Method Details
-
currentTime
public long currentTime()Returns the current wall clock time in milliseconds, multiplied by the required precision.- Returns:
- current timestamp.
-
getUniqueTimestamp
public long getUniqueTimestamp()Returns a timestamp value unique within the scope of thisTimestampGeneratorinstance. For usage by HBaseRegionObservercoprocessors, this normally means unique within a given region. Unlikely scenario of generating a non-unique timestamp: if there is a sustained rate of more than 1M hbase writes per second AND if region fails over within that time range of timestamps being generated then there may be collisions writing to a cell version of the same column.- Returns:
- unique timestamp.
-
getSupplementedTimestamp
Returns a timestamp multiplied with TS_MULTIPLIER and last few digits of application id. Unlikely scenario of generating a timestamp that is a duplicate: If more than a 1M concurrent apps are running in one flow run AND write to same column at the same time, then say appId of 1M and 1 will overlap with appId of 001 and there may be collisions for that flow run's specific column.- Parameters:
incomingTS- Timestamp to be converted.appId- Application Id.- Returns:
- a timestamp multiplied with TS_MULTIPLIER and last few digits of application id
-
getTruncatedTimestamp
public static long getTruncatedTimestamp(long incomingTS) truncates the last few digits of the timestamp which were supplemented by the TimestampGenerator#getSupplementedTimestamp function.- Parameters:
incomingTS- Timestamp to be truncated.- Returns:
- a truncated timestamp value
-