1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
|
<!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_23) on Tue Oct 25 16:49:36 EDT 2011 -->
<TITLE>
TransactionRunner (Oracle - Berkeley DB Java API)
</TITLE>
<META NAME="date" CONTENT="2011-10-25">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../style.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="TransactionRunner (Oracle - Berkeley DB Java API)";
}
}
</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="class-use/TransactionRunner.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </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>
<b>Berkeley DB</b><br><font size="-1"> version 5.1.29</font></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../com/sleepycat/collections/StoredValueSet.html" title="class in com.sleepycat.collections"><B>PREV CLASS</B></A>
<A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?com/sleepycat/collections/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 | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <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.collections</FONT>
<BR>
Class TransactionRunner</H2>
<PRE>
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A>
<IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.sleepycat.collections.TransactionRunner</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>TransactionRunner</B><DT>extends <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL>
</PRE>
<P>
Starts a transaction, calls <A HREF="../../../com/sleepycat/collections/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A>, and handles
transaction retry and exceptions. To perform a transaction, the user
implements the <A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections"><CODE>TransactionWorker</CODE></A> interface and passes an instance of
that class to the <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)"><CODE>run</CODE></A> method.
<p>A single TransactionRunner instance may be used by any number of threads
for any number of transactions.</p>
<p>The behavior of the run() method depends on whether the environment is
transactional, whether nested transactions are enabled, and whether a
transaction is already active.</p>
<ul>
<li>When the run() method is called in a transactional environment and no
transaction is active for the current thread, a new transaction is started
before calling doWork(). If DeadlockException is thrown by doWork(),
the transaction will be aborted and the process will be repeated up to the
maximum number of retries. 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 the run() method. If no exception is
thrown by doWork(), the transaction will be committed. The run() method
will not attempt to commit or abort a transaction if it has already been
committed or aborted by doWork().</li>
<li>When the run() method is called and a transaction is active for the
current thread, and nested transactions are enabled, a nested transaction is
started before calling doWork(). The transaction that is active when
calling the run() method will become the parent of the nested transaction.
The nested transaction will be committed or aborted by the run() method
following the same rules described above. Note that nested transactions may
not be enabled for the JE product, since JE does not support nested
transactions.</li>
<li>When the run() method is called in a non-transactional environment, the
doWork() method is called without starting a transaction. The run() method
will return without committing or aborting a transaction, and any exceptions
thrown by the doWork() method will be thrown by the run() method.</li>
<li>When the run() method is called and a transaction is active for the
current thread and nested transactions are not enabled (the default) the
same rules as above apply. All the operations performed by the doWork()
method will be part of the currently active transaction.</li>
</ul>
<p>In a transactional environment, the rules described above support nested
calls to the run() method and guarantee that the outermost call will cause
the transaction to be committed or aborted. This is true whether or not
nested transactions are supported or enabled. Note that nested transactions
are provided as an optimization for improving concurrency but do not change
the meaning of the outermost transaction. Nested transactions are not
currently supported by the JE product.</p>
<P>
<P>
<HR>
<P>
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_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>Field Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#DEFAULT_MAX_RETRIES">DEFAULT_MAX_RETRIES</A></B></CODE>
<BR>
The default maximum number of retries.</TD>
</TR>
</TABLE>
<!-- ======== 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/collections/TransactionRunner.html#TransactionRunner(com.sleepycat.db.Environment)">TransactionRunner</A></B>(<A HREF="../../../com/sleepycat/db/Environment.html" title="class in com.sleepycat.db">Environment</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/collections/TransactionRunner.html#TransactionRunner(com.sleepycat.db.Environment, int, com.sleepycat.db.TransactionConfig)">TransactionRunner</A></B>(<A HREF="../../../com/sleepycat/db/Environment.html" title="class in com.sleepycat.db">Environment</A> env,
int maxRetries,
<A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> config)</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/collections/TransactionRunner.html#getAllowNestedTransactions()">getAllowNestedTransactions</A></B>()</CODE>
<BR>
Returns whether nested transactions will be created if
<code>run()</code> is called when a transaction is already active for
the current thread.</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/collections/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> <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/sleepycat/collections/TransactionRunner.html#getTransactionConfig()">getTransactionConfig</A></B>()</CODE>
<BR>
Returns the transaction configuration used for calling
<A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>.</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/collections/TransactionRunner.html#handleException(java.lang.Exception, int, int)">handleException</A></B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A> exception,
int retries,
int maxRetries)</CODE>
<BR>
Handles exceptions that occur during a transaction, and may implement
transaction retry policy.</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/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)">run</A></B>(<A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections">TransactionWorker</A> worker)</CODE>
<BR>
Calls the <A HREF="../../../com/sleepycat/collections/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method and, for transactional
environments, may begin and end 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/collections/TransactionRunner.html#setAllowNestedTransactions(boolean)">setAllowNestedTransactions</A></B>(boolean allowNestedTxn)</CODE>
<BR>
Changes whether nested transactions will be created if
<code>run()</code> is called when a transaction is already active for
the current thread.</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/collections/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/collections/TransactionRunner.html#setTransactionConfig(com.sleepycat.db.TransactionConfig)">setTransactionConfig</A></B>(<A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> config)</CODE>
<BR>
Changes the transaction configuration used for calling
<A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>.</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.<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ FIELD DETAIL =========== -->
<A NAME="field_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>Field Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="DEFAULT_MAX_RETRIES"><!-- --></A><H3>
DEFAULT_MAX_RETRIES</H3>
<PRE>
public static final int <B>DEFAULT_MAX_RETRIES</B></PRE>
<DL>
<DD>The default maximum number of retries.
<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#com.sleepycat.collections.TransactionRunner.DEFAULT_MAX_RETRIES">Constant Field Values</A></DL>
</DL>
<!-- ========= 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.Environment)"><!-- --></A><H3>
TransactionRunner</H3>
<PRE>
public <B>TransactionRunner</B>(<A HREF="../../../com/sleepycat/db/Environment.html" title="class in com.sleepycat.db">Environment</A> env)</PRE>
<DL>
<DD>Creates a transaction runner for a given Berkeley DB environment.
The default maximum number of retries (<A HREF="../../../com/sleepycat/collections/TransactionRunner.html#DEFAULT_MAX_RETRIES"><CODE>DEFAULT_MAX_RETRIES</CODE></A>) and
a null (default) <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db"><CODE>TransactionConfig</CODE></A> 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.Environment, int, com.sleepycat.db.TransactionConfig)"><!-- --></A><H3>
TransactionRunner</H3>
<PRE>
public <B>TransactionRunner</B>(<A HREF="../../../com/sleepycat/db/Environment.html" title="class in com.sleepycat.db">Environment</A> env,
int maxRetries,
<A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> config)</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.<DD><CODE>config</CODE> - the transaction configuration used for calling
<A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>, or null to use the default
configuration. The configuration object is not cloned, and
any modifications to it will impact subsequent transactions.</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="getAllowNestedTransactions()"><!-- --></A><H3>
getAllowNestedTransactions</H3>
<PRE>
public boolean <B>getAllowNestedTransactions</B>()</PRE>
<DL>
<DD>Returns whether nested transactions will be created if
<code>run()</code> is called when a transaction is already active for
the current thread.
By default this property is false.
<p>Note that this method always returns false in the JE product, since
nested transactions are not supported by JE.</p>
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="setAllowNestedTransactions(boolean)"><!-- --></A><H3>
setAllowNestedTransactions</H3>
<PRE>
public void <B>setAllowNestedTransactions</B>(boolean allowNestedTxn)</PRE>
<DL>
<DD>Changes whether nested transactions will be created if
<code>run()</code> is called when a transaction is already active for
the current thread.
Calling this method does not impact transactions already running.
<p>Note that true may not be passed to this method in the JE product,
since nested transactions are not supported by JE.</p>
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getTransactionConfig()"><!-- --></A><H3>
getTransactionConfig</H3>
<PRE>
public <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> <B>getTransactionConfig</B>()</PRE>
<DL>
<DD>Returns the transaction configuration used for calling
<A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>.
<p>If this property is null, the default configuration is used. The
configuration object is not cloned, and any modifications to it will
impact subsequent transactions.</p>
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the transaction configuration.</DL>
</DD>
</DL>
<HR>
<A NAME="setTransactionConfig(com.sleepycat.db.TransactionConfig)"><!-- --></A><H3>
setTransactionConfig</H3>
<PRE>
public void <B>setTransactionConfig</B>(<A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db">TransactionConfig</A> config)</PRE>
<DL>
<DD>Changes the transaction configuration used for calling
<A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)</CODE></A>.
<p>If this property is null, the default configuration is used. The
configuration object is not cloned, and any modifications to it will
impact subsequent transactions.</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>config</CODE> - the transaction configuration.</DL>
</DD>
</DL>
<HR>
<A NAME="run(com.sleepycat.collections.TransactionWorker)"><!-- --></A><H3>
run</H3>
<PRE>
public void <B>run</B>(<A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections">TransactionWorker</A> worker)
throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A>,
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A></PRE>
<DL>
<DD>Calls the <A HREF="../../../com/sleepycat/collections/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method and, for transactional
environments, may begin and end a transaction. If the environment given
is non-transactional, a transaction will not be used but the doWork()
method will still be called. See the class description for more
information.
<P>
<DD><DL>
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db">DeadlockException</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><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A></CODE> - when any other exception is thrown by doWork(). The
exception will first be unwrapped by calling <A HREF="../../../com/sleepycat/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/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL>
</DD>
</DL>
<HR>
<A NAME="handleException(java.lang.Exception, int, int)"><!-- --></A><H3>
handleException</H3>
<PRE>
public int <B>handleException</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A> exception,
int retries,
int maxRetries)
throws <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A></PRE>
<DL>
<DD>Handles exceptions that occur during a transaction, and may implement
transaction retry policy. The transaction is aborted by the <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)"><CODE>run</CODE></A> method before calling this method.
<p>The default implementation of this method throws the <code>exception</code> parameter if it is not an instance of <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A> and otherwise returns the <code>maxRetries</code>
parameter value. This method can be overridden to throw a different
exception or return a different number of retries. For example:</p>
<ul>
<li>This method could call <code>Thread.sleep</code> for a short interval to
allow other transactions to finish.</li>
<li>This method could return a different <code>maxRetries</code> value
depending on the <code>exception</code> that occurred.</li>
<li>This method could throw an application-defined exception when the
<code>retries</code> value is greater or equal to the <code>maxRetries</code> and
a <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A> occurs, to override the default behavior
which is to throw the <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A>.</li>
</ul>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>exception</CODE> - an exception that was thrown by the <A HREF="../../../com/sleepycat/collections/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method or thrown when beginning or committing
the transaction. If the <code>retries</code> value is greater or equal to
<code>maxRetries</code> when this method returns normally, this exception
will be thrown by the <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)"><CODE>run</CODE></A> method.<DD><CODE>retries</CODE> - the current value of a counter that starts out at zero
and is incremented when each retry is performed.<DD><CODE>maxRetries</CODE> - the maximum retries to be performed. By default,
this value is set to <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#getMaxRetries()"><CODE>getMaxRetries()</CODE></A>. This method may return a
different maximum retries value to override that default.
<DT><B>Returns:</B><DD>the maximum number of retries to perform. The
default policy is to return the <code>maxRetries</code> parameter value
if the <code>exception</code> parameter value is an instance of <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A>.
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</A></CODE> - to cause the exception to be thrown by the <A HREF="../../../com/sleepycat/collections/TransactionRunner.html#run(com.sleepycat.collections.TransactionWorker)"><CODE>run</CODE></A> method. The default policy is to throw the <code>exception</code>
parameter value if it is not an instance of <A HREF="../../../com/sleepycat/db/DeadlockException.html" title="class in com.sleepycat.db"><CODE>DeadlockException</CODE></A>.<DT><B>Since:</B></DT>
<DD>3.4</DD>
</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="class-use/TransactionRunner.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </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>
<b>Berkeley DB</b><br><font size="-1"> version 5.1.29</font></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../com/sleepycat/collections/StoredValueSet.html" title="class in com.sleepycat.collections"><B>PREV CLASS</B></A>
<A HREF="../../../com/sleepycat/collections/TransactionWorker.html" title="interface in com.sleepycat.collections"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?com/sleepycat/collections/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 | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <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>
<font size=1>Copyright (c) 1996, 2010 Oracle and/or its affiliates. All rights reserved.</font>
</BODY>
</HTML>
|