Module io.github.bucket4j.core
Class PredictiveOptimization
java.lang.Object
io.github.bucket4j.distributed.proxy.optimization.predictive.PredictiveOptimization
- All Implemented Interfaces:
Optimization
Optimization that can serve requests locally without synchronization with external storage until thresholds are not violated.
This optimization is based on top of
BatchingOptimization and DelayOptimization,
and in additionally this optimization tries to predict aggregated consumption rate in whole cluster in order to reduce the risk of overconsumption that caused by DelayOptimization.
Usage of this optimization can lead to temporal over-consumption because the synchronization with external storage is performed periodically when thresholds are violated, as well as under-consumption in case of the wrong prediction of aggregated consumption rate.
- See Also:
-
Field Summary
Fields inherited from interface io.github.bucket4j.distributed.proxy.optimization.Optimization
NONE_OPTIMIZED -
Constructor Summary
ConstructorsConstructorDescriptionPredictiveOptimization(PredictionParameters predictionParameters, DelayParameters delayParameters, OptimizationListener listener, TimeMeter timeMeter) -
Method Summary
Modifier and TypeMethodDescriptionapply(AsyncCommandExecutor originalExecutor) Decorates command executor in order to apply optimization strategy.apply(CommandExecutor originalExecutor) Decorates command executor in order to apply optimization strategy.withListener(OptimizationListener listener) Specifies the listener for optimization events
-
Constructor Details
-
PredictiveOptimization
public PredictiveOptimization(PredictionParameters predictionParameters, DelayParameters delayParameters, OptimizationListener listener, TimeMeter timeMeter)
-
-
Method Details
-
withListener
Description copied from interface:OptimizationSpecifies the listener for optimization events- Specified by:
withListenerin interfaceOptimization- Parameters:
listener- the listener for optimization events- Returns:
- the new instance of
Optimizationwith configured listener
-
apply
Description copied from interface:OptimizationDecorates command executor in order to apply optimization strategy.- Specified by:
applyin interfaceOptimization- Parameters:
originalExecutor- command executor that need to be optimized- Returns:
- decorated command executor
-
apply
Description copied from interface:OptimizationDecorates command executor in order to apply optimization strategy.- Specified by:
applyin interfaceOptimization- Parameters:
originalExecutor- command executor that need to be optimized- Returns:
- decorated command executor
-