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 Summary
Constructors Modifier Constructor Description protectedCollectionCoordinator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactionable(AbstractJournalRM.JournalFile jrnlFile)Inform the CollectionCoordinator of an item that could be actioned if the CollectorDaemon was to execute.protected doublecalculateCurrentLoadFactor()Calculate current load factor for compaction (GC).AbstractJournalRM.JournalFileensureReservedFile()Return a reserved file.protected voidevacuate(AbstractJournalRM.JournalFile jrnlFile)Inform the CollectionCoordinator of aAbstractJournalRM.JournalFileabout to be evacuated.voidexhaustiveEvac(int cBytes, boolean fWait)Request the CollectorDaemon to perform an exhaustive evacuation and block this thread until the collection is complete.protected voidfinalizeCollection()Inform the CollectionCoordinator that a collection is complete and changes should be exposed.intgetAvgEvacuationMillis()Determine the average number of milliseconds to evacuate a file.intgetEvacuatedFileCount()Return the number of files evacuated since the statistics were reset.intgetExhaustiveCompactionCount()Return the total number of exhaustive evacuations performed by the collector.longgetExhaustiveCompactionTime()Return the number of milliseconds it took to perform exhaustive evacuations by the collector.AbstractJournalRM.JournalFilegetFinalJournalFile()Return aAbstractJournalRM.JournalFilebased on the context of the calling thread or null if it is determined that an exhaustive evacuation will not reclaim sufficient memory.intgetMaxEvacuationMillis()Determine the maximum number of milliseconds to evacuate a file.intgetReservedFileId()Return the reserved file id.protected longgetWaitTime()Return the amount of time the collector should wait prior to the next collection.booleanhasReclaimedMemory()Return true if memory has been reclaimed by evacuating a journal file or discarding of a garbage file.protected booleanisExhaustiveEvacuation()Return whether this is an exhaustive evacuation.voidonReleased(int cbReleased, int nFileId)Notify the CollectionCoordinator that aAbstractJournalRM.JournalFilehas released the provided amount of memory.voidonStart()Inform the CollectionCoordinator that a collection is about to commence.protected voidreclaimJournalFile(AbstractJournalRM.JournalFile jrnlFile)AAbstractJournalRM.JournalFilehas been dereferenced thus memory has been reclaimed.protected voidrelease()Release the reserved file(s) used thus far into the RM'sAbstractJournalRM.JournalFilepool so that they are linked appropriately.voidresetStatistics()Reset the collector statistics.protected booleanshouldExecuteFullGc()Return whether an exhaustive evacuation should be executed.
-
-
-
Method Detail
-
getFinalJournalFile
public AbstractJournalRM.JournalFile getFinalJournalFile()
Return aAbstractJournalRM.JournalFilebased 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 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.
nullmay 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 requestfWait- whether to block the calling thread until sufficient memory has been reclaimed
-
onReleased
public void onReleased(int cbReleased, int nFileId)Notify the CollectionCoordinator that aAbstractJournalRM.JournalFilehas released the provided amount of memory.- Parameters:
cbReleased- the number of bytes releasednFileId- 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 aAbstractJournalRM.JournalFileabout to be evacuated.- Parameters:
jrnlFile- a journal file about to be evacuated
-
reclaimJournalFile
protected void reclaimJournalFile(AbstractJournalRM.JournalFile jrnlFile)
AAbstractJournalRM.JournalFilehas 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'sAbstractJournalRM.JournalFilepool 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_lockClientGCprior to calling release.
-
shouldExecuteFullGc
protected boolean shouldExecuteFullGc()
Return whether an exhaustive evacuation should be executed.- Returns:
- whether an exhaustive evacuation should be executed
-
-