Source Code Cross Referenced for RingToken.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » protocols » ring » 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 » JGroups 2.4.1 sp3 » org.jgroups.protocols.ring 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$Id: RingToken.java,v 1.5 2004/09/15 17:40:59 belaban Exp $
002:
003:        package org.jgroups.protocols.ring;
004:
005:        import org.jgroups.Address;
006:
007:        import java.io.Externalizable;
008:        import java.io.IOException;
009:        import java.io.ObjectInput;
010:        import java.io.ObjectOutput;
011:        import java.util.Collection;
012:        import java.util.TreeSet;
013:
014:        public class RingToken implements  Externalizable {
015:
016:            public static final int OPERATIONAL = 0;
017:            public static final int RECOVERY = 1;
018:
019:            private int type = -1;
020:            private long tokenSeq;
021:            private long seq;
022:            private long aru;
023:            private int fcc;
024:            private int backlog;
025:            private int windowSize;
026:            private int windowThreshold;
027:            private Address aruId;
028:            private Collection retransmissionRequests;
029:            private Collection recoveredMembers;
030:
031:            public RingToken() {
032:                this (OPERATIONAL);
033:            }
034:
035:            public RingToken(int type) {
036:                if (type != OPERATIONAL && type != RECOVERY) {
037:                    throw new IllegalArgumentException("Illegal Ring type");
038:                }
039:                this .type = type;
040:                initToken();
041:            }
042:
043:            private void initToken() {
044:                retransmissionRequests = new TreeSet();
045:            }
046:
047:            public void setAruId(Address address) {
048:                aruId = address;
049:            }
050:
051:            public Address getAruId() {
052:                return aruId;
053:            }
054:
055:            public int getType() {
056:                return type;
057:            }
058:
059:            public void setType(int type) {
060:                if (type != OPERATIONAL && type != RECOVERY) {
061:                    throw new IllegalArgumentException("Illegal Ring type");
062:                }
063:                this .type = type;
064:
065:            }
066:
067:            public long getTokenSequence() {
068:                return tokenSeq;
069:            }
070:
071:            public void incrementTokenSequence() {
072:                tokenSeq++;
073:            }
074:
075:            public long getHighestSequence() {
076:                return seq;
077:            }
078:
079:            public void setHighestSequence(long highestSequence) {
080:                if (seq > highestSequence)
081:                    throw new IllegalArgumentException(
082:                            "Can not set highest sequence to be"
083:                                    + " lower than current higest sequence "
084:                                    + seq);
085:                this .seq = highestSequence;
086:            }
087:
088:            public long getAllReceivedUpto() {
089:                return aru;
090:            }
091:
092:            public void setAllReceivedUpto(long aru) {
093:                this .aru = aru;
094:
095:                if (aru > seq) {
096:                    seq = aru;
097:                }
098:            }
099:
100:            public int getLastRoundBroadcastCount() {
101:                return fcc;
102:            }
103:
104:            public void addLastRoundBroadcastCount(int transmitCount) {
105:                this .fcc += transmitCount;
106:                if (fcc < 0)
107:                    fcc = 0;
108:            }
109:
110:            public int getBacklog() {
111:                return backlog;
112:            }
113:
114:            public void addBacklog(int back) {
115:                this .backlog += back;
116:
117:                if (backlog < 0)
118:                    backlog = 0;
119:            }
120:
121:            public void setWindowSize(int newSize) {
122:                if (newSize < 0) {
123:                    windowSize = 0;
124:                } else {
125:                    windowSize = newSize;
126:                }
127:            }
128:
129:            public void addRecoveredMember(Address member) {
130:
131:                if (recoveredMembers == null)
132:                    recoveredMembers = new TreeSet();
133:
134:                recoveredMembers.add(member);
135:            }
136:
137:            public Collection getRecoveredMembers() {
138:                return recoveredMembers;
139:            }
140:
141:            public int getWindowSize() {
142:                return windowSize;
143:            }
144:
145:            public void setWindowThreshold(int newSize) {
146:                if (newSize < 0) {
147:                    windowThreshold = 0;
148:                } else {
149:                    windowThreshold = newSize;
150:                }
151:            }
152:
153:            public int getWindowThreshold() {
154:                return windowThreshold;
155:            }
156:
157:            public Collection getRetransmissionRequests() {
158:                return retransmissionRequests;
159:            }
160:
161:            public void writeExternal(ObjectOutput oo) throws IOException {
162:                oo.writeLong(tokenSeq);
163:                oo.writeLong(seq);
164:                oo.writeInt(type);
165:                oo.writeLong(aru);
166:                oo.writeInt(fcc);
167:                oo.writeInt(backlog);
168:                oo.writeInt(windowSize);
169:                oo.writeInt(windowThreshold);
170:                oo.writeObject(aruId);
171:                oo.writeObject(retransmissionRequests);
172:                oo.writeObject(recoveredMembers);
173:
174:            }
175:
176:            public void readExternal(ObjectInput oi) throws IOException,
177:                    ClassNotFoundException {
178:                tokenSeq = oi.readLong();
179:                seq = oi.readLong();
180:                type = oi.readInt();
181:                aru = oi.readLong();
182:                fcc = oi.readInt();
183:                backlog = oi.readInt();
184:                windowSize = oi.readInt();
185:                windowThreshold = oi.readInt();
186:                aruId = (Address) oi.readObject();
187:                retransmissionRequests = (Collection) oi.readObject();
188:                recoveredMembers = (Collection) oi.readObject();
189:            }
190:
191:            public String toString() {
192:                StringBuffer buf = new StringBuffer(200);
193:                buf.append("Token[tokenSeq=").append(tokenSeq);
194:                buf.append(",type=").append(type);
195:                buf.append(",highestseq=").append(seq);
196:                buf.append(",aru=").append(aru);
197:                buf.append(",lastRoundTransmitCount=").append(fcc);
198:                buf.append(",backlog=").append(backlog);
199:                buf.append(",windowSize=").append(windowSize);
200:                buf.append(",windowThreshold=").append(windowThreshold);
201:                buf.append(",retransmissionList=").append(
202:                        getRetransmissionRequests());
203:                buf.append(']');
204:                return buf.toString();
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.