Class Partition

  • All Implemented Interfaces:
    com.github.ambry.clustermap.PartitionId, com.github.ambry.clustermap.Resource, java.lang.Comparable<com.github.ambry.clustermap.PartitionId>

    public class Partition
    extends java.lang.Object
    implements com.github.ambry.clustermap.PartitionId
    An extension of PartitionId to be used within the StaticClusterManager. A Partition is the unit of data management in Ambry. Each Partition is uniquely identifiable by an ID. Partitions consist of one or more Replicas. Replicas ensure that a Partition is available and reliable.
    • Constructor Summary

      Constructors 
      Constructor Description
      Partition​(long id, java.lang.String partitionClass, com.github.ambry.clustermap.PartitionState partitionState, long replicaCapacityInBytes)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(com.github.ambry.clustermap.PartitionId o)  
      boolean equals​(java.lang.Object o)  
      byte[] getBytes()  
      java.lang.String getPartitionClass()  
      com.github.ambry.clustermap.PartitionState getPartitionState()  
      java.util.List<com.github.ambry.clustermap.ReplicaId> getReplicaIds()  
      java.util.List<com.github.ambry.clustermap.ReplicaId> getReplicaIdsByState​(com.github.ambry.clustermap.ReplicaState state, java.lang.String dcName)  
      org.json.JSONObject getSnapshot()  
      int hashCode()  
      boolean isEqual​(java.lang.String partitionId)  
      java.lang.String toPathString()
      Construct name based on Partition ID appropriate for use as a file or directory name.
      java.lang.String toString()
      Generates a String representation that uniquely identifies this partition.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.github.ambry.clustermap.PartitionId

        getResourceName
    • Constructor Detail

      • Partition

        public Partition​(long id,
                         java.lang.String partitionClass,
                         com.github.ambry.clustermap.PartitionState partitionState,
                         long replicaCapacityInBytes)
    • Method Detail

      • getBytes

        public byte[] getBytes()
        Specified by:
        getBytes in interface com.github.ambry.clustermap.PartitionId
      • getReplicaIds

        public java.util.List<com.github.ambry.clustermap.ReplicaId> getReplicaIds()
        Specified by:
        getReplicaIds in interface com.github.ambry.clustermap.PartitionId
      • getReplicaIdsByState

        public java.util.List<com.github.ambry.clustermap.ReplicaId> getReplicaIdsByState​(com.github.ambry.clustermap.ReplicaState state,
                                                                                          java.lang.String dcName)
        Specified by:
        getReplicaIdsByState in interface com.github.ambry.clustermap.PartitionId
      • getPartitionState

        public com.github.ambry.clustermap.PartitionState getPartitionState()
        Specified by:
        getPartitionState in interface com.github.ambry.clustermap.PartitionId
      • isEqual

        public boolean isEqual​(java.lang.String partitionId)
        Specified by:
        isEqual in interface com.github.ambry.clustermap.PartitionId
      • toPathString

        public java.lang.String toPathString()
        Construct name based on Partition ID appropriate for use as a file or directory name.
        Specified by:
        toPathString in interface com.github.ambry.clustermap.PartitionId
        Returns:
        string representation of the Partition's ID for use as part of file system path.
      • getPartitionClass

        public java.lang.String getPartitionClass()
        Specified by:
        getPartitionClass in interface com.github.ambry.clustermap.PartitionId
      • getSnapshot

        public org.json.JSONObject getSnapshot()
        Specified by:
        getSnapshot in interface com.github.ambry.clustermap.Resource
      • toString

        public java.lang.String toString()
        Generates a String representation that uniquely identifies this partition. The string is in the format of Partition[i], where i is a long id number uniquely associated with this partition.
        Specified by:
        toString in interface com.github.ambry.clustermap.PartitionId
        Overrides:
        toString in class java.lang.Object
        Returns:
        The String representation of this partition.
      • equals

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

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

        public int compareTo​(com.github.ambry.clustermap.PartitionId o)
        Specified by:
        compareTo in interface java.lang.Comparable<com.github.ambry.clustermap.PartitionId>