java.lang.Object
org.apache.hadoop.yarn.server.timelineservice.storage.common.TimestampGenerator

public class TimestampGenerator extends Object
Utility class that allows HBase coprocessors to interact with unique timestamps.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the current wall clock time in milliseconds, multiplied by the required precision.
    static long
    getSupplementedTimestamp(long incomingTS, String appId)
    Returns a timestamp multiplied with TS_MULTIPLIER and last few digits of application id.
    static long
    getTruncatedTimestamp(long incomingTS)
    truncates the last few digits of the timestamp which were supplemented by the TimestampGenerator#getSupplementedTimestamp function.
    long
    Returns a timestamp value unique within the scope of this TimestampGenerator instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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 this TimestampGenerator instance. For usage by HBase RegionObserver coprocessors, 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

      public static long getSupplementedTimestamp(long incomingTS, String appId)
      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