Class AbstractJournalRM.CollectorDaemon.CollectionCoordinator
- Enclosing class:
AbstractJournalRM.CollectorDaemon
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidactionable(AbstractJournalRM.JournalFile jrnlFile) Inform the CollectionCoordinator of an item that could be actioned if the CollectorDaemon was to execute.protected doubleCalculate current load factor for compaction (GC).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 voidInform the CollectionCoordinator that a collection is complete and changes should be exposed.intDetermine the average number of milliseconds to evacuate a file.intReturn the number of files evacuated since the statistics were reset.intReturn the total number of exhaustive evacuations performed by the collector.longReturn the number of milliseconds it took to perform exhaustive evacuations by the collector.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.intDetermine the maximum number of milliseconds to evacuate a file.intReturn the reserved file id.protected longReturn the amount of time the collector should wait prior to the next collection.booleanReturn true if memory has been reclaimed by evacuating a journal file or discarding of a garbage file.protected booleanReturn 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 voidAAbstractJournalRM.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.voidReset the collector statistics.protected booleanReturn whether an exhaustive evacuation should be executed.
-
Constructor Details
-
CollectionCoordinator
protected CollectionCoordinator()
-
-
Method Details
-
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
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
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
Inform the CollectionCoordinator of aAbstractJournalRM.JournalFileabout to be evacuated.- Parameters:
jrnlFile- a journal file about to be evacuated
-
reclaimJournalFile
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
-