public class Broker extends Object implements Serializable, Comparable<Broker>, ResourceStats
Modifier and Type | Class and Description |
---|---|
static class |
Broker.ResourceComparator
Comparator that sorts brokers in increasing / decreasing order of amount of given resource,
for different definitions of 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 |
static int |
GENESIS_BROKER_ID |
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 |
---|---|
double |
allowedCapacity(Resource.CompositeResource resource,
BalancingConstraint balancingConstraint) |
double |
allowedCapacity(Resource resource,
BalancingConstraint balancingConstraint) |
Map<String,String> |
attributes()
Get the attributes of the broker.
|
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.
|
static Broker |
createGenesisBroker()
Creates a genesis broker used as source for replicas that do not exist on any broker.
|
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) |
Collection<Replica> |
followerReplicasOfTopicInBroker(String topic)
Get follower replicas for topic.
|
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.
|
Collection<Replica> |
leaderReplicasOfTopicInBroker(String topic)
Get leader replicas for topic.
|
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 |
numFollowerReplicasOfTopicInBroker(String topic)
Get number of follower replicas from the given topic in this broker.
|
int |
numLeaderReplicas()
Get the number of leader replicas on this broker.
|
int |
numLeaderReplicasOfTopicInBroker(String topic)
Get number of leader replicas from the given topic in this broker.
|
int |
numReplicas()
Get the number of 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.
|
double |
unusedAllowedCapacity(Resource.CompositeResource resource,
BalancingConstraint balancingConstraint) |
Utilization |
utilization() |
void |
writeTo(OutputStream out)
Output writing string representation of this class to the stream.
|
public static final double DEAD_BROKER_CAPACITY
public static final int GENESIS_BROKER_ID
public Broker(int id, Host host, @Nonnull 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 static Broker createGenesisBroker()
public Host host()
public Broker.Strategy strategy()
public Rack rack()
public int id()
public Capacity capacity()
capacity
in interface ResourceStats
public double unusedAllowedCapacity(Resource.CompositeResource resource, BalancingConstraint balancingConstraint)
public double allowedCapacity(Resource.CompositeResource resource, BalancingConstraint balancingConstraint)
public double allowedCapacity(Resource resource, BalancingConstraint balancingConstraint)
public int numLeaderReplicas()
public int numReplicas()
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 Collection<Replica> leaderReplicasOfTopicInBroker(String topic)
topic
- Topic of the requested replicas.public Collection<Replica> followerReplicasOfTopicInBroker(String topic)
topic
- Topic of the requested replicas.public int numLeaderReplicasOfTopicInBroker(String topic)
topic
- Topic for which the leader replica count will be returned.public int numFollowerReplicasOfTopicInBroker(String topic)
topic
- Topic for which the follower replica count will be returned.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()
load
in interface ResourceStats
public Utilization utilization()
utilization
in interface ResourceStats
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>