|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
com.tangosol.io.journal.AbstractJournalRM
com.tangosol.io.journal.FlashJournalRM
public class FlashJournalRM
A FlashJournalRM manages disk I/O for temporary journal-based files, and acts as a shared resource for any number of journals that share a common configuration.
To use the Resource Manager, configure it (either by XML using configure(XmlElement), or by calling the appropriate setter methods such as setDirectory(File)). Once configured, start the Resource Manager via the AbstractJournalRM.start() method, and then obtain BinaryStore instances via the AbstractJournalRM.createBinaryStore() method. When a BinaryStore instance is no longer required, dispose of it via the Disposable interface, and similarly stop() or AbstractJournalRM.dispose() of the Resource Manager when it is no longer needed to ensure that any resources it allocated are cleaned up and released.
While the Resource Manager is running, there will be one or more files created in the specified temporary directory (or the default temporary directory if none is specified). The number of files is not related to the number of BinaryStore instances, but rather to the total amount of data that the Resource Manager is managing at any given time. Additionally, the Resource Manager uses three daemon threads to help manage the data: "Journal-Preparer", "Journal-Writer" and "Journal-Collector". These threads respectively lay out the data to be written, write the data, and perform asynchronous GC of the storage files.
The limits on the journal are as follows:
| Nested Class Summary | |
|---|---|
protected static class |
FlashJournalRM.BufferA Buffer is a handy shell with some helper methods around a byte[] and a ByteBuffer. |
protected static class |
FlashJournalRM.BufferPoolThe BufferPool class recycles up to a maximum number of Buffer objects. |
protected class |
FlashJournalRM.JournalFileA JournalFile is created for each OS file used to store the journal contents. |
protected class |
FlashJournalRM.PreparerDaemonThe PreparerDaemon takes the enqueued Binary values for the JournalFile objects, and lays them out in Buffer objects from the BufferPool, enqueuing them for the WriterDaemon to write. |
protected class |
FlashJournalRM.WriterDaemonThe WriterDaemon takes the enqueued Buffer objects from the PreparerDaemon, and appends them to a JournalFile. |
| Nested classes/interfaces inherited from class com.tangosol.io.journal.AbstractJournalRM |
|---|
AbstractJournalRM.CollectorDaemon, AbstractJournalRM.JournalImpl |
| Field Summary | |
|---|---|
static int |
DFT_BACKLOG_SIZEDefault maximum backlog (16MB). |
static int |
DFT_BLOCK_SIZEDefault block size (256KB). |
static double |
DFT_COLLECT_PCTDefault collection factor (collect files that are 25% or less utilized). |
static long |
DFT_FILE_SIZEDefault size of a file (2GB). |
static int |
DFT_POOL_SIZEDefault pool size (16MB). |
static int |
DFT_PURGE_DELAY_MILLISDefault delay until a tmp file is eligible for purging. 2 hours is the default. |
protected java.util.concurrent.atomic.AtomicInteger |
m_cbBacklogTotal amount of data enqueued to be written. |
protected int |
m_cbBlockBlock size for appending to files. |
protected int |
m_cbMaxBacklogConfigurable maximum backlog; defaults to 16MB. |
protected int |
m_cMaxPooledBlocksMaximum number of pooled blocks. |
protected long |
m_cPurgeDelayMillisThe delay from the last touch of a tmp file until it is eligible for purging. |
protected FlashJournalRM.PreparerDaemon |
m_daemonPreparerThe "rendering" thread that renders (copies and encrypts) the queued binaries into buffers to be written. |
protected FlashJournalRM.WriterDaemon |
m_daemonWriterThe "writing" thread that just does appends of prepared buffers to journal files. |
protected java.io.File |
m_dirTempDirectory to store the temporary files. |
protected boolean |
m_fLoggedDirectorySet to true after the directory location has been logged. |
protected java.util.concurrent.ConcurrentMap |
m_mapLocatorsMap of locators to Binary values that have been queued to be written. |
protected FlashJournalRM.BufferPool |
m_poolThe BufferPool of Buffer objects that are used to format data to append to the journal. |
protected static long |
MASK_FILE_IDThe 64-bit bitmask for the file index. |
protected static long |
MASK_LENGTHThe 64-bit bitmask for the value length. |
protected static long |
MASK_OFFSETThe 64-bit bitmask for the value offset. |
static int |
MAX_BACKLOG_SIZEMaximum backlog size (1GB). |
static int |
MAX_BLOCK_SIZEMaximum block size (1MB). |
static long |
MAX_FILE_SIZEMaximum size of a file (4GB). |
static int |
MAX_POOL_SIZEMaximum pool size (1GB). |
static int |
MAX_VALUE_SIZEMaximum value size (64MB). |
static int |
MIN_BACKLOG_SIZEMinimum backlog size (4KB). |
static int |
MIN_BLOCK_SIZEMinimum block size (4KB). |
static long |
MIN_FILE_SIZEMinimum maximum size of a file (1MB). |
protected static int |
SHIFT_FILE_IDThe location of the file id within the ticket. |
protected static int |
SHIFT_LENGTHThe location of the value-length within the ticket. |
protected static int |
SHIFT_OFFSETThe location of the value-offset within the ticket. |
protected static int |
SHIFT_OFFSET_RAWFrom an encoding point of view, the raw offset is shifted four bits less than necessary, because the four least significant bits of the offset are always zero (due to paragraph alignment). |
| Fields inherited from class com.tangosol.io.journal.AbstractJournalRM |
|---|
m_ajournalfile, m_cbMaxFile, m_cbMaxValue, m_cJournalFiles, m_daemonCollector, m_dflHighestLoadFactor, m_dflLoadFactorGC, m_jrnlfile, m_loader, m_nState, m_setJournals, m_xmlConfig, MASK_COMPACT_FLAG, MASK_COMPACT_LENGTH, MAX_COLLECT_PCT, MIN_COLLECT_PCT, SHIFT_COMPACT_FLAG, SHIFT_COMPACT_LENGTH, STATE_CONFIGURED, STATE_INITIAL, STATE_RUNNING, STATE_STOPPED, STATE_STOPPING |
| Constructor Summary | |
|---|---|
FlashJournalRM(Cluster cluster)Construct a FlashJournalRM. |
|
| Method Summary | |
|---|---|
protected void |
applyConfig(java.lang.String sName, XmlElement xmlConfig)Parse the XML configuration for the specified setting name, and configure the Journal Resource Manager accordingly. |
void |
configure(XmlElement xml)The Flash Journal Resource Manager supports the following additional configuration options above the configuration options for AbstractJournalRM. |
protected long |
encodeTicket(int nFile, long of, int cb)Encode a file number, offset and length into a "ticket". |
protected FlashJournalRM.JournalFile |
ensureCurrentJournalFile()Obtain the current JournalFile that is being appended to, creating a new one if necessary. |
protected int |
extractFileId(long lTicket)Extract a file index (a file ID) from the passed ticket. |
protected int |
extractLength(long lTicket)Extract a file offset from the passed ticket. |
protected long |
extractOffset(long lTicket)Extract a file offset from the passed ticket. |
int |
getBacklogCount()Determine the number of serialized values that have not yet been persisted to disk. |
int |
getBacklogSize()Determine the total size in bytes of the serialized values that have not yet been persisted to disk. |
protected FlashJournalRM.BufferPool |
getBufferPool()Obtain the BufferPool instance. |
int |
getBufferSize()Determine the size of the buffers used to write a chunk of data at a time to an underlying journal file. |
protected double |
getDefaultCollectorLoadFactor()Determine the default percentage at which a file is eligible for garbage collection. |
protected long |
getDefaultMaxFileSize()Determine the default maximum file size for this Journal Resource Manager. |
protected int |
getDefaultMaxValueSize()Determine the default maximum value size for this Journal Resource Manager. |
protected java.lang.String |
getDescription()Format the object attributes into a String for inclusion in the String returned from the AbstractJournalRM.toString() method. |
java.io.File |
getDirectory()Determine the directory used to store the underlying disk files for the journal. |
protected long |
getEvacuationMask()Obtain the bit mask that is used to identify tickets that need to be evacuated for a particular file id. |
protected FlashJournalRM.JournalFile |
getJournalFile(int nFileId)Obtain a JournalFile by its ID. |
int |
getMaxBacklogSize()Determine the maximum allowable size, in bytes, of the backlog; when the backlog reaches this level, writes are delayed until the backlog drops below its maximum. |
long |
getMaxPoolSize()Determine the maximum size (in bytes) of the buffers that can be held by the pool. |
long |
getMaxTotalRam()Determine the total amount, in bytes, of RAM that will be used for the Journal. |
int |
getPoolSize()Determine the size (in bytes) of the buffers that are currently available in the pool. |
protected FlashJournalRM.PreparerDaemon |
getPreparerDaemon()Obtain the PreparerDaemon instance. |
long |
getPurgeDelayMillis()Return the delay since the last touch of a tmp file until it is eligible for purging. |
protected FlashJournalRM.WriterDaemon |
getWriterDaemon()Obtain the WriterDaemon instance. |
protected FlashJournalRM.BufferPool |
instantiateBufferPool()Factory: Instantiate a pool of buffers. |
protected FlashJournalRM.JournalFile |
instantiateJournalFile(int nFile)Factory: Instantiate a JournalFile or subclass thereof. |
protected FlashJournalRM.PreparerDaemon |
instantiatePreparerDaemon()Factory: Instantiate a PreparerDaemon. |
protected FlashJournalRM.WriterDaemon |
instantiateWriterDaemon()Factory: Instantiate a WriterDaemon. |
boolean |
isNioRam()Determine if the journal will use direct buffers (NIO RAM) instead of on-heap buffers (byte arrays). |
protected void |
purgeOldTempFiles()Delete any old temp files that weren't cleaned up properly by a previous instance of the FlashJournalRM. |
void |
setBufferSize(int cb)Configure the size of the write buffers. |
void |
setDirectory(java.io.File dirTemp)Configure the directory to use for journal files. |
void |
setMaxBacklogSize(int cb)Specify the size, in bytes, of the maximum backlog. |
void |
setMaxFileSize(long cb)Configure the maximum size of the underlying journal files. |
void |
setMaxPoolSize(int cb)Configure the size of the write buffers pool. |
void |
setMaxValueSize(int cb)Specify the maximum size, in bytes, of Binary values to store. |
void |
setPurgeDelayMillis(long cPurgeDelayMillis)Sets the delay from the last touch of a tmp file until it is eligible for purging. |
protected void |
startThreads()Create and start the various threads used by this Journal Resource Manager. |
void |
stop()Hard-stop the controllable service. |
protected void |
stopThreads()Stop the various threads used by this Journal Resource Manager. |
| Field Detail |
|---|
protected static final int SHIFT_FILE_ID
protected static final long MASK_FILE_ID
protected static final int SHIFT_OFFSET
protected static final int SHIFT_OFFSET_RAW
protected static final long MASK_OFFSET
Note that the least significant four bits of the offset MUST ALWAYS be zero, because they are NOT encoded into the ticket -- hence the 16-byte paragraph boundary for entries.
protected static final int SHIFT_LENGTH
protected static final long MASK_LENGTH
public static final int MAX_VALUE_SIZE
public static final int MIN_BACKLOG_SIZE
public static final int MAX_BACKLOG_SIZE
public static final int DFT_BACKLOG_SIZE
public static final long MIN_FILE_SIZE
public static final long MAX_FILE_SIZE
public static final long DFT_FILE_SIZE
public static final int MIN_BLOCK_SIZE
public static final int MAX_BLOCK_SIZE
public static final int DFT_BLOCK_SIZE
public static final int MAX_POOL_SIZE
public static final int DFT_POOL_SIZE
public static final double DFT_COLLECT_PCT
public static final int DFT_PURGE_DELAY_MILLIS
protected java.io.File m_dirTemp
protected boolean m_fLoggedDirectory
protected java.util.concurrent.atomic.AtomicInteger m_cbBacklog
protected int m_cbMaxBacklog
protected int m_cbBlock
protected int m_cMaxPooledBlocks
protected long m_cPurgeDelayMillis
protected java.util.concurrent.ConcurrentMap m_mapLocators
protected FlashJournalRM.BufferPool m_pool
protected FlashJournalRM.PreparerDaemon m_daemonPreparer
protected FlashJournalRM.WriterDaemon m_daemonWriter
| Constructor Detail |
|---|
public FlashJournalRM(Cluster cluster)
cluster - the Cluster for which the FlashJournalRM is storing data| Method Detail |
|---|
public void configure(XmlElement xml)
AbstractJournalRM.
configure in interface Controllableconfigure in class AbstractJournalRMxml - the XmlElement containing the configurationpublic void stop()
Controllable.shutdown() for normal service termination. Calling this method for a service that has already stopped has no effect.stop in interface Controllablestop in class AbstractJournalRMpublic long getMaxTotalRam()
This property is specific to a RamJournalRM implementation.
public boolean isNioRam()
This property is specific to a RamJournalRM implementation.
public int getMaxBacklogSize()
This property is specific to a FlashJournalRM implementation.
public int getBacklogSize()
This property is specific to a FlashJournalRM implementation.
public int getBacklogCount()
This property is specific to a FlashJournalRM implementation.
public int getBufferSize()
This property is specific to a FlashJournalRM implementation.
public long getMaxPoolSize()
public int getPoolSize()
This property is specific to a FlashJournalRM implementation.
public void setMaxValueSize(int cb)
MAX_VALUE_SIZE.
Note: This value can be modified while the ResourceManager is running.
setMaxValueSize in class AbstractJournalRMcb - the maximum allowable size for a Binary value, or zero to specify no configured maximum for the value sizepublic void setMaxBacklogSize(int cb)
DFT_BACKLOG_SIZE, with a minimum defined by MIN_BACKLOG_SIZE and a maximum defined by MAX_BACKLOG_SIZE. The backlog is the amount of data that has been "dropped off" for the journal to write to disk, but which has not yet been written to disk; when the amount of backlog exceeds the maximum configured backlog, client threads attempting to "drop off" data are blocked until the backlog recedes below the maximum, thus helping to prevent out-of-memory conditions. Note that the maximum amount of memory used by the backlog is at least twice the configured amount, since the data dropped off is held in it Binary form and rendered to the write-behind buffers.
Note: This value can be modified while the ResourceManager is running.
cb - the maximum allowable size of the backlogpublic void setBufferSize(int cb)
DFT_BLOCK_SIZE, with a minimum defined by MIN_BLOCK_SIZE and a maximum defined by MAX_BLOCK_SIZE.
Note: This value can only be set before the ResourceManager is started.
cb - the size, in bytes, for the buffers to write to the underlying journal filespublic void setMaxPoolSize(int cb)
DFT_POOL_SIZE, with a maximum defined by MAX_POOL_SIZE and a minimum enforced as the size of a single buffer.
Note: This value can only be set before the ResourceManager is started.
cb - the size, in bytes, for the buffer poolpublic java.io.File getDirectory()
public void setDirectory(java.io.File dirTemp)
Note: This value can only be set before the ResourceManager is started.
dirTemp - the directory to use for journal filespublic void setMaxFileSize(long cb)
Note: This value can only be set before the ResourceManager is started.
The file size must be a multiple of the block size; if it is not, it will be rounded down to the nearest block size, but will not result in a file size less than one block. If setting both the block and file size, set the block size first, since changing the block size will adjust the file size to ensure that it is a multiple of the block size.
setMaxFileSize in class AbstractJournalRMcb - the maximum size, in bytes, for journal filespublic long getPurgeDelayMillis()
public void setPurgeDelayMillis(long cPurgeDelayMillis)
cPurgeDelayMillis - the delay in milliseconds
protected void applyConfig(java.lang.String sName,
XmlElement xmlConfig)
applyConfig in class AbstractJournalRMsName - the name of the XML settingxmlConfig - the XML element containing the settingprotected void startThreads()
startThreads in class AbstractJournalRMprotected void purgeOldTempFiles()
protected void stopThreads()
stopThreads in class AbstractJournalRMprotected java.lang.String getDescription()
AbstractJournalRM.toString() method.getDescription in class AbstractJournalRMprotected long getDefaultMaxFileSize()
getDefaultMaxFileSize in class AbstractJournalRMprotected int getDefaultMaxValueSize()
getDefaultMaxValueSize in class AbstractJournalRMprotected double getDefaultCollectorLoadFactor()
getDefaultCollectorLoadFactor in class AbstractJournalRMprotected FlashJournalRM.JournalFile getJournalFile(int nFileId)
getJournalFile in class AbstractJournalRMnFileId - the file id (0-511)protected FlashJournalRM.JournalFile ensureCurrentJournalFile()
ensureCurrentJournalFile in class AbstractJournalRMprotected FlashJournalRM.JournalFile instantiateJournalFile(int nFile)
instantiateJournalFile in class AbstractJournalRMnFile - the file number in the range 0-511 (inclusive)protected FlashJournalRM.BufferPool instantiateBufferPool()
protected FlashJournalRM.BufferPool getBufferPool()
protected FlashJournalRM.PreparerDaemon instantiatePreparerDaemon()
protected FlashJournalRM.PreparerDaemon getPreparerDaemon()
protected FlashJournalRM.WriterDaemon instantiateWriterDaemon()
protected FlashJournalRM.WriterDaemon getWriterDaemon()
protected long getEvacuationMask()
getEvacuationMask in class AbstractJournalRMprotected int extractFileId(long lTicket)
extractFileId in class AbstractJournalRMlTicket - a "ticket" that was created by the Journalprotected long extractOffset(long lTicket)
extractOffset in class AbstractJournalRMlTicket - a "ticket" that was created by the Journalprotected int extractLength(long lTicket)
extractLength in class AbstractJournalRMlTicket - a "ticket" that was created by the Journal
protected long encodeTicket(int nFile,
long of,
int cb)
encodeTicket in class AbstractJournalRMnFile - a file number (aka a file index)of - a value offsetcb - a value length
|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||