Package com.github.ambry.clustermap
Class Partition
- java.lang.Object
-
- com.github.ambry.clustermap.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 ofPartitionId
to be used within theStaticClusterManager
. A Partition is the unit of data management in Ambry. Each Partition is uniquely identifiable by an ID. Partitions consist of one or moreReplica
s. 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 aString
representation that uniquely identifies this partition.
-
-
-
Method Detail
-
getBytes
public byte[] getBytes()
- Specified by:
getBytes
in interfacecom.github.ambry.clustermap.PartitionId
-
getReplicaIds
public java.util.List<com.github.ambry.clustermap.ReplicaId> getReplicaIds()
- Specified by:
getReplicaIds
in interfacecom.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 interfacecom.github.ambry.clustermap.PartitionId
-
getPartitionState
public com.github.ambry.clustermap.PartitionState getPartitionState()
- Specified by:
getPartitionState
in interfacecom.github.ambry.clustermap.PartitionId
-
isEqual
public boolean isEqual(java.lang.String partitionId)
- Specified by:
isEqual
in interfacecom.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 interfacecom.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 interfacecom.github.ambry.clustermap.PartitionId
-
getSnapshot
public org.json.JSONObject getSnapshot()
- Specified by:
getSnapshot
in interfacecom.github.ambry.clustermap.Resource
-
toString
public java.lang.String toString()
Generates aString
representation that uniquely identifies this partition. The string is in the format ofPartition[i]
, wherei
is along
id number uniquely associated with this partition.- Specified by:
toString
in interfacecom.github.ambry.clustermap.PartitionId
- Overrides:
toString
in classjava.lang.Object
- Returns:
- The
String
representation of this partition.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(com.github.ambry.clustermap.PartitionId o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<com.github.ambry.clustermap.PartitionId>
-
-