AutoScalingEventExecutorChooserFactory Class — netty Architecture
Architecture documentation for the AutoScalingEventExecutorChooserFactory class in AutoScalingEventExecutorChooserFactory.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 89513ff1_7570_ea60_1629_69d76191e92a["AutoScalingEventExecutorChooserFactory"] 409fa4eb_44da_665a_7f39_b9b5f929789e["AutoScalingEventExecutorChooserFactory.java"] 89513ff1_7570_ea60_1629_69d76191e92a -->|defined in| 409fa4eb_44da_665a_7f39_b9b5f929789e ee0e0ad8_8fca_c938_8fe4_3d22090bfe7a["AutoScalingEventExecutorChooserFactory()"] 89513ff1_7570_ea60_1629_69d76191e92a -->|method| ee0e0ad8_8fca_c938_8fe4_3d22090bfe7a 2c8b0720_7b5e_8a9b_2d4b_ae591d1119a4["EventExecutorChooser()"] 89513ff1_7570_ea60_1629_69d76191e92a -->|method| 2c8b0720_7b5e_8a9b_2d4b_ae591d1119a4
Relationship Graph
Source Code
common/src/main/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactory.java lines 47–421
public final class AutoScalingEventExecutorChooserFactory implements EventExecutorChooserFactory {
/**
* A container for the utilization metric of a single EventExecutor.
* This object is intended to be created once and have its {@code utilization}
* field updated periodically.
*/
public static final class AutoScalingUtilizationMetric {
private final EventExecutor executor;
private final AtomicLong utilizationBits = new AtomicLong();
AutoScalingUtilizationMetric(EventExecutor executor) {
this.executor = executor;
}
/**
* Returns the most recently calculated utilization for the associated executor.
* @return a value from 0.0 to 1.0.
*/
public double utilization() {
return Double.longBitsToDouble(utilizationBits.get());
}
/**
* Returns the {@link EventExecutor} this metric belongs too.
* @return the executor.
*/
public EventExecutor executor() {
return executor;
}
void setUtilization(double utilization) {
long bits = Double.doubleToRawLongBits(utilization);
utilizationBits.lazySet(bits);
}
}
private static final Runnable NO_OOP_TASK = () -> { };
private final int minChildren;
private final int maxChildren;
private final long utilizationCheckPeriodNanos;
private final double scaleDownThreshold;
private final double scaleUpThreshold;
private final int maxRampUpStep;
private final int maxRampDownStep;
private final int scalingPatienceCycles;
/**
* Creates a new factory for a scaling-enabled {@link EventExecutorChooser}.
*
* @param minThreads the minimum number of threads to keep active.
* @param maxThreads the maximum number of threads to scale up to.
* @param utilizationWindow the period at which to check group utilization.
* @param windowUnit the unit for {@code utilizationWindow}.
* @param scaleDownThreshold the average utilization below which a thread may be suspended.
* @param scaleUpThreshold the average utilization above which a thread may be resumed.
* @param maxRampUpStep the maximum number of threads to add in one cycle.
* @param maxRampDownStep the maximum number of threads to remove in one cycle.
* @param scalingPatienceCycles the number of consecutive cycles a condition must be met before scaling.
*/
public AutoScalingEventExecutorChooserFactory(int minThreads, int maxThreads, long utilizationWindow,
TimeUnit windowUnit, double scaleDownThreshold,
double scaleUpThreshold, int maxRampUpStep, int maxRampDownStep,
int scalingPatienceCycles) {
minChildren = ObjectUtil.checkPositiveOrZero(minThreads, "minThreads");
maxChildren = ObjectUtil.checkPositive(maxThreads, "maxThreads");
if (minThreads > maxThreads) {
throw new IllegalArgumentException(String.format(
"minThreads: %d must not be greater than maxThreads: %d", minThreads, maxThreads));
}
utilizationCheckPeriodNanos = ObjectUtil.checkNotNull(windowUnit, "windowUnit")
.toNanos(ObjectUtil.checkPositive(utilizationWindow,
"utilizationWindow"));
this.scaleDownThreshold = ObjectUtil.checkInRange(scaleDownThreshold, 0.0, 1.0, "scaleDownThreshold");
this.scaleUpThreshold = ObjectUtil.checkInRange(scaleUpThreshold, 0.0, 1.0, "scaleUpThreshold");
if (scaleDownThreshold >= scaleUpThreshold) {
throw new IllegalArgumentException(
"scaleDownThreshold must be less than scaleUpThreshold: " +
scaleDownThreshold + " >= " + scaleUpThreshold);
}
this.maxRampUpStep = ObjectUtil.checkPositive(maxRampUpStep, "maxRampUpStep");
Defined In
Source
Frequently Asked Questions
What is the AutoScalingEventExecutorChooserFactory class?
AutoScalingEventExecutorChooserFactory is a class in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactory.java.
Where is AutoScalingEventExecutorChooserFactory defined?
AutoScalingEventExecutorChooserFactory is defined in common/src/main/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactory.java at line 47.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free