<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_18) on Thu Dec 02 16:59:40 UTC 2010 --> <TITLE> TransactionRunner </TITLE> <META NAME="date" CONTENT="2010-12-02"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="TransactionRunner"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../com/sleepycat/bdb/StoredClassCatalog.html" title="class in com.sleepycat.bdb"><B>PREV CLASS</B></A> <A HREF="../../../com/sleepycat/bdb/TransactionWorker.html" title="interface in com.sleepycat.bdb"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?com/sleepycat/bdb/TransactionRunner.html" target="_top"><B>FRAMES</B></A> <A HREF="TransactionRunner.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> com.sleepycat.bdb</FONT> <BR> Class TransactionRunner</H2> <PRE> java.lang.Object <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.sleepycat.bdb.TransactionRunner</B> </PRE> <HR> <DL> <DT><PRE>public class <B>TransactionRunner</B><DT>extends java.lang.Object</DL> </PRE> <P> Starts a transaction, calls <A HREF="../../../com/sleepycat/bdb/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A>, and handles transaction retry and exceptions. <P> <P> <HR> <P> <!-- ======== CONSTRUCTOR SUMMARY ======== --> <A NAME="constructor_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Constructor Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#TransactionRunner(com.sleepycat.db.DbEnv)">TransactionRunner</A></B>(<A HREF="../../../com/sleepycat/db/DbEnv.html" title="class in com.sleepycat.db">DbEnv</A> env)</CODE> <BR> Creates a transaction runner for a given Berkeley DB environment.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#TransactionRunner(com.sleepycat.db.DbEnv, int)">TransactionRunner</A></B>(<A HREF="../../../com/sleepycat/db/DbEnv.html" title="class in com.sleepycat.db">DbEnv</A> env, int maxRetries)</CODE> <BR> Creates a transaction runner for a given Berkeley DB environment and with a given number of maximum retries.</TD> </TR> </TABLE> <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#getDirtyRead()">getDirtyRead</A></B>()</CODE> <BR> Returns whether transactions will read data that is modified by another transaction but not committed.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#getMaxRetries()">getMaxRetries</A></B>()</CODE> <BR> Returns the maximum number of retries that will be performed when deadlocks are detected.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#getNoWait()">getNoWait</A></B>()</CODE> <BR> Returns whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#run(com.sleepycat.bdb.TransactionWorker)">run</A></B>(<A HREF="../../../com/sleepycat/bdb/TransactionWorker.html" title="interface in com.sleepycat.bdb">TransactionWorker</A> worker)</CODE> <BR> Calls the <A HREF="../../../com/sleepycat/bdb/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method and, for transactional environments, begins and ends a transaction.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#setDirtyRead(boolean)">setDirtyRead</A></B>(boolean dirtyRead)</CODE> <BR> Changes whether transactions will read data that is modified by another transaction but not committed.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#setMaxRetries(int)">setMaxRetries</A></B>(int maxRetries)</CODE> <BR> Changes the maximum number of retries that will be performed when deadlocks are detected.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#setNoWait(boolean)">setNoWait</A></B>(boolean noWait)</CODE> <BR> Changes whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction.</TD> </TR> </TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD> </TR> </TABLE> <P> <!-- ========= CONSTRUCTOR DETAIL ======== --> <A NAME="constructor_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Constructor Detail</B></FONT></TH> </TR> </TABLE> <A NAME="TransactionRunner(com.sleepycat.db.DbEnv)"><!-- --></A><H3> TransactionRunner</H3> <PRE> public <B>TransactionRunner</B>(<A HREF="../../../com/sleepycat/db/DbEnv.html" title="class in com.sleepycat.db">DbEnv</A> env)</PRE> <DL> <DD>Creates a transaction runner for a given Berkeley DB environment. The default maximum number of retries (10) will be used. <P> <DL> <DT><B>Parameters:</B><DD><CODE>env</CODE> - is the environment for running transactions.</DL> </DL> <HR> <A NAME="TransactionRunner(com.sleepycat.db.DbEnv, int)"><!-- --></A><H3> TransactionRunner</H3> <PRE> public <B>TransactionRunner</B>(<A HREF="../../../com/sleepycat/db/DbEnv.html" title="class in com.sleepycat.db">DbEnv</A> env, int maxRetries)</PRE> <DL> <DD>Creates a transaction runner for a given Berkeley DB environment and with a given number of maximum retries. <P> <DL> <DT><B>Parameters:</B><DD><CODE>env</CODE> - is the environment for running transactions.<DD><CODE>maxRetries</CODE> - is the maximum number of retries that will be performed when deadlocks are detected.</DL> </DL> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="getMaxRetries()"><!-- --></A><H3> getMaxRetries</H3> <PRE> public int <B>getMaxRetries</B>()</PRE> <DL> <DD>Returns the maximum number of retries that will be performed when deadlocks are detected. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="setMaxRetries(int)"><!-- --></A><H3> setMaxRetries</H3> <PRE> public void <B>setMaxRetries</B>(int maxRetries)</PRE> <DL> <DD>Changes the maximum number of retries that will be performed when deadlocks are detected. Calling this method does not impact transactions already running. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="getDirtyRead()"><!-- --></A><H3> getDirtyRead</H3> <PRE> public boolean <B>getDirtyRead</B>()</PRE> <DL> <DD>Returns whether transactions will read data that is modified by another transaction but not committed. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="setDirtyRead(boolean)"><!-- --></A><H3> setDirtyRead</H3> <PRE> public void <B>setDirtyRead</B>(boolean dirtyRead)</PRE> <DL> <DD>Changes whether transactions will read data that is modified by another transaction but not committed. Calling this method does not impact transaction already running. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="getNoWait()"><!-- --></A><H3> getNoWait</H3> <PRE> public boolean <B>getNoWait</B>()</PRE> <DL> <DD>Returns whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="setNoWait(boolean)"><!-- --></A><H3> setNoWait</H3> <PRE> public void <B>setNoWait</B>(boolean noWait)</PRE> <DL> <DD>Changes whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="run(com.sleepycat.bdb.TransactionWorker)"><!-- --></A><H3> run</H3> <PRE> public void <B>run</B>(<A HREF="../../../com/sleepycat/bdb/TransactionWorker.html" title="interface in com.sleepycat.bdb">TransactionWorker</A> worker) throws <A HREF="../../../com/sleepycat/db/DbException.html" title="class in com.sleepycat.db">DbException</A>, java.lang.Exception</PRE> <DL> <DD>Calls the <A HREF="../../../com/sleepycat/bdb/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method and, for transactional environments, begins and ends a transaction. If the environment given is non-transactional, a transaction will not be used but the doWork() method will still be called. <p> In a transactional environment, a new transaction is started before calling doWork(). This will start a nested transaction if one is already active. If DbDeadlockException is thrown by doWork(), the transaction will be aborted and the process will be repeated up to the maximum number of retries specified. If another exception is thrown by doWork() or the maximum number of retries has occurred, the transaction will be aborted and the exception will be rethrown by this method. If no exception is thrown by doWork(), the transaction will be committed. This method will not attempt to commit or abort a transaction if it has already been committed or aborted by doWork(). </p> <P> <DD><DL> <DT><B>Throws:</B> <DD><CODE><A HREF="../../../com/sleepycat/db/DbDeadlockException.html" title="class in com.sleepycat.db">DbDeadlockException</A></CODE> - when it is thrown by doWork() and the maximum number of retries has occurred. The transaction will have been aborted by this method. <DD><CODE>java.lang.Exception</CODE> - when any other exception is thrown by doWork(). The exception will first be unwrapped by calling <A HREF="../../../com/sleepycat/bdb/util/ExceptionUnwrapper.html#unwrap(java.lang.Exception)"><CODE>ExceptionUnwrapper.unwrap(java.lang.Exception)</CODE></A>. The transaction will have been aborted by this method. <DD><CODE><A HREF="../../../com/sleepycat/db/DbException.html" title="class in com.sleepycat.db">DbException</A></CODE></DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../com/sleepycat/bdb/StoredClassCatalog.html" title="class in com.sleepycat.bdb"><B>PREV CLASS</B></A> <A HREF="../../../com/sleepycat/bdb/TransactionWorker.html" title="interface in com.sleepycat.bdb"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?com/sleepycat/bdb/TransactionRunner.html" target="_top"><B>FRAMES</B></A> <A HREF="TransactionRunner.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>