bitronix.tm
Class Configuration

java.lang.Object
  extended bybitronix.tm.Configuration
All Implemented Interfaces:
Service

public class Configuration
extends java.lang.Object
implements Service

Configuration repository of the transaction manager. You can set configurable values either via the properties file or by setting properties of the Configuration object. Once the transaction manager has started it is not possible to change the configuration: all calls to setters will throw a IllegalStateException.

The configuration filename must be specified with the bitronix.tm.configuration system property.

The default settings are good enough for running in a test environment but certainly not for production usage. Also, all properties are reset to their default value after the transaction manager has shut down.

All those properties can refer to other defined ones or to system properties using the Ant notation: ${some.property.name}.

© Bitronix Software

Author:
lorban

Constructor Summary
protected Configuration()
           
 
Method Summary
 byte[] buildServerIdArray()
          Build the server ID byte array that will be prepended in generated UIDs.
 int getBackgroundRecoveryInterval()
          Deprecated. superceded by #getBackgroundRecoveryIntervalSeconds().
 int getBackgroundRecoveryIntervalSeconds()
          Interval in seconds at which to run the recovery process in the background.
 int getDefaultTransactionTimeout()
          Default transaction timeout in seconds.
 int getGracefulShutdownInterval()
          Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
 java.lang.String getJndiTransactionSynchronizationRegistryName()
          Get the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.
 java.lang.String getJndiUserTransactionName()
          Get the name the UserTransaction should be bound under in the BitronixContext.
 java.lang.String getJournal()
          Get the journal implementation.
 java.lang.String getLogPart1Filename()
          Get the journal fragment file 1 name.
 java.lang.String getLogPart2Filename()
          Get the journal fragment file 2 name.
 int getMaxLogSizeInMb()
          Maximum size in megabytes of the journal fragments.
 java.lang.String getResourceConfigurationFilename()
          ResourceLoader configuration file name.
 java.lang.String getServerId()
          ASCII ID that must uniquely identify this TM instance.
 boolean isAsynchronous2Pc()
          Should two phase commit be executed asynchronously ?
 boolean isCurrentNodeOnlyRecovery()
          Should the recovery process not recover XIDs generated with another JVM unique ID ?
 boolean isDisableJmx()
          Should JMX Mbeans not be registered even if a JMX MBean server is detected ?
 boolean isFilterLogStatus()
          Should only mandatory logs be written ?
 boolean isForceBatchingEnabled()
          Are disk forces batched ?
 boolean isForcedWriteEnabled()
          Are logs forced to disk ?
 boolean isSkipCorruptedLogs()
          Should corrupted logs be skipped ?
 boolean isWarnAboutZeroResourceTransaction()
          Should transactions executed without a single enlisted resource result in a warning or not ?
 void setAsynchronous2Pc(boolean asynchronous2Pc)
          Set if two phase commit should be executed asynchronously.
 void setBackgroundRecoveryInterval(int backgroundRecoveryInterval)
          Deprecated. superceded by #setBackgroundRecoveryIntervalSeconds(int).
 void setBackgroundRecoveryIntervalSeconds(int backgroundRecoveryIntervalSeconds)
          Set the interval in seconds at which to run the recovery process in the background.
 void setCurrentNodeOnlyRecovery(boolean currentNodeOnlyRecovery)
          Set to true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.
 void setDefaultTransactionTimeout(int defaultTransactionTimeout)
          Set the default transaction timeout in seconds.
 void setDisableJmx(boolean disableJmx)
          Set to true if JMX Mbeans should not be registered even if a JMX MBean server is detected.
 void setFilterLogStatus(boolean filterLogStatus)
          Set if only mandatory logs should be written.
 void setForceBatchingEnabled(boolean forceBatchingEnabled)
          Set if disk forces are batched.
 void setForcedWriteEnabled(boolean forcedWriteEnabled)
          Set if logs are forced to disk.
 void setGracefulShutdownInterval(int gracefulShutdownInterval)
          Set the maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
 void setJndiTransactionSynchronizationRegistryName(java.lang.String jndiTransactionSynchronizationRegistryName)
          Set the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.
 void setJndiUserTransactionName(java.lang.String jndiUserTransactionName)
          Set the name the UserTransaction should be bound under in the BitronixContext.
 void setJournal(java.lang.String journal)
          Set the journal name.
 void setLogPart1Filename(java.lang.String logPart1Filename)
          Set the journal fragment file 1 name.
 void setLogPart2Filename(java.lang.String logPart2Filename)
          Set the journal fragment file 2 name.
 void setMaxLogSizeInMb(int maxLogSizeInMb)
          Set the Maximum size in megabytes of the journal fragments.
 void setResourceConfigurationFilename(java.lang.String resourceConfigurationFilename)
          Set the ResourceLoader configuration file name.
 void setServerId(java.lang.String serverId)
          Set the ASCII ID that must uniquely identify this TM instance.
 void setSkipCorruptedLogs(boolean skipCorruptedLogs)
          Set if corrupted logs should be skipped.
 void setWarnAboutZeroResourceTransaction(boolean warnAboutZeroResourceTransaction)
          Set if transactions executed without a single enlisted resource should result in a warning or not.
 void shutdown()
          Shutdown the service and free all held resources.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Configuration

