public final class RogLog extends com.neeve.ods.impl.StorePacketPersisterBase implements IStorePersister, IRogMessageLogger, IEventSource
| Modifier and Type | Class and Description |
|---|---|
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.Entrys are not safe for concurrent access by multiple threads. |
static class |
RogLog.Stats
Holds transaction log statistics.
|
IStorePersister.ErrorHandler, IStorePersister.LogEmptinessExpectation, IStorePersister.LogPresenceExpectation, IStorePersister.StartupExpectationIStoreWriter.LogCounters, IStoreWriter.ParametersIStoreReader.IterativeReader, IStoreReader.ReadCallback| Modifier and Type | Field and Description |
|---|---|
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_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_BACKUP_RETENTION_COUNT
Property used to indicate the maximum number of log backups to retain
|
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_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_TRANSACTIONAL_INTEGRITY_CHECK
Property used to indicate whether to do a transactional integrity check of the
log on open
|
static boolean |
PROP_TRANSACTIONAL_INTEGRITY_CHECK_DEFAULT
The default value for
PROP_TRANSACTIONAL_INTEGRITY_CHECK. |
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. |
| Modifier and Type | Method and Description |
|---|---|
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 (in bytes).
|
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() |
IEventHandler |
getEventHandler()
Get a persister's event handler.
|
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() |
IStoreReader.IterativeReader |
iterativeReader(int flags)
Implementation of
IStoreReader.iterativeReader(int) |
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, boolean) and IRogMessageLogger.open() |
void |
open(boolean concurrentReadWrite)
Implementation of
IStorePersister.open(boolean) |
void |
open(PktBuffer serializedMetadata,
boolean truncateLive)
Implementation of
IStorePersister.open(PktBuffer, boolean) |
void |
open(PktBuffer serializedMetadata,
boolean truncateLive,
boolean concurrentReadWrite)
Implementation of
IStorePersister.open(PktBuffer, boolean) |
boolean |
read(IStoreReader.ReadCallback cb)
Implementation of
IStoreReader.read(com.neeve.ods.IStoreReader.ReadCallback) |
boolean |
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)
|
void |
setEventHandler(IEventHandler eventHandler)
Set a persister's event handler.
|
void |
setIsPureMessageLogger(boolean isPureMessageLogger)
Marks this RogLog as being purely for message logging purposes.
|
void |
setStartupExpectation(IStorePersister.StartupExpectation expectation,
Enum<?> value)
|
String |
toString() |
boolean |
wasRepaired()
Implementation of
IStorePersister.wasRepaired() |
getParameters, isShared, onRoleChange, sync, writeCommitEntrygetChecked, getThreaded, getTracer, setChecked, setTracerequals, getClass, hashCode, notify, notifyAll, wait, wait, waitgetParameters, isShared, onRoleChange, sync, writeCommitEntrypublic 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_TRANSACTIONAL_INTEGRITY_CHECK
public static final boolean PROP_TRANSACTIONAL_INTEGRITY_CHECK_DEFAULT
PROP_TRANSACTIONAL_INTEGRITY_CHECK.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_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_LOG_BACKUP_RETENTION_COUNT
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
public static final RogLog create(String name, Properties props) throws OdsException
name - The name of the logprops - Properties to configure the log.OdsExceptionpublic static final RogLog create(String name) throws OdsException
This method calls create(name, (Properties)null)
OdsExceptionpublic static final RogLog create(String name, StorePersisterDescriptor descriptor) throws OdsException
name - The name of the logdescriptor - The store persister descriptor used to configure the logOdsExceptionpublic 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 megabytes. A value of 0 will switch off compactionpublic final void scheduleCompactionOnNextWrite()
public final void delete()
throws IOException
IOExceptionpublic 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.
Exceptionpublic final void setStartupExpectation(IStorePersister.StartupExpectation expectation, Enum<?> value)
IStorePersister.setStartupExpectation(com.neeve.ods.IStorePersister.StartupExpectation, java.lang.Enum<?>)setStartupExpectation in interface IStorePersisterpublic final void setIsPureMessageLogger(boolean isPureMessageLogger)
public final void open(PktBuffer serializedMetadata, boolean truncateLive, boolean concurrentReadWrite) throws Exception
IStorePersister.open(PktBuffer, boolean)open in interface IStorePersisterserializedMetadata - 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.concurrentReadWrite - If true, the log is opened in a manner
that permits for concurrent read/write to occur on the log.Exceptionpublic final void open(PktBuffer serializedMetadata, boolean truncateLive) throws Exception
IStorePersister.open(PktBuffer, boolean)open in interface IStorePersisterExceptionpublic final void open(boolean concurrentReadWrite)
throws Exception
IStorePersister.open(boolean)open in interface IStorePersisterconcurrentReadWrite - If true, the log is opened in a manner
that permits for concurrent read/write to occur on the log.
Invoking this method is equivalent to invoking open(null, false, concurrentReadWrite)
Exceptionpublic final void open()
throws Exception
IStorePersister.open(com.neeve.pkt.PktBuffer, boolean, boolean) and IRogMessageLogger.open()open in interface IStorePersisteropen in interface IRogMessageLoggerExceptionpublic final com.eaio.uuid.UUID getLogUUID()
public final RogLog.CheckpointState getCheckpointState()
public final boolean isOpen()
IStorePersister.isOpen()isOpen in interface IStorePersisterpublic final String getName()
IStorePersister.getName() and IRogMessageLogger.getName()getName in interface IEventSourcegetName in interface IStorePersistergetName in interface IRogMessageLoggerpublic 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 IStorePersisterpublic final void setErrorHandler(IStorePersister.ErrorHandler errorHandler)
setErrorHandler in interface IStorePersisterpublic final IStorePersister.ErrorHandler getErrorHandler()
IStorePersister.getErrorHandler()getErrorHandler in interface IStorePersisterpublic final void setEventHandler(IEventHandler eventHandler)
IStorePersistersetEventHandler in interface IStorePersistereventHandler - The event handler for the persister.public IEventHandler getEventHandler()
IStorePersistergetEventHandler in interface IStorePersisterpublic final IStorePersisterStats getStats()
IStorePersister.getStats()getStats in interface IStorePersisterpublic final boolean wasRepaired()
IStorePersister.wasRepaired()wasRepaired in interface IStorePersisterpublic final void readMetadata(PktBuffer buffer)
IStoreReader.readMetadata(com.neeve.pkt.PktBuffer)readMetadata in interface IStoreReaderbuffer - The buffer to read the (serialized form of) metadata intopublic final IStoreReader.IterativeReader iterativeReader(int flags) throws Exception
IStoreReader.iterativeReader(int)iterativeReader in interface IStoreReaderflags - Flags that qualify read operations.Exceptionpublic final boolean read(IStoreReader.ReadCallback cb) throws Exception
IStoreReader.read(com.neeve.ods.IStoreReader.ReadCallback)read in interface IStoreReadercb - The callback used to return the read entries to the caller.Exceptionpublic final boolean read(IStoreReader.ReadCallback cb, int flags) throws Exception
IStoreReader.read(com.neeve.ods.IStoreReader.ReadCallback)read in interface IStoreReadercb - The callback used to return the read entries to the caller.flags - Flags that qualify read operations.Exceptionpublic final void log(IRogMessage message)
log in interface IRogMessageLoggermessage - The message to log.public final void log(IRogMessage message, boolean commitEnd)
IRogMessageLogger.log(IRogMessage, boolean)log in interface IRogMessageLoggermessage - 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 IRogMessageLoggersync - 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 RogLogReaderpublic 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
Note that only one CDC processor can be created per log.
Exception - If there is an error creating the RogLogReaderpublic 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 IStorePersistercause - 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 IStorePersisterpublic 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 IStorePersisterclose in interface IRogMessageLoggerCopyright © 2019 Neeve Research, LLC. All Rights Reserved.