code
stringlengths
25
201k
docstring
stringlengths
19
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
51
path
stringlengths
11
314
url
stringlengths
62
377
license
stringclasses
7 values
public static ThreadContext getThreadContext() { return threadContext.get(); }
Get the ThreadContext thread local value for the calling thread. This is the only way to access the ThreadContext. The get() call will automatically construct a ThreadContext if this thread doesn't have one (see initialValue() above). @return the calling thread's ThreadContext
getThreadContext
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/ThreadContext.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/ThreadContext.java
Apache-2.0
public BitronixTransaction getTransaction() { return transaction; }
Return the transaction linked with this ThreadContext. @return the transaction linked to this ThreadContext or null if there is none.
getTransaction
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/ThreadContext.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/ThreadContext.java
Apache-2.0
public void setTransaction(BitronixTransaction transaction) { if (transaction == null) throw new IllegalArgumentException("transaction parameter cannot be null"); if (log.isDebugEnabled()) { log.debug("assigning <" + transaction + "> to <" + this + ">"); } this.transaction = transaction; }
Link a transaction with this ThreadContext. @param transaction the transaction to link.
setTransaction
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/ThreadContext.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/ThreadContext.java
Apache-2.0
public void clearTransaction() { transaction = null; }
Clean the transaction from this ThreadContext
clearTransaction
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/ThreadContext.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/ThreadContext.java
Apache-2.0
public int getTimeout() { return timeout; }
Return this context's default timeout. @return this context's default timeout.
getTimeout
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/ThreadContext.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/ThreadContext.java
Apache-2.0
public void setTimeout(int timeout) { if (timeout == 0) { int defaultValue = TransactionManagerServices.getConfiguration().getDefaultTransactionTimeout(); if (log.isDebugEnabled()) { log.debug("resetting default timeout of thread context to default value of " + defaultValue + "s"); } this.timeout = defaultValue; } else { if (log.isDebugEnabled()) { log.debug("changing default timeout of thread context to " + timeout + "s"); } this.timeout = timeout; } }
Set this context's default timeout. All transactions started by the thread linked to this context will get this value as their default timeout. @param timeout the new default timeout value in seconds.
setTimeout
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/ThreadContext.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/ThreadContext.java
Apache-2.0
@Override public String toString() { return "a ThreadContext (" + System.identityHashCode(this) + ") with transaction " + transaction + ", default timeout " + timeout + "s"; }
Return a human-readable representation. @return a human-readable representation.
toString
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/ThreadContext.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/ThreadContext.java
Apache-2.0
public void enlist(XAResourceHolderState xaResourceHolderState) throws XAException, BitronixSystemException { XAResourceHolderState alreadyEnlistedHolder = findXAResourceHolderState(xaResourceHolderState.getXAResource()); if (alreadyEnlistedHolder != null && !alreadyEnlistedHolder.isEnded()) { xaResourceHolderState.setXid(alreadyEnlistedHolder.getXid()); log.warn("ignoring enlistment of already enlisted but not ended resource " + xaResourceHolderState); return; } XAResourceHolderState toBeJoinedHolderState = null; if (alreadyEnlistedHolder != null) { if (log.isDebugEnabled()) { log.debug("resource already enlisted but has been ended eligible for join: " + alreadyEnlistedHolder); } toBeJoinedHolderState = getManagedResourceWithSameRM(xaResourceHolderState); } BitronixXid xid; int flag; if (toBeJoinedHolderState != null) { if (log.isDebugEnabled()) { log.debug("joining " + xaResourceHolderState + " with " + toBeJoinedHolderState); } xid = toBeJoinedHolderState.getXid(); flag = XAResource.TMJOIN; } else { xid = UidGenerator.generateXid(gtrid); if (log.isDebugEnabled()) { log.debug("creating new branch with " + xid); } flag = XAResource.TMNOFLAGS; } // check for enlistment of a 2nd LRC resource, forbid this if the 2nd resource cannot be joined with the 1st one // unless this is explicitly allowed in the config if (flag != XAResource.TMJOIN && xaResourceHolderState.getTwoPcOrderingPosition() == Scheduler.ALWAYS_LAST_POSITION && !TransactionManagerServices.getConfiguration().isAllowMultipleLrc()) { List<XAResourceHolderState> alwaysLastResources = resources.getByNaturalOrderForPosition(Scheduler.ALWAYS_LAST_POSITION); if (alwaysLastResources != null && !alwaysLastResources.isEmpty()) throw new BitronixSystemException("cannot enlist more than one non-XA resource, tried enlisting " + xaResourceHolderState + ", already enlisted: " + alwaysLastResources.get(0)); } xaResourceHolderState.setXid(xid); xaResourceHolderState.start(flag); // in case of a JOIN, the resource holder is already in the scheduler -> do not add it twice if (toBeJoinedHolderState != null) { resources.remove(toBeJoinedHolderState); } // this must be done only after start() successfully returned resources.add(xaResourceHolderState, xaResourceHolderState.getTwoPcOrderingPosition()); }
Enlist the specified {@link XAResourceHolderState}. A XID is generated and the resource is started with XAResource.TMNOFLAGS or XAResource.TMJOIN if it could be joined with another previously enlisted one. <br> There are 3 different cases that can happen when a {@link XAResourceHolderState} is enlisted: <ul> <li>already enlisted and not ended: do nothing</li> <li>already enlisted and ended: try to join. if you can join, keep a reference on the passed-in {@link XAResourceHolderState} and drop the previous one. if you cannot join, it's the same as case 3</li> <li>not enlisted: create a new branch and keep a reference on the passed-in {@link XAResourceHolderState}</li> </ul> @param xaResourceHolderState the {@link XAResourceHolderState} to be enlisted. @throws XAException if a resource error occured. @throws BitronixSystemException if an internal error occured.
enlist
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
public boolean delist(XAResourceHolderState xaResourceHolderState, int flag) throws XAException, BitronixSystemException { if (findXAResourceHolderState(xaResourceHolderState.getXAResource()) != null) { if (log.isDebugEnabled()) { log.debug("delisting resource " + xaResourceHolderState); } xaResourceHolderState.end(flag); return true; } log.warn("trying to delist resource that has not been previously enlisted: " + xaResourceHolderState); return false; }
Delist the specified {@link XAResourceHolderState}. A reference to the resource is kept anyway. @param xaResourceHolderState the {@link XAResourceHolderState} to be delisted. @param flag the delistment flag. @return true if the resource could be delisted, false otherwise. @throws XAException if the resource threw an exception during delistment. @throws BitronixSystemException if an internal error occured.
delist
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
public void suspend() throws XAException { for (XAResourceHolderState xaResourceHolderState : resources) { if (!xaResourceHolderState.isEnded()) { if (log.isDebugEnabled()) { log.debug("suspending " + xaResourceHolderState); } xaResourceHolderState.end(XAResource.TMSUCCESS); } } // while }
Suspend all enlisted resources from the current transaction context. @throws XAException if the resource threw an exception during suspend.
suspend
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List<XAResourceHolderState> toBeReEnlisted = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) { log.debug("resuming " + xaResourceHolderState); } // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) { log.debug("re-enlisting resource " + xaResourceHolderState); } try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } }
Resume all enlisted resources in the current transaction context. @throws XAException if the resource threw an exception during resume.
resume
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
public XAResourceHolderState findXAResourceHolderState(XAResource xaResource) throws BitronixSystemException { for (XAResourceHolderState xaResourceHolderState : resources) { if (xaResourceHolderState.getXAResource() == xaResource) return xaResourceHolderState; } return null; }
Look if an {@link XAResource} has already been enlisted. @param xaResource the {@link XAResource} to look for. @return the {@link XAResourceHolderState} of the enlisted resource or null if the {@link XAResource} has not been enlisted in this {@link XAResourceManager}. @throws BitronixSystemException if an internal error happens.
findXAResourceHolderState
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
private XAResourceHolderState getManagedResourceWithSameRM(XAResourceHolderState xaResourceHolderState) throws XAException { if (!xaResourceHolderState.getUseTmJoin()) { if (log.isDebugEnabled()) { log.debug("join disabled on resource " + xaResourceHolderState); } return null; } for (XAResourceHolderState alreadyEnlistedHolderState : resources) { if (log.isDebugEnabled()) log.debug("checking joinability of " + xaResourceHolderState + " with " + alreadyEnlistedHolderState); if (alreadyEnlistedHolderState.isEnded() && !alreadyEnlistedHolderState.isSuspended() && xaResourceHolderState.getXAResource().isSameRM(alreadyEnlistedHolderState.getXAResource())) { if (log.isDebugEnabled()) { log.debug("resources are joinable"); } return alreadyEnlistedHolderState; } if (log.isDebugEnabled()) { log.debug("resources are not joinable"); } } if (log.isDebugEnabled()) { log.debug("no joinable resource found for " + xaResourceHolderState); } return null; }
Search for an eventually already enlisted {@link XAResourceHolderState} that could be joined with the {@link XAResourceHolderState} passed as parameter.<br/> If datasource configuration property <code>bitronix.useTmJoin=false</code> is set this method always returns null. @param xaResourceHolderState a {@link XAResourceHolderState} looking to be joined. @return another enlisted {@link XAResourceHolderState} that can be joined with the one passed in or null if none is found. @throws XAException if call to XAResource.isSameRM() fails.
getManagedResourceWithSameRM
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
public void clearXAResourceHolderStates() { if (log.isDebugEnabled()) { log.debug("clearing XAResourceHolder states on " + resources.size() + " resource(s)"); } Iterator<XAResourceHolderState> it = resources.iterator(); while (it.hasNext()) { XAResourceHolderState xaResourceHolderState = it.next(); XAResourceHolder resourceHolder = xaResourceHolderState.getXAResourceHolder(); // clear out the current state resourceHolder.removeXAResourceHolderState(xaResourceHolderState.getXid()); boolean stillExists = resourceHolder.isExistXAResourceHolderStatesForGtrid(gtrid); if (stillExists) log.warn("resource " + resourceHolder + " did not clean up " + resourceHolder.getXAResourceHolderStateCountForGtrid(gtrid) + "transaction states for GTRID [" + gtrid + "]"); else if (log.isDebugEnabled()) { log.debug("resource " + resourceHolder + " cleaned up all transaction states for GTRID [" + gtrid + "]"); } it.remove(); } }
Remove this transaction's {@link XAResourceHolderState} from all enlisted {@link bitronix.tm.resource.common.XAResourceHolder}s.
clearXAResourceHolderStates
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
public int size() { return resources.size(); }
Get the enlisted resources count. @return the enlisted resources count.
size
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
public Uid getGtrid() { return gtrid; }
Get the GTRID of the transaction the {@link XAResourceManager} instance is attached to. @return the GTRID of the transaction the {@link XAResourceManager} instance is attached to.
getGtrid
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
@Override public String toString() { return "a XAResourceManager with GTRID [" + gtrid + "] and " + resources; }
Return a human-readable representation of this object. @return a human-readable representation of this object.
toString
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/internal/XAResourceManager.java
Apache-2.0
@Override public void log(int status, Uid gtrid, Set<String> uniqueNames) throws IOException { if (activeTla.get() == null) throw new IOException("cannot write log, disk logger is not open"); if (configuration.isFilterLogStatus()) { if (status != Status.STATUS_COMMITTING && status != Status.STATUS_COMMITTED && status != Status.STATUS_UNKNOWN) { if (log.isDebugEnabled()) { log.debug("filtered out write to log for status " + Decoder.decodeStatus(status)); } return; } } TransactionLogRecord tlog = new TransactionLogRecord(status, gtrid, uniqueNames); try { if (configuration.isConservativeJournaling()) { conservativeJournalingLock.lock(); } synchronized (positionLock) { boolean rollover = activeTla.get().setPositionAndAdvance(tlog); if (rollover) { // time to swap log files swapForceLock.writeLock().lock(); try { swapJournalFiles(); activeTla.get().setPositionAndAdvance(tlog); } finally { swapForceLock.writeLock().unlock(); } } // this read lock MUST be acquired under positionLock swapForceLock.readLock().lock(); } try { activeTla.get().writeLog(tlog); needsForce.set(true); } finally { swapForceLock.readLock().unlock(); } } finally { if (configuration.isConservativeJournaling()) { conservativeJournalingLock.unlock(); } } }
Log a new transaction status to journal. Note that the DiskJournal will not check the flow of the transaction. If you call this method with erroneous data, it will be added to the journal anyway. @param status transaction status to log. See {@link javax.transaction.Status} constants. @param gtrid raw GTRID of the transaction. @param uniqueNames unique names of the {@link bitronix.tm.resource.common.ResourceBean}s participating in this transaction. @throws java.io.IOException in case of disk IO failure or if the disk journal is not open.
log
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/DiskJournal.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/DiskJournal.java
Apache-2.0
@Override public void force() throws IOException { if (activeTla.get() == null) throw new IOException("cannot force log writing, disk logger is not open"); if (needsForce.get() && configuration.isForcedWriteEnabled()) { swapForceLock.writeLock().lock(); try { activeTla.get().force(); needsForce.set(false); } finally { swapForceLock.writeLock().unlock(); } } }
Force active log file to synchronize with the underlying disk device. @throws java.io.IOException in case of disk IO failure or if the disk journal is not open.
force
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/DiskJournal.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/DiskJournal.java
Apache-2.0
@Override public synchronized void open() throws IOException { if (activeTla.get() != null) { log.warn("disk journal already open"); return; } File file1 = new File(configuration.getLogPart1Filename()); File file2 = new File(configuration.getLogPart2Filename()); if (!file1.exists() && !file2.exists()) { log.debug("creation of log files"); createLogfile(file2, configuration.getMaxLogSizeInMb()); // make the clock run a little before creating the 2nd log file to ensure the timestamp headers are not the same long before = MonotonicClock.currentTimeMillis(); while (MonotonicClock.currentTimeMillis() < before + 100L) { try { Thread.sleep(100); } catch (InterruptedException ex) { /* ignore */ } } createLogfile(file1, configuration.getMaxLogSizeInMb()); } if (file1.length() != file2.length()) { if (!configuration.isSkipCorruptedLogs()) throw new IOException("transaction log files are not of the same length, assuming they're corrupt"); log.error("transaction log files are not of the same length: corrupted files?"); } long maxFileLength = Math.max(file1.length(), file2.length()); if (log.isDebugEnabled()) { log.debug("disk journal files max length: " + maxFileLength); } tla1 = new TransactionLogAppender(file1, maxFileLength); tla2 = new TransactionLogAppender(file2, maxFileLength); byte cleanStatus = pickActiveJournalFile(tla1, tla2); if (cleanStatus != TransactionLogHeader.CLEAN_LOG_STATE) { log.warn("active log file is unclean, did you call BitronixTransactionManager.shutdown() at the end of the last run?"); } if (log.isDebugEnabled()) { log.debug("disk journal opened"); } }
Open the disk journal. Files are checked for integrity and DiskJournal will refuse to open corrupted log files. If files are not present on disk, this method will create and pre-allocate them. @throws java.io.IOException in case of disk IO failure.
open
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/DiskJournal.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/DiskJournal.java
Apache-2.0
@Override public Map<Uid, JournalRecord> collectDanglingRecords() throws IOException { if (activeTla.get() == null) throw new IOException("cannot collect dangling records, disk logger is not open"); return collectDanglingRecords(activeTla.get()); }
Collect all dangling records of the active log file. @return a Map using Uid objects GTRID as key and {@link TransactionLogRecord} as value @throws java.io.IOException in case of disk IO failure or if the disk journal is not open.
collectDanglingRecords
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/DiskJournal.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/DiskJournal.java
Apache-2.0
private static void createLogfile(File logfile, int maxLogSizeInMb) throws IOException { if (logfile.isDirectory()) throw new IOException("log file is referring to a directory: " + logfile.getAbsolutePath()); if (logfile.exists()) { boolean deleted = logfile.delete(); if (!deleted) throw new IOException("log file exists but cannot be overwritten: " + logfile.getAbsolutePath()); } if (logfile.getParentFile() != null) { logfile.getParentFile().mkdirs(); } RandomAccessFile raf = null; try { raf = new RandomAccessFile(logfile, "rw"); raf.seek(TransactionLogHeader.FORMAT_ID_HEADER); raf.writeInt(BitronixXid.FORMAT_ID); raf.writeLong(MonotonicClock.currentTimeMillis()); raf.writeByte(TransactionLogHeader.CLEAN_LOG_STATE); raf.writeLong((long) TransactionLogHeader.HEADER_LENGTH); byte[] buffer = new byte[4096]; int length = (maxLogSizeInMb *1024 *1024) /4096; for (int i = 0; i < length; i++) { raf.write(buffer); } } finally { if (raf != null) raf.close(); } }
Create a fresh log file on disk. If the specified file already exists it will be deleted then recreated. @param logfile the file to create @param maxLogSizeInMb the file size in megabytes to preallocate @throws java.io.IOException in case of disk IO failure.
createLogfile
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/DiskJournal.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/DiskJournal.java
Apache-2.0
private synchronized byte pickActiveJournalFile(TransactionLogAppender tla1, TransactionLogAppender tla2) throws IOException { if (tla1.getTimestamp() > tla2.getTimestamp()) { activeTla.set(tla1); if (log.isDebugEnabled()) { log.debug("logging to file 1: " + activeTla); } } else { activeTla.set(tla2); if (log.isDebugEnabled()) { log.debug("logging to file 2: " + activeTla); } } byte cleanState = activeTla.get().getState(); activeTla.get().setState(TransactionLogHeader.UNCLEAN_LOG_STATE); if (log.isDebugEnabled()) { log.debug("log file activated, forcing file state to disk"); } activeTla.get().force(); return cleanState; }
Initialize the activeTla member variable with the TransactionLogAppender object having the latest timestamp header. @param tla1 the first of the two candidate active TransactionLogAppenders @param tla2 the second of the two candidate active TransactionLogAppenders @return the state of the designated active TransactionLogAppender as returned by TransactionLogHeader.getState() @throws java.io.IOException in case of disk IO failure. @see TransactionLogHeader
pickActiveJournalFile
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/DiskJournal.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/DiskJournal.java
Apache-2.0
private synchronized TransactionLogAppender getPassiveTransactionLogAppender() { return (tla1 == activeTla.get() ? tla2 : tla1); }
@return the TransactionFileAppender of the passive journal file.
getPassiveTransactionLogAppender
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/DiskJournal.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/DiskJournal.java
Apache-2.0
protected boolean setPositionAndAdvance(TransactionLogRecord tlog) throws IOException { int tlogSize = tlog.calculateTotalRecordSize(); if (position + tlogSize > maxFileLength) { return true; } long writePosition = position; position += tlogSize; tlog.setWritePosition(writePosition); outstandingWrites.incrementAndGet(); return false; }
Get the current file position and advance the position by recordSize if the maximum file length won't be exceeded. Callers to this method are synchronized within the DiskJournal and it is guaranteed there will never be two callers to this method. This creates a Java memory barrier that guarantees that 'position' will never be viewed inconsistently between threads. @param tlog the TransactionLogRecord @return true if the log should rollover, false otherwise @throws IOException if an I/O error occurs
setPositionAndAdvance
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
Apache-2.0
void rewind() throws IOException { header.rewind(); position = header.getPosition(); }
Return a {@link TransactionLogHeader} that allows reading and controlling the log file's header. @throws IOException if an I/O error occurs
rewind
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
Apache-2.0
long getTimestamp() { return header.getTimestamp(); }
Get the log file header timestamp. @return the log file header timestamp
getTimestamp
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
Apache-2.0
public long getPosition() { return position; }
Get the current file position. @return the file position
getPosition
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
Apache-2.0
protected void close() throws IOException { header.setState(TransactionLogHeader.CLEAN_LOG_STATE); fc.force(false); if (lock != null) lock.release(); fc.close(); randomeAccessFile.close(); }
Close the appender and the underlying file. @throws IOException if an I/O error occurs.
close
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
Apache-2.0
protected TransactionLogCursor getCursor() throws IOException { return new TransactionLogCursor(file); }
Creates a cursor on this journal file allowing iteration of its records. This opens a new read-only file descriptor independent of the write-only one still used for writing transaction logs. @return a TransactionLogCursor. @throws IOException if an I/O error occurs.
getCursor
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogAppender.java
Apache-2.0
public TransactionLogRecord readLog() throws IOException { return readLog(false); }
Fetch the next TransactionLogRecord from log, recalculating the CRC and checking it against the stored one. InvalidChecksumException is thrown if the check fails. @return the TransactionLogRecord or null if the end of the log file has been reached @throws IOException if an I/O error occurs.
readLog
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogCursor.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogCursor.java
Apache-2.0
public TransactionLogRecord readLog(boolean skipCrcCheck) throws IOException { if (currentPosition >= endPosition) { if (log.isDebugEnabled()) log.debug("end of transaction log file reached at " + currentPosition); return null; } final int status = page.getInt(); // currentPosition += 4; final int recordLength = page.getInt(); // currentPosition += 4; currentPosition += 8; if (page.position() + recordLength + 8 > page.limit()) { page.compact(); fileChannel.read(page); page.rewind(); } final int endOfRecordPosition = page.position() + recordLength; if (currentPosition + recordLength > endPosition) { page.position(page.position() + recordLength); currentPosition += recordLength; throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + " (record terminator outside of file bounds: " + currentPosition + recordLength + " of " + endPosition + ", recordLength: " + recordLength + ")"); } final int headerLength = page.getInt(); // currentPosition += 4; final long time = page.getLong(); // currentPosition += 8; final int sequenceNumber = page.getInt(); // currentPosition += 4; final int crc32 = page.getInt(); // currentPosition += 4; final byte gtridSize = page.get(); // currentPosition += 1; currentPosition += 21; // check for log terminator page.mark(); page.position(endOfRecordPosition - 4); int endCode = page.getInt(); page.reset(); if (endCode != TransactionLogAppender.END_RECORD) throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + " (no record terminator found)"); // check that GTRID is not too long if (4 + 8 + 4 + 4 + 1 + gtridSize > recordLength) { page.position(endOfRecordPosition); throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + " (GTRID size too long)"); } final byte[] gtridArray = new byte[gtridSize]; page.get(gtridArray); currentPosition += gtridSize; Uid gtrid = new Uid(gtridArray); final int uniqueNamesCount = page.getInt(); currentPosition += 4; Set<String> uniqueNames = new HashSet<String>(); int currentReadCount = 4 + 8 + 4 + 4 + 1 + gtridSize + 4; for (int i = 0; i < uniqueNamesCount; i++) { int length = page.getShort(); currentPosition += 2; // check that names aren't too long currentReadCount += 2 + length; if (currentReadCount > recordLength) { page.position(endOfRecordPosition); throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + " (unique names too long, " + (i + 1) + " out of " + uniqueNamesCount + ", length: " + length + ", currentReadCount: " + currentReadCount + ", recordLength: " + recordLength + ")"); } byte[] nameBytes = new byte[length]; page.get(nameBytes); currentPosition += length; uniqueNames.add(new String(nameBytes, "US-ASCII")); } final int cEndRecord = page.getInt(); currentPosition += 4; TransactionLogRecord tlog = new TransactionLogRecord(status, recordLength, headerLength, time, sequenceNumber, crc32, gtrid, uniqueNames, cEndRecord); // check that CRC is okay if (!skipCrcCheck && !tlog.isCrc32Correct()) { page.position(endOfRecordPosition); throw new CorruptedTransactionLogException("corrupted log found at position " + currentPosition + "(invalid CRC, recorded: " + tlog.getCrc32() + ", calculated: " + tlog.calculateCrc32() + ")"); } return tlog; }
Fetch the next TransactionLogRecord from log. @param skipCrcCheck if set to false, the method will thow an InvalidChecksumException if the CRC on disk does not match the recalculated one. Otherwise, the CRC is not recalculated nor checked agains the stored one. @return the TransactionLogRecord or null if the end of the log file has been reached @throws IOException if an I/O error occurs.
readLog
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogCursor.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogCursor.java
Apache-2.0
public void close() throws IOException { fis.close(); fileChannel.close(); }
Close the cursor and the underlying file @throws IOException if an I/O error occurs.
close
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogCursor.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogCursor.java
Apache-2.0
public void setFormatId(int formatId) throws IOException { ByteBuffer buf = ByteBuffer.allocate(8); buf.putInt(formatId); buf.flip(); while (buf.hasRemaining()) { fc.write(buf, FORMAT_ID_HEADER + buf.position()); } this.formatId = formatId; }
Set FORMAT_ID_HEADER. @see #FORMAT_ID_HEADER @param formatId the FORMAT_ID_HEADER value. @throws IOException if an I/O error occurs.
setFormatId
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
Apache-2.0
public void setTimestamp(long timestamp) throws IOException { ByteBuffer buf = ByteBuffer.allocate(8); buf.putLong(timestamp); buf.flip(); while (buf.hasRemaining()) { fc.write(buf, TIMESTAMP_HEADER + buf.position()); } this.timestamp = timestamp; }
Set TIMESTAMP_HEADER. @see #TIMESTAMP_HEADER @param timestamp the TIMESTAMP_HEADER value. @throws IOException if an I/O error occurs.
setTimestamp
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
Apache-2.0
public void setState(byte state) throws IOException { ByteBuffer buf = ByteBuffer.allocate(1); buf.put(state); buf.flip(); while (buf.hasRemaining()) { fc.write(buf, STATE_HEADER + buf.position()); } this.state = state; }
Set STATE_HEADER. @see #STATE_HEADER @param state the STATE_HEADER value. @throws IOException if an I/O error occurs.
setState
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
Apache-2.0
public void setPosition(long position) throws IOException { if (position < HEADER_LENGTH) throw new IOException("invalid position " + position + " (too low)"); if (position > maxFileLength) throw new IOException("invalid position " + position + " (too high)"); ByteBuffer buf = ByteBuffer.allocate(8); buf.putLong(position); buf.flip(); while (buf.hasRemaining()) { fc.write(buf, CURRENT_POSITION_HEADER + buf.position()); } this.position = position; fc.position(position); }
Set CURRENT_POSITION_HEADER. @see #CURRENT_POSITION_HEADER @param position the CURRENT_POSITION_HEADER value. @throws IOException if an I/O error occurs.
setPosition
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
Apache-2.0
@Override public String toString() { return "a Bitronix TransactionLogHeader with timestamp=" + timestamp + ", state=" + Decoder.decodeHeaderState(state) + ", position=" + position; }
Create human-readable String representation. @return a human-readable String representing this object's state.
toString
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogHeader.java
Apache-2.0
private void refresh() { crc32 = calculateCrc32(); }
Recalculate and store the dynamic values of this record: {@link #getRecordLength()}, {@link #getRecordHeaderLength()} and {@link #calculateCrc32()}. This method must be called each time after the set of contained unique names is updated.
refresh
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogRecord.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogRecord.java
Apache-2.0
public boolean isCrc32Correct() { return calculateCrc32() == getCrc32(); }
Recalculate the CRC32 value of this record (using {@link #calculateCrc32()}) and compare it with the stored value. @return true if the recalculated value equals the stored one, false otherwise.
isCrc32Correct
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogRecord.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogRecord.java
Apache-2.0
int calculateTotalRecordSize() { return recordLength + 4 + 4; // + status + record length }
this is the total size on disk of a TransactionLog. @return recordLength
calculateTotalRecordSize
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/journal/TransactionLogRecord.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/journal/TransactionLogRecord.java
Apache-2.0
@Override public void run() { if (!isRunning.compareAndSet(false, true)) { log.info("recoverer is already running, abandoning this recovery request"); return; } try { committedCount = 0; rolledbackCount = 0; long oldestTransactionTimestamp = Long.MAX_VALUE; // Collect dangling records from journal, must run before oldestTransactionTimestamp is calculated Map<Uid, JournalRecord> danglingRecords = TransactionManagerServices.getJournal().collectDanglingRecords(); // Query resources from ResourceRegistrar synchronized (ResourceRegistrar.class) { for (String name : ResourceRegistrar.getResourcesUniqueNames()) { registeredResources.put(name, ResourceRegistrar.get(name)); } if (TransactionManagerServices.isTransactionManagerRunning()) { oldestTransactionTimestamp = TransactionManagerServices.getTransactionManager().getOldestInFlightTransactionTimestamp(); } } // 1. call recover on all known resources recoverAllResources(); // 2. commit dangling COMMITTING transactions Set<Uid> committedGtrids = commitDanglingTransactions(oldestTransactionTimestamp, danglingRecords); committedCount = committedGtrids.size(); // 3. rollback any remaining recovered transaction rolledbackCount = rollbackAbortedTransactions(oldestTransactionTimestamp, committedGtrids); if (executionsCount == 0 || committedCount > 0 || rolledbackCount > 0) { log.info("recovery committed " + committedCount + " dangling transaction(s) and rolled back " + rolledbackCount + " aborted transaction(s) on " + registeredResources.size() + " resource(s) [" + getRegisteredResourcesUniqueNames() + "]" + ((TransactionManagerServices.getConfiguration().isCurrentNodeOnlyRecovery()) ? " (restricted to serverId '" + TransactionManagerServices.getConfiguration().getServerId() + "')" : "")); } else if (log.isDebugEnabled()) { log.debug("recovery committed " + committedCount + " dangling transaction(s) and rolled back " + rolledbackCount + " aborted transaction(s) on " + registeredResources.size() + " resource(s) [" + getRegisteredResourcesUniqueNames() + "]" + ((TransactionManagerServices.getConfiguration().isCurrentNodeOnlyRecovery()) ? " (restricted to serverId '" + TransactionManagerServices.getConfiguration().getServerId() + "')" : "")); } this.completionException = null; } catch (Exception ex) { this.completionException = ex; log.warn("recovery failed, registered resource(s): " + getRegisteredResourcesUniqueNames(), ex); } finally { recoveredXidSets.clear(); registeredResources.clear(); executionsCount++; isRunning.set(false); } }
Run the recovery process. This method is automatically called by the transaction manager, you should never call it manually.
run
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/Recoverer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/Recoverer.java
Apache-2.0
@Override public Exception getCompletionException() { return completionException; }
Get the exception reported when recovery failed. @return the exception that made recovery fail or null if last recovery execution was successful.
getCompletionException
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/Recoverer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/Recoverer.java
Apache-2.0
@Override public int getRolledbackCount() { return rolledbackCount; }
Get the amount of transactions rolled back during the last recovery run. @return the amount of rolled back transactions.
getRolledbackCount
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/Recoverer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/Recoverer.java
Apache-2.0
@Override public int getExecutionsCount() { return executionsCount; }
Get how many times the recoverer has run since the transaction manager started. @return how many times the recoverer has run since the transaction manager started.
getExecutionsCount
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/Recoverer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/Recoverer.java
Apache-2.0
@Override public boolean isRunning() { return isRunning.get(); }
Check if the recoverer currently is running. @return true if the recoverer currently is running, false otherwise.
isRunning
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/Recoverer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/Recoverer.java
Apache-2.0
private void recoverAllResources() { // a cloned registeredResources Map must be iterated as the original one can be modified in the loop for (Map.Entry<String, XAResourceProducer> entry : new HashMap<String, XAResourceProducer>(registeredResources).entrySet()) { String uniqueName = entry.getKey(); XAResourceProducer producer = entry.getValue(); try { if (log.isDebugEnabled()) { log.debug("performing recovery on " + uniqueName); } Set<BitronixXid> xids = recover(producer); if (log.isDebugEnabled()) { log.debug("recovered " + xids.size() + " XID(s) from resource " + uniqueName); } recoveredXidSets.put(uniqueName, xids); producer.setFailed(false); } catch (XAException ex) { producer.setFailed(true); registeredResources.remove(uniqueName); String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); log.warn("error running recovery on resource '" + uniqueName + "', resource marked as failed (background recoverer will retry recovery)" + " (error=" + Decoder.decodeXAExceptionErrorCode(ex) + ")" + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } catch (Exception ex) { producer.setFailed(true); registeredResources.remove(uniqueName); log.warn("error running recovery on resource '" + uniqueName + "', resource marked as failed (background recoverer will retry recovery)", ex); } } }
Recover all configured resources and fill the <code>recoveredXidSets</code> with all recovered XIDs. Step 1.
recoverAllResources
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/Recoverer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/Recoverer.java
Apache-2.0
private Set<BitronixXid> recover(XAResourceProducer producer) throws XAException, RecoveryException { if (producer == null) throw new IllegalArgumentException("recoverable resource cannot be null"); try { if (log.isDebugEnabled()) { log.debug("running recovery on " + producer); } XAResourceHolderState xaResourceHolderState = producer.startRecovery(); return RecoveryHelper.recover(xaResourceHolderState); } finally { producer.endRecovery(); } }
Run the recovery process on the target resource. Step 1. @return a Set of BitronixXids. @param producer the {@link XAResourceProducer} to recover. @throws javax.transaction.xa.XAException if {@link XAResource#recover(int)} call fails. @throws RecoveryException if an error preventing recovery happened.
recover
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/Recoverer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/Recoverer.java
Apache-2.0
private boolean rollback(String uniqueName, Xid xid) throws RecoveryException { XAResourceProducer producer = registeredResources.get(uniqueName); if (producer == null) { if (log.isDebugEnabled()) { log.debug("resource " + uniqueName + " has not recovered, skipping rollback"); } return false; } try { XAResourceHolderState xaResourceHolderState = producer.startRecovery(); return RecoveryHelper.rollback(xaResourceHolderState, xid); } finally { producer.endRecovery(); } }
Rollback the specified branch of a dangling transaction. Step 3. @param uniqueName the unique name of the resource on which to rollback branches. @param xid the {@link Xid} to rollback. @return true when rollback was successful. @throws RecoveryException if an error preventing recovery happened.
rollback
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/Recoverer.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/Recoverer.java
Apache-2.0
public static Set<BitronixXid> recover(XAResourceHolderState xaResourceHolderState) throws XAException { Set<BitronixXid> xids = new HashSet<BitronixXid>(); if (log.isDebugEnabled()) { log.debug("recovering with STARTRSCAN"); } int xidCount; try { xidCount = recover(xaResourceHolderState, xids, XAResource.TMSTARTRSCAN); } catch (XAException ex) { if (xaResourceHolderState.getIgnoreRecoveryFailures()) { if (log.isDebugEnabled()) { log.debug("ignoring recovery failure on resource " + xaResourceHolderState, ex); } return Collections.emptySet(); } throw ex; } if (log.isDebugEnabled()) { log.debug("STARTRSCAN recovered " + xidCount + " xid(s) on " + xaResourceHolderState); } try { while (xidCount > 0) { if (log.isDebugEnabled()) { log.debug("recovering with NOFLAGS"); } xidCount = recover(xaResourceHolderState, xids, XAResource.TMNOFLAGS); if (log.isDebugEnabled()) { log.debug("NOFLAGS recovered " + xidCount + " xid(s) on " + xaResourceHolderState); } } } catch (XAException ex) { if (log.isDebugEnabled()) { log.debug("NOFLAGS recovery call failed", ex); } } try { if (log.isDebugEnabled()) { log.debug("recovering with ENDRSCAN"); } xidCount = recover(xaResourceHolderState, xids, XAResource.TMENDRSCAN); if (log.isDebugEnabled()) { log.debug("ENDRSCAN recovered " + xidCount + " xid(s) on " + xaResourceHolderState); } } catch (XAException ex) { if (log.isDebugEnabled()) { log.debug("ENDRSCAN recovery call failed", ex); } } return xids; }
Run the recovery process on the target resource. @return a Set of BitronixXids. @param xaResourceHolderState the {@link XAResourceHolderState} to recover. @throws javax.transaction.xa.XAException if {@link XAResource#recover(int)} calls fail.
recover
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/RecoveryHelper.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/RecoveryHelper.java
Apache-2.0
private static int recover(XAResourceHolderState resourceHolderState, Set<BitronixXid> alreadyRecoveredXids, int flags) throws XAException { Xid[] xids = resourceHolderState.getXAResource().recover(flags); if (xids == null) return 0; boolean currentNodeOnly = TransactionManagerServices.getConfiguration().isCurrentNodeOnlyRecovery(); Set<BitronixXid> freshlyRecoveredXids = new HashSet<BitronixXid>(); for (Xid xid : xids) { if (xid.getFormatId() != BitronixXid.FORMAT_ID) { if (log.isDebugEnabled()) log.debug("skipping non-bitronix XID " + xid + "(format ID: " + xid.getFormatId() + " GTRID: " + new Uid(xid.getGlobalTransactionId()) + "BQUAL: " + new Uid(xid.getBranchQualifier()) + ")"); continue; } BitronixXid bitronixXid = new BitronixXid(xid); if (currentNodeOnly) { if (log.isDebugEnabled()) { log.debug("recovering XIDs generated by this node only - recovered XIDs' GTRID must contain this JVM uniqueId"); } byte[] extractedServerId = bitronixXid.getGlobalTransactionIdUid().extractServerId(); byte[] jvmUniqueId = TransactionManagerServices.getConfiguration().buildServerIdArray(); if (extractedServerId == null) { log.error("skipping XID " + bitronixXid + " as its GTRID's serverId is null. It looks like the disk journal is corrupted!"); continue; } if (!Arrays.equals(jvmUniqueId, extractedServerId)) { String extractedServerIdString = new String(extractedServerId); String jvmUniqueIdString = new String(jvmUniqueId); if (log.isDebugEnabled()) { log.debug("skipping XID " + bitronixXid + " as its GTRID's serverId <" + extractedServerIdString + "> does not match this JVM unique ID <" + jvmUniqueIdString + ">"); } continue; } } else { if (log.isDebugEnabled()) { log.debug("recovering all XIDs regardless of this JVM uniqueId"); } } if (alreadyRecoveredXids.contains(bitronixXid)) { if (log.isDebugEnabled()) { log.debug("already recovered XID " + bitronixXid + ", skipping it"); } continue; } if (freshlyRecoveredXids.contains(bitronixXid)) { log.warn("resource " + resourceHolderState.getUniqueName() + " recovered two identical XIDs within the same recover call: " + bitronixXid); continue; } if (log.isDebugEnabled()) { log.debug("recovered " + bitronixXid); } freshlyRecoveredXids.add(bitronixXid); } // for i < xids.length alreadyRecoveredXids.addAll(freshlyRecoveredXids); return freshlyRecoveredXids.size(); }
Call {@link XAResource#recover(int)} on the resource and fill the <code>alreadyRecoveredXids</code> Set with recovered {@link BitronixXid}s. Step 1. @return the amount of recovered {@link Xid}. @param resourceHolderState the {@link XAResourceHolderState} to recover. @param alreadyRecoveredXids a set of {@link Xid}s already recovered from this resource in this recovery session. @param flags any combination of {@link XAResource#TMSTARTRSCAN}, {@link XAResource#TMNOFLAGS} or {@link XAResource#TMENDRSCAN}. @throws javax.transaction.xa.XAException if {@link XAResource#recover(int)} call fails.
recover
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/RecoveryHelper.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/RecoveryHelper.java
Apache-2.0
public static boolean rollback(XAResourceHolderState xaResourceHolderState, Xid xid) { String uniqueName = xaResourceHolderState.getUniqueName(); boolean success = true; boolean forget = false; try { xaResourceHolderState.getXAResource().rollback(xid); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); if (ex.errorCode == XAException.XAER_NOTA) { log.error("unable to rollback aborted in-doubt branch on resource " + uniqueName + " - error=XAER_NOTA" + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ". Forgotten heuristic?", ex); } else if (ex.errorCode == XAException.XA_HEURRB) { log.info("unable to rollback aborted in-doubt branch on resource " + uniqueName + " - error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ". Heuristic decision compatible with the global state of this transaction."); forget = true; } else if (ex.errorCode == XAException.XA_HEURHAZ || ex.errorCode == XAException.XA_HEURMIX || ex.errorCode == XAException.XA_HEURCOM) { log.error("unable to rollback aborted in-doubt branch on resource " + uniqueName + " - error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ". Heuristic decision incompatible with the global state of this transaction!"); forget = true; success = false; } else { log.error("unable to rollback aborted in-doubt branch on resource " + uniqueName + " - error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails) + ".", ex); success = false; } } if (forget) { try { if (log.isDebugEnabled()) { log.debug("forgetting XID " + xid + " on resource " + uniqueName); } xaResourceHolderState.getXAResource().forget(xid); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); log.error("unable to forget XID " + xid + " on resource " + uniqueName + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } } return success; }
Rollback the specified branch of a dangling transaction. @param xaResourceHolderState the {@link XAResourceHolderState} to rollback the branch on. @param xid the {@link Xid} to rollback. @return true when rollback was successful.
rollback
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/recovery/RecoveryHelper.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/recovery/RecoveryHelper.java
Apache-2.0
public Map<String, XAResourceProducer> getResources() { return resourcesByUniqueName; }
Get a Map with the configured uniqueName as key and {@link XAResourceProducer} as value. @return a Map using the uniqueName as key and {@link XAResourceProducer} as value.
getResources
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
Apache-2.0
private static XAResourceProducer instantiate(String xaResourceClassName) throws ClassNotFoundException, IllegalAccessException, InstantiationException { Class<?> clazz = ClassLoaderUtils.loadClass(xaResourceClassName); // resource classes are instantiated via reflection so that there is no hard class binding between this internal // transaction manager service and 3rd party libraries like the JMS ones. // This allows using the TM with a 100% JDBC application without requiring JMS libraries. if (XADataSource.class.isAssignableFrom(clazz)) { return (XAResourceProducer) ClassLoaderUtils.loadClass(JDBC_RESOURCE_CLASSNAME).newInstance(); } else if (XAConnectionFactory.class.isAssignableFrom(clazz)) { return (XAResourceProducer) ClassLoaderUtils.loadClass(JMS_RESOURCE_CLASSNAME).newInstance(); } else return null; }
Create an unitialized {@link XAResourceProducer} implementation which depends on the XA resource class name. @param xaResourceClassName an XA resource class name. @return a {@link XAResourceProducer} implementation. @throws ClassNotFoundException if the {@link XAResourceProducer} cannot be instantiated. @throws IllegalAccessException if the {@link XAResourceProducer} cannot be instantiated. @throws InstantiationException if the {@link XAResourceProducer} cannot be instantiated.
instantiate
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
Apache-2.0
private int init(String propertiesFilename) { try { FileInputStream fis = null; Properties properties; try { fis = new FileInputStream(propertiesFilename); properties = new Properties(); properties.load(fis); } finally { if (fis != null) fis.close(); } return initXAResourceProducers(properties); } catch (IOException ex) { throw new InitializationException("cannot create resource loader", ex); } }
Read the resources properties file and create {@link XAResourceProducer} accordingly. @param propertiesFilename the name of the properties file to load. @return the number of resources which failed to initialize.
init
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
Apache-2.0
int initXAResourceProducers(Properties properties) { Map<String, List<PropertyPair>> entries = buildConfigurationEntriesMap(properties); int errorCount = 0; for (Map.Entry<String, List<PropertyPair>> entry : entries.entrySet()) { String uniqueName = entry.getKey(); List<PropertyPair> propertyPairs = entry.getValue(); XAResourceProducer producer = buildXAResourceProducer(uniqueName, propertyPairs); if (ResourceRegistrar.get(producer.getUniqueName()) != null) { if (log.isDebugEnabled()) { log.debug("resource already registered, skipping it:" + producer.getUniqueName()); } continue; } if (log.isDebugEnabled()) { log.debug("creating resource " + producer); } try { producer.init(); } catch (ResourceConfigurationException ex) { log.warn("unable to create resource with unique name " + producer.getUniqueName(), ex); producer.close(); errorCount++; } resourcesByUniqueName.put(producer.getUniqueName(), producer); } return errorCount; }
Initialize {@link XAResourceProducer}s given a set of properties. @param properties the properties to use for initialization. @return the number of resources which failed to initialize.
initXAResourceProducers
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
Apache-2.0
private Map<String, List<PropertyPair>> buildConfigurationEntriesMap(Properties properties) { Map<String, List<PropertyPair>> entries = new HashMap<String, List<PropertyPair>>(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); if (key.startsWith("resource.")) { String[] keyParts = key.split("\\."); if (keyParts.length < 3) { log.warn("ignoring invalid entry in configuration file: " + key); continue; } String configuredName = keyParts[1]; String propertyName = keyParts[2]; if (keyParts.length > 3) { for (int i = 3; i < keyParts.length; i++) { propertyName += "." + keyParts[i]; } } List<PropertyPair> pairs = entries.get(configuredName); if (pairs == null) { pairs = new ArrayList<PropertyPair>(); entries.put(configuredName, pairs); } pairs.add(new PropertyPair(propertyName, value)); } } return entries; }
Create a map using the configured resource name as the key and a List of PropertyPair objects as the value. @param properties object to analyze. @return the built map.
buildConfigurationEntriesMap
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
Apache-2.0
private XAResourceProducer buildXAResourceProducer(String configuredName, List<PropertyPair> propertyPairs) throws ResourceConfigurationException { String lastPropertyName = "className"; try { XAResourceProducer producer = createBean(configuredName, propertyPairs); for (PropertyPair propertyPair : propertyPairs) { lastPropertyName = propertyPair.getName(); String propertyValue = propertyPair.getValue(); PropertyUtils.setProperty(producer, lastPropertyName, propertyValue); } if (producer.getUniqueName() == null) throw new ResourceConfigurationException("missing mandatory property [uniqueName] of resource [" + configuredName + "] in resources configuration file"); return producer; } catch (ResourceConfigurationException ex) { throw ex; } catch (Exception ex) { throw new ResourceConfigurationException("cannot configure resource for configuration entries with name [" + configuredName + "]" + " - failing property is [" + lastPropertyName + "]", ex); } }
Build a populated {@link XAResourceProducer} out of a list of property pairs and the config name. @param configuredName index name of the config file. @param propertyPairs the properties attached to this index. @return a populated {@link XAResourceProducer}. @throws ResourceConfigurationException if the {@link XAResourceProducer} cannot be built.
buildXAResourceProducer
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceLoader.java
Apache-2.0
@Override public Object getObjectInstance(Object obj, Name jndiNameObject, Context nameCtx, Hashtable<?,?> environment) throws Exception { Reference ref = (Reference) obj; if (log.isDebugEnabled()) { log.debug("referencing resource with reference of type " + ref.getClass()); } RefAddr refAddr = ref.get("uniqueName"); if (refAddr == null) throw new NamingException("no 'uniqueName' RefAddr found"); Object content = refAddr.getContent(); if (!(content instanceof String)) throw new NamingException("'uniqueName' RefAddr content is not of type java.lang.String"); String uniqueName = (String) content; if (log.isDebugEnabled()) { log.debug("getting registered resource with uniqueName '" + uniqueName + "'"); } Referenceable resource = ResourceRegistrar.get(uniqueName); if (resource == null) throw new NamingException("no resource registered with uniqueName '" + uniqueName + "', available resources: " + ResourceRegistrar.getResourcesUniqueNames()); return resource; }
{@link bitronix.tm.resource.common.XAResourceProducer} object factory for JNDI references. @see bitronix.tm.resource.common.ResourceBean @author Ludovic Orban
getObjectInstance
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceObjectFactory.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceObjectFactory.java
Apache-2.0
public static XAResourceProducer get(final String uniqueName) { if (uniqueName != null) { for (ProducerHolder holder : resources) { if (!holder.isInitialized()) continue; if (uniqueName.equals(holder.getUniqueName())) return holder.producer; } } return null; }
Get a registered {@link XAResourceProducer}. @param uniqueName the name of the recoverable resource producer. @return the {@link XAResourceProducer} or null if there was none registered under that name.
get
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
Apache-2.0
public static Set<String> getResourcesUniqueNames() { final Set<String> names = new HashSet<String>(resources.size()); for (ProducerHolder holder : resources) { if (!holder.isInitialized()) continue; names.add(holder.getUniqueName()); } return Collections.unmodifiableSet(names); }
Get all {@link XAResourceProducer}s unique names. @return a Set containing all {@link bitronix.tm.resource.common.XAResourceProducer}s unique names.
getResourcesUniqueNames
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
Apache-2.0
public static void register(XAResourceProducer producer) throws RecoveryException { try { final boolean alreadyRunning = TransactionManagerServices.isTransactionManagerRunning(); final ProducerHolder holder = alreadyRunning ? new InitializableProducerHolder(producer) : new ProducerHolder(producer); if (resources.add(holder)) { if (holder instanceof InitializableProducerHolder) { boolean recovered = false; try { if (log.isDebugEnabled()) { log.debug("Transaction manager is running, recovering resource '" + holder.getUniqueName() + "'."); } IncrementalRecoverer.recover(producer); ((InitializableProducerHolder) holder).initialize(); recovered = true; } finally { if (!recovered) { resources.remove(holder); } } } } else { throw new IllegalStateException("A resource with uniqueName '" + holder.getUniqueName() + "' has already been registered. " + "Cannot register XAResourceProducer '" + producer + "'."); } } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Cannot register the XAResourceProducer '" + producer + "' caused by invalid input.", e); } }
Register a {@link XAResourceProducer}. If registration happens after the transaction manager started, incremental recovery is run on that resource. @param producer the {@link XAResourceProducer}. @throws RecoveryException When an error happens during recovery.
register
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
Apache-2.0
public static void unregister(XAResourceProducer producer) { final ProducerHolder holder = new ProducerHolder(producer); if (!resources.remove(holder)) { if (log.isDebugEnabled()) { log.debug("resource with uniqueName '{}' has not been registered", holder.getUniqueName()); } } }
Unregister a previously registered {@link XAResourceProducer}. @param producer the {@link XAResourceProducer}.
unregister
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
Apache-2.0
public static XAResourceHolder findXAResourceHolder(XAResource xaResource) { final boolean debug = log.isDebugEnabled(); for (ProducerHolder holder : resources) { if (!holder.isInitialized()) continue; final XAResourceProducer producer = holder.producer; final XAResourceHolder resourceHolder = producer.findXAResourceHolder(xaResource); if (resourceHolder != null) { if (debug) { log.debug("XAResource " + xaResource + " belongs to " + resourceHolder + " that itself belongs to " + producer); } return resourceHolder; } if (debug) { log.debug("XAResource " + xaResource + " does not belong to any resource of " + producer); } } return null; }
Find in the registered {@link XAResourceProducer}s the {@link XAResourceHolder} from which the specified {@link XAResource} comes from. @param xaResource the {@link XAResource} to look for @return the associated {@link XAResourceHolder} or null if it cannot be found.
findXAResourceHolder
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/ResourceRegistrar.java
Apache-2.0
public Set<String> getXAResourceHolderStateGtrids() { rwLock.readLock().lock(); try { HashSet<String> gtridsAsStrings = new HashSet<String>(); for (Uid uid : xaResourceHolderStates.keySet()) { gtridsAsStrings.add(uid.toString()); } return gtridsAsStrings; } finally { rwLock.readLock().unlock(); } }
Simple helper method which returns a set of GTRIDs of transactions in which this resource is enlisted. Useful for monitoring. @return a set of String-encoded GTRIDs of transactions in which this resource is enlisted.
getXAResourceHolderStateGtrids
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/AbstractXAResourceHolder.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/AbstractXAResourceHolder.java
Apache-2.0
public String getClassName() { return className; }
@return the underlying implementation class name.
getClassName
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setClassName(String className) { this.className = className; }
Specify the underlying implementation class name of the XA resource described by this bean. @param className the underlying implementation class name.
setClassName
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setUniqueName(String uniqueName) { this.uniqueName = uniqueName; }
Specify the resource unique name to be used to identify this resource during recovery. This name will be registered in the transactions journal so once assigned it must never be changed. @param uniqueName the resource's unique name.
setUniqueName
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public boolean getAutomaticEnlistingEnabled() { return automaticEnlistingEnabled; }
@return true if the the XA resource wrapper should enlist/delist this resource automatically in global transactions.
getAutomaticEnlistingEnabled
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setAutomaticEnlistingEnabled(boolean automaticEnlistingEnabled) { this.automaticEnlistingEnabled = automaticEnlistingEnabled; }
Specify if the XA resource wrapper should enlist/delist this resource automatically in global transactions. When set to false, you have to enlist resources yourself with {@link javax.transaction.Transaction#enlistResource(javax.transaction.xa.XAResource)} and delist them {@link javax.transaction.Transaction#delistResource(javax.transaction.xa.XAResource, int)}. @param automaticEnlistingEnabled true if the the XA resource wrapper should enlist/delist this resource automatically in global transactions.
setAutomaticEnlistingEnabled
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public boolean getUseTmJoin() { return useTmJoin; }
@return true if transaction branches joining should be used.
getUseTmJoin
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setUseTmJoin(boolean useTmJoin) { this.useTmJoin = useTmJoin; }
Specify if the transaction manager should try to join resources by calling {@link javax.transaction.xa.XAResource#start(javax.transaction.xa.Xid, int)} with {@link javax.transaction.xa.XAResource#TMJOIN}. The transaction manager checks if two branches can be joined by calling {@link javax.transaction.xa.XAResource#isSameRM(javax.transaction.xa.XAResource)}. It should only be set to true if the underlying implementation supports resource joining. @param useTmJoin true if transaction branches joining should be used.
setUseTmJoin
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public Properties getDriverProperties() { return driverProperties; }
@return the properties that should be set on the underlying implementation.
getDriverProperties
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setDriverProperties(Properties driverProperties) { this.driverProperties = driverProperties; }
Set the properties that should be set on the underlying implementation. @param driverProperties the properties that should be set on the underlying implementation.
setDriverProperties
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public int getMaxPoolSize() { return maxPoolSize; }
@return the maximum amount of connections that can be in the pool.
getMaxPoolSize
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setMaxPoolSize(int maxPoolSize) { this.maxPoolSize = maxPoolSize; }
Define the maximum amount of connections that can be in the pool. @param maxPoolSize the maximum amount of connections that can be in the pool.
setMaxPoolSize
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public int getMinPoolSize() { return minPoolSize; }
@return the minimal amount of connections that can be in the pool.
getMinPoolSize
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setMinPoolSize(int minPoolSize) { this.minPoolSize = minPoolSize; }
Define the minimal amount of connections that can be in the pool. @param minPoolSize the maximum amount of connections that can be in the pool.
setMinPoolSize
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public int getMaxIdleTime() { return maxIdleTime; }
@return the amount of seconds and idle connection can stay in the pool before getting closed.
getMaxIdleTime
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setMaxIdleTime(int maxIdleTime) { this.maxIdleTime = maxIdleTime; }
Define the amount of seconds and idle connection can stay in the pool before getting closed. @param maxIdleTime the amount of seconds and idle connection can stay in the pool before getting closed.
setMaxIdleTime
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public int getMaxLifeTime() { return maxLifeTime; }
@return the maximum lifetime (in seconds) that a connection can stay in the pool before getting closed.
getMaxLifeTime
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setMaxLifeTime(int maxLifeTime) { this.maxLifeTime = maxLifeTime; }
Define the maximum lifetime (in seconds) that a connection can stay in the pool before getting closed. @param maxLifeTime the maximum lifetime (in seconds) that a connection can stay in the pool before getting closed.
setMaxLifeTime
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public int getAcquireIncrement() { return acquireIncrement; }
@return the amount of connections to be created at once when the pool needs to grow.
getAcquireIncrement
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setAcquireIncrement(int acquireIncrement) { this.acquireIncrement = acquireIncrement; }
Define the amount of connections to be created at once when the pool needs to grow. @param acquireIncrement the amount of connections to be created at once when the pool needs to grow.
setAcquireIncrement
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public int getAcquisitionTimeout() { return acquisitionTimeout; }
@return the amount of time in seconds a call to get a connection from the pool will wait when the pool is empty.
getAcquisitionTimeout
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setAcquisitionTimeout(int acquisitionTimeout) { this.acquisitionTimeout = acquisitionTimeout; }
Define the amount of time in seconds a call to get a connection from the pool will wait when the pool is empty. @param acquisitionTimeout the amount of time in seconds.
setAcquisitionTimeout
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public boolean getDeferConnectionRelease() { return deferConnectionRelease; }
@return false only if the database can run many transactions on the same connection.
getDeferConnectionRelease
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setDeferConnectionRelease(boolean deferConnectionRelease) { this.deferConnectionRelease = deferConnectionRelease; }
Define the transaction interleaving capability of the database. Should be true only if the database can run many transactions on the same connection. @param deferConnectionRelease false only if the database can run many transactions on the same connection.
setDeferConnectionRelease
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public int getAcquisitionInterval() { return acquisitionInterval; }
@return the amount of time between failed connection acquirements.
getAcquisitionInterval
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setAcquisitionInterval(int acquisitionInterval) { this.acquisitionInterval = acquisitionInterval; }
Set the amount of time in seconds the pool will wait before trying to acquire a connection again after an invalid connection has been attempted to be acquired. @param acquisitionInterval amount of time in seconds.
setAcquisitionInterval
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public boolean getAllowLocalTransactions() { return allowLocalTransactions; }
@return true if the transaction manager should allow mixing XA and non-XA transactions.
getAllowLocalTransactions
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setAllowLocalTransactions(boolean allowLocalTransactions) { this.allowLocalTransactions = allowLocalTransactions; }
Set if the transaction manager should allow mixing XA and non-XA transactions. If you know all your transactions should be executed within global (ie: XA) scope it is a good idea to set this property to false. @param allowLocalTransactions if the transaction manager should allow mixing XA and non-XA transactions.
setAllowLocalTransactions
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public boolean getApplyTransactionTimeout() { return applyTransactionTimeout; }
@return true if the transaction-timeout should be set on the XAResource.
getApplyTransactionTimeout
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setApplyTransactionTimeout(boolean applyTransactionTimeout) { this.applyTransactionTimeout = applyTransactionTimeout; }
Set if the transaction-timeout should be set on the XAResource when the XAResource is enlisted. @param applyTransactionTimeout true if the transaction-timeout should be set.
setApplyTransactionTimeout
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setShareTransactionConnections(boolean shareAccessibleConnections) { this.shareTransactionConnections = shareAccessibleConnections; }
Set whether connections in the ACCESSIBLE state can be shared within the context of a transaction. @param shareAccessibleConnections the shareAccessibleConnections to set.
setShareTransactionConnections
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public boolean getShareTransactionConnections() { return shareTransactionConnections; }
@return true if accessible connections can be shared.
getShareTransactionConnections
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setIgnoreRecoveryFailures(boolean ignoreRecoveryFailures) { this.ignoreRecoveryFailures = ignoreRecoveryFailures; }
Set whether XA recovery errors should quarantine the resource or be ignored. @param ignoreRecoveryFailures true if recovery errors should be ignored, false otherwise.
setIgnoreRecoveryFailures
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public boolean getIgnoreRecoveryFailures() { return ignoreRecoveryFailures; }
@return true if recovery errors should be ignored, false otherwise.
getIgnoreRecoveryFailures
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public void setDisabled(boolean disabled) { this.disabled = disabled; }
Set whether this resource is disabled, meaning it's temporarily forbidden to acquire a connection from its pool. @param disabled true to disable the resource, false to enable it.
setDisabled
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0
public boolean isDisabled() { return disabled; }
@return true if the resource is disabled, false if it is enabled.
isDisabled
java
scalar-labs/btm
btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
https://github.com/scalar-labs/btm/blob/master/btm/src/main/java/bitronix/tm/resource/common/ResourceBean.java
Apache-2.0