Module io.github.bucket4j.core
Class PredictiveOptimization
- java.lang.Object
-
- io.github.bucket4j.distributed.proxy.optimization.predictive.PredictiveOptimization
-
- All Implemented Interfaces:
Optimization
public class PredictiveOptimization extends Object implements Optimization
Optimization that can serve requests locally without synchronization with external storage until thresholds are not violated. This optimization is based on top ofBatchingOptimizationandDelayOptimization, and in additionally this optimization tries to predict aggregated consumption rate in whole cluster in order to reduce the risk of overconsumption that caused byDelayOptimization.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:
DelayParameters,PredictionParameters
-
-
Field Summary
-
Fields inherited from interface io.github.bucket4j.distributed.proxy.optimization.Optimization
NONE_OPTIMIZED
-
-
Constructor Summary
Constructors Constructor Description PredictiveOptimization(PredictionParameters predictionParameters, DelayParameters delayParameters, OptimizationListener listener, TimeMeter timeMeter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncCommandExecutorapply(AsyncCommandExecutor originalExecutor)Decorates command executor in order to apply optimization strategy.CommandExecutorapply(CommandExecutor originalExecutor)Decorates command executor in order to apply optimization strategy.OptimizationwithListener(OptimizationListener listener)Specifies the listener for optimization events
-
-
-
Constructor Detail
-
PredictiveOptimization
public PredictiveOptimization(PredictionParameters predictionParameters, DelayParameters delayParameters, OptimizationListener listener, TimeMeter timeMeter)
-
-
Method Detail
-
withListener
public Optimization withListener(OptimizationListener listener)
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
public CommandExecutor apply(CommandExecutor originalExecutor)
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
public AsyncCommandExecutor apply(AsyncCommandExecutor originalExecutor)
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
-
-