@NotThreadSafe public final class BrokerExecutionTaskTracker extends Object
Constructor and Description |
---|
BrokerExecutionTaskTracker(int maxInProgressMovements) |
Modifier and Type | Method and Description |
---|---|
void |
addTaskForBroker(int brokerId,
int numMovements)
Add tasks for a specific broker.
|
int |
brokerTaskCount(int brokerId)
Indicate the number of tasks being tracked for a given broker ID.
|
void |
clear()
Clear the task tracker.
|
static BrokerExecutionTaskTracker |
duplicate(BrokerExecutionTaskTracker that) |
Set<Integer> |
knownBrokers()
Return the set of brokers that are being tracked.
|
void |
maybeAddBroker(int brokerId)
Add a broker ID to the map for tracking.
|
void |
removeTaskForBroker(int brokerId,
int numMovements)
Remove N tasks from the accounting for a broker.
|
String |
toString() |
boolean |
wouldOverloadBroker(int brokerId,
int numMovements)
Indicate if a task with N movements would overload the broker.
|
public BrokerExecutionTaskTracker(int maxInProgressMovements)
public static BrokerExecutionTaskTracker duplicate(BrokerExecutionTaskTracker that)
public void maybeAddBroker(int brokerId)
brokerId
- -- broker ID to track execution assignments for.public Set<Integer> knownBrokers()
public void addTaskForBroker(int brokerId, int numMovements) throws IllegalArgumentException
brokerId
- -- broker accounting for these movements.numMovements
- -- number of mevements being accounted for. Must be positive.IllegalArgumentException
- if the broker ID is unknown, if the numMovements is 0 or fewer,
or if the broker doesn't have that many in flightpublic void removeTaskForBroker(int brokerId, int numMovements) throws IllegalArgumentException
brokerId
- -- broker accounting for these movements.numMovements
- -- number of movements being accounted for. Must be positive.IllegalArgumentException
- if the number of movements to remove is 0, if the broker ID doesn't exist, or
if the broker doesn't have that many in flightpublic int brokerTaskCount(int brokerId)
brokerId
- public boolean wouldOverloadBroker(int brokerId, int numMovements) throws IllegalArgumentException
brokerId
- -- the broker that's accounting for the movements.numMovements
- -- number of movements to consume. Can be positive or negative.IllegalArgumentException
public void clear()