protected Configuration()
Method Detail

getServerId

public java.lang.String getServerId()
ASCII ID that must uniquely identify this TM instance. It must not exceed 51 characters or it will be truncated.

Property name:
bitronix.tm.serverId - (defaults to server's IP address but that's unsafe for production use)

Returns:
the unique ID of this TM instance.

setServerId

public void setServerId(java.lang.String serverId)
Set the ASCII ID that must uniquely identify this TM instance. It must not exceed 51 characters or it will be truncated.

Parameters:
serverId - the unique ID of this TM instance.
See Also:
getServerId()

getLogPart1Filename

public java.lang.String getLogPart1Filename()
Get the journal fragment file 1 name.

Property name:
bitronix.tm.journal.disk.logPart1Filename - (defaults to btm1.tlog)

Returns:
the journal fragment file 1 name.

setLogPart1Filename

public void setLogPart1Filename(java.lang.String logPart1Filename)
Set the journal fragment file 1 name.

Parameters:
logPart1Filename - the journal fragment file 1 name.
See Also:
getLogPart1Filename()

getLogPart2Filename

public java.lang.String getLogPart2Filename()
Get the journal fragment file 2 name.

Property name:
bitronix.tm.journal.disk.logPart2Filename - (defaults to btm2.tlog)

Returns:
the journal fragment file 2 name.

setLogPart2Filename

public void setLogPart2Filename(java.lang.String logPart2Filename)
Set the journal fragment file 2 name.

Parameters:
logPart2Filename - the journal fragment file 2 name.
See Also:
getLogPart2Filename()

isForcedWriteEnabled

public boolean isForcedWriteEnabled()
Are logs forced to disk ? Do not set to false in production since without disk force, integrity is not guaranteed.

Property name:
bitronix.tm.journal.disk.forcedWriteEnabled - (defaults to true)

Returns:
true if logs are forced to disk, false otherwise.

setForcedWriteEnabled

public void setForcedWriteEnabled(boolean forcedWriteEnabled)
Set if logs are forced to disk. Do not set to false in production since without disk force, integrity is not guaranteed.

Parameters:
forcedWriteEnabled - true if logs should be forced to disk, false otherwise.
See Also:
isForcedWriteEnabled()

isForceBatchingEnabled

public boolean isForceBatchingEnabled()
Are disk forces batched ? Disabling batching can seriously lower the transaction manager's throughput.

Property name:
bitronix.tm.journal.disk.forceBatchingEnabled - (defaults to true)

Returns:
true if disk forces are batched, false otherwise.

setForceBatchingEnabled

public void setForceBatchingEnabled(boolean forceBatchingEnabled)
Set if disk forces are batched. Disabling batching can seriously lower the transaction manager's throughput.

Parameters:
forceBatchingEnabled - true if disk forces are batched, false otherwise.
See Also:
isForceBatchingEnabled()

getMaxLogSizeInMb

public int getMaxLogSizeInMb()
Maximum size in megabytes of the journal fragments. Larger logs allow transactions to stay longer in-doubt but the TM pauses longer when a fragment is full.

Property name:
bitronix.tm.journal.disk.maxLogSize - (defaults to 2)

Returns:
the maximum size in megabytes of the journal fragments.

setMaxLogSizeInMb

public void setMaxLogSizeInMb(int maxLogSizeInMb)
Set the Maximum size in megabytes of the journal fragments. Larger logs allow transactions to stay longer in-doubt but the TM pauses longer when a fragment is full.

Parameters:
maxLogSizeInMb - the maximum size in megabytes of the journal fragments.
See Also:
getMaxLogSizeInMb()

isFilterLogStatus

