Polish "Allow graceful shutdown of Atomikos"

Closes gh-11237
This commit is contained in:
Stephane Nicoll 2017-12-12 08:30:24 +01:00
parent 46d94aba4f
commit 408368a1f9
4 changed files with 25 additions and 25 deletions

View File

@ -53,7 +53,6 @@ import org.springframework.util.StringUtils;
* @author Andy Wilkinson
* @author Stephane Nicoll
* @author Kazuki Shimizu
* @author Nakul Mishra
* @since 1.2.0
*/
@Configuration

View File

@ -749,6 +749,7 @@ content into your application. Rather, pick only the properties that you need.
spring.jta.atomikos.properties.allow-sub-transactions=true # Specify whether sub-transactions are allowed.
spring.jta.atomikos.properties.checkpoint-interval=500 # Interval between checkpoints, in milliseconds.
spring.jta.atomikos.properties.default-jta-timeout=10000 # Default timeout for JTA transactions, in milliseconds.
spring.jta.atomikos.properties.default-max-wait-time-on-shutdown=9223372036854775807 # How long should normal shutdown (no-force) wait for transactions to complete.
spring.jta.atomikos.properties.enable-logging=true # Whether to enable disk logging.
spring.jta.atomikos.properties.force-shutdown-on-vm-exit=false # Whether 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.

View File

