Class ArchiveCacheStorage

java.lang.Object
fr.gouv.vitam.storage.offers.tape.cas.ArchiveCacheStorage

@ThreadSafe public class ArchiveCacheStorage extends Object
Cache for archive storage on disk with Least Recently Used (LRU) eviction policy. Archives are stored as files on a cache directory in the following topology {cacheDirectory}/{fileBucketId}/{tarId}. Cache is configured with storage capacity thresholds : - Max storage space : max capacity that cannot be exceeded by archive cache. - An eviction storage space threshold : triggers background delete of old unused archive files. - Safe storage capacity threshold : causes background delete process to stop when enough disk space is available. Typical use would be : - reserveArchiveStorageSpace() to ensure enough disk space is available - Write data to temporary archive in a dedicated folder (different from cache directory which is managed by the cache), but on same file system partition (to ensure atomic file move is available) - moveArchiveToCache() to move atomically temporary archive to cache directory and add it to cache OR cancelReservedArchive() on failure - At any time, try read an archive from disk using the tryReadFile() method. When initialized, the cache loads all existing archive files from storage directory. This class is Thread-Safe.
  • Constructor Details

    • ArchiveCacheStorage

      public ArchiveCacheStorage(String cacheDirectory, BucketTopologyHelper bucketTopologyHelper, ArchiveCacheEvictionController archiveCacheEvictionController, long maxStorageSpace, long evictionStorageSpaceThreshold, long safeStorageSpaceThreshold) throws IllegalPathException, IOException
      Parameters:
      cacheDirectory - the cache storage directory
      bucketTopologyHelper - bucket topology helper
      archiveCacheEvictionController - controller of archive cache eviction.
      maxStorageSpace - max capacity (in bytes) that cannot be exceeded by archive cache.
      evictionStorageSpaceThreshold - : storage space capacity (in bytes) that triggers background delete of old unused archive files
      safeStorageSpaceThreshold - safe storage space capacity level (in bytes). When enough storage space is available, background cache delete process ends.
      Throws:
      IllegalPathException - if provided cache directory contains unsafe or illegal archive names.
      IOException - if an I/O error is thrown when accessing disk.
  • Method Details