Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions btm/src/main/java/bitronix/tm/BitronixTransactionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,17 @@ public void dumpTransactionContexts() {
} // if
}

/**
* Dump an overview of all running transactions as info logs.
*/
public void dumpTransactionContextsInfo() {
log.info("dumping " + inFlightTransactions.size() + " transaction context(s)");
for (Map.Entry<Uid, BitronixTransaction> entry : inFlightTransactions.entrySet()) {
BitronixTransaction tx = entry.getValue();
log.info(tx.toString());
}
}

/**
* Shut down the transaction manager and release all resources held by it.
* <p>This call will also close the resources pools registered by the {@link bitronix.tm.resource.ResourceLoader}
Expand All @@ -321,40 +332,40 @@ public synchronized void shutdown() {
log.info("shutting down Bitronix Transaction Manager");
internalShutdown();

if (log.isDebugEnabled()) log.debug("shutting down resource loader");
log.info("shutting down resource loader");
TransactionManagerServices.getResourceLoader().shutdown();

if (log.isDebugEnabled()) log.debug("shutting down executor");
log.info("shutting down executor");
TransactionManagerServices.getExecutor().shutdown();

if (log.isDebugEnabled()) log.debug("shutting down task scheduler");
log.info("shutting down task scheduler");
TransactionManagerServices.getTaskScheduler().shutdown();

if (log.isDebugEnabled()) log.debug("shutting down journal");
log.info("shutting down journal");
TransactionManagerServices.getJournal().shutdown();

if (log.isDebugEnabled()) log.debug("shutting down recoverer");
log.info("shutting down recoverer");
TransactionManagerServices.getRecoverer().shutdown();

if (log.isDebugEnabled()) log.debug("shutting down configuration");
log.info("shutting down configuration");
TransactionManagerServices.getConfiguration().shutdown();

// clear references
TransactionManagerServices.clear();

if (log.isDebugEnabled()) log.debug("shutdown ran successfully");
log.info("shutdown ran successfully");
}

private void internalShutdown() {
shuttingDown = true;
dumpTransactionContexts();
dumpTransactionContextsInfo();

int seconds = TransactionManagerServices.getConfiguration().getGracefulShutdownInterval();
int txCount = 0;
try {
txCount = inFlightTransactions.size();
while (seconds > 0 && txCount > 0) {
if (log.isDebugEnabled()) log.debug("still " + txCount + " in-flight transactions, waiting... (" + seconds + " second(s) left)");
log.info("still " + txCount + " in-flight transactions, waiting... (" + seconds + " second(s) left)");
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Expand All @@ -368,11 +379,11 @@ private void internalShutdown() {
}

if (txCount > 0) {
if (log.isDebugEnabled()) log.debug("still " + txCount + " in-flight transactions, shutting down anyway");
dumpTransactionContexts();
log.info("still " + txCount + " in-flight transactions, shutting down anyway");
dumpTransactionContextsInfo();
}
else {
if (log.isDebugEnabled()) log.debug("all transactions finished, resuming shutdown");
log.info("all transactions finished, resuming shutdown");
}
}

Expand Down