Debian Codegraph @

docs/gsg_txn/JAVA/apireq.html

raw
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>Application Requirements</title>
7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Getting Started with Berkeley DB Transaction Processing" />
10 <link rel="up" href="introduction.html" title="Chapter 1. Introduction" />
11 <link rel="prev" href="sysfailure.html" title="A Note on System Failure" />
12 <link rel="next" href="multithread-intro.html" title="Multi-threaded and Multi-process Applications" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">Application Requirements</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="sysfailure.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 1. Introduction</th>
26 <td width="20%" align="right"> <a accesskey="n" href="multithread-intro.html">Next</a></td>
27 </tr>
28 </table>
29 <hr />
30 </div>
31 <div class="sect1" lang="en" xml:lang="en">
32 <div class="titlepage">
33 <div>
34 <div>
35 <h2 class="title" style="clear: both"><a id="apireq"></a>Application Requirements</h2>
36 </div>
37 </div>
38 </div>
39 <p>
40 In order to use transactions, your application has certain
41 requirements beyond what is required of non-transactional protected
42 applications. They are:
43 </p>
44 <div class="itemizedlist">
45 <ul type="disc">
46 <li>
47 <p>
48 Environments.
49 </p>
50 <p>
51 Environments are optional for non-transactional
52 applications that use the base API, but they are required for transactional
53 applications. (Of course, applications that use the
54 DPL always require the DPL.)
55 </p>
56 <p>
57 Environment usage is described in detail in
58 <a class="xref" href="usingtxns.html" title="Chapter 3. Transaction Basics">Transaction Basics</a>.
59 </p>
60 </li>
61 <li>
62 <p>
63 Transaction subsystem.
64 </p>
65 <p>
66 In order to use transactions, you must explicitly
67 enable the transactional subsystem for your
68 application, and this must be done at the time that
69 your environment is first created.
70 </p>
71 </li>
72 <li>
73 <p>
74 Logging subsystem.
75 </p>
76 <p>
77 The logging subsystem is required for recovery purposes, but
78 its usage also means your application may require a
79 little more administrative effort than it does when logging
80 is not in use. See <a class="xref" href="filemanagement.html" title="Chapter 5. Managing DB Files">Managing DB Files</a> for more information.
81 </p>
82 </li>
83 <li>
84 <p>
85
86
87 <span>Transaction</span>
88
89 handles.
90 </p>
91 <p>
92 In order to obtain the atomicity guarantee offered by
93 the transactional subsystem (that is, combine multiple
94 operations in a single unit of work), your application must use
95 transaction handles. These handles are obtained from your
96
97
98
99 <span>Environment</span>
100 objects. They should normally be short-lived, and their usage is
101 reasonably simple. To complete a transaction and save
102 the work it performed, you
103 call its <code class="methodname">commit()</code> method. To
104 complete a transaction and discard its work, you call its
105 <code class="methodname">abort()</code> method.
106 </p>
107 <p>
108 In addition, it is possible to use auto commit if you want
109 to transactional protect a single write operation. Auto
110 commit allows a transaction to be used without
111 obtaining an explicit transaction handle. See
112 <a class="xref" href="autocommit.html" title="Auto Commit">Auto Commit</a>
113 for information on how to use auto commit.
114 </p>
115 </li>
116 <li>
117 <p>
118 Entity Store
119 </p>
120 <p>
121 If you are using the DPL, then you must
122 configure your entity stores for transactional
123 support before opening them (that is, before
124 obtaining a primary index from them for the first
125 time).
126 </p>
127 </li>
128 <li>
129 <p>
130 Database open requirements.
131 </p>
132 <p>
133
134 <span>In addition to using
135 environments and initializing the
136 correct subsystems, your</span>
137
138
139 application must transaction protect the database
140
141 opens<span>,
142 and any secondary index associations,</span>
143
144 if subsequent operations on the databases are to be transaction
145 protected. The database open and secondary index
146 association are commonly transaction protected using
147 auto commit.
148 </p>
149 <p>
150 Note that if you are using the DPL, you do not
151 have to explicitly do anything to the underlying
152 databases unless you want to modify their default
153 behavior — such as the isolation level that they
154 use, for example.
155 </p>
156 </li>
157 <li>
158 <p>
159 Deadlock detection.
160 </p>
161 <p>
162 Typically transactional applications use multiple
163 threads of control when accessing the database.
164 Any time multiple threads are used on a single resource,
165 the potential for lock contention arises. In turn, lock
166 contention can lead to deadlocks. See
167 <a class="xref" href="blocking_deadlocks.html" title="Locks, Blocks, and Deadlocks">Locks, Blocks, and Deadlocks</a>
168 for more information.
169 </p>
170 <p>
171 Therefore, transactional applications must frequently
172 include code for detecting and responding to deadlocks.
173 Note that this requirement is not
174 <span class="emphasis"><em>specific</em></span> to transactions
175 – you can certainly write concurrent
176 non-transactional DB applications. Further, not
177 every transactional application uses concurrency and
178 so not every transactional application must
179 manage deadlocks. Still, deadlock management is so
180 frequently a characteristic of transactional
181 applications that we discuss it in this
182 book. See <a class="xref" href="txnconcurrency.html" title="Chapter 4. Concurrency">Concurrency</a>
183 for more information.
184 </p>
185 </li>
186 </ul>
187 </div>
188 </div>
189 <div class="navfooter">
190 <hr />
191 <table width="100%" summary="Navigation footer">
192 <tr>
193 <td width="40%" align="left"><a accesskey="p" href="sysfailure.html">Prev</a> </td>
194 <td width="20%" align="center">
195 <a accesskey="u" href="introduction.html">Up</a>
196 </td>
197 <td width="40%" align="right"> <a accesskey="n" href="multithread-intro.html">Next</a></td>
198 </tr>
199 <tr>
200 <td width="40%" align="left" valign="top">A Note on System Failure </td>
201 <td width="20%" align="center">
202 <a accesskey="h" href="index.html">Home</a>
203 </td>
204 <td width="40%" align="right" valign="top"> Multi-threaded
205 <span>and Multi-process</span>
206 Applications</td>
207 </tr>
208 </table>
209 </div>
210 </body>
211 </html>