Source Code Cross Referenced for LatchedLockManager.java in  » JMX » je » com » sleepycat » je » txn » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » JMX » je » com.sleepycat.je.txn 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2002,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: LatchedLockManager.java,v 1.11.2.5 2008/01/07 15:14:17 cwl Exp $
007:         */
008:
009:        package com.sleepycat.je.txn;
010:
011:        import java.util.Set;
012:
013:        import com.sleepycat.je.DatabaseException;
014:        import com.sleepycat.je.DeadlockException;
015:        import com.sleepycat.je.LockStats;
016:        import com.sleepycat.je.dbi.DatabaseImpl;
017:        import com.sleepycat.je.dbi.EnvironmentImpl;
018:        import com.sleepycat.je.dbi.MemoryBudget;
019:        import com.sleepycat.je.latch.Latch;
020:
021:        /**
022:         * LatchedLockManager uses latches to implement its critical sections.
023:         */
024:        public class LatchedLockManager extends LockManager {
025:
026:            public LatchedLockManager(EnvironmentImpl envImpl)
027:                    throws DatabaseException {
028:                super (envImpl);
029:            }
030:
031:            /**
032:             * @see LockManager#lookupLock
033:             */
034:            protected Lock lookupLock(Long nodeId) throws DatabaseException {
035:
036:                int lockTableIndex = getLockTableIndex(nodeId);
037:                Latch latch = lockTableLatches[lockTableIndex];
038:                latch.acquire();
039:                try {
040:                    return lookupLockInternal(nodeId, lockTableIndex);
041:                } finally {
042:                    latch.release();
043:                }
044:            }
045:
046:            /**
047:             * @see LockManager#attemptLock
048:             */
049:            protected LockAttemptResult attemptLock(Long nodeId, Locker locker,
050:                    LockType type, boolean nonBlockingRequest)
051:                    throws DatabaseException {
052:
053:                int lockTableIndex = getLockTableIndex(nodeId);
054:                Latch latch = lockTableLatches[lockTableIndex];
055:                latch.acquire();
056:                try {
057:                    return attemptLockInternal(nodeId, locker, type,
058:                            nonBlockingRequest, lockTableIndex);
059:                } finally {
060:                    latch.release();
061:                }
062:            }
063:
064:            /**
065:             * @see LockManager#makeTimeoutMsg
066:             */
067:            protected DeadlockException makeTimeoutMsg(String lockOrTxn,
068:                    Locker locker, long nodeId, LockType type,
069:                    LockGrantType grantType, Lock useLock, long timeout,
070:                    long start, long now, DatabaseImpl database)
071:                    throws DatabaseException {
072:
073:                int lockTableIndex = getLockTableIndex(nodeId);
074:                Latch latch = lockTableLatches[lockTableIndex];
075:                latch.acquire();
076:                try {
077:                    return makeTimeoutMsgInternal(lockOrTxn, locker, nodeId,
078:                            type, grantType, useLock, timeout, start, now,
079:                            database);
080:                } finally {
081:                    latch.release();
082:                }
083:            }
084:
085:            /**
086:             * @see LockManager#releaseAndNotifyTargets
087:             */
088:            protected Set releaseAndFindNotifyTargets(long nodeId, Locker locker)
089:                    throws DatabaseException {
090:
091:                long nid = nodeId;
092:                int lockTableIndex = getLockTableIndex(nid);
093:                Latch latch = lockTableLatches[lockTableIndex];
094:                latch.acquire();
095:                try {
096:                    return releaseAndFindNotifyTargetsInternal(nodeId, locker,
097:                            lockTableIndex);
098:                } finally {
099:                    latch.release();
100:                }
101:            }
102:
103:            /**
104:             * @see LockManager#transfer
105:             */
106:            void transfer(long nodeId, Locker owningLocker, Locker destLocker,
107:                    boolean demoteToRead) throws DatabaseException {
108:
109:                int lockTableIndex = getLockTableIndex(nodeId);
110:                Latch latch = lockTableLatches[lockTableIndex];
111:                latch.acquire();
112:                try {
113:                    transferInternal(nodeId, owningLocker, destLocker,
114:                            demoteToRead, lockTableIndex);
115:                } finally {
116:                    latch.release();
117:                }
118:            }
119:
120:            /**
121:             * @see LockManager#transferMultiple
122:             */
123:            void transferMultiple(long nodeId, Locker owningLocker,
124:                    Locker[] destLockers) throws DatabaseException {
125:
126:                int lockTableIndex = getLockTableIndex(nodeId);
127:                Latch latch = lockTableLatches[lockTableIndex];
128:                latch.acquire();
129:                try {
130:                    transferMultipleInternal(nodeId, owningLocker, destLockers,
131:                            lockTableIndex);
132:                } finally {
133:                    latch.release();
134:                }
135:            }
136:
137:            /**
138:             * @see LockManager#demote
139:             */
140:            void demote(long nodeId, Locker locker) throws DatabaseException {
141:
142:                int lockTableIndex = getLockTableIndex(nodeId);
143:                Latch latch = lockTableLatches[lockTableIndex];
144:                latch.acquire();
145:                try {
146:                    demoteInternal(nodeId, locker, lockTableIndex);
147:                } finally {
148:                    latch.release();
149:                }
150:            }
151:
152:            /**
153:             * @see LockManager#isLocked
154:             */
155:            boolean isLocked(Long nodeId) throws DatabaseException {
156:
157:                int lockTableIndex = getLockTableIndex(nodeId);
158:                Latch latch = lockTableLatches[lockTableIndex];
159:                latch.acquire();
160:                try {
161:                    return isLockedInternal(nodeId, lockTableIndex);
162:                } finally {
163:                    latch.release();
164:                }
165:            }
166:
167:            /**
168:             * @see LockManager#isOwner
169:             */
170:            boolean isOwner(Long nodeId, Locker locker, LockType type)
171:                    throws DatabaseException {
172:
173:                int lockTableIndex = getLockTableIndex(nodeId);
174:                Latch latch = lockTableLatches[lockTableIndex];
175:                latch.acquire();
176:                try {
177:                    return isOwnerInternal(nodeId, locker, type, lockTableIndex);
178:                } finally {
179:                    latch.release();
180:                }
181:            }
182:
183:            /**
184:             * @see LockManager#isWaiter
185:             */
186:            boolean isWaiter(Long nodeId, Locker locker)
187:                    throws DatabaseException {
188:
189:                int lockTableIndex = getLockTableIndex(nodeId);
190:                Latch latch = lockTableLatches[lockTableIndex];
191:                latch.acquire();
192:                try {
193:                    return isWaiterInternal(nodeId, locker, lockTableIndex);
194:                } finally {
195:                    latch.release();
196:                }
197:            }
198:
199:            /**
200:             * @see LockManager#nWaiters
201:             */
202:            int nWaiters(Long nodeId) throws DatabaseException {
203:
204:                int lockTableIndex = getLockTableIndex(nodeId);
205:                Latch latch = lockTableLatches[lockTableIndex];
206:                latch.acquire();
207:                try {
208:                    return nWaitersInternal(nodeId, lockTableIndex);
209:                } finally {
210:                    latch.release();
211:                }
212:            }
213:
214:            /**
215:             * @see LockManager#nOwners
216:             */
217:            int nOwners(Long nodeId) throws DatabaseException {
218:
219:                int lockTableIndex = getLockTableIndex(nodeId);
220:                Latch latch = lockTableLatches[lockTableIndex];
221:                latch.acquire();
222:                try {
223:                    return nOwnersInternal(nodeId, lockTableIndex);
224:                } finally {
225:                    latch.release();
226:                }
227:            }
228:
229:            /**
230:             * @see LockManager#getWriterOwnerLocker
231:             */
232:            Locker getWriteOwnerLocker(Long nodeId) throws DatabaseException {
233:
234:                int lockTableIndex = getLockTableIndex(nodeId);
235:                Latch latch = lockTableLatches[lockTableIndex];
236:                latch.acquire();
237:                try {
238:                    return getWriteOwnerLockerInternal(nodeId, lockTableIndex);
239:                } finally {
240:                    latch.release();
241:                }
242:            }
243:
244:            /**
245:             * @see LockManager#validateOwnership
246:             */
247:            protected boolean validateOwnership(Long nodeId, Locker locker,
248:                    LockType type, boolean flushFromWaiters, MemoryBudget mb)
249:                    throws DatabaseException {
250:
251:                int lockTableIndex = getLockTableIndex(nodeId);
252:                Latch latch = lockTableLatches[lockTableIndex];
253:                latch.acquire();
254:                try {
255:                    return validateOwnershipInternal(nodeId, locker, type,
256:                            flushFromWaiters, mb, lockTableIndex);
257:                } finally {
258:                    latch.release();
259:                }
260:            }
261:
262:            /**
263:             * @see LockManager#dumpLockTable
264:             */
265:            protected void dumpLockTable(LockStats stats)
266:                    throws DatabaseException {
267:
268:                for (int i = 0; i < nLockTables; i++) {
269:                    lockTableLatches[i].acquire();
270:                    try {
271:                        dumpLockTableInternal(stats, i);
272:                    } finally {
273:                        lockTableLatches[i].release();
274:                    }
275:                }
276:            }
277:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.