Class PredictiveActivator

java.lang.Object
com.tnsai.coordination.pool.PredictiveActivator
All Implemented Interfaces:
PoolListener

public final class PredictiveActivator extends Object implements 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
 
  • Method Details

    • onActivated

      public void onActivated(com.tnsai.agents.Agent agent)
      Description copied from interface: PoolListener
      Called when an agent is checked out (activated).
      Specified by:
      onActivated in interface PoolListener
    • onExhausted

      public void onExhausted()
      Description copied from interface: PoolListener
      Called when a checkout fails because the pool is exhausted.
      Specified by:
      onExhausted in interface PoolListener
    • 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

      public static PredictiveActivator.Builder builder()