public class Cell extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEAD_BROKERS_CELL_ID |
static int |
DEFAULT_CELL_ID |
static int |
GENESIS_BROKER_CELL_ID |
Constructor and Description |
---|
Cell(org.apache.kafka.common.message.DescribeCellsResponseData.Cell cellData) |
Cell(int id)
Constructor of the cell class using the given id to identify the cell.
|
Modifier and Type | Method and Description |
---|---|
void |
addBroker(Broker broker) |
void |
addBrokerLoad(Broker broker) |
Collection<Broker> |
aliveBrokers() |
Broker |
broker(int brokerId)
Get the broker with the given broker id.
|
Collection<Broker> |
brokers()
Get the collection of brokers in the current cell.
|
Capacity |
capacity()
Get capacity for the cell.
|
boolean |
containsBroker(int brokerId) |
static Cell |
createDeadCell()
Create a dead cell.
|
static Cell |
createGenesisCell()
Genesis cell is a cell that do not exist but can be used as a source cell for genesis brokers
|
Collection<Broker> |
eligibleBrokers()
Deprecated and for backward-compatibility only.
|
Collection<Broker> |
eligibleDestinationBrokers()
Get the set of eligible destination brokers in the cell.
|
Collection<Broker> |
eligibleSourceBrokers()
Get the set of eligible source brokers in the cell.
|
Collection<Broker> |
eligibleSourceOrDestinationBrokers()
Get the set of eligible source or destination brokers in the cell as described by the
Broker.isEligible() method. |
boolean |
equals(Object o) |
int |
hashCode() |
int |
id()
Get the cell Id.
|
static Set<Integer> |
imaginaryCellIds()
Gives the list of cell ids that are used for grouping, but cannot be used for any intra-cell moves and calculations associated with them.
|
boolean |
isAlive()
Checks if cell has at least one alive brokers.
|
static boolean |
isDeadCellId(int cellId)
Returns if the cell id is for a dead one.
|
boolean |
isDefaultCell()
Returns true if the current cell is a default one, meaning it was assigned to the cell automatically when cells is not enabled.
|
static boolean |
isDefaultCellId(int cellId)
Returns if the cell id is a default one when cell is not enabled.
|
boolean |
isEligibleDestination()
Checks if cell has at least one broker eligible for replica placement (alive & not-excluded).
|
boolean |
isImaginaryCell()
Returns true if the cell is part of the cell that does not exist and shouldn't be used as a destination for any replica movements.
|
static boolean |
isImaginaryCellId(int cellId)
Returns if the cell id is imaginary, meaning it is supposed to not exist outside ephemeral way to satisfy temporary transitions.
|
boolean |
isQuarantined() |
Load |
load()
Get the cell load information.
|
int |
numReplicas()
Return total number of replicas in this cell.
|
long |
numTopicReplicas(String topic)
Get the number of replicas with the given topic name in this cell.
|
List<Replica> |
replicas()
Get the list of replicas in the cell.
|
void |
state(org.apache.kafka.common.CellState state) |
Set<String> |
topics()
Get a set of topic names in the cell.
|
String |
toString() |
Utilization |
utilization() |
double |
utilizationRatioBetweenSourceAndDestinationBrokers(Resource resource)
Computes the ratio between source's utilization and destination's capacity.
|
public static final int DEFAULT_CELL_ID
public static final int DEAD_BROKERS_CELL_ID
public static final int GENESIS_BROKER_CELL_ID
public Cell(int id)
id
- An identifier for this cell.public Cell(org.apache.kafka.common.message.DescribeCellsResponseData.Cell cellData)
public static Cell createGenesisCell()
public static Cell createDeadCell()
public static Set<Integer> imaginaryCellIds()
public static boolean isImaginaryCellId(int cellId)
cellId
- the cell id that needs to be checked.public static boolean isDefaultCellId(int cellId)
cellId
- the cell id that needs to be checked.public static boolean isDeadCellId(int cellId)
cellId
- the cell id that needs to be checked.public void addBroker(Broker broker)
public void addBrokerLoad(Broker broker)
public Capacity capacity()
public Load load()
public Utilization utilization()
public void state(org.apache.kafka.common.CellState state)
public int id()
public Collection<Broker> brokers()
public Collection<Broker> aliveBrokers()
public Collection<Broker> eligibleBrokers()
eligibleDestinationBrokers()
is preferred.public Collection<Broker> eligibleDestinationBrokers()
Broker.Strategy
eligible destination is true as described in Broker.isEligibleDestination()
.public Collection<Broker> eligibleSourceBrokers()
Broker.Strategy
eligible source is true as described in Broker.isEligibleSource()
.public Collection<Broker> eligibleSourceOrDestinationBrokers()
Broker.isEligible()
method.public Broker broker(int brokerId)
brokerId
- Id of the queried broker.public boolean containsBroker(int brokerId)
public long numTopicReplicas(String topic)
topic
- Name of the topic for which the number of replicas in this cell will be counted.public int numReplicas()
public boolean isAlive()
public boolean isEligibleDestination()
public boolean isQuarantined()
public boolean isImaginaryCell()
IMAGINARY_CELL_IDS
.public boolean isDefaultCell()
public double utilizationRatioBetweenSourceAndDestinationBrokers(Resource resource)