Class InstancePartitionsUtils


  • public class InstancePartitionsUtils
    extends Object
    Utility class for instance partitions.
    • Field Detail

    • Method Detail

      • getInstancePartitionsName

        public static String getInstancePartitionsName​(String tableName,
                                                       String instancePartitionsType)
        Returns the name of the instance partitions for the given table name (with or without type suffix) and instance partitions type.
      • fetchOrComputeInstancePartitions

        public static InstancePartitions fetchOrComputeInstancePartitions​(org.apache.helix.HelixManager helixManager,
                                                                          TableConfig tableConfig,
                                                                          InstancePartitionsType instancePartitionsType)
        Fetches the instance partitions from Helix property store if it exists, or computes it for backward-compatibility.
      • fetchInstancePartitions

        @Nullable
        public static InstancePartitions fetchInstancePartitions​(org.apache.helix.store.HelixPropertyStore<org.apache.helix.zookeeper.datamodel.ZNRecord> propertyStore,
                                                                 String instancePartitionsName)
        Fetches the instance partitions from Helix property store.
      • fetchInstancePartitionsWithRename

        public static InstancePartitions fetchInstancePartitionsWithRename​(org.apache.helix.store.HelixPropertyStore<org.apache.helix.zookeeper.datamodel.ZNRecord> propertyStore,
                                                                           String instancePartitionsName,
                                                                           String newName)
        Gets the instance partitions with the given name, and returns a re-named copy of the same. This method is useful when we use a table with instancePartitionsMap since in that case the value of a table's instance partitions are copied over from an existing instancePartitions.
      • computeDefaultInstancePartitions

        public static InstancePartitions computeDefaultInstancePartitions​(org.apache.helix.HelixManager helixManager,
                                                                          TableConfig tableConfig,
                                                                          InstancePartitionsType instancePartitionsType)
        Computes the default instance partitions. Sort all qualified instances and rotate the list based on the table name to prevent creating hotspot servers.

        Choose both enabled and disabled instances with the server tag as the qualified instances to avoid unexpected data shuffling when instances get disabled.

      • computeDefaultInstancePartitionsForTag

        public static InstancePartitions computeDefaultInstancePartitionsForTag​(org.apache.helix.HelixManager helixManager,
                                                                                String tableNameWithType,
                                                                                String instancePartitionsType,
                                                                                String serverTag)
        Computes the default instance partitions using the given serverTag. Sort all qualified instances and rotate the list based on the table name to prevent creating hotspot servers.

        Choose both enabled and disabled instances with the server tag as the qualified instances to avoid unexpected data shuffling when instances get disabled.

      • persistInstancePartitions

        public static void persistInstancePartitions​(org.apache.helix.store.HelixPropertyStore<org.apache.helix.zookeeper.datamodel.ZNRecord> propertyStore,
                                                     InstancePartitions instancePartitions)
        Persists the instance partitions to Helix property store.
      • removeInstancePartitions

        public static void removeInstancePartitions​(org.apache.helix.store.HelixPropertyStore<org.apache.helix.zookeeper.datamodel.ZNRecord> propertyStore,
                                                    String instancePartitionsName)
        Removes the instance partitions from Helix property store.