public class Broker extends Object implements Serializable, Comparable<Broker>
Modifier and Type | Class and Description |
---|---|
static class |
Broker.ResourceComparator
Comparator that sorts brokers in decreasing order of available resource.
|
static class |
Broker.Strategy
Denotes the strategy of how plan computation should take an existing broker into account.
|
Modifier and Type | Field and Description |
---|---|
static double |
DEAD_BROKER_CAPACITY |
Constructor and Description |
---|
Broker(int id,
Host host,
Cell cell,
BrokerCapacityInfo brokerCapacityInfo,
boolean populateReplicaPlacementInfo,
Broker.Strategy strategy)
Constructor for Broker class.
|
Modifier and Type | Method and Description |
---|---|
Map<String,String> |
attributes()
Get the attributes of the broker.
|
double |
availableResource(Resource resource,
BalancingConstraint balancingConstraint) |
Capacity |
capacity() |
Capacity |
capacity(Resource resource)
Get the capacity of the broker based on the provided resource.
|
Cell |
cell()
Get broker's cell.
|
int |
compareTo(Broker o)
Compare by broker id.
|
Set<Replica> |
currentOfflineReplicas()
Get current offline replicas -- i.e.
|
Disk |
disk(String logdir)
Get disk information that corresponds to the logdir.
|
Collection<Disk> |
disks()
Get all the disks of the broker.
|
Map<String,DiskStats> |
diskStats()
Get per-logdir disk statistics of the broker.
|
boolean |
equals(Object o) |
Map<String,Object> |
getJsonStructure() |
boolean |
hasBadDisks()
Check if the broker has bad disks (i.e.
|
int |
hashCode() |
boolean |
hasReplicaOfPartition(org.apache.kafka.common.TopicPartition topicPartition) |
Host |
host() |
int |
id()
Get broker Id.
|
Set<Replica> |
immigrantReplicas()
Get the immigrant replicas (The replicas that are moved here).
|
boolean |
isAlive()
Check broker liveness status.
|
boolean |
isEligible()
Denotes whether the broker is eligible for any kinds of movements
|
boolean |
isEligibleDestination()
Check whether the broker is eligible as a destination broker
|
boolean |
isEligibleSource()
Check whether the broker is eligible as a source broker
|
boolean |
isExcludedForReplicaPlacement()
Denotes whether the broker is excluded.
|
boolean |
isNew()
Check if the broker is a new broker
|
Set<Replica> |
leaderReplicas()
Get all the leader replicas.
|
Load |
leadershipLoadForNwResources()
The load for the replicas for which this broker is a leader.
|
Utilization |
leadershipUtilizationForNwResources() |
Load |
load()
Get the broker load of the broker.
|
Load |
load(Resource resource)
Get the broker load of the broker based on the provided resource.
|
int |
numLeaderReplicas()
Get the number of leader replicas on this broker.
|
int |
numReplicasOfTopicInBroker(String topic)
Get number of replicas from the given topic in this broker.
|
Rack |
rack()
Get broker's rack.
|
Replica |
replica(org.apache.kafka.common.TopicPartition tp)
Get the replica if it is in the broker.
|
Comparator<Replica> |
replicaComparator()
Get a comparator for the replicas in the broker.
|
Set<Replica> |
replicas()
Get replicas residing in the broker.
|
Collection<Replica> |
replicasOfTopicInBroker(String topic)
Get replicas for topic.
|
Broker.Strategy |
strategy() |
Set<String> |
topics()
Get the set of topics in the broker.
|
String |
toString() |
SortedReplicas |
trackedSortedReplicas(String sortName)
Get the tracked sorted replicas using the given sort name.
|
Utilization |
utilization() |
void |
writeTo(OutputStream out)
Output writing string representation of this class to the stream.
|
public static final double DEAD_BROKER_CAPACITY
public Broker(int id, Host host, Cell cell, BrokerCapacityInfo brokerCapacityInfo, boolean populateReplicaPlacementInfo, Broker.Strategy strategy)
host
- The host this broker is onid
- The id of the broker.brokerCapacityInfo
- Capacity information of the created broker.populateReplicaPlacementInfo
- Whether populate replica placement over disk information or not.public Host host()
public Broker.Strategy strategy()
public Rack rack()
public Cell cell()
public int id()
public Capacity capacity()
public double availableResource(Resource resource, BalancingConstraint balancingConstraint)
public int numLeaderReplicas()
public Set<Replica> immigrantReplicas()
public Set<Replica> currentOfflineReplicas()
public Replica replica(org.apache.kafka.common.TopicPartition tp)
tp
- Topic partition of the replica.public Collection<Replica> replicasOfTopicInBroker(String topic)
topic
- Topic of the requested replicas.public int numReplicasOfTopicInBroker(String topic)
topic
- Topic for which the replica count will be returned.public boolean isAlive()
public boolean isEligibleDestination()
public boolean isEligibleSource()
public boolean isEligible()
public boolean isExcludedForReplicaPlacement()
Broker.Strategy.IGNORE
denotes an alive-broker that is excluded for
replica placement.
SBC treats such brokers by completely disregarding any possible replica/leader/partition moves that involve such brokers
public boolean isNew()
public boolean hasBadDisks()
Broker.Strategy.DEAD
, a Broker.Strategy.BAD_DISKS
broker might receive replicas from other brokers during a rebalance.public Load load()
public Utilization utilization()
public Load leadershipLoadForNwResources()
public Utilization leadershipUtilizationForNwResources()
public Map<String,String> attributes()
public SortedReplicas trackedSortedReplicas(String sortName)
sortName
- the sort name.SortedReplicas
for the given sort name.public Comparator<Replica> replicaComparator()
public Disk disk(String logdir)
logdir
- The logdir of the disk to query.public Collection<Disk> disks()
public Map<String,DiskStats> diskStats()
ClusterModel
has
been created with a request to populate replica placement info, otherwise returns an empty map.public void writeTo(OutputStream out) throws IOException
out
- the output stream.IOException
public boolean hasReplicaOfPartition(org.apache.kafka.common.TopicPartition topicPartition)
public int compareTo(Broker o)
compareTo
in interface Comparable<Broker>