Class Partition


  • public class Partition
    extends java.lang.Object
    Class defines the partition in Venice.

    Partition is a logic unit to distribute the data in Venice cluster. Each resource(Store Version) will be assigned to a set of partition so that data in this resource will be distributed averagely in ideal. Each partition contains 1 or multiple replica which hold the same data in ideal.

    In Helix Full-auto model, Helix manager is responsible to assign partitions to nodes. So here partition is read-only. In the future, if Venice need more flexibility to manage cluster, some update/delete methods could be added here.

    • Constructor Detail

      • Partition

        public Partition​(int id,
                         java.util.EnumMap<HelixState,​java.util.List<Instance>> helixStateToInstancesMap,
                         java.util.EnumMap<ExecutionStatus,​java.util.List<Instance>> executionStatusToInstancesMap)
    • Method Detail

      • getInstancesInState

        public java.util.List<Instance> getInstancesInState​(HelixState state)
      • getReadyToServeInstances

        public java.util.List<Instance> getReadyToServeInstances()
      • getWorkingInstances

        public java.util.List<Instance> getWorkingInstances()
      • getErrorInstances

        public java.util.List<Instance> getErrorInstances()
      • getLeaderInstance

        public Instance getLeaderInstance()
      • getAllInstancesSet

        public java.util.Set<Instance> getAllInstancesSet()
      • getAllInstancesByHelixState

        public java.util.Map<HelixState,​java.util.List<Instance>> getAllInstancesByHelixState()
      • getAllInstancesByExecutionStatus

        public java.util.EnumMap<ExecutionStatus,​java.util.List<Instance>> getAllInstancesByExecutionStatus()
      • getInstanceToHelixStateMap

        public java.util.Map<Instance,​HelixState> getInstanceToHelixStateMap()
      • getHelixStateByInstanceId

        public HelixState getHelixStateByInstanceId​(java.lang.String instanceId)
        Find the status of given instance in this partition.
      • getExecutionStatusByInstanceId

        public ExecutionStatus getExecutionStatusByInstanceId​(java.lang.String instanceId)
      • getNumOfTotalInstances

        public int getNumOfTotalInstances()
      • withRemovedInstance

        public Partition withRemovedInstance​(java.lang.String instanceId)
        Remove the given instance from this partition. As partition is an immutable object, so we return a new partition after removing.
      • getId

        public int getId()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object