Harmonize JTA properties

Previously, both Atomikos and Bitronix were bound on the `spring.jta`
namespace which makes very hard to figure out which property belong to
which implementation. Besides, `AtomikosProperties` only exposed public
setter which does not generate any useful meta-data.

This commit moves the external configuration for Atomikos and Bitronix to
`spring.jta.atomikos.properties` and `spring.jta.bitronix.properties`
respectively. It also improves the meta-data support for those two
namespaces.

Closes gh-5165
This commit is contained in:
Stephane Nicoll 2016-02-16 16:44:50 +01:00
parent ff5b05fed9
commit 90f0fc6ce3
7 changed files with 353 additions and 26 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,7 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationHome; import org.springframework.boot.ApplicationHome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.jta.XAConnectionFactoryWrapper; import org.springframework.boot.jta.XAConnectionFactoryWrapper;
import org.springframework.boot.jta.XADataSourceWrapper; import org.springframework.boot.jta.XADataSourceWrapper;
import org.springframework.boot.jta.atomikos.AtomikosDependsOnBeanFactoryPostProcessor; import org.springframework.boot.jta.atomikos.AtomikosDependsOnBeanFactoryPostProcessor;
@ -50,9 +50,11 @@ import org.springframework.util.StringUtils;
* @author Josh Long * @author Josh Long
* @author Phillip Webb * @author Phillip Webb
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Stephane Nicoll
* @since 1.2.0 * @since 1.2.0
*/ */
@Configuration @Configuration
@EnableConfigurationProperties(AtomikosProperties.class)
@ConditionalOnClass({ JtaTransactionManager.class, UserTransactionManager.class }) @ConditionalOnClass({ JtaTransactionManager.class, UserTransactionManager.class })
@ConditionalOnMissingBean(PlatformTransactionManager.class) @ConditionalOnMissingBean(PlatformTransactionManager.class)
class AtomikosJtaConfiguration { class AtomikosJtaConfiguration {
@ -60,13 +62,6 @@ class AtomikosJtaConfiguration {
@Autowired @Autowired
private JtaProperties jtaProperties; private JtaProperties jtaProperties;
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = JtaProperties.PREFIX)
public AtomikosProperties atomikosProperties() {
return new AtomikosProperties();
}
@Bean(initMethod = "init", destroyMethod = "shutdownForce") @Bean(initMethod = "init", destroyMethod = "shutdownForce")
@ConditionalOnMissingBean(UserTransactionService.class) @ConditionalOnMissingBean(UserTransactionService.class)
public UserTransactionServiceImp userTransactionService( public UserTransactionServiceImp userTransactionService(

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -59,7 +59,7 @@ class BitronixJtaConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@ConfigurationProperties(prefix = JtaProperties.PREFIX) @ConfigurationProperties("spring.jta.bitronix.properties")
public bitronix.tm.Configuration bitronixConfiguration() { public bitronix.tm.Configuration bitronixConfiguration() {
bitronix.tm.Configuration config = TransactionManagerServices.getConfiguration(); bitronix.tm.Configuration config = TransactionManagerServices.getConfiguration();
if (StringUtils.hasText(this.jtaProperties.getTransactionManagerId())) { if (StringUtils.hasText(this.jtaProperties.getTransactionManagerId())) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,11 +29,9 @@ import org.springframework.transaction.jta.JtaTransactionManager;
* @author Andy Wilkinson * @author Andy Wilkinson
* @since 1.2.0 * @since 1.2.0
*/ */
@ConfigurationProperties(prefix = JtaProperties.PREFIX, ignoreUnknownFields = true) @ConfigurationProperties(prefix = "spring.jta", ignoreUnknownFields = true)
public class JtaProperties { public class JtaProperties {
public static final String PREFIX = "spring.jta";
/** /**
* Transaction logs directory. * Transaction logs directory.
*/ */

View File

@ -130,6 +130,119 @@
"description": "Enable JTA support.", "description": "Enable JTA support.",
"defaultValue": true "defaultValue": true
}, },
{
"name": "spring.jta.bitronix.properties.allow-multiple-lrc",
"description": "Allow multiple LRC resources to be enlisted into the same transaction.",
"defaultValue": false
},
{
"name": "spring.jta.bitronix.properties.asynchronous2-pc",
"description": "Enable asynchronously execution of two phase commit.",
"defaultValue": false
},
{
"name": "spring.jta.bitronix.properties.background-recovery-interval",
"description": "Interval in minutes at which to run the recovery process in the background.",
"defaultValue": 1,
"deprecation": {
"replacement": "spring.jta.bitronix.properties.background-recovery-interval-seconds"
}
},
{
"name": "spring.jta.bitronix.properties.background-recovery-interval-seconds",
"description": "Interval in seconds at which to run the recovery process in the background.",
"defaultValue": 60
},
{
"name": "spring.jta.bitronix.properties.current-node-only-recovery",
"description": "Recover only the current node. Should be enabled if you run multiple instances of the transaction manager on the same JMS and JDBC resources.",
"defaultValue": true
},
{
"name": "spring.jta.bitronix.properties.debug-zero-resource-transaction",
"description": "Log the creation and commit call stacks of transactions executed without a single enlisted resource.",
"defaultValue": false
},
{
"name": "spring.jta.bitronix.properties.default-transaction-timeout",
"description": "Default transaction timeout in seconds.",
"defaultValue": 60
},
{
"name": "spring.jta.bitronix.properties.disable-jmx",
"description": "Enable JMX support.",
"defaultValue": false
},
{
"name": "spring.jta.bitronix.properties.exception-analyzer",
"description": "Set the fully qualified name of the exception analyzer implementation to use."
},
{
"name": "spring.jta.bitronix.properties.filter-log-status",
"description": "Enable filtering of logs so that only mandatory logs are written.",
"defaultValue": false
},
{
"name": "spring.jta.bitronix.properties.force-batching-enabled",
"description": " Set if disk forces are batched.",
"defaultValue": true
},
{
"name": "spring.jta.bitronix.properties.forced-write-enabled",
"description": "Set if logs are forced to disk.",
"defaultValue": true
},
{
"name": "spring.jta.bitronix.properties.graceful-shutdown-interval",
"description": "Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.",
"defaultValue": 60
},
{
"name": "spring.jta.bitronix.properties.jndi-transaction-synchronization-registry-name",
"description": "JNDI name of the TransactionSynchronizationRegistry."
},
{
"name": "spring.jta.bitronix.properties.jndi-user-transaction-name",
"description": "JNDI name of the UserTransaction."
},
{
"name": "spring.jta.bitronix.properties.journal",
"description": "Name of the journal. Can be 'disk', 'null' or a class name.",
"defaultValue": "disk"
},
{
"name": "spring.jta.bitronix.properties.log-part1-filename",
"description": "Name of the first fragment of the journal.",
"defaultValue": "btm1.tlog"
},
{
"name": "spring.jta.bitronix.properties.log-part2-filename",
"description": "Name of the second fragment of the journal.",
"defaultValue": "btm2.tlog"
},
{
"name": "spring.jta.bitronix.properties.max-log-size-in-mb",
"description": "Maximum size in megabytes of the journal fragments.",
"defaultValue": 2
},
{
"name": "spring.jta.bitronix.properties.resource-configuration-filename",
"description": "ResourceLoader configuration file name."
},
{
"name": "spring.jta.bitronix.properties.server-id",
"description": "ASCII ID that must uniquely identify this TM instance. Default to the machine's IP address."
},
{
"name": "spring.jta.bitronix.properties.skip-corrupted-logs",
"description": "Skip corrupted transactions log entries. Use only at last resort when all you have to recover is a pair of corrupted files.",
"defaultValue": false
},
{
"name": "spring.jta.bitronix.properties.warn-about-zero-resource-transaction",
"description": "Log a warning for transactions executed without a single enlisted resource.",
"defaultValue": true
},
{ {
"name": "spring.mobile.devicedelegatingviewresolver.enabled", "name": "spring.mobile.devicedelegatingviewresolver.enabled",
"type": "java.lang.Boolean", "type": "java.lang.Boolean",

View File

@ -579,8 +579,9 @@ content into your application; rather pick only the properties that you need.
spring.jpa.show-sql=false # Enable logging of SQL statements. spring.jpa.show-sql=false # Enable logging of SQL statements.
# JTA ({sc-spring-boot-autoconfigure}/transaction/jta/JtaAutoConfiguration.{sc-ext}[JtaAutoConfiguration]) # JTA ({sc-spring-boot-autoconfigure}/transaction/jta/JtaAutoConfiguration.{sc-ext}[JtaAutoConfiguration])
spring.jta.*= # technology specific configuration spring.jta.enabled=true # Enable JTA support.
spring.jta.log-dir= # Transaction logs directory. spring.jta.log-dir= # Transaction logs directory.
spring.jta.transaction-manager-id= # Transaction manager unique identifier.
# ATOMIKOS # ATOMIKOS
spring.jta.atomikos.connectionfactory.borrow-connection-timeout=30 # Timeout, in seconds, for borrowing connections from the pool. spring.jta.atomikos.connectionfactory.borrow-connection-timeout=30 # Timeout, in seconds, for borrowing connections from the pool.
@ -604,6 +605,23 @@ content into your application; rather pick only the properties that you need.
spring.jta.atomikos.datasource.reap-timeout=0 # The reap timeout, in seconds, for borrowed connections. 0 denotes no limit. spring.jta.atomikos.datasource.reap-timeout=0 # The reap timeout, in seconds, for borrowed connections. 0 denotes no limit.
spring.jta.atomikos.datasource.test-query= # SQL query or statement used to validate a connection before returning it. spring.jta.atomikos.datasource.test-query= # SQL query or statement used to validate a connection before returning it.
spring.jta.atomikos.datasource.unique-resource-name=dataSource # The unique name used to identify the resource during recovery. spring.jta.atomikos.datasource.unique-resource-name=dataSource # The unique name used to identify the resource during recovery.
spring.jta.atomikos.properties.checkpoint-interval=500 # Interval between checkpoints.
spring.jta.atomikos.properties.console-file-count=1 # Number of debug logs files that can be created.
spring.jta.atomikos.properties.console-file-limit=-1 # How many bytes can be stored at most in debug logs files.
spring.jta.atomikos.properties.console-file-name=tm.out # Debug logs file name.
spring.jta.atomikos.properties.console-log-level= # Console log level.
spring.jta.atomikos.properties.default-jta-timeout=10000 # Default timeout for JTA transactions.
spring.jta.atomikos.properties.enable-logging=true # Enable disk logging.
spring.jta.atomikos.properties.force-shutdown-on-vm-exit=false # Specify if a VM shutdown should trigger forced shutdown of the transaction core.
spring.jta.atomikos.properties.log-base-dir= # Directory in which the log files should be stored.
spring.jta.atomikos.properties.log-base-name=tmlog # Transactions log file base name.
spring.jta.atomikos.properties.max-actives=50 # Maximum number of active transactions.
spring.jta.atomikos.properties.max-timeout=300000 # Maximum timeout (in milliseconds) that can be allowed for transactions.
spring.jta.atomikos.properties.output-dir= # Directory in which to store the debug log files.
spring.jta.atomikos.properties.serial-jta-transactions=true # Specify if sub-transactions should be joined when possible.
spring.jta.atomikos.properties.service= # Transaction manager implementation that should be started.
spring.jta.atomikos.properties.threaded-two-phase-commit=true # Use different (and concurrent) threads for two-phase commit on the participating resources.
spring.jta.atomikos.properties.transaction-manager-unique-name= # Transaction manager's unique name.
# BITRONIX # BITRONIX
spring.jta.bitronix.connectionfactory.acquire-increment=1 # Number of connections to create when growing the pool. spring.jta.bitronix.connectionfactory.acquire-increment=1 # Number of connections to create when growing the pool.
@ -647,6 +665,28 @@ content into your application; rather pick only the properties that you need.
spring.jta.bitronix.datasource.two-pc-ordering-position=1 # The position that this resource should take during two-phase commit (always first is Integer.MIN_VALUE, always last is Integer.MAX_VALUE). spring.jta.bitronix.datasource.two-pc-ordering-position=1 # The position that this resource should take during two-phase commit (always first is Integer.MIN_VALUE, always last is Integer.MAX_VALUE).
spring.jta.bitronix.datasource.unique-name=dataSource # The unique name used to identify the resource during recovery. spring.jta.bitronix.datasource.unique-name=dataSource # The unique name used to identify the resource during recovery.
spring.jta.bitronix.datasource.use-tm-join=true Whether or not TMJOIN should be used when starting XAResources. spring.jta.bitronix.datasource.use-tm-join=true Whether or not TMJOIN should be used when starting XAResources.
spring.jta.bitronix.properties.allow-multiple-lrc=false # Allow multiple LRC resources to be enlisted into the same transaction.
spring.jta.bitronix.properties.asynchronous2-pc=false # Enable asynchronously execution of two phase commit.
spring.jta.bitronix.properties.background-recovery-interval-seconds=60 # Interval in seconds at which to run the recovery process in the background.
spring.jta.bitronix.properties.current-node-only-recovery=true # Recover only the current node.
spring.jta.bitronix.properties.debug-zero-resource-transaction=false # Log the creation and commit call stacks of transactions executed without a single enlisted resource.
spring.jta.bitronix.properties.default-transaction-timeout=60 # Default transaction timeout in seconds.
spring.jta.bitronix.properties.disable-jmx=false # Enable JMX support.
spring.jta.bitronix.properties.exception-analyzer= # Set the fully qualified name of the exception analyzer implementation to use.
spring.jta.bitronix.properties.filter-log-status=false # Enable filtering of logs so that only mandatory logs are written.
spring.jta.bitronix.properties.force-batching-enabled=true # Set if disk forces are batched.
spring.jta.bitronix.properties.forced-write-enabled=true # Set if logs are forced to disk.
spring.jta.bitronix.properties.graceful-shutdown-interval=60 # Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
spring.jta.bitronix.properties.jndi-transaction-synchronization-registry-name= # JNDI name of the TransactionSynchronizationRegistry.
spring.jta.bitronix.properties.jndi-user-transaction-name= # JNDI name of the UserTransaction.
spring.jta.bitronix.properties.journal=disk # Name of the journal. Can be 'disk', 'null' or a class name.
spring.jta.bitronix.properties.log-part1-filename=btm1.tlog # Name of the first fragment of the journal.
spring.jta.bitronix.properties.log-part2-filename=btm2.tlog # Name of the second fragment of the journal.
spring.jta.bitronix.properties.max-log-size-in-mb=2 # Maximum size in megabytes of the journal fragments.
spring.jta.bitronix.properties.resource-configuration-filename= # ResourceLoader configuration file name.
spring.jta.bitronix.properties.server-id= # ASCII ID that must uniquely identify this TM instance. Default to the machine's IP address.
spring.jta.bitronix.properties.skip-corrupted-logs=false # Skip corrupted transactions log entries.
spring.jta.bitronix.properties.warn-about-zero-resource-transaction=true # Log a warning for transactions executed without a single enlisted resource.
# EMBEDDED MONGODB ({sc-spring-boot-autoconfigure}/mongo/embedded/EmbeddedMongoProperties.{sc-ext}[EmbeddedMongoProperties]) # EMBEDDED MONGODB ({sc-spring-boot-autoconfigure}/mongo/embedded/EmbeddedMongoProperties.{sc-ext}[EmbeddedMongoProperties])
spring.mongodb.embedded.features=SYNC_DELAY # Comma-separated list of features to enable. spring.mongodb.embedded.features=SYNC_DELAY # Comma-separated list of features to enable.

View File

@ -3778,8 +3778,8 @@ startup and shutdown ordering.
By default Atomikos transaction logs will be written to a `transaction-logs` directory in By default Atomikos transaction logs will be written to a `transaction-logs` directory in
your application home directory (the directory in which your application jar file your application home directory (the directory in which your application jar file
resides). You can customize this directory by setting a `spring.jta.log-dir` property in resides). You can customize this directory by setting a `spring.jta.log-dir` property in
your `application.properties` file. Properties starting `spring.jta.` can also be used to your `application.properties` file. Properties starting `spring.jta.atomikos.properties`
customize the Atomikos `UserTransactionServiceImp`. See the can also be used to customize the Atomikos `UserTransactionServiceImp`. See the
{dc-spring-boot}/jta/atomikos/AtomikosProperties.{dc-ext}[`AtomikosProperties` Javadoc] {dc-spring-boot}/jta/atomikos/AtomikosProperties.{dc-ext}[`AtomikosProperties` Javadoc]
for complete details. for complete details.
@ -3800,9 +3800,9 @@ correct.
By default Bitronix transaction log files (`part1.btm` and `part2.btm`) will be written to By default Bitronix transaction log files (`part1.btm` and `part2.btm`) will be written to
a `transaction-logs` directory in your application home directory. You can customize this a `transaction-logs` directory in your application home directory. You can customize this
directory by using the `spring.jta.log-dir` property. Properties starting `spring.jta.` directory by using the `spring.jta.log-dir` property. Properties starting
are also bound to the `bitronix.tm.Configuration` bean, allowing for complete `spring.jta.bitronix.properties` are also bound to the `bitronix.tm.Configuration` bean,
customization. See the allowing for complete customization. See the
https://github.com/bitronix/btm/wiki/Transaction-manager-configuration[Bitronix documentation] https://github.com/bitronix/btm/wiki/Transaction-manager-configuration[Bitronix documentation]
for details. for details.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,6 +20,8 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.TreeMap; import java.util.TreeMap;
import org.springframework.boot.context.properties.ConfigurationProperties;
/** /**
* Bean friendly variant of * Bean friendly variant of
* <a href="http://www.atomikos.com/Documentation/JtaProperties">Atomikos configuration * <a href="http://www.atomikos.com/Documentation/JtaProperties">Atomikos configuration
@ -27,13 +29,107 @@ import java.util.TreeMap;
* binding. * binding.
* *
* @author Phillip Webb * @author Phillip Webb
* @author Stephane Nicoll
* @since 1.2.0 * @since 1.2.0
* @see #asProperties() * @see #asProperties()
*/ */
@ConfigurationProperties("spring.jta.atomikos.properties")
public class AtomikosProperties { public class AtomikosProperties {
private final Map<String, String> values = new TreeMap<String, String>(); private final Map<String, String> values = new TreeMap<String, String>();
/**
* Transaction manager implementation that should be started.
*/
private String service;
/**
* Maximum timeout (in milliseconds) that can be allowed for transactions.
*/
private long maxTimeout = 300000;
/**
* Default timeout for JTA transactions.
*/
private long defaultJtaTimeout = 10000;
/**
* Maximum number of active transactions.
*/
private int maxActives = 50;
/**
* Enable disk logging.
*/
private boolean enableLogging = true;
/**
* Transaction manager's unique name. Defaults to the machine's IP address. If you
* plan to run more than one transaction manager against one database you must set
* this property to a unique value.
*/
private String transactionManagerUniqueName;
/**
* Specify if sub-transactions should be joined when possible.
*/
private boolean serialJtaTransactions = true;
/**
* Specify if a VM shutdown should trigger forced shutdown of the transaction core.
*/
private boolean forceShutdownOnVmExit;
/**
* Transactions log file base name.
*/
private String logBaseName = "tmlog";
/**
* Directory in which the log files should be stored. Defaults to the current working
* directory.
*/
private String logBaseDir;
/**
* Interval between checkpoints. A checkpoint reduces the log file size at the
* expense of adding some overhead in the runtime.
*/
private long checkpointInterval = 500;
/**
* Console log level.
*/
private AtomikosLoggingLevel consoleLogLevel = AtomikosLoggingLevel.WARN;
/**
* Directory in which to store the debug log files. Defaults to the current working
* directory.
*/
private String outputDir;
/**
* Debug logs file name.
*/
private String consoleFileName = "tm.out";
/**
* Number of debug logs files that can be created.
*/
private int consoleFileCount = 1;
/**
* How many bytes can be stored at most in debug logs files. Negative values means
* unlimited.
*/
private int consoleFileLimit = -1;
/**
* Use different (and concurrent) threads for two-phase commit on the participating
* resources.
*/
private boolean threadedTwoPhaseCommit = true;
/** /**
* Specifies the transaction manager implementation that should be started. There is * Specifies the transaction manager implementation that should be started. There is
* no default value and this must be set. Generally, * no default value and this must be set. Generally,
@ -42,9 +138,14 @@ public class AtomikosProperties {
* @param service the service * @param service the service
*/ */
public void setService(String service) { public void setService(String service) {
this.service = service;
set("service", service); set("service", service);
} }
public String getService() {
return this.service;
}
/** /**
* Specifies the maximum timeout (in milliseconds) that can be allowed for * Specifies the maximum timeout (in milliseconds) that can be allowed for
* transactions. Defaults to {@literal 300000}. This means that calls to * transactions. Defaults to {@literal 300000}. This means that calls to
@ -53,28 +154,43 @@ public class AtomikosProperties {
* @param maxTimeout the max timeout * @param maxTimeout the max timeout
*/ */
public void setMaxTimeout(long maxTimeout) { public void setMaxTimeout(long maxTimeout) {
this.maxTimeout = maxTimeout;
set("max_timeout", maxTimeout); set("max_timeout", maxTimeout);
} }
public long getMaxTimeout() {
return this.maxTimeout;
}
/** /**
* The default timeout for JTA transactions (optional, defaults to {@literal 10000} * The default timeout for JTA transactions (optional, defaults to {@literal 10000}
* ms). * ms).
* @param defaultJtaTimeout the default JTA timeout * @param defaultJtaTimeout the default JTA timeout
*/ */
public void setDefaultJtaTimeout(long defaultJtaTimeout) { public void setDefaultJtaTimeout(long defaultJtaTimeout) {
this.defaultJtaTimeout = defaultJtaTimeout;
set("default_jta_timeout", defaultJtaTimeout); set("default_jta_timeout", defaultJtaTimeout);
} }
public long getDefaultJtaTimeout() {
return this.defaultJtaTimeout;
}
/** /**
* Specifies the maximum number of active transactions. Defaults to {@literal 50}. A * Specifies the maximum number of active transactions. Defaults to {@literal 50}. A
* negative value means infinite amount. You will get an {@code IllegalStateException} * negative value means infinite amount. You will get an {@code IllegalStateException}
* with error message "Max number of active transactions reached" if you call * with error message "Max number of active transactions reached" if you call
* {@code UserTransaction.begin()} while there are already n concurrent transactions * {@code UserTransaction.begin()} while there are already n concurrent transactions
* running, n being this value. * running, n being this value.
* @param maxActivities the max activities * @param maxActives the max activities
*/ */
public void setMaxActives(int maxActivities) { public void setMaxActives(int maxActives) {
set("max_actives", maxActivities); this.maxActives = maxActives;
set("max_actives", maxActives);
}
public int getMaxActives() {
return this.maxActives;
} }
/** /**
@ -85,9 +201,14 @@ public class AtomikosProperties {
* @param enableLogging if logging is enabled * @param enableLogging if logging is enabled
*/ */
public void setEnableLogging(boolean enableLogging) { public void setEnableLogging(boolean enableLogging) {
this.enableLogging = enableLogging;
set("enable_logging", enableLogging); set("enable_logging", enableLogging);
} }
public boolean isEnableLogging() {
return this.enableLogging;
}
/** /**
* Specifies the transaction manager's unique name. Defaults to the machine's IP * Specifies the transaction manager's unique name. Defaults to the machine's IP
* address. If you plan to run more than one transaction manager against one database * address. If you plan to run more than one transaction manager against one database
@ -100,9 +221,14 @@ public class AtomikosProperties {
* @param uniqueName the unique name * @param uniqueName the unique name
*/ */
public void setTransactionManagerUniqueName(String uniqueName) { public void setTransactionManagerUniqueName(String uniqueName) {
this.transactionManagerUniqueName = uniqueName;
set("tm_unique_name", uniqueName); set("tm_unique_name", uniqueName);
} }
public String getTransactionManagerUniqueName() {
return this.transactionManagerUniqueName;
}
/** /**
* Specifies if subtransactions should be joined when possible. Defaults to true. When * Specifies if subtransactions should be joined when possible. Defaults to true. When
* false, no attempt to call {@code XAResource.start(TM_JOIN)} will be made for * false, no attempt to call {@code XAResource.start(TM_JOIN)} will be made for
@ -112,18 +238,28 @@ public class AtomikosProperties {
* @param serialJtaTransactions if serial JTA transaction are supported * @param serialJtaTransactions if serial JTA transaction are supported
*/ */
public void setSerialJtaTransactions(boolean serialJtaTransactions) { public void setSerialJtaTransactions(boolean serialJtaTransactions) {
this.serialJtaTransactions = serialJtaTransactions;
set("serial_jta_transactions", serialJtaTransactions); set("serial_jta_transactions", serialJtaTransactions);
} }
public boolean isSerialJtaTransactions() {
return this.serialJtaTransactions;
}
/** /**
* Specifies whether VM shutdown should trigger forced shutdown of the transaction * Specifies whether VM shutdown should trigger forced shutdown of the transaction
* core. Defaults to false. * core. Defaults to false.
* @param forceShutdownOnVmExit if VM shutdown should be forced * @param forceShutdownOnVmExit if VM shutdown should be forced
*/ */
public void setForceShutdownOnVmExit(boolean forceShutdownOnVmExit) { public void setForceShutdownOnVmExit(boolean forceShutdownOnVmExit) {
this.forceShutdownOnVmExit = forceShutdownOnVmExit;
set("force_shutdown_on_vm_exit", forceShutdownOnVmExit); set("force_shutdown_on_vm_exit", forceShutdownOnVmExit);
} }
public boolean isForceShutdownOnVmExit() {
return this.forceShutdownOnVmExit;
}
/** /**
* Specifies the transactions log file base name. Defaults to {@literal tmlog}. The * Specifies the transactions log file base name. Defaults to {@literal tmlog}. The
* transactions logs are stored in files using this name appended with a number and * transactions logs are stored in files using this name appended with a number and
@ -132,9 +268,14 @@ public class AtomikosProperties {
* @param logBaseName the log base name * @param logBaseName the log base name
*/ */
public void setLogBaseName(String logBaseName) { public void setLogBaseName(String logBaseName) {
this.logBaseName = logBaseName;
set("log_base_name", logBaseName); set("log_base_name", logBaseName);
} }
public String getLogBaseName() {
return this.logBaseName;
}
/** /**
* Specifies the directory in which the log files should be stored. Defaults to the * Specifies the directory in which the log files should be stored. Defaults to the
* current working directory. This directory should be a stable storage like a SAN, * current working directory. This directory should be a stable storage like a SAN,
@ -143,60 +284,95 @@ public class AtomikosProperties {
* @param logBaseDir the log base dir * @param logBaseDir the log base dir
*/ */
public void setLogBaseDir(String logBaseDir) { public void setLogBaseDir(String logBaseDir) {
this.logBaseDir = logBaseDir;
set("log_base_dir", logBaseDir); set("log_base_dir", logBaseDir);
} }
public String getLogBaseDir() {
return this.logBaseDir;
}
/** /**
* Specifies the interval between checkpoints. A checkpoint reduces the log file size * Specifies the interval between checkpoints. A checkpoint reduces the log file size
* at the expense of adding some overhead in the runtime. Defaults to {@literal 500}. * at the expense of adding some overhead in the runtime. Defaults to {@literal 500}.
* @param checkpointInterval the checkpoint interval * @param checkpointInterval the checkpoint interval
*/ */
public void setCheckpointInterval(long checkpointInterval) { public void setCheckpointInterval(long checkpointInterval) {
this.checkpointInterval = checkpointInterval;
set("checkpoint_interval", checkpointInterval); set("checkpoint_interval", checkpointInterval);
} }
public long getCheckpointInterval() {
return this.checkpointInterval;
}
/** /**
* Specifies the console log level. Defaults to {@link AtomikosLoggingLevel#WARN}. * Specifies the console log level. Defaults to {@link AtomikosLoggingLevel#WARN}.
* @param consoleLogLevel the console log level * @param consoleLogLevel the console log level
*/ */
public void setConsoleLogLevel(AtomikosLoggingLevel consoleLogLevel) { public void setConsoleLogLevel(AtomikosLoggingLevel consoleLogLevel) {
this.consoleLogLevel = consoleLogLevel;
set("console_log_level", consoleLogLevel); set("console_log_level", consoleLogLevel);
} }
public AtomikosLoggingLevel getConsoleLogLevel() {
return this.consoleLogLevel;
}
/** /**
* Specifies the directory in which to store the debug log files. Defaults to the * Specifies the directory in which to store the debug log files. Defaults to the
* current working directory. * current working directory.
* @param outputDir the output dir * @param outputDir the output dir
*/ */
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir;
set("output_dir", outputDir); set("output_dir", outputDir);
} }
public String getOutputDir() {
return this.outputDir;
}
/** /**
* Specifies the debug logs file name. Defaults to {@literal tm.out}. * Specifies the debug logs file name. Defaults to {@literal tm.out}.
* @param consoleFileName the console file name * @param consoleFileName the console file name
*/ */
public void setConsoleFileName(String consoleFileName) { public void setConsoleFileName(String consoleFileName) {
this.consoleFileName = consoleFileName;
set("console_file_name", consoleFileName); set("console_file_name", consoleFileName);
} }
public String getConsoleFileName() {
return this.consoleFileName;
}
/** /**
* Specifies how many debug logs files can be created. Defaults to {@literal 1}. * Specifies how many debug logs files can be created. Defaults to {@literal 1}.
* @param consoleFileCount the console file count * @param consoleFileCount the console file count
*/ */
public void setConsoleFileCount(int consoleFileCount) { public void setConsoleFileCount(int consoleFileCount) {
this.consoleFileCount = consoleFileCount;
set("console_file_count", consoleFileCount); set("console_file_count", consoleFileCount);
} }
public int getConsoleFileCount() {
return this.consoleFileCount;
}
/** /**
* Specifies how many bytes can be stored at most in debug logs files. Defaults to * Specifies how many bytes can be stored at most in debug logs files. Defaults to
* {@literal -1}. Negative values means unlimited. * {@literal -1}. Negative values means unlimited.
* @param consoleFileLimit the console file limit * @param consoleFileLimit the console file limit
*/ */
public void setConsoleFileLimit(int consoleFileLimit) { public void setConsoleFileLimit(int consoleFileLimit) {
this.consoleFileLimit = consoleFileLimit;
set("console_file_limit", consoleFileLimit); set("console_file_limit", consoleFileLimit);
} }
public int getConsoleFileLimit() {
return this.consoleFileLimit;
}
/** /**
* Specifies whether or not to use different (and concurrent) threads for two-phase * Specifies whether or not to use different (and concurrent) threads for two-phase
* commit on the participating resources. Setting this to {@literal true} implies that * commit on the participating resources. Setting this to {@literal true} implies that
@ -207,9 +383,14 @@ public class AtomikosProperties {
* @param threadedTwoPhaseCommit if threaded two phase commits should be used * @param threadedTwoPhaseCommit if threaded two phase commits should be used
*/ */
public void setThreadedTwoPhaseCommit(boolean threadedTwoPhaseCommit) { public void setThreadedTwoPhaseCommit(boolean threadedTwoPhaseCommit) {
this.threadedTwoPhaseCommit = threadedTwoPhaseCommit;
set("threaded_2pc", threadedTwoPhaseCommit); set("threaded_2pc", threadedTwoPhaseCommit);
} }
public boolean isThreadedTwoPhaseCommit() {
return this.threadedTwoPhaseCommit;
}
private void set(String key, Object value) { private void set(String key, Object value) {
set("com.atomikos.icatch.", key, value); set("com.atomikos.icatch.", key, value);
} }