Package com.tnsai.coordination.pool
Class PredictiveActivator
java.lang.Object
com.tnsai.coordination.pool.PredictiveActivator
- All Implemented Interfaces:
PoolListener
Usage-pattern-based predictive activation for
LazyAgentPool.
Tracks agent checkout patterns in a sliding window and pre-warms agents
when burst demand is detected.
Example usage:
LazyAgentPool pool = LazyAgentPool.builder()
.factory(() -> new MyAgent(...))
.maxSize(20)
.build();
PredictiveActivator activator = PredictiveActivator.builder()
.pool(pool)
.windowSize(60) // 60-second sliding window
.burstThreshold(5) // 5+ checkouts/window triggers pre-warm
.preWarmCount(3) // pre-warm 3 agents
.analyzeInterval(10) // analyze every 10 seconds
.build();
activator.start(); // begins monitoring
// ... use pool normally ...
activator.stop(); // stops monitoring
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic PredictiveActivator.Builderbuilder()booleanReturns whether the activator is running.voidonActivated(com.tnsai.agents.Agent agent) Called when an agent is checked out (activated).voidCalled when a checkout fails because the pool is exhausted.intReturns the number of activations in the current sliding window.intReturns the number of exhaustion events in the current sliding window.voidstart()Starts the predictive analysis loop.voidstop()Stops the predictive analysis loop.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tnsai.coordination.pool.PoolListener
onDestroyed, onReturned
-
Method Details
-
onActivated
public void onActivated(com.tnsai.agents.Agent agent) Description copied from interface:PoolListenerCalled when an agent is checked out (activated).- Specified by:
onActivatedin interfacePoolListener
-
onExhausted
public void onExhausted()Description copied from interface:PoolListenerCalled when a checkout fails because the pool is exhausted.- Specified by:
onExhaustedin interfacePoolListener
-
start
public void start()Starts the predictive analysis loop. -
stop
public void stop()Stops the predictive analysis loop. -
isRunning
public boolean isRunning()Returns whether the activator is running. -
recentActivationCount
public int recentActivationCount()Returns the number of activations in the current sliding window. -
recentExhaustionCount
public int recentExhaustionCount()Returns the number of exhaustion events in the current sliding window. -
builder
-