Class Configuration

java.lang.Object
org.objectweb.howl.log.Configuration
All Implemented Interfaces:
ConfigurationMBean

public class Configuration extends Object implements ConfigurationMBean
Provides configuration information for a Logger instance.
  • Field Details

    • 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:
    • prop

      private 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 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 String logFileDir
      directory used to create log files.

      Default is logs directory relative to parent of current working dir.

    • logFileExt

      private String logFileExt
      file name extension for log files.

      Default value is "log"

    • logFileName

      private String logFileName
      filename used to create log files.

      Default value is "logger"

      file names are generated using the following pattern:

          + "_" +  + "." + 
       
    • logFileMode

      private String 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

      public Configuration(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(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 Details

    • showConfig

      private void showConfig(String key, int val, 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 displaed
      val - value for the parameter
      text - additional text to be displayed such as "Kb" or "Ms".
    • getInteger

      private int getInteger(String key, int val, 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 return
      val - default value if the parameter is not configured
      text - additional text to pass to showConfig(String, int, String)
      Returns:
      int value of requested parameter
      See Also:
    • getInteger

      private int getInteger(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 return
      val - default value if the parameter is not configured
      Returns:
      int value of requested parameter
      See Also:
    • getBoolean

      private boolean getBoolean(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 return
      val - 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 String getString(String key, 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 return
      val - 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 String getLogFileDir()
      Specified by:
      getLogFileDir in interface ConfigurationMBean
      Returns:
      Returns the logDir.
    • setLogFileDir

      public void setLogFileDir(String logFileDir)
      Parameters:
      logFileDir - The logFileDir to set.
    • getLogFileExt

      public String getLogFileExt()
      Specified by:
      getLogFileExt in interface ConfigurationMBean
      Returns:
      Returns the logFileExt.
    • setLogFileExt

      public void setLogFileExt(String logFileExt)
      Parameters:
      logFileExt - The logFileExt to set.
    • getLogFileName

      public String getLogFileName()
      Specified by:
      getLogFileName in interface ConfigurationMBean
      Returns:
      Returns the logFileName.
    • setLogFileName

      public void setLogFileName(String logFileName)
      Parameters:
      logFileName - The logFileName to set.
    • isAdler32ChecksumEnabled

      public boolean isAdler32ChecksumEnabled()
      Specified by:
      isAdler32ChecksumEnabled in interface ConfigurationMBean
      Returns:
      the adler32Checksum option.
    • isChecksumEnabled

      public boolean isChecksumEnabled()
      Specified by:
      isChecksumEnabled in interface ConfigurationMBean
      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 interface ConfigurationMBean
      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 String getBufferClassName()
      Specified by:
      getBufferClassName in interface ConfigurationMBean
      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(String bufferClassName)
      Parameters:
      bufferClassName - The bufferClassName to set.
    • getMaxBuffers

      public int getMaxBuffers()
      Specified by:
      getMaxBuffers in interface ConfigurationMBean
      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 interface ConfigurationMBean
      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 interface ConfigurationMBean
      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 interface ConfigurationMBean
      Returns:
      Returns the threadsWaitingForceThreshold.
    • setThreadsWaitingForceThreshold

      public void setThreadsWaitingForceThreshold(int threadsWaitingForceThreshold)
      Parameters:
      threadsWaitingForceThreshold - The threadsWaitingForceThreshold to set.
    • getMaxBlocksPerFile

      public int getMaxBlocksPerFile()
      Specified by:
      getMaxBlocksPerFile in interface ConfigurationMBean
      Returns:
      Returns the maxBlocksPerFile.
    • setMaxBlocksPerFile

      public void setMaxBlocksPerFile(int maxBlocksPerFile)
      Parameters:
      maxBlocksPerFile - The maxBlocksPerFile to set.
    • getMaxLogFiles

      public int getMaxLogFiles()
      Specified by:
      getMaxLogFiles in interface ConfigurationMBean
      Returns:
      Returns the maxLogFiles.
    • setMaxLogFiles

      public void setMaxLogFiles(int maxLogFiles)
      Parameters:
      maxLogFiles - The maxLogFiles to set.
    • getLogFileMode

      public String getLogFileMode()
      Specified by:
      getLogFileMode in interface ConfigurationMBean
      Returns:
      Returns the logFileMode.
    • setLogFileMode

      public void setLogFileMode(String logFileMode) throws LogConfigurationException
      Parameters:
      logFileMode - The logFileMode to set.
      Throws:
      LogConfigurationException
    • store

      public void store(OutputStream out) throws IOException
      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.