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


001:        // $Id: TransportedVectorTime.java,v 1.5 2005/08/08 12:45:45 belaban Exp $
002:
003:        package org.jgroups.protocols;
004:
005:        import org.jgroups.Message;
006:
007:        import java.io.Serializable;
008:
009:        /**
010:         * Lighweight representation of the VectorTime clock suitable for network transport
011:         *
012:         * @author Vladimir Blagojevic vladimir@cs.yorku.ca
013:         * @version $Revision: 1.5 $
014:         */
015:        public class TransportedVectorTime implements  Serializable {
016:            /**
017:             * index of the sender
018:             */
019:            int senderPosition;
020:
021:            /**
022:             * values represented as an array
023:             */
024:            int[] values;
025:
026:            /**
027:             * Message associated with this vector clock
028:             */
029:            private transient Message m;
030:            private static final long serialVersionUID = 5857647322589533545L;
031:
032:            /**
033:             *
034:             */
035:            public TransportedVectorTime() {
036:            }
037:
038:            /**
039:             * Constructs TransportedVectorTime with sender index and vector values
040:             *
041:             * @param senderIndex index of the sender of the message
042:             * @param values vector values
043:             */
044:            public TransportedVectorTime(int senderIndex, int[] values) {
045:                this .values = values;
046:                this .senderPosition = senderIndex;
047:            }
048:
049:            /**
050:             * Returns sender index
051:             * @return sender index position
052:             */
053:            public int getSenderIndex() {
054:                return senderPosition;
055:            }
056:
057:            /**
058:             * Returns vector values
059:             * @return an array of vector values
060:             */
061:            public int[] getValues() {
062:                return values;
063:            }
064:
065:            /**
066:             * Returns size of this vector timestamp  i.e number of process group members
067:             * @return vector timestamp size
068:             */
069:            public int size() {
070:                return values.length;
071:            }
072:
073:            /**
074:             * Sets a message associated with this vector timestamp
075:             * @param owner Message that is associated with this vector timestamp
076:             */
077:            public void setAssociatedMessage(Message owner) {
078:                m = owner;
079:            }
080:
081:            /**
082:             * Returns a message associated with this vector timestamp.
083:             * @return Message associated with this vector timestamp
084:             */
085:            public Message getAssociatedMessage() {
086:                return m;
087:            }
088:
089:            /**
090:             *<p>
091:             *Checks if this TransportedVectorTime is less than or equal to the the specified TransportedVectorTime.
092:             *The check is done as follows:
093:             *</p>
094:             * <p>
095:             * VT1<=VT2 iff for every i:1..k VT1[i]<=VT2[i]
096:             * </p>
097:             * @param other TransportedVectorTimebeing compared with this.
098:             * @return true if this TransportedVectorTimeis less than or equal from
099:             * other, false othwerwise
100:             */
101:            public boolean lessThanOrEqual(TransportedVectorTime other) {
102:                int[] b = other.getValues();
103:                int[] a = values;
104:                for (int k = 0; k < a.length; k++) {
105:                    if (a[k] <= b[k])
106:                        return true;
107:                    else
108:                        return false;
109:                }
110:                return true;
111:            }
112:
113:            /**
114:             * <p>
115:             * Checks if this TransportedVectorTimeis equal to the specified TransportedVectorTime.
116:             * The check is done as follows:
117:             * </p>
118:             * <p>
119:             *  VT1==VT2 iff for every i:1..k VT1[i]==VT2[i]
120:             * @param other TransportedVectorTimebeing compared with this.
121:             * @return true if the equation given above is true, false otherwise
122:             */
123:            public boolean equals(Object other) {
124:                int a[] = getValues();
125:                int b[] = ((TransportedVectorTime) other).getValues();
126:
127:                for (int i = 0; i < a.length; i++)
128:                    if (a[i] != b[i])
129:                        return false;
130:
131:                return true;
132:            }
133:
134:            /**
135:             * Returns String representation of this vector timestamp
136:             * @return String representing this vetor timestamp
137:             */
138:            public String toString() {
139:                String classType = "TransportedVectorTime[";
140:                int bufferLength = classType.length() + values.length * 2 + 1;
141:                StringBuffer buf = new StringBuffer(bufferLength);
142:                buf.append(classType);
143:                for (int i = 0; i < values.length - 1; i++) {
144:                    buf.append(values[i]).append(',');
145:                }
146:                buf.append(values[values.length - 1]);
147:                buf.append(']');
148:                return buf.toString();
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.