KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > store > raw > xact > TransactionFactory


1 /*
2
3    Derby - Class org.apache.derby.iapi.store.raw.xact.TransactionFactory
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.store.raw.xact;
23
24 import org.apache.derby.iapi.services.context.ContextManager;
25 import org.apache.derby.iapi.services.daemon.Serviceable;
26 import org.apache.derby.iapi.services.io.Formatable;
27 import org.apache.derby.iapi.services.locks.LockFactory;
28
29 import org.apache.derby.iapi.store.access.TransactionInfo;
30
31 import org.apache.derby.iapi.store.raw.RawStoreFactory;
32 import org.apache.derby.iapi.store.raw.Transaction;
33 import org.apache.derby.iapi.store.raw.Corruptable;
34
35 import org.apache.derby.iapi.store.raw.log.LogInstant;
36
37 import org.apache.derby.iapi.error.StandardException;
38
39 /**
40     This module is intended to be used only within the RawStore. RawStore functionality
41     is accessed only through the RawStoreFactory interface.
42     The transaction manager is responsible for:
43
44     <UL>
45     <LI>Generating unique transaction identifiers.
46     <LI>Keeping a list of all open transactions within the raw store.
47     </UL>
48
49     @see RawStoreFactory
50     @see Transaction
51 */

52
53 public interface TransactionFactory extends Corruptable {
54
55     public static String JavaDoc MODULE =
56         "org.apache.derby.iapi.store.raw.xact.TransactionFactory";
57
58     /**
59         Get the LockFactory to use with this store.
60     */

61     public LockFactory getLockFactory();
62
63     /*
64      * Return the module providing XAresource interface to the transaction
65      * table.
66      *
67      * @exception StandardException Standard cloudscape exception policy.
68      */

69     public /* XAResourceManager */ Object JavaDoc getXAResourceManager()
70         throws StandardException;
71
72     /**
73         Start a new transaction within the given raw store. This method will
74         push a transaction context as described in
75         RawStoreFactory.startTransaction
76
77         @param contextMgr is the context manager to use. It must be the current
78                           context manager.
79         @param transName is the transaction name. It will be displayed in the
80             transactiontable VTI.
81
82         @see RawStoreFactory#startTransaction
83
84         @exception StandardException Standard Cloudscape error policy.
85     */

86     public RawTransaction startTransaction(
87     RawStoreFactory rsf,
88     ContextManager contextMgr,
89     String JavaDoc transName)
90         throws StandardException;
91
92     /**
93         Start a new read only transaction within the given raw store. This
94         method will push a transaction context as described in
95         RawStoreFactory.startNestedTransaction
96
97         @param compatibilitySpace compatibility space to use for locks.
98         @param contextMgr is the context manager to use. It must be
99                                     the current context manager.
100         @param transName is the transaction name. It will be
101                                     displayed in the transactiontable VTI.
102
103         @see RawStoreFactory#startNestedReadOnlyUserTransaction
104
105         @exception StandardException Standard Cloudscape error policy.
106     */

107     public RawTransaction startNestedReadOnlyUserTransaction(
108     RawStoreFactory rsf,
109     Object JavaDoc compatibilitySpace,
110     ContextManager contextMgr,
111     String JavaDoc transName)
112         throws StandardException;
113
114     /**
115         Start a new update transaction within the given raw store. This method
116         will push a transaction context as described in
117         RawStoreFactory.startNestedTransaction
118
119         @param contextMgr is the context manager to use. It must be
120                                     the current context manager.
121         @param transName is the transaction name. It will be
122                                     displayed in the transactiontable VTI.
123
124         @see RawStoreFactory#startNestedUpdateUserTransaction
125
126         @exception StandardException Standard Cloudscape error policy.
127     */

128     public RawTransaction startNestedUpdateUserTransaction(
129     RawStoreFactory rsf,
130     ContextManager contextMgr,
131     String JavaDoc transName)
132         throws StandardException;
133
134
135     /**
136         Start a new transaction within the given raw store. This method will
137         push a transaction context as described in
138         RawStoreFactory.startTransaction
139
140         @param format_id the format id part of the Xid - ie. Xid.getFormatId().
141         @param global_id the global transaction identifier part of XID - ie.
142                           Xid.getGlobalTransactionId().
143         @param branch_id The branch qualifier of the Xid - ie.
144                           Xid.getBranchQaulifier()
145         @param contextMgr is the context manager to use. It must be the current
146                           context manager.
147
148         @see RawStoreFactory#startGlobalTransaction
149
150         @exception StandardException Standard Cloudscape error policy.
151     */

152     public RawTransaction startGlobalTransaction(
153     RawStoreFactory rsf,
154     ContextManager contextMgr,
155     int format_id,
156     byte[] global_id,
157     byte[] branch_id)
158         throws StandardException;
159
160     /**
161         Find a user transaction within the given raw store and the given
162         contextMgr. If no user transaction exist, then start one with name
163         transName. This method will push a transaction context as described in
164         RawStoreFactory.startTransaction
165
166         @see RawStoreFactory#findUserTransaction
167         @see RawStoreFactory#startTransaction
168
169         @exception StandardException Standard Cloudscape error policy.
170     */

171     public RawTransaction findUserTransaction(
172         RawStoreFactory rsf,
173         ContextManager contextMgr,
174         String JavaDoc transName) throws StandardException;
175
176     /**
177         Start a new nested top transaction within the given raw store. This
178         method will push a transaction context as described in
179         RawStoreFactory.startNestedTopTransaction
180
181         @see RawStoreFactory#startTransaction(ContextManager, String)
182
183         @exception StandardException Standard Cloudscape error policy.
184     */

185     public RawTransaction startNestedTopTransaction(RawStoreFactory rsf, ContextManager contextMgr) throws StandardException;
186
187
188     /**
189         Start a new internal transaction within the given raw store. This
190         method will push a transaction context as described in
191         RawStoreFactory.startInternalTransaction
192
193         @see RawStoreFactory#startTransaction
194
195         @exception StandardException Standard Cloudscape error policy.
196     */

197     public RawTransaction startInternalTransaction(RawStoreFactory rsf, ContextManager contextMgr) throws StandardException;
198
199
200     /**
201         Find a transaction using a transactionId and make the passed in
202         transaction assume the identity and properties of that transaction.
203         Used in recovery only.
204     */

205     public boolean findTransaction(TransactionId id, RawTransaction tran);
206
207
208     /**
209         Reset any resettable transaction Id
210         @exception StandardException Standard Cloudscape error policy.
211     */

212     public void resetTranId() throws StandardException;
213
214     /**
215         The first log instant that belongs to a transaction that is still
216         active in the raw store. This is the first log record of the longest
217         running transaction at this moment.
218     */

219     public LogInstant firstUpdateInstant();
220
221     /**
222         Run through all prepared transactions known to this factory
223         and restore their state such that they remain after recovery, and
224         can be found and handled by a XA transaction manager. This includes
225         creating a context manager for each, pushing a xact context, and
226         reclaiming update locks on all data changed by the transaction.
227
228         Used only in recovery.
229
230         @exception StandardException Cloudscape Standard Error policy
231     */

232     public void handlePreparedXacts(
233     RawStoreFactory rsf)
234          throws StandardException;
235
236
237     /**
238         Rollback and close all transactions known to this factory using a
239         passed in transaction. Used only in recovery.
240
241         @param recoveryTransaction the transaction used to rollback
242         @exception StandardException Cloudscape Standard Error policy
243     */

244     public void rollbackAllTransactions(RawTransaction recoveryTransaction,
245                                         RawStoreFactory rsf)
246          throws StandardException ;
247
248
249     /**
250         Submit a post commit work to the post commit daemon.
251         The work is always added to the deamon, regardless of the
252         state it returns.
253
254         @return true if the daemon indicates it is being overloaded,
255         false it's happy.
256
257         <MT> must be MT-safe
258     */

259     public boolean submitPostCommitWork(Serviceable work);
260
261     /**
262         make Transaction factory aware of which raw store factory it belongs to
263     */

264     public void setRawStoreFactory(RawStoreFactory rsf) throws StandardException;
265
266     /**
267         Returns true if the transaction factory has no active updating
268         transaction
269     */

270     public boolean noActiveUpdateTransaction();
271
272
273     /**
274      * Check if there are any prepared transanctions.
275      *
276      * <P>MT - unsafe, called during boot, which is single threaded.
277      *
278      * @return <tt>true</tt> if prepared transactions exist,
279      * <tt>false</tt> otherwise.
280      */

281     public boolean hasPreparedXact();
282
283     /**
284         Database creation finished
285
286         @exception StandardException Standard cloudscape exception policy.
287     */

288     public void createFinished() throws StandardException;
289
290     /**
291         Return the transaction table so it can get logged with the checkpoint
292         log record.
293      */

294     public Formatable getTransactionTable();
295
296     /**
297         Use this transaction table, which is gotten from a checkpoint
298         operation. Use ONLY during recovery.
299
300         @exception StandardException Standard cloudscape exception policy.
301      */

302     public void useTransactionTable(Formatable transactionTable)
303          throws StandardException;
304
305     /**
306       @see org.apache.derby.iapi.store.access.AccessFactory#getTransactionInfo
307      */

308     public TransactionInfo[] getTransactionInfo();
309
310
311     /**
312      * Checks if there any backup blocking operations are in progress and
313      * prevents new ones from starting until the backup is finished.
314      *
315      * @param wait if <tt>true</tt>, waits for the current backup blocking
316      * operations in progress to finish.
317      * @return <tt>true</tt> if there are no backup blocking
318      * operations in progress.
319      * <tt>false</tt> otherwise.
320      * @exception StandardException if interrupted or a runtime exception occurs.
321      */

322     public boolean blockBackupBlockingOperations(boolean wait)
323         throws StandardException ;
324
325     /**
326      * Backup completed. Allow backup blocking operations.
327      */

328     public void unblockBackupBlockingOperations();
329
330                                                        
331
332                                                        
333 }
334
Popular Tags