Class Configuration
- All Implemented Interfaces:
ConfigurationMBean
Logger
instance.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
When set to true and checksumEnabled is also true checksums are computed using java.util.zip.Adler32.private String
Name of class that implements LogBuffer used by LogBufferManager.private int
Size (in K bytes) of buffers used to write log blocks.private boolean
When set to true checksums are computed on the contents of each buffer prior to writing buffer contents to disk.private boolean
Indicates whether LogBufferManager should flush buffers before they are full.private int
The amount of time (specified in number of milli-seconds) the ForceManager sleeps between log forces.private boolean
When set to true the configuration properties are displayed to System.out following construction of a Configuration object.private String
directory used to create log files.private String
file name extension for log files.private String
IO mode used to open the file.private String
filename used to create log files.(package private) static final int
maximum size of a LogBuffer (number of K bytes).private int
maximum number of blocks to store in each LogFile.private int
maximum number of buffers to be allocated by LogBufferManager.private int
number of log files to configure.private int
minimum number of buffers to be allocated by LogBufferManager.private Properties
The Properties used to construct this object.private int
the maximum number of threads that should wait for an IO force. -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a Configuration object with default values.Configuration
(File propertyFile) Construct a Configuration object using a Properties file specified by the caller.Configuration
(Properties prop) Construct a Configuration object using a Properties object supplied by the caller. -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
getBoolean
(String key, boolean val) called by parseProperties to obtain a boolean configuration property and optionally display the configured value.int
Returns the size of buffers specified as a number of 1K blocks.int
private int
getInteger
(String key, int val) called by parseProperties to obtain an int configuration property and optionally display the configured value.private int
getInteger
(String key, int val, String text) called by parseProperties to obtain an int configuration property and optionally display the configured value.int
int
int
int
private String
called by parseProperties to obtain a String configuration property and optionally display the configured value.int
boolean
boolean
boolean
private void
initialize member variables from property file.void
setAdler32Checksum
(boolean adler32Checksum) void
setBufferClassName
(String bufferClassName) void
setBufferSize
(int bufferSize) void
setChecksumEnabled
(boolean checksumOption) void
setFlushPartialBuffers
(boolean flushPartialBuffers) void
setFlushSleepTime
(int flushSleepTime) void
setLogFileDir
(String logFileDir) void
setLogFileExt
(String logFileExt) void
setLogFileMode
(String logFileMode) void
setLogFileName
(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
(String key, int val, String text) Display the value of an int configuration parameter to System.err if listConfig is true.void
store
(OutputStream out) Stores configuration properties to OutputStream.
-
Field Details
-
MAX_BUFFER_SIZE
static final int MAX_BUFFER_SIZEmaximum 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:
-
prop
The Properties used to construct this object. -
listConfig
private boolean listConfigWhen 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 adler32ChecksumWhen set to true and checksumEnabled is also true checksums are computed using java.util.zip.Adler32. -
checksumEnabled
private boolean checksumEnabledWhen 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 bufferSizeSize (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
Name of class that implements LogBuffer used by LogBufferManager.Class must extend LogBuffer.
-
maxBuffers
private int maxBuffersmaximum number of buffers to be allocated by LogBufferManager.Default value is 0 (zero) -- no limit.
-
minBuffers
private int minBuffersminimum number of buffers to be allocated by LogBufferManager.Default value is 4.
-
flushSleepTime
private int flushSleepTimeThe 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 flushPartialBuffersIndicates 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 threadsWaitingForceThresholdthe 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 maxBlocksPerFilemaximum 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 maxLogFilesnumber of log files to configure.Default is 2 log files.
-
logFileDir
directory used to create log files.Default is logs directory relative to parent of current working dir.
-
logFileExt
file name extension for log files.Default value is "log"
-
logFileName
filename used to create log files.Default value is "logger"
file names are generated using the following pattern:
+ "_" + + "." + -
logFileMode
IO mode used to open the file.Default is "rw"
Must be "rw" or "rwd"
- See Also:
-
-
Constructor Details
-
Configuration
public Configuration()Construct a Configuration object with default values.Caller will use setter methods to change the defaults.
-
Configuration
Construct a Configuration object using a Properties object supplied by the caller.- Parameters:
prop
- Properties object containing default settings- Throws:
LogConfigurationException
-
Configuration
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 Details
-
showConfig
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
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:
-
getInteger
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:
-
getBoolean
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
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
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
- Specified by:
getLogFileDir
in interfaceConfigurationMBean
- Returns:
- Returns the logDir.
-
setLogFileDir
- Parameters:
logFileDir
- The logFileDir to set.
-
getLogFileExt
- Specified by:
getLogFileExt
in interfaceConfigurationMBean
- Returns:
- Returns the logFileExt.
-
setLogFileExt
- Parameters:
logFileExt
- The logFileExt to set.
-
getLogFileName
- Specified by:
getLogFileName
in interfaceConfigurationMBean
- Returns:
- Returns the logFileName.
-
setLogFileName
- 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
- 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
- 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
- Parameters:
bufferClassName
- The bufferClassName to set.
-
getMaxBuffers
public int getMaxBuffers()- Specified by:
getMaxBuffers
in interfaceConfigurationMBean
- Returns:
- Returns the maxBuffers.
-
setMaxBuffers
- Parameters:
maxBuffers
- The maxBuffers to set.- Throws:
LogConfigurationException
-
getMinBuffers
public int getMinBuffers()- Specified by:
getMinBuffers
in interfaceConfigurationMBean
- Returns:
- Returns the minBuffers.
-
setMinBuffers
- 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
- Specified by:
getLogFileMode
in interfaceConfigurationMBean
- Returns:
- Returns the logFileMode.
-
setLogFileMode
- Parameters:
logFileMode
- The logFileMode to set.- Throws:
LogConfigurationException
-
store
Stores configuration properties to OutputStream.- Throws:
IOException
- See Also:
-
isFlushPartialBuffers
public boolean isFlushPartialBuffers()- Returns:
- Returns the flushPartialBuffers.
-
setFlushPartialBuffers
public void setFlushPartialBuffers(boolean flushPartialBuffers) - Parameters:
flushPartialBuffers
- The flushPartialBuffers to set.
-