Class Configuration
- java.lang.Object
-
- org.objectweb.howl.log.Configuration
-
- All Implemented Interfaces:
ConfigurationMBean
public class Configuration extends java.lang.Object implements ConfigurationMBean
Provides configuration information for aLogger
instance.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
adler32Checksum
When set to true and checksumEnabled is also true checksums are computed using java.util.zip.Adler32.private java.lang.String
bufferClassName
Name of class that implements LogBuffer used by LogBufferManager.private int
bufferSize
Size (in K bytes) of buffers used to write log blocks.private boolean
checksumEnabled
When set to true checksums are computed on the contents of each buffer prior to writing buffer contents to disk.private boolean
flushPartialBuffers
Indicates whether LogBufferManager should flush buffers before they are full.private int
flushSleepTime
The amount of time (specified in number of milli-seconds) the ForceManager sleeps between log forces.private boolean
listConfig
When set to true the configuration properties are displayed to System.out following construction of a Configuration object.private java.lang.String
logFileDir
directory used to create log files.private java.lang.String
logFileExt
file name extension for log files.private java.lang.String
logFileMode
IO mode used to open the file.private java.lang.String
logFileName
filename used to create log files.(package private) static int
MAX_BUFFER_SIZE
maximum size of a LogBuffer (number of K bytes).private int
maxBlocksPerFile
maximum number of blocks to store in each LogFile.private int
maxBuffers
maximum number of buffers to be allocated by LogBufferManager.private int
maxLogFiles
number of log files to configure.private int
minBuffers
minimum number of buffers to be allocated by LogBufferManager.private java.util.Properties
prop
The Properties used to construct this object.private int
threadsWaitingForceThreshold
the maximum number of threads that should wait for an IO force.
-
Constructor Summary
Constructors Constructor Description Configuration()
Construct a Configuration object with default values.Configuration(java.io.File propertyFile)
Construct a Configuration object using a Properties file specified by the caller.Configuration(java.util.Properties prop)
Construct a Configuration object using a Properties object supplied by the caller.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
getBoolean(java.lang.String key, boolean val)
called by parseProperties to obtain a boolean configuration property and optionally display the configured value.java.lang.String
getBufferClassName()
int
getBufferSize()
Returns the size of buffers specified as a number of 1K blocks.int
getFlushSleepTime()
private int
getInteger(java.lang.String key, int val)
called by parseProperties to obtain an int configuration property and optionally display the configured value.private int
getInteger(java.lang.String key, int val, java.lang.String text)
called by parseProperties to obtain an int configuration property and optionally display the configured value.java.lang.String
getLogFileDir()
java.lang.String
getLogFileExt()
java.lang.String
getLogFileMode()
java.lang.String
getLogFileName()
int
getMaxBlocksPerFile()
int
getMaxBuffers()
int
getMaxLogFiles()
int
getMinBuffers()
private java.lang.String
getString(java.lang.String key, java.lang.String val)
called by parseProperties to obtain a String configuration property and optionally display the configured value.int
getThreadsWaitingForceThreshold()
boolean
isAdler32ChecksumEnabled()
boolean
isChecksumEnabled()
boolean
isFlushPartialBuffers()
private void
parseProperties()
initialize member variables from property file.void
setAdler32Checksum(boolean adler32Checksum)
void
setBufferClassName(java.lang.String bufferClassName)
void
setBufferSize(int bufferSize)
void
setChecksumEnabled(boolean checksumOption)
void
setFlushPartialBuffers(boolean flushPartialBuffers)
void
setFlushSleepTime(int flushSleepTime)
void
setLogFileDir(java.lang.String logFileDir)
void
setLogFileExt(java.lang.String logFileExt)
void
setLogFileMode(java.lang.String logFileMode)
void
setLogFileName(java.lang.String logFileName)
void
setMaxBlocksPerFile(int maxBlocksPerFile)
void
setMaxBuffers(int maxBuffers)
void
setMaxLogFiles(int maxLogFiles)
void
setMinBuffers(int minBuffers)
void
setThreadsWaitingForceThreshold(int threadsWaitingForceThreshold)
private void
showConfig(java.lang.String key, int val, java.lang.String text)
Display the value of an int configuration parameter to System.err if listConfig is true.void
store(java.io.OutputStream out)
Stores configuration properties to OutputStream.
-
-
-
Field Detail
-
MAX_BUFFER_SIZE
static final int MAX_BUFFER_SIZE
maximum size of a LogBuffer (number of K bytes).Good performance can be achieved with buffers between 2K and 6K when using a reasonably fast disk. Larger sizes may help with slower disks, but large buffers may be mostly empty in lightly loaded systems. MG 20060508 remove private qualifier so test case can access the constant.
- See Also:
- Constant Field Values
-
prop
private java.util.Properties prop
The Properties used to construct this object.
-
listConfig
private boolean listConfig
When set to true the configuration properties are displayed to System.out following construction of a Configuration object.Default is false --> config is not displayed
-
adler32Checksum
private boolean adler32Checksum
When set to true and checksumEnabled is also true checksums are computed using java.util.zip.Adler32.
-
checksumEnabled
private boolean checksumEnabled
When set to true checksums are computed on the contents of each buffer prior to writing buffer contents to disk.The checksum is used when blocks of data are retrieved from the log during replay to validate the content of the file.
Default value is true.
Setting this option to false may reduce slightly the amount of cpu time that is used by the logger.
-
bufferSize
private int bufferSize
Size (in K bytes) of buffers used to write log blocks.Specify values between 1 and 32 to allocate buffers between 1K and 32K in size.
The default size of 4K bytes should be suitable for most applications.
Larger buffers may provide improved performance for applications with transaction rates that exceed 5K TX/Sec and a large number of threads.
-
bufferClassName
private java.lang.String bufferClassName
Name of class that implements LogBuffer used by LogBufferManager.Class must extend LogBuffer.
-
maxBuffers
private int maxBuffers
maximum number of buffers to be allocated by LogBufferManager.Default value is 0 (zero) -- no limit.
-
minBuffers
private int minBuffers
minimum number of buffers to be allocated by LogBufferManager.Default value is 4.
-
flushSleepTime
private int flushSleepTime
The amount of time (specified in number of milli-seconds) the ForceManager sleeps between log forces.During periods of low activity, threads could wait an excessive amount of time (possibly for ever) for buffers to fill and be flushed. To mitigate this situation, the Logger runs a ForceManager thread that wakes up periodically and forces IO when other threads are waiting.
The default value is 50 milli-seconds.
-
flushPartialBuffers
private boolean flushPartialBuffers
Indicates whether LogBufferManager should flush buffers before they are full.Normally, buffers are flushed to disk only when they become full. In lightly loaded situations, one or more threads may have to wait until the flushSleepTime expires before the buffer is written. In the worst case, a single thread is using the log, and every put() with sync requested will be delayed flushSleepTime ms before the buffer is written.
Setting flushPartialBuffers true will allow the LogBufferManager to flush buffers to disk any time the channel is not busy. This improves throughput in single threaded and lightly loaded environments.
By default, this feature is disabled (false) to provide compatability with earlier versions of this library.
-
threadsWaitingForceThreshold
private int threadsWaitingForceThreshold
the maximum number of threads that should wait for an IO force.Setting this value may have an effect on latency when threads are waiting for the force.
By default, there is no limit.
-
maxBlocksPerFile
private int maxBlocksPerFile
maximum number of blocks to store in each LogFile.controls when logging is switched to a new log file, and/or when a circular log is reset to seek address zero.
-
maxLogFiles
private int maxLogFiles
number of log files to configure.Default is 2 log files.
-
logFileDir
private java.lang.String logFileDir
directory used to create log files.Default is logs directory relative to parent of current working dir.
-
logFileExt
private java.lang.String logFileExt
file name extension for log files.Default value is "log"
-
logFileName
private java.lang.String logFileName
filename used to create log files.Default value is "logger"
file names are generated using the following pattern:
+ "_" + + "." +
-
logFileMode
private java.lang.String logFileMode
IO mode used to open the file.Default is "rw"
Must be "rw" or "rwd"
- See Also:
RandomAccessFile(java.io.File, java.lang.String)
-
-
Constructor Detail
-
Configuration
public Configuration()
Construct a Configuration object with default values.Caller will use setter methods to change the defaults.
-
Configuration
public Configuration(java.util.Properties prop) throws LogConfigurationException
Construct a Configuration object using a Properties object supplied by the caller.- Parameters:
prop
- Properties object containing default settings- Throws:
LogConfigurationException
-
Configuration
public Configuration(java.io.File propertyFile) throws LogConfigurationException
Construct a Configuration object using a Properties file specified by the caller.- Parameters:
propertyFile
- File object describing a properties file- Throws:
LogConfigurationException
- if property file cannot be processed.
-
-
Method Detail
-
showConfig
private void showConfig(java.lang.String key, int val, java.lang.String text)
Display the value of an int configuration parameter to System.err if listConfig is true.The text parameter allows the program to provide additional text that will be displayed following the value to explain the type of value. For example, values that represent Milliseconds might be displayed with "Ms".
- Parameters:
key
- name of the parameter being displaedval
- value for the parametertext
- additional text to be displayed such as "Kb" or "Ms".
-
getInteger
private int getInteger(java.lang.String key, int val, java.lang.String text)
called by parseProperties to obtain an int configuration property and optionally display the configured value.save result in prop member.
- Parameters:
key
- name of the parameter to returnval
- default value if the parameter is not configuredtext
- additional text to pass to showConfig(String, int, String)- Returns:
- int value of requested parameter
- See Also:
showConfig(String, int, String)
-
getInteger
private int getInteger(java.lang.String key, int val)
called by parseProperties to obtain an int configuration property and optionally display the configured value.This routine calls getInteger(String, ing, String) passing a zero length string as the third parameter.
save result in prop member.
- Parameters:
key
- name of parameter to returnval
- default value if the parameter is not configured- Returns:
- int value of requested parameter
- See Also:
getInteger(String, int, String)
-
getBoolean
private boolean getBoolean(java.lang.String key, boolean val) throws LogConfigurationException
called by parseProperties to obtain a boolean configuration property and optionally display the configured value.save result in prop member.
- Parameters:
key
- name of parameter to returnval
- default value if the parameter is not configured- Returns:
- boolean value of the requested parameter
- Throws:
LogConfigurationException
- if the configured value of the property is something other than 'true' or 'false'
-
getString
private java.lang.String getString(java.lang.String key, java.lang.String val)
called by parseProperties to obtain a String configuration property and optionally display the configured value.save result in prop member.
- Parameters:
key
- name of parameter to returnval
- default value if the parameter is not configured- Returns:
- String value of the requested parameter
-
parseProperties
private void parseProperties() throws LogConfigurationException
initialize member variables from property file.entire property set is saved in prop member for use in store(OutputStream) method.
- Throws:
LogConfigurationException
- with text explaining the reason for the exception.
-
getLogFileDir
public java.lang.String getLogFileDir()
- Specified by:
getLogFileDir
in interfaceConfigurationMBean
- Returns:
- Returns the logDir.
-
setLogFileDir
public void setLogFileDir(java.lang.String logFileDir)
- Parameters:
logFileDir
- The logFileDir to set.
-
getLogFileExt
public java.lang.String getLogFileExt()
- Specified by:
getLogFileExt
in interfaceConfigurationMBean
- Returns:
- Returns the logFileExt.
-
setLogFileExt
public void setLogFileExt(java.lang.String logFileExt)
- Parameters:
logFileExt
- The logFileExt to set.
-
getLogFileName
public java.lang.String getLogFileName()
- Specified by:
getLogFileName
in interfaceConfigurationMBean
- Returns:
- Returns the logFileName.
-
setLogFileName
public void setLogFileName(java.lang.String logFileName)
- Parameters:
logFileName
- The logFileName to set.
-
isAdler32ChecksumEnabled
public boolean isAdler32ChecksumEnabled()
- Specified by:
isAdler32ChecksumEnabled
in interfaceConfigurationMBean
- Returns:
- the adler32Checksum option.
-
isChecksumEnabled
public boolean isChecksumEnabled()
- Specified by:
isChecksumEnabled
in interfaceConfigurationMBean
- Returns:
- Returns the checksumEnabled option.
-
setChecksumEnabled
public void setChecksumEnabled(boolean checksumOption)
- Parameters:
checksumOption
- The checksumOption to set.
-
getBufferSize
public int getBufferSize()
Returns the size of buffers specified as a number of 1K blocks.As an example, if buffers are 4096 bytes large, getBufferSize() returns 4.
- Specified by:
getBufferSize
in interfaceConfigurationMBean
- Returns:
- Returns the bufferSize as a number of 1K blocks.
-
setBufferSize
public void setBufferSize(int bufferSize) throws LogConfigurationException
- Parameters:
bufferSize
- The size of a log buffer specified as a number of 1024 byte blocks.The value specified by bufferSize is multiplied by 1024 to establish the actual buffer size used by the logger.
- Throws:
LogConfigurationException
-
getBufferClassName
public java.lang.String getBufferClassName()
- Specified by:
getBufferClassName
in interfaceConfigurationMBean
- Returns:
- Returns the bufferClassName.
-
setAdler32Checksum
public void setAdler32Checksum(boolean adler32Checksum)
- Parameters:
adler32Checksum
- true if application wishes to use java.util.zip.Adler32 checksum method.
-
setBufferClassName
public void setBufferClassName(java.lang.String bufferClassName)
- Parameters:
bufferClassName
- The bufferClassName to set.
-
getMaxBuffers
public int getMaxBuffers()
- Specified by:
getMaxBuffers
in interfaceConfigurationMBean
- Returns:
- Returns the maxBuffers.
-
setMaxBuffers
public void setMaxBuffers(int maxBuffers) throws LogConfigurationException
- Parameters:
maxBuffers
- The maxBuffers to set.- Throws:
LogConfigurationException
-
getMinBuffers
public int getMinBuffers()
- Specified by:
getMinBuffers
in interfaceConfigurationMBean
- Returns:
- Returns the minBuffers.
-
setMinBuffers
public void setMinBuffers(int minBuffers) throws LogConfigurationException
- Parameters:
minBuffers
- The minBuffers to set.- Throws:
LogConfigurationException
-
getFlushSleepTime
public int getFlushSleepTime()
- Specified by:
getFlushSleepTime
in interfaceConfigurationMBean
- Returns:
- Returns the flushSleepTime.
-
setFlushSleepTime
public void setFlushSleepTime(int flushSleepTime)
- Parameters:
flushSleepTime
- The amount of time (specified in milli-seconds) the FlushManager should sleep.
-
getThreadsWaitingForceThreshold
public int getThreadsWaitingForceThreshold()
- Specified by:
getThreadsWaitingForceThreshold
in interfaceConfigurationMBean
- Returns:
- Returns the threadsWaitingForceThreshold.
-
setThreadsWaitingForceThreshold
public void setThreadsWaitingForceThreshold(int threadsWaitingForceThreshold)
- Parameters:
threadsWaitingForceThreshold
- The threadsWaitingForceThreshold to set.
-
getMaxBlocksPerFile
public int getMaxBlocksPerFile()
- Specified by:
getMaxBlocksPerFile
in interfaceConfigurationMBean
- Returns:
- Returns the maxBlocksPerFile.
-
setMaxBlocksPerFile
public void setMaxBlocksPerFile(int maxBlocksPerFile)
- Parameters:
maxBlocksPerFile
- The maxBlocksPerFile to set.
-
getMaxLogFiles
public int getMaxLogFiles()
- Specified by:
getMaxLogFiles
in interfaceConfigurationMBean
- Returns:
- Returns the maxLogFiles.
-
setMaxLogFiles
public void setMaxLogFiles(int maxLogFiles)
- Parameters:
maxLogFiles
- The maxLogFiles to set.
-
getLogFileMode
public java.lang.String getLogFileMode()
- Specified by:
getLogFileMode
in interfaceConfigurationMBean
- Returns:
- Returns the logFileMode.
-
setLogFileMode
public void setLogFileMode(java.lang.String logFileMode) throws LogConfigurationException
- Parameters:
logFileMode
- The logFileMode to set.- Throws:
LogConfigurationException
-
store
public void store(java.io.OutputStream out) throws java.io.IOException
Stores configuration properties to OutputStream.- Throws:
java.io.IOException
- See Also:
Properties.store(java.io.OutputStream, java.lang.String)
-
isFlushPartialBuffers
public boolean isFlushPartialBuffers()
- Returns:
- Returns the flushPartialBuffers.
-
setFlushPartialBuffers
public void setFlushPartialBuffers(boolean flushPartialBuffers)
- Parameters:
flushPartialBuffers
- The flushPartialBuffers to set.
-
-