public class Partition extends Object implements Serializable
Constructor and Description |
---|
Partition(org.apache.kafka.common.TopicPartition tp)
Constructor for Partition class.
|
Modifier and Type | Method and Description |
---|---|
void |
addBadDiskBroker(Broker ineligibleBroker)
Record the broker which is unable to host the replica of the partition.
|
boolean |
canAssignReplicaToBroker(Broker candidateBroker)
Check if the broker is eligible to host the replica of the partition.
|
void |
clear()
Clear the leader to null and clear followers.
|
boolean |
containsRack(Rack rack)
Returns a boolean indicating if replica of this partition are on rack
passed in as argument.
|
List<Broker> |
followerBrokers()
Get the set of brokers that followers reside in.
|
List<Replica> |
followers()
Get follower replicas.
|
Replica |
leader()
Get the leader replica.
|
void |
moveReplicaToEnd(Replica replica)
Move a replica to the end of the replica list.
|
List<Broker> |
onlineFollowerBrokers()
Get the set of brokers that online followers reside in.
|
List<Replica> |
onlineFollowers()
Get online follower replicas.
|
Set<Broker> |
partitionBrokers()
Get the set of brokers that contain replicas of the partition.
|
Set<Broker> |
partitionObserverBrokers()
Get the set of brokers that contain observer replicas of the partition.
|
Set<Broker> |
partitionSyncBrokers()
Get the set of brokers that contain sync(non-observer) replicas of the partition
|
Set<Broker> |
partitionSyncBrokersOfStateOtherThan(Broker.Strategy state)
Returns all sync brokers of the partition with state other than the one provided.
|
List<Replica> |
replicas() |
List<Replica> |
replicasNotInCell(Cell cell) |
void |
swapFollowerPositions(int index1,
int index2)
Given two follower indices in the replica list, swap their positions.
|
void |
swapReplicaPositions(int index1,
int index2)
Given two replica indices in the replica list, swap their positions.
|
org.apache.kafka.common.TopicPartition |
topicPartition() |
String |
toString()
Get string representation of Partition in XML format.
|
public Partition(org.apache.kafka.common.TopicPartition tp)
tp
- Topic partition information for the replica in this partition,public org.apache.kafka.common.TopicPartition topicPartition()
public Replica leader()
public List<Broker> followerBrokers()
public List<Broker> onlineFollowerBrokers()
public void swapFollowerPositions(int index1, int index2)
index1
- The index of the first follower to be swapped.index2
- The index of the second follower to be swappedpublic void swapReplicaPositions(int index1, int index2)
index1
- The index of the first replica to be swapped.index2
- The index of the second replica to be swappedpublic void moveReplicaToEnd(Replica replica)
replica
- the replica to move to the end.public Set<Broker> partitionBrokers()
public Set<Broker> partitionObserverBrokers()
public Set<Broker> partitionSyncBrokers()
public Set<Broker> partitionSyncBrokersOfStateOtherThan(Broker.Strategy state)
public boolean containsRack(Rack rack)
public void clear()
public String toString()
public void addBadDiskBroker(Broker ineligibleBroker)
ineligibleBroker
- The ineligible broker.public boolean canAssignReplicaToBroker(Broker candidateBroker)
candidateBroker
- The candidate broker.