public boolean isFilterLogStatus()
Should only mandatory logs be written ? Enabling this parameter lowers space usage of the fragments but makes debugging more complex.

Property name:
bitronix.tm.journal.disk.filterLogStatus - (defaults to false)

Returns:
true if only mandatory logs should be written.

setFilterLogStatus

public void setFilterLogStatus(boolean filterLogStatus)
Set if only mandatory logs should be written. Enabling this parameter lowers space usage of the fragments but makes debugging more complex.

Parameters:
filterLogStatus - true if only mandatory logs should be written.
See Also:
isFilterLogStatus()

isSkipCorruptedLogs

public boolean isSkipCorruptedLogs()
Should corrupted logs be skipped ?

Property name:
bitronix.tm.journal.disk.skipCorruptedLogs - (defaults to false)

Returns:
true if corrupted logs should be skipped.

setSkipCorruptedLogs

public void setSkipCorruptedLogs(boolean skipCorruptedLogs)
Set if corrupted logs should be skipped.

Parameters:
skipCorruptedLogs - true if corrupted logs should be skipped.
See Also:
isSkipCorruptedLogs()

isAsynchronous2Pc

public boolean isAsynchronous2Pc()
Should two phase commit be executed asynchronously ? Asynchronous two phase commit can improve performance when there are many resources enlisted in transactions but is more CPU intensive due to the dynamic thread spawning requirements. It also makes debugging more complex.

Property name:
bitronix.tm.2pc.async - (defaults to false)

Returns:
true if two phase commit should be executed asynchronously.

setAsynchronous2Pc

public void setAsynchronous2Pc(boolean asynchronous2Pc)
Set if two phase commit should be executed asynchronously. Asynchronous two phase commit can improve performance when there are many resources enlisted in transactions but is more CPU intensive due to the dynamic thread spawning requirements. It also makes debugging more complex.

Parameters:
asynchronous2Pc - true if two phase commit should be executed asynchronously.
See Also:
isAsynchronous2Pc()

isWarnAboutZeroResourceTransaction

public boolean isWarnAboutZeroResourceTransaction()
Should transactions executed without a single enlisted resource result in a warning or not ? Most of the time transactions executed with no enlisted resource reflect a bug or a mis-configuration somewhere.

Property name:
bitronix.tm.2pc.warnAboutZeroResourceTransactions - (defaults to true)

Returns:
true if transactions executed without a single enlisted resource should result in a warning.

setWarnAboutZeroResourceTransaction

public void setWarnAboutZeroResourceTransaction(boolean warnAboutZeroResourceTransaction)
Set if transactions executed without a single enlisted resource should result in a warning or not. Most of the time transactions executed with no enlisted resource reflect a bug or a mis-configuration somewhere.

Parameters:
warnAboutZeroResourceTransaction - true if transactions executed without a single enlisted resource should result in a warning.
See Also:
isWarnAboutZeroResourceTransaction()

getDefaultTransactionTimeout

public int getDefaultTransactionTimeout()
Default transaction timeout in seconds.

Property name:
bitronix.tm.timer.defaultTransactionTimeout - (defaults to 60)

Returns:
the default transaction timeout in seconds.

setDefaultTransactionTimeout

public void setDefaultTransactionTimeout(int defaultTransactionTimeout)
Set the default transaction timeout in seconds.

Parameters:
defaultTransactionTimeout - the default transaction timeout in seconds.
See Also:
getDefaultTransactionTimeout()

getGracefulShutdownInterval

public int getGracefulShutdownInterval()
Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.

Property name:
bitronix.tm.timer.gracefulShutdownInterval - (defaults to 60)

Returns:
the maximum amount of time in seconds.

setGracefulShutdownInterval

public void setGracefulShutdownInterval(int gracefulShutdownInterval)
Set the maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.

Parameters:
gracefulShutdownInterval - the maximum amount of time in seconds.
See Also:
getGracefulShutdownInterval()

getBackgroundRecoveryInterval

public int getBackgroundRecoveryInterval()
Deprecated. superceded by #getBackgroundRecoveryIntervalSeconds().

Interval in minutes at which to run the recovery process in the background. Disabled when set to 0.

Property name:
bitronix.tm.timer.backgroundRecoveryInterval - (defaults to 0)

Returns:
the interval in minutes.

setBackgroundRecoveryInterval

public void setBackgroundRecoveryInterval(int backgroundRecoveryInterval)
Deprecated. superceded by #setBackgroundRecoveryIntervalSeconds(int).

