1 8 9 package com.sleepycat.je.txn; 10 11 import com.sleepycat.je.DatabaseException; 12 import com.sleepycat.je.dbi.CursorImpl; 13 import com.sleepycat.je.dbi.DatabaseImpl; 14 import com.sleepycat.je.dbi.EnvironmentImpl; 15 import com.sleepycat.je.tree.BIN; 16 import com.sleepycat.je.tree.Key; 17 18 22 public class ReadCommittedLocker extends BuddyLocker { 23 24 29 public ReadCommittedLocker(EnvironmentImpl env, Locker buddy) 30 throws DatabaseException { 31 32 36 super(env, 37 (buddy instanceof ReadCommittedLocker) ? 38 ((ReadCommittedLocker) buddy).getBuddy() : buddy); 39 40 assert getBuddy().isTransactional(); 41 } 42 43 48 public Locker newNonTxnLocker() 49 throws DatabaseException { 50 51 return new ReadCommittedLocker(envImpl, getBuddy().newNonTxnLocker()); 52 } 53 54 60 LockResult lockInternal(long nodeId, 61 LockType lockType, 62 boolean noWait, 63 DatabaseImpl database) 64 throws DatabaseException { 65 66 if (lockType.isWriteLock()) { 67 return getBuddy().lockInternal(nodeId, lockType, noWait, database); 68 } else { 69 return super.lockInternal(nodeId, lockType, noWait, database); 70 } 71 } 72 73 77 public void releaseLock(long nodeId) 78 throws DatabaseException { 79 80 if (!lockManager.release(nodeId, this)) { 81 lockManager.release(nodeId, getBuddy()); 82 } 83 } 84 85 89 public boolean createdNode(long nodeId) 90 throws DatabaseException { 91 92 return getBuddy().createdNode(nodeId); 93 } 94 95 99 public long getAbortLsn(long nodeId) 100 throws DatabaseException { 101 102 return getBuddy().getAbortLsn(nodeId); 103 } 104 105 108 public WriteLockInfo getWriteLockInfo(long nodeId) 109 throws DatabaseException { 110 111 return getBuddy().getWriteLockInfo(nodeId); 112 } 113 114 118 public void addDeleteInfo(BIN bin, Key deletedKey) 119 throws DatabaseException { 120 121 getBuddy().addDeleteInfo(bin, deletedKey); 122 } 123 124 128 public void registerCursor(CursorImpl cursor) 129 throws DatabaseException { 130 131 getBuddy().registerCursor(cursor); 132 } 133 134 138 public void unRegisterCursor(CursorImpl cursor) 139 throws DatabaseException { 140 141 getBuddy().unRegisterCursor(cursor); 142 } 143 144 147 public boolean isTransactional() { 148 return true; 149 } 150 151 154 public boolean isReadCommittedIsolation() { 155 return true; 156 } 157 } 158 | Popular Tags |