Class CapacityPlanner

java.lang.Object
com.loomcache.server.metrics.CapacityPlanner

public class CapacityPlanner extends Object
Predicts future resource needs based on historical growth trends. Estimates capacity exhaustion and recommends scaling actions.

Thread-safe using ReentrantReadWriteLock.

  • Constructor Details

    • CapacityPlanner

      public CapacityPlanner()
      Create a new CapacityPlanner.
  • Method Details

    • recordSnapshot

      public void recordSnapshot(long entryCount, long memoryUsed, long maxMemory)
      Record a capacity snapshot.
      Parameters:
      entryCount - current entry count
      memoryUsed - current memory used in bytes
      maxMemory - max available memory in bytes
    • estimateGrowthRate

      public double estimateGrowthRate()
      Estimate growth rate in entries per hour based on recent trend.
      Returns:
      entries per hour
    • predictCapacityExhaustion

      public Optional<Instant> predictCapacityExhaustion(long maxEntries)
      Predict when capacity will be exhausted.
      Parameters:
      maxEntries - maximum number of entries allowed
      Returns:
      Optional with instant of exhaustion, or empty if growth is stable/negative
    • recommendScaling

      public CapacityPlanner.ScalingRecommendation recommendScaling()
      Get scaling recommendation based on current and projected utilization.
      Returns:
      scaling recommendation
    • getCurrentUtilization

      public double getCurrentUtilization()
      Get current capacity utilization (0.0 to 1.0).
      Returns:
      utilization ratio
    • clear

      public void clear()
      Clear all recorded snapshots.
    • getSnapshotCount

      public int getSnapshotCount()
      Get number of recorded snapshots.
      Returns:
      snapshot count