001: /*
002:
003: Derby - Class org.apache.derby.iapi.store.access.conglomerate.TransactionManager
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.iapi.store.access.conglomerate;
023:
024: import org.apache.derby.iapi.services.daemon.Serviceable;
025: import org.apache.derby.iapi.store.access.AccessFactory;
026: import org.apache.derby.iapi.store.access.ConglomerateController;
027: import org.apache.derby.iapi.store.access.SortController;
028: import org.apache.derby.iapi.store.access.TransactionController;
029: import org.apache.derby.iapi.store.raw.LockingPolicy;
030: import org.apache.derby.iapi.store.raw.Page;
031: import org.apache.derby.iapi.store.raw.Transaction;
032: import org.apache.derby.iapi.error.StandardException;
033:
034: /**
035:
036: The TransactionManager interface provides methods on the transaction needed
037: by an access method implementer, but should not be visible to clients of a
038: TransactionController.
039: <p>
040: @see TransactionController
041:
042: **/
043:
044: public interface TransactionManager extends TransactionController {
045:
046: /**
047: * Constant used for the lock_level argument to openConglomerate() and
048: * openScan() calls. Pass in MODE_NONE if you want no table or row locks.
049: * This is currently only supported from within access.
050: **/
051: static final int MODE_NONE = 5;
052:
053: /**
054: * release lock immediately after getting lock.
055: **/
056: public static final int LOCK_INSTANT_DURATION = 1;
057: /**
058: * hold lock until end of transaction.
059: **/
060: public static final int LOCK_COMMIT_DURATION = 2;
061: /**
062: * Allow lock to be released manually prior to end transaction.
063: **/
064: public static final int LOCK_MANUAL_DURATION = 3;
065:
066: /**
067: * Add to the list of post commit work.
068: * <p>
069: * Add to the list of post commit work that may be processed after this
070: * transaction commits. If this transaction aborts, then the post commit
071: * work list will be thrown away. No post commit work will be taken out
072: * on a rollback to save point.
073: * <p>
074: * This routine simply delegates the work to the Rawstore transaction.
075: *
076: * @param work The post commit work to do.
077: *
078: **/
079: public void addPostCommitWork(Serviceable work);
080:
081: /**
082: * The ScanManager.close() method has been called on "scan".
083: * <p>
084: * Take whatever cleanup action is appropriate to a closed scan. It is
085: * likely this routine will remove references to the scan object that it
086: * was maintaining for cleanup purposes.
087: *
088: **/
089: public void closeMe(ScanManager scan);
090:
091: /**
092: * The ConglomerateController.close() method has been called on
093: * "conglom_control".
094: * <p>
095: * Take whatever cleanup action is appropriate to a closed
096: * conglomerateController. It is likely this routine will remove
097: * references to the ConglomerateController object that it was maintaining
098: * for cleanup purposes.
099: **/
100: public void closeMe(ConglomerateController conglom_control);
101:
102: /**
103: * The SortController.close() method has been called on "sort_control".
104: * <p>
105: * Take whatever cleanup action is appropriate to a closed
106: * sortController. It is likely this routine will remove
107: * references to the SortController object that it was maintaining
108: * for cleanup purposes.
109: **/
110: public void closeMe(SortController sort_control);
111:
112: /**
113: * Get reference to access factory which started this transaction.
114: * <p>
115: *
116: * @return The AccessFactory which started this transaction.
117: **/
118: public AccessFactory getAccessManager();
119:
120: /**
121: * Get an Internal transaction.
122: * <p>
123: * Start an internal transaction. An internal transaction is a completely
124: * separate transaction from the current user transaction. All work done
125: * in the internal transaction must be physical (ie. it can be undone
126: * physically by the rawstore at the page level, rather than logically
127: * undone like btree insert/delete operations). The rawstore guarantee's
128: * that in the case of a system failure all open Internal transactions are
129: * first undone in reverse order, and then other transactions are undone
130: * in reverse order.
131: * <p>
132: * Internal transactions are meant to implement operations which, if
133: * interupted before completion will cause logical operations like tree
134: * searches to fail. This special undo order insures that the state of
135: * the tree is restored to a consistent state before any logical undo
136: * operation which may need to search the tree is performed.
137: * <p>
138: *
139: * @return The new internal transaction.
140: *
141: * @exception StandardException Standard exception policy.
142: **/
143: public TransactionManager getInternalTransaction()
144: throws StandardException;
145:
146: /**
147: * Get the Transaction from the Transaction manager.
148: * <p>
149: * Access methods often need direct access to the "Transaction" - ie. the
150: * raw store transaction, so give access to it.
151: *
152: * @return The raw store transaction.
153: *
154: * @exception StandardException Standard exception policy.
155: **/
156: public Transaction getRawStoreXact() throws StandardException;
157:
158: /**
159: * Do work necessary to maintain the current position in all the scans.
160: * <p>
161: * The latched page in the conglomerate "congomid" is changing, do
162: * whatever is necessary to maintain the current position of all the
163: * scans open in this transaction.
164: * <p>
165: * For some conglomerates this may be a no-op.
166: * <p>
167: *
168: * @param conglom Conglomerate object of the conglomerate being changed.
169: * @param page Page in the conglomerate being changed.
170: *
171: * @exception StandardException Standard exception policy.
172: **/
173: public void saveScanPositions(Conglomerate conglom, Page page)
174: throws StandardException;
175: }
|