1 /*
2
3 Derby - Class org.apache.derby.iapi.store.access.conglomerate.TransactionManager
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.access.conglomerate;
23
24 import org.apache.derby.iapi.services.daemon.Serviceable;
25 import org.apache.derby.iapi.store.access.ConglomerateController;
26 import org.apache.derby.iapi.store.access.SortController;
27 import org.apache.derby.iapi.store.access.TransactionController;
28 import org.apache.derby.iapi.store.raw.Transaction;
29 import org.apache.derby.iapi.error.StandardException;
30
31
32 /**
33
34 The TransactionManager interface provides methods on the transaction needed
35 by an access method implementer, but should not be visible to clients of a
36 TransactionController.
37 <p>
38 @see TransactionController
39
40 **/
41
42 public interface TransactionManager extends TransactionController
43 {
44
45 /**
46 * Constant used for the lock_level argument to openConglomerate() and
47 * openScan() calls. Pass in MODE_NONE if you want no table or row locks.
48 * This is currently only supported from within access.
49 **/
50 static final int MODE_NONE = 5;
51
52 /**
53 * release lock immediately after getting lock.
54 **/
55 public static final int LOCK_INSTANT_DURATION = 1;
56 /**
57 * hold lock until end of transaction.
58 **/
59 public static final int LOCK_COMMIT_DURATION = 2;
60 /**
61 * Allow lock to be released manually prior to end transaction.
62 **/
63 public static final int LOCK_MANUAL_DURATION = 3;
64
65 /**
66 * Add to the list of post commit work.
67 * <p>
68 * Add to the list of post commit work that may be processed after this
69 * transaction commits. If this transaction aborts, then the post commit
70 * work list will be thrown away. No post commit work will be taken out
71 * on a rollback to save point.
72 * <p>
73 * This routine simply delegates the work to the Rawstore transaction.
74 *
75 * @param work The post commit work to do.
76 *
77 **/
78 public void addPostCommitWork(Serviceable work);
79
80 /**
81 * Check to see if a database has been upgraded to the required
82 * level in order to use a store feature.
83 *
84 * @param requiredMajorVersion required database Engine major version
85 * @param requiredMinorVersion required database Engine minor version
86 * @param feature Non-null to throw an exception, null to
87 * return the state of the version match.
88 *
89 * @return <code> true </code> if the database has been upgraded to
90 * the required level, <code> false </code> otherwise.
91 *
92 * @exception StandardException
93 * if the database is not at the require version
94 * when <code>feature</code> feature is
95 * not <code> null </code>.
96 */
97 public boolean checkVersion(
98 int requiredMajorVersion,
99 int requiredMinorVersion,
100 String feature)
101 throws StandardException;
102
103 /**
104 * The ScanManager.close() method has been called on "scan".
105 * <p>
106 * Take whatever cleanup action is appropriate to a closed scan. It is
107 * likely this routine will remove references to the scan object that it
108 * was maintaining for cleanup purposes.
109 *
110 **/
111 public void closeMe(ScanManager scan);
112
113 /**
114 * The ConglomerateController.close() method has been called on
115 * "conglom_control".
116 * <p>
117 * Take whatever cleanup action is appropriate to a closed
118 * conglomerateController. It is likely this routine will remove
119 * references to the ConglomerateController object that it was maintaining
120 * for cleanup purposes.
121 **/
122 public void closeMe(ConglomerateController conglom_control);
123
124 /**
125 * The SortController.close() method has been called on "sort_control".
126 * <p>
127 * Take whatever cleanup action is appropriate to a closed
128 * sortController. It is likely this routine will remove
129 * references to the SortController object that it was maintaining
130 * for cleanup purposes.
131 **/
132 public void closeMe(SortController sort_control);
133
134 /**
135 * Get an Internal transaction.
136 * <p>
137 * Start an internal transaction. An internal transaction is a completely
138 * separate transaction from the current user transaction. All work done
139 * in the internal transaction must be physical (ie. it can be undone
140 * physically by the rawstore at the page level, rather than logically
141 * undone like btree insert/delete operations). The rawstore guarantee's
142 * that in the case of a system failure all open Internal transactions are
143 * first undone in reverse order, and then other transactions are undone
144 * in reverse order.
145 * <p>
146 * Internal transactions are meant to implement operations which, if
147 * interupted before completion will cause logical operations like tree
148 * searches to fail. This special undo order insures that the state of
149 * the tree is restored to a consistent state before any logical undo
150 * operation which may need to search the tree is performed.
151 * <p>
152 *
153 * @return The new internal transaction.
154 *
155 * @exception StandardException Standard exception policy.
156 **/
157 public TransactionManager getInternalTransaction()
158 throws StandardException;
159
160 /**
161 * Get the Transaction from the Transaction manager.
162 * <p>
163 * Access methods often need direct access to the "Transaction" - ie. the
164 * raw store transaction, so give access to it.
165 *
166 * @return The raw store transaction.
167 *
168 * @exception StandardException Standard exception policy.
169 **/
170 public Transaction getRawStoreXact()
171 throws StandardException;
172 }