@ -29,7 +29,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* @author Phillip Webb
* @author Stephane Nicoll
* @author Nakul Mishra
* @since 1.2.0
* @see #asProperties()
*/
@ -83,6 +82,11 @@ public class AtomikosProperties {
*/
private boolean forceShutdownOnVmExit;
/**
* How long should normal shutdown (no-force) wait for transactions to complete.
*/
private long defaultMaxWaitTimeOnShutdown = Long.MAX_VALUE;
/**
* Transactions log file base name.
*/
@ -108,10 +112,6 @@ public class AtomikosProperties {
private final Recovery recovery = new Recovery();
/**
* How long should normal shutdown (no-force) wait for transactions to complete.
*/
private long defaultMaxWaitTimeOnShutdown = Long.MAX_VALUE;
/**
* Specifies the transaction manager implementation that should be started. There is
@ -242,6 +242,19 @@ public class AtomikosProperties {
return this.forceShutdownOnVmExit;
}
/**
* Specifies how long should a normal shutdown (no-force) wait for transactions to complete.
* Defaults to {@literal Long.MAX_VALUE}.
* @param defaultMaxWaitTimeOnShutdown the default max wait time on shutdown
*/
public void setDefaultMaxWaitTimeOnShutdown(long defaultMaxWaitTimeOnShutdown) {
this.defaultMaxWaitTimeOnShutdown = defaultMaxWaitTimeOnShutdown;
}
public long getDefaultMaxWaitTimeOnShutdown() {
return this.defaultMaxWaitTimeOnShutdown;
}
/**
* 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
@ -306,19 +319,6 @@ public class AtomikosProperties {
return this.recovery;
}
/**
* Specifies how long should a normal shutdown (no-force) wait for transactions to complete.
* Defaults to {@literal Long.MAX_VALUE}.
* @param defaultMaxWaitTimeOnShutdown the default max wait time on shutdown
*/
public void setDefaultMaxWaitTimeOnShutdown(long defaultMaxWaitTimeOnShutdown) {
this.defaultMaxWaitTimeOnShutdown = defaultMaxWaitTimeOnShutdown;
}
public long getDefaultMaxWaitTimeOnShutdown() {
return this.defaultMaxWaitTimeOnShutdown;
}
/**
* Returns the properties as a {@link Properties} object that can be used with
* Atomikos.
@ -335,6 +335,8 @@ public class AtomikosProperties {
set(properties, "serial_jta_transactions", isSerialJtaTransactions());
set(properties, "allow_subtransactions", isAllowSubTransactions());
set(properties, "force_shutdown_on_vm_exit", isForceShutdownOnVmExit());
set(properties, "default_max_wait_time_on_shutdown",
getDefaultMaxWaitTimeOnShutdown());
set(properties, "log_base_name", getLogBaseName());
set(properties, "log_base_dir", getLogBaseDir());
set(properties, "checkpoint_interval", getCheckpointInterval());
@ -345,7 +347,6 @@ public class AtomikosProperties {
set(properties, "recovery_delay", recovery.getDelay());
set(properties, "oltp_max_retries", recovery.getMaxRetries());
set(properties, "oltp_retry_interval", recovery.getRetryInterval());
set(properties, "default_max_wait_time_on_shutdown", getDefaultMaxWaitTimeOnShutdown());
return properties;
}

View File

@ -33,7 +33,6 @@ import static org.assertj.core.api.Assertions.entry;
*
* @author Phillip Webb
* @author Stephane Nicoll
* @author Nakul Mishra
*/
public class AtomikosPropertiesTests {
@ -50,6 +49,7 @@ public class AtomikosPropertiesTests {
this.properties.setSerialJtaTransactions(true);
this.properties.setAllowSubTransactions(false);
this.properties.setForceShutdownOnVmExit(true);
this.properties.setDefaultMaxWaitTimeOnShutdown(20);
this.properties.setLogBaseName("logBaseName");
this.properties.setLogBaseDir("logBaseDir");
this.properties.setCheckpointInterval(4);
@ -59,7 +59,6 @@ public class AtomikosPropertiesTests {
this.properties.getRecovery().setDelay(Duration.ofMillis(3000));
this.properties.getRecovery().setMaxRetries(10);
this.properties.getRecovery().setRetryInterval(Duration.ofMillis(4000));
this.properties.setDefaultMaxWaitTimeOnShutdown(20);
assertThat(this.properties.asProperties().size()).isEqualTo(18);
assertProperty("com.atomikos.icatch.service", "service");
assertProperty("com.atomikos.icatch.max_timeout", "1");
@ -70,6 +69,7 @@ public class AtomikosPropertiesTests {
assertProperty("com.atomikos.icatch.serial_jta_transactions", "true");
assertProperty("com.atomikos.icatch.allow_subtransactions", "false");
assertProperty("com.atomikos.icatch.force_shutdown_on_vm_exit", "true");
assertProperty("com.atomikos.icatch.default_max_wait_time_on_shutdown", "20");
assertProperty("com.atomikos.icatch.log_base_name", "logBaseName");
assertProperty("com.atomikos.icatch.log_base_dir", "logBaseDir");
assertProperty("com.atomikos.icatch.checkpoint_interval", "4");
@ -78,7 +78,6 @@ public class AtomikosPropertiesTests {
assertProperty("com.atomikos.icatch.recovery_delay", "3000");
assertProperty("com.atomikos.icatch.oltp_max_retries", "10");
assertProperty("com.atomikos.icatch.oltp_retry_interval", "4000");
assertProperty("com.atomikos.icatch.default_max_wait_time_on_shutdown", "20");
}
@Test
@ -92,13 +91,13 @@ public class AtomikosPropertiesTests {
"com.atomikos.icatch.serial_jta_transactions",
"com.atomikos.icatch.allow_subtransactions",
"com.atomikos.icatch.force_shutdown_on_vm_exit",
"com.atomikos.icatch.default_max_wait_time_on_shutdown",
"com.atomikos.icatch.log_base_name",
"com.atomikos.icatch.checkpoint_interval",
"com.atomikos.icatch.threaded_2pc",
"com.atomikos.icatch.forget_orphaned_log_entries_delay",
"com.atomikos.icatch.oltp_max_retries",
"com.atomikos.icatch.oltp_retry_interval",
"com.atomikos.icatch.default_max_wait_time_on_shutdown"));
"com.atomikos.icatch.oltp_retry_interval"));
assertThat(properties).contains(entry("com.atomikos.icatch.recovery_delay",
defaultSettings.get("com.atomikos.icatch.default_jta_timeout")));
assertThat(properties).hasSize(15);