Class AbstractJournalRM.CollectorDaemon.CollectionCoordinator

java.lang.Object
com.tangosol.io.journal.AbstractJournalRM.CollectorDaemon.CollectionCoordinator
Enclosing class:
AbstractJournalRM.CollectorDaemon

protected class AbstractJournalRM.CollectorDaemon.CollectionCoordinator extends Object
A CollectionCoordinator is responsible for shaping an evacuation as well as managing any reserved files created to ensure the journal continues to operate. The CollectionCoordinator is notified of any actions performed during the evacuation thus can suggest when the next evacuation should execute.

The CollectionCoordinator is also responsible for finalizing a collection which in this context acts as a barrier to clients exposing the memory reclaimed during the evacuation.

  • Constructor Details

    • CollectionCoordinator

      protected CollectionCoordinator()
  • Method Details

    • getFinalJournalFile

      public AbstractJournalRM.JournalFile getFinalJournalFile()
      Return a AbstractJournalRM.JournalFile based on the context of the calling thread or null if it is determined that an exhaustive evacuation will not reclaim sufficient memory. This method should only be invoked in a "depleted" state when:
      • the maximum number of files is used
      • all those files are non-appending
      When called on a client thread, any operation against this file will block until the full compaction is performed. There is no guarantee that compaction will result in available memory therefore an out of memory error is still possible.

      When called on the CollectorDaemon thread this method returns a normal JournalFile, with the only exception that it will be in excess to the maximum number of permitted journal files and used exclusively by the CollectorDaemon to perform evacuation in a depleted state.

      Returns:
      a JournalFile either triggering a full collection or a file used exclusively by the CollectorDaemon. null may be returned if it is determined that an exhaustive evacuation will not reclaim sufficient memory
    • exhaustiveEvac

      public void exhaustiveEvac(int cBytes, boolean fWait)
      Request the CollectorDaemon to perform an exhaustive evacuation and block this thread until the collection is complete.
      Parameters:
      cBytes - the number of bytes required by this store request
      fWait - whether to block the calling thread until sufficient memory has been reclaimed
    • onReleased

      public void onReleased(int cbReleased, int nFileId)
      Notify the CollectionCoordinator that a AbstractJournalRM.JournalFile has released the provided amount of memory.
      Parameters:
      cbReleased - the number of bytes released
      nFileId - the journal file id that was released from
    • getReservedFileId

      public int getReservedFileId()
      Return the reserved file id.
      Returns:
      the reserved file id
    • getEvacuatedFileCount

      public int getEvacuatedFileCount()
      Return the number of files evacuated since the statistics were reset.
      Returns:
      the number of files evacuated
    • getExhaustiveCompactionCount

      public int getExhaustiveCompactionCount()
      Return the total number of exhaustive evacuations performed by the collector.
      Returns:
      the total number of exhaustive evacuations performed by the collector
    • getExhaustiveCompactionTime

      public long getExhaustiveCompactionTime()
      Return the number of milliseconds it took to perform exhaustive evacuations by the collector.
      Returns:
      the total number of milliseconds spent in performing exhaustive evacuations
    • getAvgEvacuationMillis

      public int getAvgEvacuationMillis()
      Determine the average number of milliseconds to evacuate a file.
      Returns:
      the average number of milliseconds to perform evacuation
    • getMaxEvacuationMillis

      public int getMaxEvacuationMillis()
      Determine the maximum number of milliseconds to evacuate a file.
      Returns:
      the number of milliseconds of the longest evacuation
    • resetStatistics

      public void resetStatistics()
      Reset the collector statistics.
    • ensureReservedFile

      public AbstractJournalRM.JournalFile ensureReservedFile()
      Return a reserved file.

      This method is only invoked in a 'depleted' state in which no more journal files can be created thus the reserved slot in the JournalFile[] must be used. This slot is reserved exclusively for the CollectorDaemon.

      Returns:
      a usable file from the survivor pool
    • onStart

      public void onStart()
      Inform the CollectionCoordinator that a collection is about to commence.
    • finalizeCollection

      protected void finalizeCollection()
      Inform the CollectionCoordinator that a collection is complete and changes should be exposed.
    • getWaitTime

      protected long getWaitTime()
      Return the amount of time the collector should wait prior to the next collection.
      Returns:
      the amount of time prior to the next collection
    • actionable

      protected void actionable(AbstractJournalRM.JournalFile jrnlFile)
      Inform the CollectionCoordinator of an item that could be actioned if the CollectorDaemon was to execute. This may influence the interval before the next CollectorDaemon execution.
    • evacuate

      protected void evacuate(AbstractJournalRM.JournalFile jrnlFile)
      Inform the CollectionCoordinator of a AbstractJournalRM.JournalFile about to be evacuated.
      Parameters:
      jrnlFile - a journal file about to be evacuated
    • reclaimJournalFile

      protected void reclaimJournalFile(AbstractJournalRM.JournalFile jrnlFile)
      A AbstractJournalRM.JournalFile has been dereferenced thus memory has been reclaimed.
      Parameters:
      jrnlFile - the journal file that has transitioned
    • isExhaustiveEvacuation

      protected boolean isExhaustiveEvacuation()
      Return whether this is an exhaustive evacuation.
      Returns:
      whether this is an exhaustive evacuation
    • hasReclaimedMemory

      public boolean hasReclaimedMemory()
      Return true if memory has been reclaimed by evacuating a journal file or discarding of a garbage file.
      Returns:
      whether any files have been discarded during the collection
    • calculateCurrentLoadFactor

      protected double calculateCurrentLoadFactor()
      Calculate current load factor for compaction (GC).
      Returns:
      calculated load factor
    • release

      protected void release()
      Release the reserved file(s) used thus far into the RM's AbstractJournalRM.JournalFile pool so that they are linked appropriately. Additionally expose the slots that were free'd allowing clients awoken to carry out store requests.

      Calls to release when in exhaustive evacuation mode must hold the lock f_lockClientGC prior to calling release.

    • shouldExecuteFullGc

      protected boolean shouldExecuteFullGc()
      Return whether an exhaustive evacuation should be executed.
      Returns:
      whether an exhaustive evacuation should be executed