Class AbstractJournalRM
- java.lang.Object
-
- com.tangosol.io.journal.AbstractJournalRM
-
- All Implemented Interfaces:
Disposable,BinaryStoreManager,ClassLoaderAware,JournalMBean,Controllable,AutoCloseable
- Direct Known Subclasses:
FlashJournalRM,RamJournalRM
public abstract class AbstractJournalRM extends Object implements Controllable, Disposable, BinaryStoreManager, JournalMBean
The AbstractJournalRM represents a Journal Resource Manager that manages storage for journaled data, and acts as a shared resource for any number of journals that share a common configuration. This implementation is intended to support both file-based and memory-based implementations.The limits on the journal are as follows:
- Values are limited by default to 64MB;
- An individual file is limited by default to 2GB (and maximum 4GB);
- A journal is composed of up to 512 files;
- A journal is thus limited by default to 1TB, with a theoretical maximum of 2TB.
- Since:
- Coherence 3.7
- Author:
- cp/cf 2010-06-23
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractJournalRM.CollectorDaemonThe CollectorDaemon evaluates the JournalFile objects to see which ones should be evacuated, it evacuates those that should be, and it deletes those that have been successfully evacuated.static classAbstractJournalRM.DefaultDependenciesThe DefaultDependencies class provides a default implementation of Dependencies.protected static interfaceAbstractJournalRM.DependenciesThe Dependencies interface provides AbstractJournalRM with its external dependencies.protected classAbstractJournalRM.JournalFileA JournalFile object is created for each file used to store the journal contents.protected classAbstractJournalRM.JournalImplA Journal implementation managed by this Journal Resource Manager.
-
Field Summary
Fields Modifier and Type Field Description protected static booleanDEDUPE_ENABLEDWhether de-duping (interning) the byte arrays held by the BinaryRadixTree should be requested.protected AbstractJournalRM.JournalFile[]m_ajournalfileRegistry of JournalFile objects indexed by file id.protected intm_cJournalFilesThe number of JournalFiles that currently exist.protected AbstractJournalRM.CollectorDaemonm_daemonCollectorThe "garbage collector" thread that determines when journal files are ripe to be evacuated and deleted.protected doublem_dblFileSizeFactorThe size of the file as a ratio to the largest possible file size.protected AbstractJournalRM.Dependenciesm_dependenciesThe configuration used by this instance.protected doublem_dflHighestLoadFactorThe highest percentage (as a double in the range 0.00 to 1.00) of the configured capacity that this journal has reached.protected AbstractJournalRM.JournalFilem_jrnlfileThe current JournalFile.protected ClassLoaderm_loaderThe ClassLoader supplied to this Controllable instance.protected intm_nStateThe current state of the Resource Manager; one of the STATE_* constants.protected Set<AbstractJournalRM.JournalImpl>m_setJournalsRegistry of JournalImpl objects.protected static longMASK_COMPACT_FLAGThe 64-bit bitmask for the compact flag.protected static longMASK_COMPACT_LENGTHThe 64-bit bitmask for the compact length.protected static intSHIFT_COMPACT_FLAGThe location of the compact flag within the ticket.protected static intSHIFT_COMPACT_LENGTHThe location of the compact length within the ticket.protected static intSTATE_CONFIGUREDState: Configured (ready to be started).protected static intSTATE_INITIALState: Initial (unconfigured).protected static intSTATE_RUNNINGState: Running (able to be shut down or stopped).protected static intSTATE_STOPPEDState: Stopped.protected static intSTATE_STOPPINGState: Stopping.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractJournalRM(Cluster cluster, AbstractJournalRM.Dependencies deps)Construct anAbstractJournalRM.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected doublecalculateCurrentLoadFactor()Calculate current load factor for compaction (GC).abstract AbstractJournalRM.DefaultDependenciescloneDependencies(AbstractJournalRM.Dependencies deps)Clone the Dependencies object.voidclose()Deprecated.use the Disposable interfacevoidcompact(boolean fRegular)Execute either a regular or exhaustive compaction on the journal based on the provided parameter.voidconfigure(XmlElement xml)Configure the dependencies object given the xml configuration.JournalBinaryStorecreateBinaryStore()Create a new BinaryStore that will journal its information using this Journal Resource Manager.JournalcreateJournal(Journal.JournalConsumer consumer)Create a new Journal that exposes the storage capabilities of this Journal Resource Manager.voiddestroyBinaryStore(BinaryStore store)Lifecycle method: Destroy a BinaryStore previously created by this manager.voiddispose()Invoked when all resources owned by the implementer can safely be released.protected abstract longencodeTicket(int nFile, long of, int cb)Encode a file number, offset and length into a "ticket".protected longencodeTicket(ByteSequence bin)Encode a Binary into a "ticket".protected AbstractJournalRM.JournalFileensureCurrentJournalFile()Obtain the current JournalFile that is being appended to, creating a new one if necessary.protected BinaryextractBinary(long lTicket)Extract a Binary from the passed ticket.protected abstract intextractFileId(long lTicket)Extract a file index (a file ID) from the passed ticket.protected abstract intextractLength(long lTicket)Extract a file offset from the passed ticket.protected abstract longextractOffset(long lTicket)Extract a file offset from the passed ticket.intgetBinaryStoreCount()Determine the number of active BinaryStore objects that are using this Journal.protected ClustergetCluster()Returns theClusterfor which theAbstractJournalRMis storing data.protected AbstractJournalRM.CollectorDaemongetCollectorDaemon()Obtain the CollectorDaemon instance.doublegetCollectorLoadFactor()Determine the load factor threshold at which files become eligible for garbage collection (compaction).protected longgetCollectorTimeout()Return the number of milliseconds the Collector can be unresponsive prior to considering the Collector timed out.intgetCompactionCount()Determine the number of compactions (garbage collections) performed by this journal.ClassLoadergetContextClassLoader()Retrieve the context ClassLoader for this object.doublegetCurrentCollectorLoadFactor()Determine the current load factor threshold for the journal.AbstractJournalRM.DependenciesgetDependencies()Return the Dependencies object.protected StringgetDescription()Format the object attributes into a String for inclusion in the String returned from thetoString()method.protected abstract longgetEvacuationMask()Obtain the bit mask that is used to identify tickets that need to be evacuated for a particular file id.intgetExhaustiveCompactionCount()Determine the total number of exhaustive compactions performed by the collector.longgetExhaustiveCompactionTime()Return the total amount time spent performing exhaustive compaction.intgetFileCount()Determine the number of Journal files used by this Journal.protected GuardiangetGuardian()doublegetHighestLoadFactor()Determine the high-water mark load factor for the entire journal.protected AbstractJournalRM.JournalFilegetJournalFile(int nFileId)Obtain a JournalFile by its ID.protected longgetMaxCollectorSleepMillis()Determine the maximum sleep cycle between collections.longgetMaxFileSize()Determine the maximum allowable size, in bytes, of each individual file used to hold Journal data.protected intgetMaxJournalFiles()Determine the maximum number of journal files.intgetMaxJournalFilesNumber()Determine the maximum number of Journal files.protected longgetMaxJournalSize()Return the total amount of memory, in bytes, that can be allocated for Journal storage.intgetMaxValueSize()Determine the maximum allowable size, in bytes, of a Binary value.protected longgetMinCollectorSleepMillis()Determine the minimum sleep cycle between collections.protected abstract StringgetName()Returns the name value to be used in MBean Objectname key "name".protected intgetState()Determine the current state of the AbstractJournalRM.protected static StringgetStateDescription(int nState)Format the passed state identifier into a human-readable string.protected AbstractJournalRM.JournalFilegetSurvivorFile()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.protected StringgetTicketDescription(long lTicket)Format the information encoded in a ticket into a debug string.longgetTotalDataSize()Determine the amount of data currently stored by this Journal.longgetTotalFileSize()Determine the number of bytes in the Journal files for this Journal.protected AbstractJournalRM.CollectorDaemoninstantiateCollectorDaemon()Factory: Instantiate a CollectorDaemon.protected AbstractJournalRM.JournalImplinstantiateJournal()Factory: Instantiate a JournalImpl object.protected abstract AbstractJournalRM.JournalFileinstantiateJournalFile(int nFile)Factory: Instantiate a JournalFile or subclass thereof.protected booleanisCompact(long lTicket)Determine if the ticket is in the compact form.protected booleanisDedupEnabled()Determine if this journal resource manager should de-dup the keys that its JournalBinaryStore instances are managing.booleanisRunning()Determine whether or not the controllable service is running.protected booleanisSingleEvacuation()Determine if this journal resource manager should only evacuate one single JournalFile (at the most) per collection cycle.protected Iterator<AbstractJournalRM.JournalFile>iterateJournalFiles()Iterate all of the JournalFile objects.protected Iterator<AbstractJournalRM.JournalImpl>iterateJournals()Iterate through the Journal instances that have been created by this Journal Resource Manager but have not been disposed of yet.protected voidonDependencies(AbstractJournalRM.Dependencies deps)Process the Dependencies after they have been injected into this object.protected voidregisterJournal(AbstractJournalRM.JournalImpl journal)Register a Journal that uses this Journal Resource Manager.protected voidregisterMBean()Register an MBean for this JournalRM.voidresetStatistics()Reset the journal statistics.voidsetContextClassLoader(ClassLoader loader)Specify the context ClassLoader for this object.protected voidsetState(int nState)Modify the current state of the AbstractJournalRM.protected booleanshouldNotifyCollector()Check if the Collector daemon needs to be notified to come out of sleepvoidshutdown()Stop the controllable service.voidstart()Start the controllable service.protected voidstartThreads()Create and start the various threads used by this Journal Resource Manager.voidstop()Hard-stop the controllable service.protected voidstopThreads()Stop the various threads used by this Journal Resource Manager.StringtoString()protected voidunregisterJournal(AbstractJournalRM.JournalImpl journal)Register a Journal that uses this Journal Resource Manager.protected voidunregisterMBean()Unregister an MBean for this JournalRM.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tangosol.io.journal.JournalMBean
getBacklogCount, getBacklogSize, getBufferSize, getHighFileCount, getMaxBacklogSize, getMaxPoolSize, getMaxTotalRam, getPoolSize, isNioRam
-
-
-
-
Field Detail
-
STATE_INITIAL
protected static final int STATE_INITIAL
State: Initial (unconfigured).- See Also:
- Constant Field Values
-
STATE_CONFIGURED
protected static final int STATE_CONFIGURED
State: Configured (ready to be started).- See Also:
- Constant Field Values
-
STATE_RUNNING
protected static final int STATE_RUNNING
State: Running (able to be shut down or stopped).- See Also:
- Constant Field Values
-
STATE_STOPPING
protected static final int STATE_STOPPING
State: Stopping.- See Also:
- Constant Field Values
-
STATE_STOPPED
protected static final int STATE_STOPPED
State: Stopped.- See Also:
- Constant Field Values
-
SHIFT_COMPACT_FLAG
protected static final int SHIFT_COMPACT_FLAG
The location of the compact flag within the ticket.- See Also:
- Constant Field Values
-
MASK_COMPACT_FLAG
protected static final long MASK_COMPACT_FLAG
The 64-bit bitmask for the compact flag.The compact flag is the bit that signifies whether the ticket contains the actual value encoded into the long, versus a "proper" journal file ticket.
- See Also:
- Constant Field Values
-
SHIFT_COMPACT_LENGTH
protected static final int SHIFT_COMPACT_LENGTH
The location of the compact length within the ticket.- See Also:
- Constant Field Values
-
MASK_COMPACT_LENGTH
protected static final long MASK_COMPACT_LENGTH
The 64-bit bitmask for the compact length.- See Also:
- Constant Field Values
-
DEDUPE_ENABLED
protected static final boolean DEDUPE_ENABLED
Whether de-duping (interning) the byte arrays held by the BinaryRadixTree should be requested.
-
m_nState
protected int m_nState
The current state of the Resource Manager; one of the STATE_* constants.
-
m_dependencies
protected AbstractJournalRM.Dependencies m_dependencies
The configuration used by this instance.
-
m_loader
protected ClassLoader m_loader
The ClassLoader supplied to this Controllable instance. (Controllable extends ClassLoaderAware.)
-
m_dflHighestLoadFactor
protected double m_dflHighestLoadFactor
The highest percentage (as a double in the range 0.00 to 1.00) of the configured capacity that this journal has reached. In other words, this is a high water mark of how full the journal has ever gotten.
-
m_dblFileSizeFactor
protected double m_dblFileSizeFactor
The size of the file as a ratio to the largest possible file size. Used to tune the aggressiveness of the collection.
-
m_setJournals
protected final Set<AbstractJournalRM.JournalImpl> m_setJournals
Registry of JournalImpl objects.
-
m_ajournalfile
protected final AbstractJournalRM.JournalFile[] m_ajournalfile
Registry of JournalFile objects indexed by file id.
-
m_cJournalFiles
protected volatile int m_cJournalFiles
The number of JournalFiles that currently exist.
-
m_jrnlfile
protected volatile AbstractJournalRM.JournalFile m_jrnlfile
The current JournalFile.
-
m_daemonCollector
protected AbstractJournalRM.CollectorDaemon m_daemonCollector
The "garbage collector" thread that determines when journal files are ripe to be evacuated and deleted.
-
-
Constructor Detail
-
AbstractJournalRM
protected AbstractJournalRM(Cluster cluster, AbstractJournalRM.Dependencies deps)
Construct anAbstractJournalRM.- Parameters:
cluster- theClusterfor which theAbstractJournalRMis storing datadeps- the Dependencies object
-
-
Method Detail
-
configure
public void configure(XmlElement xml)
Configure the dependencies object given the xml configuration.- Specified by:
configurein interfaceControllable- Parameters:
xml- the XML configuration for the object
-
start
public void start()
Start the controllable service.This method should only be called once per the life cycle of the Controllable service. This method has no affect if the service is already running.
- Specified by:
startin interfaceControllable
-
isRunning
public boolean isRunning()
Determine whether or not the controllable service is running. This method returns false before a service is started, while the service is starting, while a service is shutting down and after the service has stopped. It only returns true after completing its start processing and before beginning its shutdown processing.- Specified by:
isRunningin interfaceControllable- Returns:
- true if the service is running; false otherwise
-
shutdown
public void shutdown()
Stop the controllable service. This is a controlled shut-down, and is preferred to theControllable.stop()method.This method should only be called once per the life cycle of the controllable service. Calling this method for a service that has already stopped has no effect.
- Specified by:
shutdownin interfaceControllable
-
stop
public void stop()
Hard-stop the controllable service. UseControllable.shutdown()for normal service termination. Calling this method for a service that has already stopped has no effect.- Specified by:
stopin interfaceControllable
-
getContextClassLoader
public ClassLoader getContextClassLoader()
Retrieve the context ClassLoader for this object. The context ClassLoader is provided by the creator of the object for use by the object when loading classes and resources.- Specified by:
getContextClassLoaderin interfaceClassLoaderAware- Returns:
- the context ClassLoader for this object
- See Also:
Thread.getContextClassLoader()
-
setContextClassLoader
public void setContextClassLoader(ClassLoader loader)
Specify the context ClassLoader for this object. The context ClassLoader can be set when the object is created, and allows the creator to provide the appropriate class loader to be used by the object when when loading classes and resources.- Specified by:
setContextClassLoaderin interfaceClassLoaderAware- Parameters:
loader- the context ClassLoader for this object
-
dispose
public void dispose()
Invoked when all resources owned by the implementer can safely be released.Once disposed of the object should no longer be considered to be usable.
Note the Disposable interface is compatible with try-with-resources which will automatically invoke this method.
- Specified by:
disposein interfaceDisposable
-
close
public void close()
Deprecated.use the Disposable interfacePrevious to the Disposable interface, clean-up was performed by invoking a close method via reflection.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDisposable
-
getMaxJournalFilesNumber
public int getMaxJournalFilesNumber()
Determine the maximum number of Journal files.- Specified by:
getMaxJournalFilesNumberin interfaceJournalMBean- Returns:
- the maximum number of simultaneous Journal files that will be used to store the contents of this Journal
-
getBinaryStoreCount
public int getBinaryStoreCount()
Determine the number of active BinaryStore objects that are using this Journal.- Specified by:
getBinaryStoreCountin interfaceJournalMBean- Returns:
- the number of BinaryStore objects that are currently active
-
getFileCount
public int getFileCount()
Determine the number of Journal files used by this Journal.- Specified by:
getFileCountin interfaceJournalMBean- Returns:
- the number of files for this journal
-
getTotalDataSize
public long getTotalDataSize()
Determine the amount of data currently stored by this Journal. This value does not include data that have been released.- Specified by:
getTotalDataSizein interfaceJournalMBean- Returns:
- the number of bytes for this Journal used to store Binary values that have not been released
-
getTotalFileSize
public long getTotalFileSize()
Determine the number of bytes in the Journal files for this Journal. This number could include released data that has not yet been compacted.- Specified by:
getTotalFileSizein interfaceJournalMBean- Returns:
- the total size of all Journal files for this Journal
-
getMaxValueSize
public int getMaxValueSize()
Determine the maximum allowable size, in bytes, of a Binary value.- Specified by:
getMaxValueSizein interfaceJournalMBean- Returns:
- the maximum allowable size for a value to write
-
getMaxFileSize
public long getMaxFileSize()
Determine the maximum allowable size, in bytes, of each individual file used to hold Journal data. This is not the total size limit of the Journal, since the Journal may use a number of files to store its data.- Specified by:
getMaxFileSizein interfaceJournalMBean- Returns:
- the maximum allowable size for an underlying file
-
getCollectorLoadFactor
public double getCollectorLoadFactor()
Determine the load factor threshold at which files become eligible for garbage collection (compaction). The load factor threshold is the ratio between the portion of the file used for live data and the total size of the file, and is expressed as a double value in the interval (0.0, 1.0).When the portion of released data exceeds (1 - threshold), the file becomes eligible for compaction (garbage collection).
- Specified by:
getCollectorLoadFactorin interfaceJournalMBean- Returns:
- the compaction factor threshold between 0.0 and 1.0
-
getCurrentCollectorLoadFactor
public double getCurrentCollectorLoadFactor()
Determine the current load factor threshold for the journal.- Specified by:
getCurrentCollectorLoadFactorin interfaceJournalMBean- Returns:
- the current load factor threshold between 0.0 and 1.0
-
getHighestLoadFactor
public double getHighestLoadFactor()
Determine the high-water mark load factor for the entire journal. The load factor is the ratio of the highest number of journal files that have concurrently existed to the maximum number of journal files that can concurrently exist.- Specified by:
getHighestLoadFactorin interfaceJournalMBean- Returns:
- the high-water journal load factor in the range 0.00 to 1.00
-
getCompactionCount
public int getCompactionCount()
Determine the number of compactions (garbage collections) performed by this journal.- Specified by:
getCompactionCountin interfaceJournalMBean- Returns:
- the number of compactions
-
getExhaustiveCompactionCount
public int getExhaustiveCompactionCount()
Determine the total number of exhaustive compactions performed by the collector. An exhaustive compaction is performed when there appears to be no memory available, however the garbage collector may have the ability reclaim memory via compaction.- Specified by:
getExhaustiveCompactionCountin interfaceJournalMBean- Returns:
- number of exhaustive compactions executed
-
getExhaustiveCompactionTime
public long getExhaustiveCompactionTime()
Return the total amount time spent performing exhaustive compaction.- Specified by:
getExhaustiveCompactionTimein interfaceJournalMBean- Returns:
- the total amount time spent performing exhaustive compaction
-
resetStatistics
public void resetStatistics()
Reset the journal statistics.- Specified by:
resetStatisticsin interfaceJournalMBean
-
compact
public void compact(boolean fRegular)
Execute either a regular or exhaustive compaction on the journal based on the provided parameter. The compaction is performed asynchronous to the invocation of this operation.An exhaustive compaction is only executed if sufficient memory has been released or sufficient time has elapsed since the previous exhaustive compaction.
- Specified by:
compactin interfaceJournalMBean- Parameters:
fRegular- whether the compaction should be regular; false for an exhaustive compaction
-
createBinaryStore
public JournalBinaryStore createBinaryStore()
Create a new BinaryStore that will journal its information using this Journal Resource Manager.- Specified by:
createBinaryStorein interfaceBinaryStoreManager- Returns:
- a new instance of JournalBinaryStore that uses this Journal Resource Manager for storage
-
destroyBinaryStore
public void destroyBinaryStore(BinaryStore store)
Lifecycle method: Destroy a BinaryStore previously created by this manager.- Specified by:
destroyBinaryStorein interfaceBinaryStoreManager- Parameters:
store- a BinaryStore object previously created by this manager
-
createJournal
public Journal createJournal(Journal.JournalConsumer consumer)
Create a new Journal that exposes the storage capabilities of this Journal Resource Manager.- Parameters:
consumer- the JournalConsumer that will be using the Journal- Returns:
- a new instance of Journal that uses this Journal Resource Manager for storage
-
getDependencies
public AbstractJournalRM.Dependencies getDependencies()
Return the Dependencies object.- Returns:
- the journal dependencies object
-
cloneDependencies
public abstract AbstractJournalRM.DefaultDependencies cloneDependencies(AbstractJournalRM.Dependencies deps)
Clone the Dependencies object.- Parameters:
deps- the populated Dependencies object- Returns:
- the cloned Dependencies object
-
onDependencies
protected void onDependencies(AbstractJournalRM.Dependencies deps)
Process the Dependencies after they have been injected into this object.- Parameters:
deps- the populated Dependencies object
-
getState
protected int getState()
Determine the current state of the AbstractJournalRM.- Returns:
- one of the STATE_* constants
-
setState
protected void setState(int nState)
Modify the current state of the AbstractJournalRM.- Parameters:
nState- one of the STATE_* constants
-
startThreads
protected void startThreads()
Create and start the various threads used by this Journal Resource Manager.
-
stopThreads
protected void stopThreads()
Stop the various threads used by this Journal Resource Manager.
-
calculateCurrentLoadFactor
protected double calculateCurrentLoadFactor()
Calculate current load factor for compaction (GC).- Returns:
- calculated load factor
-
getStateDescription
protected static String getStateDescription(int nState)
Format the passed state identifier into a human-readable string.- Parameters:
nState- a state identifier- Returns:
- a human-readable string for the state
-
getDescription
protected String getDescription()
Format the object attributes into a String for inclusion in the String returned from thetoString()method.- Returns:
- a comma-delimited String listing the attributes of this object in the form "attribute=value"
-
getMaxJournalFiles
protected int getMaxJournalFiles()
Determine the maximum number of journal files.- Returns:
- the maximum number of simultaneous journal files that will be used to store the contents of this journal
-
getMaxJournalSize
protected long getMaxJournalSize()
Return the total amount of memory, in bytes, that can be allocated for Journal storage.- Returns:
- the maximum number of bytes that can be allocated for Journal storage
-
getMinCollectorSleepMillis
protected long getMinCollectorSleepMillis()
Determine the minimum sleep cycle between collections.- Returns:
- the minimum number of milliseconds to sleep between collections
-
getMaxCollectorSleepMillis
protected long getMaxCollectorSleepMillis()
Determine the maximum sleep cycle between collections.- Returns:
- the maximum number of milliseconds to sleep between collections
-
isDedupEnabled
protected boolean isDedupEnabled()
Determine if this journal resource manager should de-dup the keys that its JournalBinaryStore instances are managing.- Returns:
- true iff this journal resource manager should routinely cause its JournalBinaryStore instances to de-dup their keys
-
isSingleEvacuation
protected boolean isSingleEvacuation()
Determine if this journal resource manager should only evacuate one single JournalFile (at the most) per collection cycle.- Returns:
- true iff this journal resource manager should only evacuate the emptiest JournalFile instead of all the JournalFile instances that qualify for evacuation
-
getSurvivorFile
protected AbstractJournalRM.JournalFile getSurvivorFile()
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:
- either a JournalFile whose usage triggers a full collection or
a JournalFile used exclusively by the CollectorDaemon.
nullmay be returned if it is determined that an exhaustive evacuation will not reclaim sufficient memory
-
registerMBean
protected void registerMBean()
Register an MBean for this JournalRM.
-
unregisterMBean
protected void unregisterMBean()
Unregister an MBean for this JournalRM.
-
instantiateJournal
protected AbstractJournalRM.JournalImpl instantiateJournal()
Factory: Instantiate a JournalImpl object.- Returns:
- a JournalImpl instance or subclass thereof
-
registerJournal
protected void registerJournal(AbstractJournalRM.JournalImpl journal)
Register a Journal that uses this Journal Resource Manager.- Parameters:
journal- an instance of JournalImpl created by this Journal Resource Manager
-
unregisterJournal
protected void unregisterJournal(AbstractJournalRM.JournalImpl journal)
Register a Journal that uses this Journal Resource Manager.- Parameters:
journal- an instance of JournalImpl created by this Journal Resource Manager
-
iterateJournals
protected Iterator<AbstractJournalRM.JournalImpl> iterateJournals()
Iterate through the Journal instances that have been created by this Journal Resource Manager but have not been disposed of yet.- Returns:
- an Iterator of the current JournalImpl instances
-
getJournalFile
protected AbstractJournalRM.JournalFile getJournalFile(int nFileId)
Obtain a JournalFile by its ID.- Parameters:
nFileId- the file id (0-511)- Returns:
- the JournalFile for that file id, or null if there is currently no JournalFile for that file id
-
ensureCurrentJournalFile
protected AbstractJournalRM.JournalFile ensureCurrentJournalFile()
Obtain the current JournalFile that is being appended to, creating a new one if necessary.- Returns:
- the current JournalFile, or null if the storage is full and no new JournalFile can be created as a result
-
iterateJournalFiles
protected Iterator<AbstractJournalRM.JournalFile> iterateJournalFiles()
Iterate all of the JournalFile objects.- Returns:
- an Iterator of the existing JournalFile instances
-
instantiateJournalFile
protected abstract AbstractJournalRM.JournalFile instantiateJournalFile(int nFile)
Factory: Instantiate a JournalFile or subclass thereof.- Parameters:
nFile- the file number in the range 0-511 (inclusive)- Returns:
- a new JournalFile instance
-
instantiateCollectorDaemon
protected AbstractJournalRM.CollectorDaemon instantiateCollectorDaemon()
Factory: Instantiate a CollectorDaemon.- Returns:
- a CollectorDaemon or a sub-class thereof
-
getCollectorDaemon
protected AbstractJournalRM.CollectorDaemon getCollectorDaemon()
Obtain the CollectorDaemon instance.- Returns:
- the CollectorDaemon for this Journal Resource Manager
-
isCompact
protected boolean isCompact(long lTicket)
Determine if the ticket is in the compact form.- Parameters:
lTicket- a "ticket" that was created by the Journal- Returns:
- true iff the ticket is a compact ticket
-
getEvacuationMask
protected abstract long getEvacuationMask()
Obtain the bit mask that is used to identify tickets that need to be evacuated for a particular file id.- Returns:
- the the bit mask for the file index within a ticket and whatever other bits are necessary to ensure that a ticket refers to that file
-
extractFileId
protected abstract int extractFileId(long lTicket)
Extract a file index (a file ID) from the passed ticket.- Parameters:
lTicket- a "ticket" that was created by the Journal- Returns:
- the file index for the value represented by that ticket
-
extractOffset
protected abstract long extractOffset(long lTicket)
Extract a file offset from the passed ticket.- Parameters:
lTicket- a "ticket" that was created by the Journal- Returns:
- the file offset for the value represented by that ticket
-
extractLength
protected abstract int extractLength(long lTicket)
Extract a file offset from the passed ticket.- Parameters:
lTicket- a "ticket" that was created by the Journal- Returns:
- the file offset for the value represented by that ticket
-
encodeTicket
protected abstract long encodeTicket(int nFile, long of, int cb)Encode a file number, offset and length into a "ticket".- Parameters:
nFile- a file number (aka a file index)of- a value offsetcb- a value length- Returns:
- a "ticket" containing the file number, offset and length
-
encodeTicket
protected long encodeTicket(ByteSequence bin)
Encode a Binary into a "ticket".- Parameters:
bin- a ByteSequence with (length() <= 7)- Returns:
- a compact "ticket" containing the passed Binary value
-
extractBinary
protected Binary extractBinary(long lTicket)
Extract a Binary from the passed ticket.- Parameters:
lTicket- a compact "ticket" that was created by the Journal- Returns:
- the Binary encoded into the ticket
-
getTicketDescription
protected String getTicketDescription(long lTicket)
Format the information encoded in a ticket into a debug string.- Parameters:
lTicket- the ticket value- Returns:
- a description of the contents of the ticket value
-
shouldNotifyCollector
protected boolean shouldNotifyCollector()
Check if the Collector daemon needs to be notified to come out of sleep- Returns:
- true if collector daemon should be notified
-
getCluster
protected Cluster getCluster()
Returns theClusterfor which theAbstractJournalRMis storing data.- Returns:
- the
Cluster
-
getGuardian
protected Guardian getGuardian()
- Returns:
- the Guardian associated with the Cluster or null
-
getCollectorTimeout
protected long getCollectorTimeout()
Return the number of milliseconds the Collector can be unresponsive prior to considering the Collector timed out.- Returns:
- the number of milliseconds the Collector can be unresponsive
-
getName
protected abstract String getName()
Returns the name value to be used in MBean Objectname key "name".- Returns:
- the name
-
-