KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > access > btree > index > B2IRowLocking2


1 /*
2
3    Derby - Class org.apache.derby.impl.store.access.btree.index.B2IRowLocking2
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.impl.store.access.btree.index;
23
24 import org.apache.derby.iapi.services.sanity.SanityManager;
25
26 import org.apache.derby.iapi.error.StandardException;
27
28 import org.apache.derby.iapi.store.access.conglomerate.TransactionManager;
29
30 import org.apache.derby.iapi.store.access.ConglomerateController;
31 import org.apache.derby.iapi.types.RowLocation;
32 import org.apache.derby.iapi.store.access.TransactionController;
33
34 import org.apache.derby.iapi.store.raw.LockingPolicy;
35 import org.apache.derby.iapi.store.raw.Page;
36 import org.apache.derby.iapi.store.raw.RecordHandle;
37 import org.apache.derby.iapi.store.raw.Transaction;
38
39 import org.apache.derby.iapi.types.DataValueDescriptor;
40
41 import org.apache.derby.impl.store.access.btree.BTree;
42 import org.apache.derby.impl.store.access.btree.BTreeLockingPolicy;
43 import org.apache.derby.impl.store.access.btree.BTreeRowPosition;
44 import org.apache.derby.impl.store.access.btree.ControlRow;
45 import org.apache.derby.impl.store.access.btree.LeafControlRow;
46 import org.apache.derby.impl.store.access.btree.OpenBTree;
47 import org.apache.derby.impl.store.access.btree.WaitError;
48
49 /**
50
51 The btree locking policy which implements read committed isolation level.
52
53 It inherits all functionality from B2IRowLockingRR (repeatable read) except
54 that it releases read locks after obtaining them. It provides a single
55 implementation of unlockScanRecordAfterRead() which releases a read lock
56 after it has been locked and processed.
57
58 **/

59
60 class B2IRowLocking2 extends B2IRowLockingRR implements BTreeLockingPolicy
61 {
62
63     /**************************************************************************
64      * Constructors for This class:
65      **************************************************************************
66      */

67     B2IRowLocking2(
68     Transaction rawtran,
69     int lock_level,
70     LockingPolicy locking_policy,
71     ConglomerateController base_cc,
72     OpenBTree open_btree)
73     {
74         super(rawtran, lock_level, locking_policy, base_cc, open_btree);
75     }
76
77     /**************************************************************************
78      * Public Methods of This class:
79      **************************************************************************
80      */

81
82
83     /**
84      * Release read lock on a row.
85      *
86      * @param forUpdate Is the scan for update or for read only.
87      *
88      **/

89     public void unlockScanRecordAfterRead(
90     BTreeRowPosition pos,
91     boolean forUpdate)
92         throws StandardException
93     {
94         if (SanityManager.DEBUG)
95         {
96             SanityManager.ASSERT(open_btree != null, "open_btree is null");
97
98             SanityManager.ASSERT(pos.current_leaf != null , "leaf is null");
99
100             SanityManager.ASSERT(
101                 pos.current_lock_row_loc != null ,
102                 "pos.current_lock_row_loc is null");
103
104             SanityManager.ASSERT(
105                 !pos.current_lock_row_loc.isNull(),
106                 "pos.current_lock_row_loc isNull()");
107         }
108
109         // always unlock in read committed, so pass false for qualified arg.
110
base_cc.unlockRowAfterRead(pos.current_lock_row_loc, forUpdate, false);
111     }
112 }
113
Popular Tags