Package jline.lang.constant
Class BalkingThreshold
java.lang.Object
jline.lang.constant.BalkingThreshold
- All Implemented Interfaces:
Serializable
Represents a balking threshold for queue-length based balking.
A threshold specifies that when the queue length is within a certain range,
the customer will balk (refuse to join) with a given probability.
Example: BalkingThreshold(5, 10, 0.3) means:
- When queue length is between 5 and 10 (inclusive)
- Customer balks with 30% probability
Thresholds are evaluated in order; the first matching range determines the probability.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBalkingThreshold(int minJobs, double probability) Creates a balking threshold for all queue lengths >= minJobs.BalkingThreshold(int minJobs, int maxJobs, double probability) Creates a balking threshold for a queue length range. -
Method Summary
Modifier and TypeMethodDescriptionintGet the maximum queue length for this threshold.intGet the minimum queue length for this threshold.doubleGet the balking probability for this threshold.booleanmatches(int queueLength) Check if a given queue length falls within this threshold's range.toString()
-
Constructor Details
-
BalkingThreshold
public BalkingThreshold(int minJobs, int maxJobs, double probability) Creates a balking threshold for a queue length range.- Parameters:
minJobs- minimum queue length (inclusive) for this thresholdmaxJobs- maximum queue length (inclusive), use Integer.MAX_VALUE for unboundedprobability- probability of balking when queue length is in range [0.0, 1.0]- Throws:
IllegalArgumentException- if probability is not in [0, 1] or minJobs > maxJobs
-
BalkingThreshold
public BalkingThreshold(int minJobs, double probability) Creates a balking threshold for all queue lengths >= minJobs.- Parameters:
minJobs- minimum queue length (inclusive)probability- probability of balking
-
-
Method Details
-
getMinJobs
public int getMinJobs()Get the minimum queue length for this threshold.- Returns:
- minimum queue length (inclusive)
-
getMaxJobs
public int getMaxJobs()Get the maximum queue length for this threshold.- Returns:
- maximum queue length (inclusive)
-
getProbability
public double getProbability()Get the balking probability for this threshold.- Returns:
- probability in [0.0, 1.0]
-
matches
public boolean matches(int queueLength) Check if a given queue length falls within this threshold's range.- Parameters:
queueLength- the current queue length- Returns:
- true if queueLength is in [minJobs, maxJobs]
-
toString
-