Class GroupId


  • public final class GroupId
    extends Object
    This class represents a replication group ID which allows grouping DJ instances by setting the same group ID on several DJ instances. For example, you would group DJ instances that are in the same datacenter so that they would preferentially connect to RS instances in the same datacenter. This allows to reduce cross datacenter communications across WAN and thus reduces costs.

    In DJ versions previous to 6.5, group IDs are represented as integers (byte). Since 6.5, group IDs are represented as case insensitive strings. This class helps converting to/from old/new group IDs to deal with legacy protocol versions.

    • Field Detail

      • DEFAULT_GROUP_ID

        public static final GroupId DEFAULT_GROUP_ID
        The default group ID to use when no group ID is set by the users.
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toLegacyGroupId

        public byte toLegacyGroupId()
        Maps a string groupID to a format accepted by legacy versions of the replication, if possible.

        Strings representing a number from 1 to 127 (as supported by legacy versions) will return the integer value. All others will return 1.

        Returns:
        the byte representation of this groupId
      • fromLegacyGroupId

        public static GroupId fromLegacyGroupId​(byte legacyGroupId)
        Returns a GroupId from a replication message sent by a replica running a legacy version.
        Parameters:
        legacyGroupId - the groupID from a replication message
        Returns:
        a GroupId
      • newGroupId

        public static GroupId newGroupId​(String groupId)
        Generates a new GroupId from the provided value.
        Parameters:
        groupId - the new groupID
        Returns:
        a new GroupId