Class Snowflake

java.lang.Object
io.rocketbase.commons.util.Snowflake

public class Snowflake extends Object
Author:
callicoder: https://github.com/callicoder/java-snowflake

Distributed Sequence Generator. Inspired by Twitter snowflake: https://github.com/twitter/snowflake/tree/snowflake-2010

This class should be used as a Singleton. Make sure that you create and reuse a Single instance of Snowflake per node in your distributed system cluster.

  • Field Details

  • Constructor Details

    • Snowflake

      public Snowflake(long nodeId, long customEpoch)
    • Snowflake

      public Snowflake(long nodeId)
    • Snowflake

      public Snowflake()
  • Method Details

    • nextId

      public long nextId()
    • parse

      public long[] parse(long id)
    • toString

      public String toString()
      Overrides:
      toString in class Object