public class Replica extends Object implements Serializable, Comparable<Replica>
Constructor and Description |
---|
Replica(org.apache.kafka.common.TopicPartition tp,
Broker broker,
boolean isLeader)
The constructor for an online replica without disk information.
|
Replica(org.apache.kafka.common.TopicPartition tp,
Broker broker,
boolean isLeader,
boolean isOriginalOffline,
Disk disk,
boolean isObserver)
A constructor for a replica.
|
Modifier and Type | Method and Description |
---|---|
Broker |
broker()
Get broker that the replica resides in.
|
int |
compareTo(Replica o)
Compare by (1) offline / online status (2) partition id then (2) original broker id then (3) topic name.
|
Disk |
disk()
Get disk that the replica resides in.
|
boolean |
equals(Object o) |
Map<String,Object> |
getJsonStructureForLoad() |
Load |
getNewReplicaLoadFromLeader()
Get the expected load if we add a new replica to the replica set.
|
int |
hashCode() |
boolean |
isCurrentOffline()
Check whether the replica is currently offline.
|
boolean |
isImmigrant()
Check whether the replica is an immigrant replica of the broker.
|
boolean |
isLeader()
Check the leadership status of the broker.
|
boolean |
isObserver()
Check whether the replica is an observer.
|
boolean |
isOriginalOffline()
Get the original state of the replica before rebalance.
|
Load |
load()
Get the replica load for each resource.
|
void |
markOriginalOffline()
Package private for unit test.
|
Broker |
originalBroker()
Get the original broker of this replica before rebalance.
|
Disk |
originalDisk()
Get disk that the replica originally resides in.
|
void |
setObservership(boolean isObserver)
Set observership status of the replica
|
org.apache.kafka.common.TopicPartition |
topicPartition()
Get the topic partition.
|
String |
toString()
Get string representation of the
Replica . |
Utilization |
utilization() |
void |
writeTo(OutputStream out)
Output writing string representation of this class to the stream.
|
public Replica(org.apache.kafka.common.TopicPartition tp, Broker broker, boolean isLeader)
tp
- Topic partition information of the replica.broker
- The broker of the replica.isLeader
- A flag to represent whether the replica is the isLeader or not.public Replica(org.apache.kafka.common.TopicPartition tp, Broker broker, boolean isLeader, boolean isOriginalOffline, Disk disk, boolean isObserver)
tp
- Topic partition information of the replica.broker
- The broker of the replica.isLeader
- A flag to represent whether the replica is the isLeader or not.isOriginalOffline
- True if the replica is offline in its original location, false otherwise.disk
- The disk of the replica. If replica placement over disk information is not populated, this parameter is null.isObserver
- A flag to represent whether the replica is an observerpublic boolean isOriginalOffline()
public boolean isCurrentOffline()
public void markOriginalOffline()
public org.apache.kafka.common.TopicPartition topicPartition()
public Load load()
public Utilization utilization()
public Broker originalBroker()
public Broker broker()
public boolean isLeader()
public boolean isObserver()
public boolean isImmigrant()
public void setObservership(boolean isObserver)
public Disk originalDisk()
ClusterModel
, null will be returned.public Disk disk()
ClusterModel
, null will be returned.public Load getNewReplicaLoadFromLeader()
public void writeTo(OutputStream out) throws IOException
out
- the output stream.IOException
public int compareTo(Replica o)
compareTo
in interface Comparable<Replica>