Class LeadControllerUtils


  • public class LeadControllerUtils
    extends Object
    • Method Detail

      • getPartitionIdForTable

        public static int getPartitionIdForTable​(String rawTableName)
        Given a raw table name and number of partitions, returns the partition id in lead controller resource. Uses murmur2 function to get hashcode for table, ignores the most significant bit. Note: This method CANNOT be changed when lead controller resource is enabled. Otherwise it will assign different controller for the same table, which will mess up the controller periodic tasks and realtime segment completion.
        Parameters:
        rawTableName - raw table name
        Returns:
        partition id in lead controller resource.
      • generateParticipantInstanceId

        public static String generateParticipantInstanceId​(String controllerHost,
                                                           int controllerPort)
        Generates participant instance id, e.g. returns Controller_localhost_9000 given localhost as hostname and 9000 as port.
      • generatePartitionName

        public static String generatePartitionName​(int partitionId)
        Generates partition name, e.g. returns leadControllerResource_0 given 0 as partition index.
      • extractPartitionId

        public static int extractPartitionId​(String partitionName)
        Extracts partition index from partition name, e.g. returns 0 given leadControllerResource_0 as partition name.
      • isLeadControllerResourceEnabled

        public static boolean isLeadControllerResourceEnabled​(org.apache.helix.HelixManager helixManager)
        Checks from ZK if resource config of leadControllerResource is enabled.
        Parameters:
        helixManager - helix manager
      • getHelixClusterLeader

        public static String getHelixClusterLeader​(org.apache.helix.HelixManager helixManager)
        Gets Helix leader in the cluster. Null if there is no leader.
        Parameters:
        helixManager - helix manager
        Returns:
        instance id of Helix cluster leader, e.g. localhost_9000.