Java Doc for TransactionRunner.java in  » JMX » je » com » sleepycat » collections » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » JMX » je » com.sleepycat.collections 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.sleepycat.collections.TransactionRunner

All known Subclasses:   com.sleepycat.collections.test.NullTransactionRunner,
TransactionRunner
public class TransactionRunner (Code)
Starts a transaction, calls TransactionWorker.doWork , and handles transaction retry and exceptions. To perform a transaction, the user implements the TransactionWorker interface and passes an instance of that class to the TransactionRunner.run method.

A single TransactionRunner instance may be used by any number of threads for any number of transactions.

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.

  • 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().
  • 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.
  • 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.
  • 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.

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.


author:
   Mark Hayes


Field Summary
final public static  intDEFAULT_MAX_RETRIES
     The default maximum number of retries.

Constructor Summary
public  TransactionRunner(Environment env)
     Creates a transaction runner for a given Berkeley DB environment.
public  TransactionRunner(Environment env, int maxRetries, TransactionConfig config)
     Creates a transaction runner for a given Berkeley DB environment and with a given number of maximum retries.
Parameters:
  env - is the environment for running transactions.
Parameters:
  maxRetries - is the maximum number of retries that will beperformed when deadlocks are detected.
Parameters:
  config - the transaction configuration used for callingEnvironment.beginTransaction, or null to use the defaultconfiguration.

Method Summary
public  booleangetAllowNestedTransactions()
     Returns whether nested transactions will be created if run() is called when a transaction is already active for the current thread.
public  intgetMaxRetries()
     Returns the maximum number of retries that will be performed when deadlocks are detected.
public  TransactionConfiggetTransactionConfig()
     Returns the transaction configuration used for calling Environment.beginTransaction .

If this property is null, the default configuration is used.

public  voidrun(TransactionWorker worker)
     Calls the TransactionWorker.doWork method and, for transactional environments, may begin and end a transaction.
public  voidsetAllowNestedTransactions(boolean allowNestedTxn)
     Changes whether nested transactions will be created if run() is called when a transaction is already active for the current thread.
public  voidsetMaxRetries(int maxRetries)
     Changes the maximum number of retries that will be performed when deadlocks are detected.
public  voidsetTransactionConfig(TransactionConfig config)
     Changes the transaction configuration used for calling Environment.beginTransaction .

If this property is null, the default configuration is used.


Field Detail
DEFAULT_MAX_RETRIES
final public static int DEFAULT_MAX_RETRIES(Code)
The default maximum number of retries.




Constructor Detail
TransactionRunner
public TransactionRunner(Environment env)(Code)
Creates a transaction runner for a given Berkeley DB environment. The default maximum number of retries ( TransactionRunner.DEFAULT_MAX_RETRIES ) and a null (default) TransactionConfig will be used.
Parameters:
  env - is the environment for running transactions.



TransactionRunner
public TransactionRunner(Environment env, int maxRetries, TransactionConfig config)(Code)
Creates a transaction runner for a given Berkeley DB environment and with a given number of maximum retries.
Parameters:
  env - is the environment for running transactions.
Parameters:
  maxRetries - is the maximum number of retries that will beperformed when deadlocks are detected.
Parameters:
  config - the transaction configuration used for callingEnvironment.beginTransaction, or null to use the defaultconfiguration. The configuration object is not cloned, andany modifications to it will impact subsequent transactions.




Method Detail
getAllowNestedTransactions
public boolean getAllowNestedTransactions()(Code)
Returns whether nested transactions will be created if run() is called when a transaction is already active for the current thread. By default this property is false.

Note that this method always returns false in the JE product, since nested transactions are not supported by JE.




getMaxRetries
public int getMaxRetries()(Code)
Returns the maximum number of retries that will be performed when deadlocks are detected.



getTransactionConfig
public TransactionConfig getTransactionConfig()(Code)
Returns the transaction configuration used for calling Environment.beginTransaction .

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.

the transaction configuration.



run
public void run(TransactionWorker worker) throws DatabaseException, Exception(Code)
Calls the TransactionWorker.doWork 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.
throws:
  DeadlockException - when it is thrown by doWork() and themaximum number of retries has occurred. The transaction will have beenaborted by this method.
throws:
  Exception - when any other exception is thrown by doWork(). Theexception will first be unwrapped by calling ExceptionUnwrapper.unwrap. The transaction will have been aborted bythis method.



setAllowNestedTransactions
public void setAllowNestedTransactions(boolean allowNestedTxn)(Code)
Changes whether nested transactions will be created if run() is called when a transaction is already active for the current thread. Calling this method does not impact transactions already running.

Note that true may not be passed to this method in the JE product, since nested transactions are not supported by JE.




setMaxRetries
public void setMaxRetries(int maxRetries)(Code)
Changes the maximum number of retries that will be performed when deadlocks are detected. Calling this method does not impact transactions already running.



setTransactionConfig
public void setTransactionConfig(TransactionConfig config)(Code)
Changes the transaction configuration used for calling Environment.beginTransaction .

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.


Parameters:
  config - the transaction configuration.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.