Class SpaceBasedCacheLimitPolicy

java.lang.Object
org.apache.flink.state.forst.fs.cache.SpaceBasedCacheLimitPolicy
All Implemented Interfaces:
CacheLimitPolicy

public class SpaceBasedCacheLimitPolicy extends Object implements CacheLimitPolicy
A space based cache limit policy that leverages the system to check the free space dynamically, the free space may fluctuate in size due to other components. This class is not thread-safe, and the thread safe should be ensured by the invoker.
  • Constructor Details

    • SpaceBasedCacheLimitPolicy

      public SpaceBasedCacheLimitPolicy(File instanceBasePath, long reservedSize, long baseTargetFileSize)
  • Method Details

    • worksOn

      public static boolean worksOn(File instanceBasePath)
    • directWriteInCache

      public boolean directWriteInCache()
      Description copied from interface: CacheLimitPolicy
      Whether to support directly write in cache.
      Specified by:
      directWriteInCache in interface CacheLimitPolicy
    • isSafeToAdd

      public boolean isSafeToAdd(long toAddSize)
      Description copied from interface: CacheLimitPolicy
      Whether the cache usage is safe to add.
      Specified by:
      isSafeToAdd in interface CacheLimitPolicy
      Returns:
      false if the toAddSize is larger than max available capacity, true otherwise.
    • isOverflow

      public boolean isOverflow(long toAddSize, boolean hasFile)
      Description copied from interface: CacheLimitPolicy
      Whether the cache usage is exceeded the upperbound.
      Specified by:
      isOverflow in interface CacheLimitPolicy
      Parameters:
      toAddSize - the size about to add.
      hasFile - whether the file is already in cache.
      Returns:
      true if the cache usage is overflow, false otherwise.
    • acquire

      public void acquire(long toAddSize)
      Description copied from interface: CacheLimitPolicy
      Acquire cache.
      Specified by:
      acquire in interface CacheLimitPolicy
    • release

      public void release(long toReleaseSize)
      Description copied from interface: CacheLimitPolicy
      Release cache.
      Specified by:
      release in interface CacheLimitPolicy
    • usedBytes

      public long usedBytes()
      Description copied from interface: CacheLimitPolicy
      Get current used bytes.
      Specified by:
      usedBytes in interface CacheLimitPolicy
      Returns:
      cache bytes.
    • registerCustomizedMetrics

      public void registerCustomizedMetrics(String prefix, org.apache.flink.metrics.MetricGroup metricGroup)
      Description copied from interface: CacheLimitPolicy
      Register customized metrics.
      Specified by:
      registerCustomizedMetrics in interface CacheLimitPolicy
    • toString

      public String toString()
      Overrides:
      toString in class Object