Source Code Cross Referenced for LockResponseContext.java in  » Net » Terracotta » com » tc » objectserver » context » 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 » Net » Terracotta » com.tc.objectserver.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003:         * notice. All rights reserved.
004:         */
005:        package com.tc.objectserver.context;
006:
007:        import com.tc.async.api.EventContext;
008:        import com.tc.net.groups.NodeID;
009:        import com.tc.object.lockmanager.api.LockID;
010:        import com.tc.object.lockmanager.api.LockLevel;
011:        import com.tc.object.lockmanager.api.ThreadID;
012:        import com.tc.object.lockmanager.impl.GlobalLockInfo;
013:        import com.tc.object.lockmanager.impl.GlobalLockStateInfo;
014:        import com.tc.objectserver.lockmanager.api.LockWaitContext;
015:        import com.tc.objectserver.lockmanager.impl.Holder;
016:        import com.tc.util.Assert;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collection;
020:        import java.util.Iterator;
021:
022:        public class LockResponseContext implements  EventContext {
023:
024:            public static final int LOCK_AWARD = 1;
025:            public static final int LOCK_RECALL = 2;
026:            public static final int LOCK_WAIT_TIMEOUT = 3;
027:            public static final int LOCK_INFO = 4;
028:            public static final int LOCK_NOT_AWARDED = 5;
029:            public static final int LOCK_STAT_ENABLED = 6;
030:            public static final int LOCK_STAT_DISABLED = 7;
031:
032:            private final LockID lockID;
033:            private final ThreadID threadID;
034:            private final int level;
035:            private final NodeID nodeID;
036:            private final int responseType;
037:            private final int stackTraceDepth;
038:            private final int statCollectFrequency;
039:            private final GlobalLockInfo globalLockInfo;
040:
041:            public LockResponseContext(LockID lockID, NodeID nodeID,
042:                    ThreadID threadID, int level, int lockRequestQueueLength,
043:                    Collection greedyHolders, Collection holders,
044:                    Collection waiters, int type) {
045:                this (lockID, nodeID, threadID, level, new GlobalLockInfo(
046:                        lockID, level, lockRequestQueueLength,
047:                        getGlobalLockHolderInfo(greedyHolders),
048:                        getGlobalLockHolderInfo(holders),
049:                        getGlobalLockWaiterInfo(lockID, waiters)), type, -1, -1);
050:            }
051:
052:            public LockResponseContext(LockID lockID, NodeID nodeID,
053:                    ThreadID sourceID, int level, int type) {
054:                this (lockID, nodeID, sourceID, level, null, type, -1, -1);
055:            }
056:
057:            public LockResponseContext(LockID lockID, NodeID nodeID,
058:                    ThreadID sourceID, int level, int type,
059:                    int stackTraceDepth, int statCollectFrequency) {
060:                this (lockID, nodeID, sourceID, level, null, type,
061:                        stackTraceDepth, statCollectFrequency);
062:            }
063:
064:            private LockResponseContext(LockID lockID, NodeID nodeID,
065:                    ThreadID sourceID, int level,
066:                    GlobalLockInfo globalLockInfo, int type,
067:                    int stackTraceDepth, int statCollectFrequency) {
068:                this .lockID = lockID;
069:                this .nodeID = nodeID;
070:                this .threadID = sourceID;
071:                this .level = level;
072:                this .responseType = type;
073:                this .globalLockInfo = globalLockInfo;
074:                this .stackTraceDepth = stackTraceDepth;
075:                this .statCollectFrequency = statCollectFrequency;
076:                Assert.assertTrue(responseType == LOCK_AWARD
077:                        || responseType == LOCK_RECALL
078:                        || responseType == LOCK_WAIT_TIMEOUT
079:                        || responseType == LOCK_INFO
080:                        || responseType == LOCK_NOT_AWARDED
081:                        || responseType == LOCK_STAT_ENABLED
082:                        || responseType == LOCK_STAT_DISABLED);
083:            }
084:
085:            public NodeID getNodeID() {
086:                return nodeID;
087:            }
088:
089:            public int getType() {
090:                return level;
091:            }
092:
093:            public LockID getLockID() {
094:                return lockID;
095:            }
096:
097:            public ThreadID getThreadID() {
098:                return threadID;
099:            }
100:
101:            public int getLockLevel() {
102:                return level;
103:            }
104:
105:            public int getStackTraceDepth() {
106:                return stackTraceDepth;
107:            }
108:
109:            public int getStatCollectFrequency() {
110:                return statCollectFrequency;
111:            }
112:
113:            public GlobalLockInfo getGlobalLockInfo() {
114:                return globalLockInfo;
115:            }
116:
117:            public boolean isLockAward() {
118:                return (this .responseType == LOCK_AWARD);
119:            }
120:
121:            public boolean isLockRecall() {
122:                return (this .responseType == LOCK_RECALL);
123:            }
124:
125:            public boolean isLockWaitTimeout() {
126:                return (this .responseType == LOCK_WAIT_TIMEOUT);
127:            }
128:
129:            public boolean isLockInfo() {
130:                return (this .responseType == LOCK_INFO);
131:            }
132:
133:            public boolean isLockNotAwarded() {
134:                return (this .responseType == LOCK_NOT_AWARDED);
135:            }
136:
137:            public boolean isLockStatEnabled() {
138:                return (this .responseType == LOCK_STAT_ENABLED);
139:            }
140:
141:            public boolean isLockStatDisabled() {
142:                return (this .responseType == LOCK_STAT_DISABLED);
143:            }
144:
145:            public String toString() {
146:                return "LockResponseContext(" + lockID + "," + nodeID + ","
147:                        + threadID + ", " + LockLevel.toString(level) + " , "
148:                        + toString(responseType) + ")";
149:            }
150:
151:            private static String toString(int responseType2) {
152:                switch (responseType2) {
153:                case LOCK_AWARD:
154:                    return "LOCK_AWARD";
155:                case LOCK_RECALL:
156:                    return "LOCK_RECALL";
157:                case LOCK_WAIT_TIMEOUT:
158:                    return "LOCK_WAIT_TIMEOUT";
159:                case LOCK_INFO:
160:                    return "LOCK_INFO";
161:                case LOCK_NOT_AWARDED:
162:                    return "LOCK_NOT_AWARDED";
163:                default:
164:                    return "UNKNOWN";
165:                }
166:            }
167:
168:            private static Collection getGlobalLockHolderInfo(
169:                    Collection holderInfo) {
170:                Collection holdersInfo = new ArrayList();
171:                for (Iterator i = holderInfo.iterator(); i.hasNext();) {
172:                    Holder holder = (Holder) i.next();
173:                    holdersInfo.add(new GlobalLockStateInfo(holder.getLockID(),
174:                            holder.getNodeID(), holder.getThreadID(), holder
175:                                    .getTimestamp(), holder.getTimeout(),
176:                            holder.getLockLevel()));
177:                }
178:                return holdersInfo;
179:            }
180:
181:            private static Collection getGlobalLockWaiterInfo(LockID id,
182:                    Collection waiters) {
183:                Collection waitersInfo = new ArrayList();
184:                for (Iterator i = waiters.iterator(); i.hasNext();) {
185:                    LockWaitContext lockWaitContext = (LockWaitContext) i
186:                            .next();
187:                    waitersInfo.add(new GlobalLockStateInfo(id, lockWaitContext
188:                            .getNodeID(), lockWaitContext.getThreadID(),
189:                            lockWaitContext.getTimestamp(), -1, lockWaitContext
190:                                    .lockLevel()));
191:                }
192:                return waitersInfo;
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.