Appia Documentation

net.sf.appia.protocols.group
Class ViewID

java.lang.Object
  extended by net.sf.appia.protocols.group.ViewID
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
AppiaMembershipID

public class ViewID
extends java.lang.Object
implements java.io.Externalizable

The unique identifier of a ViewState.
It is constructed from the coordinator and logical time of the view.

Version:
0.1
Author:
Alexandre Pinto
See Also:
ViewState, Serialized Form

Field Summary
 Endpt coord
          The Endpt of the coordinator of the view.
 long ltime
          The logical time of the view.
 
Constructor Summary
ViewID()
          Constructs a new empty ViewID.
ViewID(long ltime, Endpt coord)
          Constructs a new ViewID.
 
Method Summary
 boolean equals(java.lang.Object o)
          Redefines Object.equals().
 boolean equals(ViewID vid)
          Compares if the given ViewID is equal to the current one.
 int hashCode()
          Redefines Object.hashCode().
 ViewID merge(ViewID view_id, Endpt new_coord)
          Constructs a new ViewID that follows the current and the given ViewIDs.
 ViewID next()
          Constructs a new ViewID that follows the current ViewID.
 ViewID next(Endpt new_coord)
          Constructs a new ViewID that follows the current ViewID, but there is a different coordinator.
static ViewID peek(Message message)
           
static ViewID pop(Message message)
           
static void push(ViewID viewid, Message message)
           
 void readExternal(java.io.ObjectInput in)
           
 java.lang.String toString()
          Creates a String representation of the ViewID.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ltime

public long ltime
The logical time of the view.


coord

public Endpt coord
The Endpt of the coordinator of the view.

Constructor Detail

ViewID

public ViewID()
Constructs a new empty ViewID. Needed for Externalizable interface.


ViewID

public ViewID(long ltime,
              Endpt coord)
Constructs a new ViewID.

Parameters:
coord - the coordinator of the view
ltime - the logical time of the view
Method Detail

next

public ViewID next()
Constructs a new ViewID that follows the current ViewID.

Returns:
the new ViewID

next

public ViewID next(Endpt new_coord)
Constructs a new ViewID that follows the current ViewID, but there is a different coordinator.

Parameters:
new_coord - the coordinator of the view
Returns:
the new ViewID

merge

public ViewID merge(ViewID view_id,
                    Endpt new_coord)
Constructs a new ViewID that follows the current and the given ViewIDs. The coordinator is the given one.

Parameters:
new_coord - The new view coordinator
view_id - the other ViewID
Returns:
the new ViewID

equals

public boolean equals(ViewID vid)
Compares if the given ViewID is equal to the current one.

Parameters:
vid - the other ViewID to compare to
Returns:
true if the ViewIDs are equal, false otherwise

equals

public boolean equals(java.lang.Object o)
Redefines Object.equals().

Overrides:
equals in class java.lang.Object
Parameters:
o - The object to compare with.
Returns:
True if this and the given object represent the same ViewID.

toString

public java.lang.String toString()
Creates a String representation of the ViewID.

Overrides:
toString in class java.lang.Object
Returns:
the String representation

hashCode

public int hashCode()
Redefines Object.hashCode().
The hashcode is equal to coordinator_hashcode ^ ((logical_time * 0x5DEECE66DL + 0xBL) & ((1L << 48)-1));. This is based on java.math.Random that was based in a linear congruential pseudorandom number generator, as defined by D. H. Lehmer and described by Donald E. Knuth in The Art of Computer Programming, Volume 2: Seminumerical Algorithms, section 3.2.1.

Overrides:
hashCode in class java.lang.Object
Returns:
hashcode for this ViewID

push

public static void push(ViewID viewid,
                        Message message)

pop

public static ViewID pop(Message message)

peek

public static ViewID peek(Message message)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

Appia Documentation

COPYRIGHT 2006-2009, University of Lisbon and INESC-ID
For updates and related information please see Appia Home Page
Send questions, sugestions or remarks to the appia-users mailing list