Class MemoryMappedFileCache

  • All Implemented Interfaces:
    FileCacheIF

    @ThreadSafe
    public class MemoryMappedFileCache
    extends Object
    implements FileCacheIF
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected ConcurrentHashMap<Object,​MemoryMappedFileCache.CacheElement> cache  
      protected static Logger cacheLog  
      protected AtomicInteger cleanups  
      protected ConcurrentHashMap<FileCacheable,​MemoryMappedFileCache.CacheElement.CacheFile> files  
      protected int hardLimit  
      protected AtomicBoolean hasScheduled  
      protected AtomicInteger hits  
      protected static Logger log  
      protected int minElements  
      protected AtomicInteger miss  
      protected String name  
      protected long period  
      protected int softLimit  
      protected ConcurrentHashMap<Object,​MemoryMappedFileCache.CacheTracking> track  
      protected boolean trackAll  
    • Constructor Summary

      Constructors 
      Constructor Description
      MemoryMappedFileCache​(int minElementsInMemory, int maxElementsInMemory, int period)  
      MemoryMappedFileCache​(int minElementsInMemory, int softLimit, int hardLimit, int period)  
      MemoryMappedFileCache​(String name, int minElementsInMemory, int softLimit, int hardLimit, int period)  
    • Field Detail

      • log

        protected static final Logger log
      • cacheLog

        protected static final Logger cacheLog
      • name

        protected String name
      • softLimit

        protected final int softLimit
      • minElements

        protected final int minElements
      • hardLimit

        protected final int hardLimit
      • period

        protected final long period
      • hasScheduled

        protected final AtomicBoolean hasScheduled
      • cache

        protected final ConcurrentHashMap<Object,​MemoryMappedFileCache.CacheElement> cache
      • files

        protected final ConcurrentHashMap<FileCacheable,​MemoryMappedFileCache.CacheElement.CacheFile> files
      • cleanups

        protected final AtomicInteger cleanups
      • hits

        protected final AtomicInteger hits
      • miss

        protected final AtomicInteger miss
      • track

        protected ConcurrentHashMap<Object,​MemoryMappedFileCache.CacheTracking> track
      • trackAll

        protected boolean trackAll
    • Constructor Detail

      • MemoryMappedFileCache

        public MemoryMappedFileCache​(int minElementsInMemory,
                                     int maxElementsInMemory,
                                     int period)
      • MemoryMappedFileCache

        public MemoryMappedFileCache​(int minElementsInMemory,
                                     int softLimit,
                                     int hardLimit,
                                     int period)
      • MemoryMappedFileCache

        public MemoryMappedFileCache​(String name,
                                     int minElementsInMemory,
                                     int softLimit,
                                     int hardLimit,
                                     int period)
    • Method Detail

      • shutdown

        public static void shutdown()
      • disable

        public void disable()
        Specified by:
        disable in interface FileCacheIF
      • enable

        public void enable()
        Specified by:
        enable in interface FileCacheIF
      • acquire

        public FileCacheable acquire​(FileFactory factory,
                                     DatasetUrl durl)
                              throws IOException
        Specified by:
        acquire in interface FileCacheIF
        Throws:
        IOException
      • acquire

        public FileCacheable acquire​(FileFactory factory,
                                     Object hashKey,
                                     DatasetUrl location,
                                     int buffer_size,
                                     CancelTask cancelTask,
                                     Object spiObject)
                              throws IOException
        Specified by:
        acquire in interface FileCacheIF
        Throws:
        IOException
      • eject

        public void eject​(Object hashKey)
        Specified by:
        eject in interface FileCacheIF
      • release

        public boolean release​(FileCacheable ncfile)
                        throws IOException
        Specified by:
        release in interface FileCacheIF
        Throws:
        IOException
      • clearCache

        public void clearCache​(boolean force)
        Specified by:
        clearCache in interface FileCacheIF
      • showCache

        public void showCache​(Formatter format)
        Specified by:
        showCache in interface FileCacheIF
      • showCache

        public List<String> showCache()
        Specified by:
        showCache in interface FileCacheIF
      • showStats

        public void showStats​(Formatter format)
        Specified by:
        showStats in interface FileCacheIF
      • showTracking

        public void showTracking​(Formatter format)
        Specified by:
        showTracking in interface FileCacheIF
      • resetTracking

        public void resetTracking()
        Specified by:
        resetTracking in interface FileCacheIF