Class TerracottaBootstrapCacheLoader

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean DEFAULT_DEDICATED_THREAD
      The default on whether to do the snapshot on a dedicated thread or using the CacheManager's ScheduledExecutorService
      static long DEFAULT_INTERVAL
      The default interval in seconds, between each snapshot
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Clones the loader
      void dispose()
      Will shut the keysnapshot thread and other resources down.
      void doLocalKeySnapshot()
      Calling this method will result in a snapshot being taken or wait for the one in progress to finish
      boolean isAsynchronous()
      boolean isImmediateShutdown()
      Whether the on going keysnapshot will finish before the instance is disposed
      void load​(Ehcache cache)
      Instructs the loader to load the given cache
      void setImmediateShutdown​(boolean immediateShutdown)
      Sets whether the disposal of the instance will let the potential current key set being written to disk finish, or whether the shutdown will be immediate
      void setSnapshotOnDispose​(boolean doKeySnapshotOnDispose)
      Configures the Loader to take a snapshot when it is being disposed
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_INTERVAL

        public static final long DEFAULT_INTERVAL
        The default interval in seconds, between each snapshot
        See Also:
        Constant Field Values
      • DEFAULT_DEDICATED_THREAD

        public static final boolean DEFAULT_DEDICATED_THREAD
        The default on whether to do the snapshot on a dedicated thread or using the CacheManager's ScheduledExecutorService
        See Also:
        Constant Field Values
    • Constructor Detail

      • TerracottaBootstrapCacheLoader

        public TerracottaBootstrapCacheLoader​(boolean asynchronous,
                                              java.lang.String directory,
                                              boolean doKeySnapshots)
        Constructor
        Parameters:
        asynchronous - do the loading asynchronously, or synchronously
        directory - the directory to read snapshot files from, and write them to
        doKeySnapshots - Whether to do keysnapshotting
      • TerracottaBootstrapCacheLoader

        public TerracottaBootstrapCacheLoader​(boolean asynchronous,
                                              java.lang.String directory,
                                              long interval)
        Constructor
        Parameters:
        asynchronous - do the loading asynchronously, or synchronously
        directory - the directory to read snapshot files from, and write them to
        interval - the interval in seconds at which the snapshots of the local key set has to occur
      • TerracottaBootstrapCacheLoader

        public TerracottaBootstrapCacheLoader​(boolean asynchronous,
                                              java.lang.String directory,
                                              long interval,
                                              boolean onDedicatedThread)
        Constructor
        Parameters:
        asynchronous - do the loading asynchronously, or synchronously
        directory - the directory to read snapshot files from, and write them to
        interval - the interval in seconds at which the snapshots of the local key set has to occur
        onDedicatedThread - whether to do the snapshot on a dedicated thread or using the CacheManager's ScheduledExecutorService
    • Method Detail

      • isImmediateShutdown

        public boolean isImmediateShutdown()
        Whether the on going keysnapshot will finish before the instance is disposed
        Returns:
        true if disposable is immediate
        See Also:
        Disposable
      • setImmediateShutdown

        public void setImmediateShutdown​(boolean immediateShutdown)
        Sets whether the disposal of the instance will let the potential current key set being written to disk finish, or whether the shutdown will be immediate
        Parameters:
        immediateShutdown - true if immediate, false to let the snapshot finish
      • isAsynchronous

        public boolean isAsynchronous()
        Specified by:
        isAsynchronous in interface BootstrapCacheLoader
        Returns:
        true if this bootstrap loader is asynchronous
      • dispose

        public void dispose()
        Will shut the keysnapshot thread and other resources down. If a snapshot is currently in progress, the method will either shutdown immediately or let the snapshot finish based on the configured setImmediateShutdown(boolean) value
        Specified by:
        dispose in interface Disposable
      • doLocalKeySnapshot

        public void doLocalKeySnapshot()
                                throws java.io.IOException
        Calling this method will result in a snapshot being taken or wait for the one in progress to finish
        Throws:
        java.io.IOException - On exception being thrown while doing the snapshot
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Clones the loader
        Specified by:
        clone in interface BootstrapCacheLoader
        Overrides:
        clone in class MemoryLimitedCacheLoader
        Returns:
        clone of this instance
        Throws:
        java.lang.CloneNotSupportedException - if the object's class does not support the Cloneable interface.
      • setSnapshotOnDispose

        public void setSnapshotOnDispose​(boolean doKeySnapshotOnDispose)
        Configures the Loader to take a snapshot when it is being disposed
        Parameters:
        doKeySnapshotOnDispose - whether to snapshot on loader disposal