Set the interval in minutes at which to run the recovery process in the background. Disabled when set to 0.

Parameters:
backgroundRecoveryInterval - the interval in minutes.
See Also:
getBackgroundRecoveryInterval()

getBackgroundRecoveryIntervalSeconds

public int getBackgroundRecoveryIntervalSeconds()
Interval in seconds at which to run the recovery process in the background. Disabled when set to 0.

Property name:
bitronix.tm.timer.backgroundRecoveryIntervalSeconds - (defaults to 60)

Returns:
the interval in seconds.

setBackgroundRecoveryIntervalSeconds

public void setBackgroundRecoveryIntervalSeconds(int backgroundRecoveryIntervalSeconds)
Set the interval in seconds at which to run the recovery process in the background. Disabled when set to 0.

Parameters:
backgroundRecoveryIntervalSeconds - the interval in minutes.
See Also:
getBackgroundRecoveryIntervalSeconds()

isDisableJmx

public boolean isDisableJmx()
Should JMX Mbeans not be registered even if a JMX MBean server is detected ?

Property name:
bitronix.tm.disableJmx - (defaults to false)

Returns:
true if JMX MBeans should never be registered.

setDisableJmx

public void setDisableJmx(boolean disableJmx)
Set to true if JMX Mbeans should not be registered even if a JMX MBean server is detected.

Parameters:
disableJmx - true if JMX MBeans should never be registered.
See Also:
isDisableJmx()

getJndiUserTransactionName

public java.lang.String getJndiUserTransactionName()
Get the name the UserTransaction should be bound under in the BitronixContext.

Returns:
the name the UserTransaction should be bound under in the BitronixContext.

setJndiUserTransactionName

public void setJndiUserTransactionName(java.lang.String jndiUserTransactionName)
Set the name the UserTransaction should be bound under in the BitronixContext.

Parameters:
jndiUserTransactionName - the name the UserTransaction should be bound under in the BitronixContext.
See Also:
getJndiUserTransactionName()

getJndiTransactionSynchronizationRegistryName

public java.lang.String getJndiTransactionSynchronizationRegistryName()
Get the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.

Returns:
the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.

setJndiTransactionSynchronizationRegistryName

public void setJndiTransactionSynchronizationRegistryName(java.lang.String jndiTransactionSynchronizationRegistryName)
Set the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.

Parameters:
jndiTransactionSynchronizationRegistryName - the name the TransactionSynchronizationRegistry should be bound under in the BitronixContext.
See Also:
getJndiUserTransactionName()

getJournal

public java.lang.String getJournal()
Get the journal implementation. Can be disk, null or a class name.

Returns:
the journal name.

setJournal

public void setJournal(java.lang.String journal)
Set the journal name. Can be disk, null or a class name.

Parameters:
journal - the journal name.
See Also:
getJournal()

isCurrentNodeOnlyRecovery

public boolean isCurrentNodeOnlyRecovery()
Should the recovery process not recover XIDs generated with another JVM unique ID ? Setting this property to true is useful in clustered environments where multiple instances of BTM are running on different nodes.

Returns:
true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.
See Also:
contains the value used as the JVM unique ID.

setCurrentNodeOnlyRecovery

public void setCurrentNodeOnlyRecovery(boolean currentNodeOnlyRecovery)
Set to true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.

Parameters:
currentNodeOnlyRecovery - true if recovery should filter out recovered XIDs that do not contain this JVM's unique ID, false otherwise.
See Also:
isCurrentNodeOnlyRecovery()

getResourceConfigurationFilename

public java.lang.String getResourceConfigurationFilename()
ResourceLoader configuration file name. ResourceLoader will be disabled if this value is null.

Property name:
bitronix.tm.resource.configuration - (defaults to null)

Returns:
the filename of the resources configuration file or null if not configured.

setResourceConfigurationFilename

public void setResourceConfigurationFilename(java.lang.String resourceConfigurationFilename)
Set the ResourceLoader configuration file name.

Parameters:
resourceConfigurationFilename - the filename of the resources configuration file or null you do not want to use the ResourceLoader.
See Also:
getResourceConfigurationFilename()

buildServerIdArray

public byte[] buildServerIdArray()
Build the server ID byte array that will be prepended in generated UIDs. Once built, the value is cached for the duration of the JVM lifespan.

Returns:
the server ID.

shutdown

public void shutdown()
Description copied from interface: Service
Shutdown the service and free all held resources.

Specified by:
shutdown in interface Service

toString

public java.lang.String toString()