|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.root.RootObject
com.neeve.ods.OdsObject
com.neeve.ods.impl.StorePacketPersisterBase
com.neeve.rog.log.RogLog
public final class RogLog
The ROG transaction log
Nested Class Summary | |
---|---|
static class |
RogLog.CheckpointState
Enumerates the state of entries being checkpointed in the log |
static class |
RogLog.Entry
Represents a transaction log entry Threading: RogLog.Entry s are not safe for concurrent access by multiple threads. |
static class |
RogLog.Stats
Holds transaction log statistics. |
Nested classes/interfaces inherited from interface com.neeve.ods.IStorePersister |
---|
IStorePersister.ErrorHandler, IStorePersister.LogEmptinessExpectation, IStorePersister.LogPresenceExpectation, IStorePersister.StartupExpectation |
Nested classes/interfaces inherited from interface com.neeve.ods.IStoreWriter |
---|
IStoreWriter.LogCounters, IStoreWriter.Parameters |
Nested classes/interfaces inherited from interface com.neeve.ods.IStoreReader |
---|
IStoreReader.ReadCallback |
Field Summary | |
---|---|
static String |
PROP_AUTO_FLUSH_SIZE
Property used to specify the log's auto flush size. |
static String |
PROP_AUTO_REPAIR
Property used to indicate whether should attempt to repair files on open. |
static String |
PROP_CDC_ENABLED
Property used to indicate whether CDC is enabled on the log If CDC is not enabled, then a CDC processor run on a log will not dispatch any events. |
static String |
PROP_COMPACTION_THRESHOLD
Property used to indicate the log compaction threshold The log compaction threshold is the size (in megabytes) that triggers a log compaction. |
static String |
PROP_DETACHED_MESSAGE_SERIALIZATION
Property used to indicate that serialization of messages logged via log(IRogMessage) should be deferred to the detached writer when operating
in detached mode. |
static String |
PROP_FLUSH_USING_MAPPED_MEMORY
Property used to indicate that flush should be performed using a memory mapped region of the log rather than via a RandomAccessFile handle |
static String |
PROP_INITIAL_LOG_LENGTH
Property used to set the initial file length of the log in gigabytes. |
static float |
PROP_INITIAL_LOG_LENGTH_DEFAULT
The default value for PROP_INITIAL_LOG_LENGTH . |
static String |
PROP_IS_PURE_MESSAGE_LOGGER
Property used to indicate that this log is for message logging only. |
static String |
PROP_LOG_MODE
Property used to indicate that mode in which the log should be opened |
static String |
PROP_LOG_SCAVENGE_POLICY
Property used to indicate policy used to scavenge logs A log with number N is considered a candidate for scavenging when N < live log number and N < CDC log number. |
static String |
PROP_MAX_COMPACTION_WINDOW_SIZE
Property used to indicate the max log compaction window size The log compaction window is the approximate maximum size (in megabytes) rounded up to the end of the nearest checkpoint that a compact operation uses to determine how many log entries it will hold in memory. |
static String |
PROP_PAGE_SIZE
Property used to specify the log's page size. |
static String |
PROP_STORE_ROOT
Property used to indicate the directory in which the log should be placed. |
static String |
PROP_ZERO_OUT_INITIAL
Property used to indicate whether the log should be zeroed out when freshly created This property is only applicable if PROP_INITIAL_LOG_LENGTH is set. |
Fields inherited from class com.neeve.ods.impl.StorePacketPersisterBase |
---|
PROP_DETACHED, PROP_DETACHED_QUEUE_DEPTH, PROP_DETACHED_QUEUE_DRAINER_CPU_AFFINITIZATION_MASK, PROP_DETACHED_QUEUE_OFFER_STRATEGY, PROP_DETACHED_QUEUE_WAIT_STRATEGY, PROP_FLUSH_ON_COMMIT, PROP_SHARED |
Method Summary | |
---|---|
File |
archive(File archiveFolder,
String archiveId)
Archives a transaction log's files to the specified folder, using the given archive id. |
RogLogRepository |
asRepository()
Return the log as a query repository |
String |
backupLog(boolean shrinkToSize)
Backup a persister's log file. |
static String |
backupLog(String logName,
Properties props,
boolean shrinkToSize)
Convenience method for backing up a log file. |
void |
close()
Implementation of IStorePersister.close() and IRogMessageLogger.open() |
static RogLog |
create(String name)
Create a new log. |
static RogLog |
create(String name,
Properties props)
Create a new log using a set of properties to configure it |
static RogLog |
create(String name,
StorePersisterDescriptor descriptor)
Create a new log using a store persister descriptor to configure it. |
RogLogCdcProcessor |
createCdcProcessor(IRogChangeDataCaptureHandler handler)
Create a log CDC processor. |
RogLogReader |
createReader()
Create a reader of the live log file. |
RogLogReader |
createReader(int logNumber)
Create a private reader of the numbered log file. |
void |
delete()
Delete a log file and associated metadata files |
void |
fail()
Force fail the log. |
void |
fail(Exception cause)
Force fail the log. |
static void |
failOpen(boolean val)
Force fail the next open. |
void |
flush(boolean sync)
Implementation of IRogMessageLogger.flush(boolean) |
long |
getAllocatedSize()
Get the log file's allocated size. |
RogLog.CheckpointState |
getCheckpointState()
Get the log's checkpoint state |
long |
getCompactionThreshold()
Get the compaction threshold |
RogLogCompactor |
getCompactor()
Get the log compactor |
StorePersisterDescriptor |
getDescriptor()
Implementation of IStorePersister.getDescriptor()
Note: This method will return null if the log was created directly using
a property table rather than a store persister descriptor. |
IStorePersister.ErrorHandler |
getErrorHandler()
Implementation of IStorePersister.getErrorHandler() |
File |
getLogFile()
Get the underlying log file |
com.eaio.uuid.UUID |
getLogUUID()
Get the log UUID. |
RogLogMetadata |
getMetadata()
Get the log metadata |
File |
getMetadataFile()
Get the underlying log metadata file |
String |
getName()
Implementation of IStorePersister.getName() and IRogMessageLogger.getName() |
long |
getSize()
Get the log file size. |
IStorePersisterStats |
getStats()
Implementation of IStorePersister.getStats() |
boolean |
isOpen()
Implementation of IStorePersister.isOpen() |
void |
log(IRogMessage message)
Log a message. |
void |
log(IRogMessage message,
boolean commitEnd)
Implementation of IRogMessageLogger.log(IRogMessage, boolean) |
void |
open()
Implementation of IStorePersister.open(com.neeve.pkt.PktBuffer, boolean) and IRogMessageLogger.open() |
void |
open(PktBuffer serializedMetadata,
boolean truncateLive)
Implementation of IStorePersister.open(PktBuffer, boolean) |
void |
read(IStoreReader.ReadCallback cb)
Implementation of IStoreReader.read(com.neeve.ods.IStoreReader.ReadCallback) |
void |
read(IStoreReader.ReadCallback cb,
int flags)
Implementation of IStoreReader.read(com.neeve.ods.IStoreReader.ReadCallback) |
void |
readMetadata(PktBuffer buffer)
Implementation of IStoreReader.readMetadata(com.neeve.pkt.PktBuffer) |
void |
scheduleCompactionOnNextWrite()
Schedule a compaction to occur on the next write |
void |
setCompactionThreshold(int val)
Set the compaction threshold |
void |
setErrorHandler(IStorePersister.ErrorHandler errorHandler)
Implementation of IStorePersister.setErrorHandler(com.neeve.ods.IStorePersister.ErrorHandler) |
void |
setIsPureMessageLogger(boolean isPureMessageLogger)
Marks this RogLog as being purely for message logging purposes. |
void |
setStartupExpectation(IStorePersister.StartupExpectation expectation,
Enum<?> value)
Implementation of IStorePersister.setStartupExpectation(com.neeve.ods.IStorePersister.StartupExpectation, java.lang.Enum>) |
String |
toString()
|
boolean |
wasRepaired()
Implementation of IStorePersister.wasRepaired() |
Methods inherited from class com.neeve.ods.impl.StorePacketPersisterBase |
---|
getParameters, isShared, onRoleChange, sync, writeCommitEntry |
Methods inherited from class com.neeve.root.RootObject |
---|
getChecked, getThreaded, getTracer, setChecked, setTracer |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.neeve.ods.IStoreWriter |
---|
getParameters, isShared, onRoleChange, sync, writeCommitEntry |
Field Detail |
---|
public static final String PROP_STORE_ROOT
public static final String PROP_INITIAL_LOG_LENGTH
The initial length of the recovery log this can be set to the maximum size to which the log is expected to grow to avoid costs with growing the file.
public static final float PROP_INITIAL_LOG_LENGTH_DEFAULT
PROP_INITIAL_LOG_LENGTH
.
public static final String PROP_ZERO_OUT_INITIAL
This property is only applicable if PROP_INITIAL_LOG_LENGTH
is set. If set
to true, then the log is zeroed out after initial creation.
public static final String PROP_AUTO_REPAIR
public static final String PROP_CDC_ENABLED
If CDC is not enabled, then a CDC processor run on a log will not dispatch any events. If CDC is not enabled on a log and then reenabled later, CDC will start from the live log at the time the CDC is enabled. If a compaction occurred while CDC was disabled, then the change events that occurred during that time will be lost.
public static final String PROP_COMPACTION_THRESHOLD
The log compaction threshold is the size (in megabytes) that triggers a log compaction. The act of compacting a log will compact as many complete checkpoints in the log and switch the live log over to the compacted log. A threshold value of <= 0 disables live log compaction.
public static final String PROP_MAX_COMPACTION_WINDOW_SIZE
The log compaction window is the approximate maximum size (in megabytes) rounded up to the end of the nearest checkpoint that a compact operation uses to determine how many log entries it will hold in memory. The more entries the compactor can hold in memory while performing a compaction, the more efficient the compact operation will be.
Note: The minimum compaction window is a checkpoint. Therefore, if the system is configured such that a checkpooint covers entries that cumulatively exceeds the value of this parameter, then this parameter will not reduce the compaction memory usage - the compator will load the entire checkpoint into memory when performing the checkpoint operation. Note: When calculating memory needed by the compaction operation, one should multiply this parameter by a factor of 2 i.e. the memory used by compaction will be twice the memory specified via this parameter
public static final String PROP_LOG_SCAVENGE_POLICY
A log with number N is considered a candidate for scavenging when N < live log number and N < CDC log number. This parameter specifies how such logs need to be scavenged. Currently, the only permissible value is 'Delete'
public static final String PROP_IS_PURE_MESSAGE_LOGGER
public static final String PROP_DETACHED_MESSAGE_SERIALIZATION
log(IRogMessage)
should be deferred to the detached writer when operating
in detached mode.
public static final String PROP_LOG_MODE
public static final String PROP_FLUSH_USING_MAPPED_MEMORY
public static final String PROP_AUTO_FLUSH_SIZE
public static final String PROP_PAGE_SIZE
Method Detail |
---|
public static final RogLog create(String name, Properties props) throws OdsException
name
- The name of the logprops
- Properties to configure the log.
OdsException
public static final RogLog create(String name) throws OdsException
This method calls create(name, (Properties)null)
OdsException
public static final RogLog create(String name, StorePersisterDescriptor descriptor) throws OdsException
name
- The name of the logdescriptor
- The store persister descriptor used to configure the log
OdsException
public static final void failOpen(boolean val)
public static final String backupLog(String logName, Properties props, boolean shrinkToSize) throws Exception
logName
- The log file nameprops
- The log propertiesshrinkToSize
- If the log should be shrinked down to size.
Exception
- If ther is an error backing up the logpublic final File getLogFile()
public final File getMetadataFile()
public final RogLogMetadata getMetadata()
public final long getCompactionThreshold()
public final void setCompactionThreshold(int val)
val
- The compaction threshold to set in gigabytes. A value of 0 will switch off compactionpublic final void scheduleCompactionOnNextWrite()
public final void delete() throws IOException
IOException
public final String backupLog(boolean shrinkToSize) throws Exception
shrinkToSize
- Specifies whether the backed up file should
be shrunk to the amount of space actually used in the file.
IllegalStateException
- Thrown if this method is invoked
after the persister has been opened.
This method backs up the persister's transaction log file. The method first shrinks the log to the amount of space actually used in the log (only if shrinkToSize is set to true) and then renames the log to a log named by appending the current date and time to the log file name. The backup file name is returned by the method.
Exception
public final void setStartupExpectation(IStorePersister.StartupExpectation expectation, Enum<?> value)
IStorePersister.setStartupExpectation(com.neeve.ods.IStorePersister.StartupExpectation, java.lang.Enum>)
setStartupExpectation
in interface IStorePersister
public final void setIsPureMessageLogger(boolean isPureMessageLogger)
public final void open(PktBuffer serializedMetadata, boolean truncateLive) throws Exception
IStorePersister.open(PktBuffer, boolean)
open
in interface IStorePersister
serializedMetadata
- Serialized form of the metadata to use
for the log being opened. A value of null indicates that the
existing metadata be used for the log and, if any metadata
does not exist, then start with a fresh metadata objecttruncateLive
- If true, then the live log file is truncated
during open. If metadata is supplied to this method, then
the live log is determined from that metadata.
Exception
public final void open() throws Exception
IStorePersister.open(com.neeve.pkt.PktBuffer, boolean)
and IRogMessageLogger.open()
open
in interface IStorePersister
open
in interface IRogMessageLogger
Exception
public final com.eaio.uuid.UUID getLogUUID()
public final RogLog.CheckpointState getCheckpointState()
public final boolean isOpen()
IStorePersister.isOpen()
isOpen
in interface IStorePersister
public final String getName()
IStorePersister.getName()
and IRogMessageLogger.getName()
getName
in interface IStorePersister
getName
in interface IRogMessageLogger
public final StorePersisterDescriptor getDescriptor()
IStorePersister.getDescriptor()
Note: This method will return null if the log was created directly using a property table rather than a store persister descriptor.
getDescriptor
in interface IStorePersister
public final void setErrorHandler(IStorePersister.ErrorHandler errorHandler)
IStorePersister.setErrorHandler(com.neeve.ods.IStorePersister.ErrorHandler)
setErrorHandler
in interface IStorePersister
public final IStorePersister.ErrorHandler getErrorHandler()
IStorePersister.getErrorHandler()
getErrorHandler
in interface IStorePersister
public final IStorePersisterStats getStats()
IStorePersister.getStats()
getStats
in interface IStorePersister
public final boolean wasRepaired()
IStorePersister.wasRepaired()
wasRepaired
in interface IStorePersister
public void readMetadata(PktBuffer buffer)
IStoreReader.readMetadata(com.neeve.pkt.PktBuffer)
readMetadata
in interface IStoreReader
buffer
- The buffer to read the (serialized form of) metadata intopublic final void read(IStoreReader.ReadCallback cb) throws Exception
IStoreReader.read(com.neeve.ods.IStoreReader.ReadCallback)
read
in interface IStoreReader
cb
- The callback used to return the read entries to the caller.
Exception
public final void read(IStoreReader.ReadCallback cb, int flags) throws Exception
IStoreReader.read(com.neeve.ods.IStoreReader.ReadCallback)
read
in interface IStoreReader
cb
- The callback used to return the read entries to the caller.flags
- Flags that qualify read operations.
Exception
public final void log(IRogMessage message)
log
in interface IRogMessageLogger
message
- The message to log.public final void log(IRogMessage message, boolean commitEnd)
IRogMessageLogger.log(IRogMessage, boolean)
log
in interface IRogMessageLogger
message
- The message to log.commitEnd
- Indicates whether to mark this log entry as
the end of an application commit leg.public final void flush(boolean sync)
IRogMessageLogger.flush(boolean)
flush
in interface IRogMessageLogger
sync
- Indicates if the flush should sync to the durable mediapublic final RogLogReader createReader() throws Exception
RogLogReader
instance.
Exception
- If there is an error creating the RogLogReader
public final RogLogReader createReader(int logNumber) throws Exception
RogLogReader
instance.
Exception
- If there is an error creating the RogLogReader
This method creates a private log reader of a specific numbered log file.
public final RogLogCdcProcessor createCdcProcessor(IRogChangeDataCaptureHandler handler) throws Exception
Exception
- If there is an error creating the RogLogReader
public final long getSize()
This method returns the amount of space used in the log file, including data that is buffered for write, but not yet flushed.
IllegalStateException
- Thrown if this method is invoked
before the log has been opened.public final long getAllocatedSize()
This method returns the actual size of the log file currently allocated.
This call differs from getSize()
in that this value may be
greater if the log has been preallocated to a larger size.
IllegalStateException
- Thrown if this method is invoked
before the log has been opened.public final void fail(Exception cause)
fail
in interface IStorePersister
cause
- The cause of the failure.
CAUTION: This method is only for testing purposes and should not be invoked outside of test frameworks.
This method invokes the error handler if installed and marks the log has failed. This will cause all subsequent commits or syncs to immediately fail with a runtime exception.
public final void fail()
This method invokes the following:
fail(new OdsException("force failed by user"))
fail
in interface IStorePersister
public final RogLogRepository asRepository()
public final RogLogCompactor getCompactor()
public final File archive(File archiveFolder, String archiveId) throws IOException
archiveFolder
- The folder to which to archive this transaction log's files.archiveId
- The archive id with which to suffix archived files.
IOException
- If there is an error creating the backup files.
IllegalStateException
- If the transaction log is not in a state where it can be archived (e.g. open)public final void close()
IStorePersister.close()
and IRogMessageLogger.open()
close
in interface IStorePersister
close
in interface IRogMessageLogger
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |