Class HazelcastCacheManager

java.lang.Object
com.norconex.crawler.core.cluster.impl.hazelcast.HazelcastCacheManager
All Implemented Interfaces:
CacheManager, Closeable, AutoCloseable

public class HazelcastCacheManager extends Object implements CacheManager, Closeable
  • Constructor Details

    • HazelcastCacheManager

      public HazelcastCacheManager(com.hazelcast.core.HazelcastInstance hazelcastInstance)
  • Method Details

    • getHazelcastInstance

      public static com.hazelcast.core.HazelcastInstance getHazelcastInstance(String name)
      Returns the HazelcastInstance with the given name using Hazelcast's own instance registry. Returns null if no instance with that name is currently running on this JVM.
    • getCacheMap

      public <T> CacheMap<T> getCacheMap(String name, Class<T> valueType)
      Description copied from interface: CacheManager
      Gets a named cache storing objects of the supplied type. By default the returned cache is persisted, but cache implementations may decide otherwise (based on cache name, configuration, etc.).
      Specified by:
      getCacheMap in interface CacheManager
      Type Parameters:
      T - type of the value to store
      Parameters:
      name - cache name
      valueType - class of the value to store
      Returns:
      a named cache
    • getCacheSet

      public CacheSet getCacheSet(String name)
      Description copied from interface: CacheManager
      As string-based set, keeping only unique keys.
      Specified by:
      getCacheSet in interface CacheManager
      Parameters:
      name - cache name
      Returns:
      a named cache set
    • getCacheQueue

      public <T> CacheQueue<T> getCacheQueue(String name, Class<T> valueType)
      Description copied from interface: CacheManager
      Gets a FIFO queue.
      Specified by:
      getCacheQueue in interface CacheManager
      Type Parameters:
      T - the type of elements in the queue
      Parameters:
      name - the queue name
      valueType - the value type
      Returns:
      cache queue
    • getCrawlerCache

      public CacheMap<String> getCrawlerCache()
      Description copied from interface: CacheManager
      Gets a generic shared cache bound to a crawler that persists forever (never deleted).
      Specified by:
      getCrawlerCache in interface CacheManager
      Returns:
      crawler-scoped persistent cache
    • getCrawlSessionCache

      public CacheMap<String> getCrawlSessionCache()
      Description copied from interface: CacheManager
      Gets a generic shared cache bound to a crawl session that persists until a new crawl session is started (for the same crawler).
      Specified by:
      getCrawlSessionCache in interface CacheManager
      Returns:
      crawl session-scoped persistent cache
    • getCrawlRunCache

      public CacheMap<String> getCrawlRunCache()
      Description copied from interface: CacheManager
      Gets a generic shared cache tied to a specific crawler run and does not get persisted when the crawler run terminates.
      Specified by:
      getCrawlRunCache in interface CacheManager
      Returns:
      crawl run non-persistent cache
    • cacheExists

      public boolean cacheExists(String name)
      Specified by:
      cacheExists in interface CacheManager
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • vendor

      public com.hazelcast.core.HazelcastInstance vendor()
      Description copied from interface: CacheManager
      Gets the vendor-specific implementation object.
      Specified by:
      vendor in interface CacheManager
      Returns:
      vendor implementation
    • exportCaches

      public void exportCaches(Consumer<SerializedCache> c)
      Description copied from interface: CacheManager
      Consumes every caches, where record value are serialized JSON String. Entries are lazy loaded.
      Specified by:
      exportCaches in interface CacheManager
      Parameters:
      c - serialized cache.
    • importCaches

      public void importCaches(List<SerializedCache> caches)
      Description copied from interface: CacheManager
      Import caches previously exported with CacheManager.exportCaches(Consumer).
      Specified by:
      importCaches in interface CacheManager
      Parameters:
      caches - caches to import
    • clearCaches

      public void clearCaches()
      Description copied from interface: CacheManager
      Clears all caches.
      Specified by:
      clearCaches in interface CacheManager
    • getAdminCache

      public CacheMap<String> getAdminCache()
      Description copied from interface: CacheManager
      Gets the admin cache for storing administrative data.
      Specified by:
      getAdminCache in interface CacheManager
      Returns:
      admin cache
    • getPipelineStepCache

      public CacheMap<StepRecord> getPipelineStepCache()
      Description copied from interface: CacheManager
      Gets the pipeline step cache for storing current pipeline steps.
      Specified by:
      getPipelineStepCache in interface CacheManager
      Returns:
      pipeline step cache
    • getPipelineWorkerStatusCache

      public CacheMap<StepRecord> getPipelineWorkerStatusCache()
      Description copied from interface: CacheManager
      Gets the pipeline worker status cache for storing worker statuses.
      Specified by:
      getPipelineWorkerStatusCache in interface CacheManager
      Returns:
      pipeline worker status cache
    • addCacheEntryChangeListener

      public <T> void addCacheEntryChangeListener(@NonNull @NonNull CacheEntryChangeListener<T> listener, String cacheName)
      Description copied from interface: CacheManager
      Adds a cache entry change listener to the specified cache.
      Specified by:
      addCacheEntryChangeListener in interface CacheManager
      Type Parameters:
      T - the type of values in the cache
      Parameters:
      listener - the listener to add
      cacheName - the name of the cache
    • removeCacheEntryChangeListener

      public <T> void removeCacheEntryChangeListener(@NonNull @NonNull CacheEntryChangeListener<T> listener, String cacheName)
      Description copied from interface: CacheManager
      Removes a cache entry change listener from the specified cache.
      Specified by:
      removeCacheEntryChangeListener in interface CacheManager
      Type Parameters:
      T - the type of values in the cache
      Parameters:
      listener - the listener to remove
      cacheName - the name of the cache