Package org.jgroups

Class ViewId

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, Streamable

    public class ViewId
    extends java.lang.Object
    implements java.io.Externalizable, java.lang.Comparable, java.lang.Cloneable, Streamable
    ViewIds are used for ordering views (each view has a ViewId and a list of members). Ordering between views is important for example in a virtual synchrony protocol where all views seen by a member have to be ordered.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ViewId()  
      ViewId​(Address coord_addr)
      Creates a ViewID with the coordinator address and a Lamport timestamp of 0.
      ViewId​(Address coord_addr, long id)
      Creates a ViewID with the coordinator address and the given Lamport timestamp.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Cloneable interface Returns a new ViewID object containing the same address and lamport timestamp as this view
      int compare​(java.lang.Object o)
      Old Compare
      int compareTo​(java.lang.Object other)
      Establishes an order between 2 ViewIds.
      ViewId copy()
      Old Copy method, deprecated because it is substituted by clone()
      boolean equals​(java.lang.Object other_view)  
      Address getCoordAddress()
      returns the address of the member that issued this view
      long getId()
      returns the lamport time of the view
      int hashCode()  
      void readExternal​(java.io.ObjectInput in)  
      void readFrom​(java.io.DataInputStream in)
      Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
      int serializedSize()  
      java.lang.String toString()  
      void writeExternal​(java.io.ObjectOutput out)  
      void writeTo​(java.io.DataOutputStream out)
      Write the entire state of the current object (including superclasses) to outstream.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ViewId

        public ViewId()
      • ViewId

        public ViewId​(Address coord_addr)
        Creates a ViewID with the coordinator address and a Lamport timestamp of 0.
        Parameters:
        coord_addr - the address of the member that issued this view
      • ViewId

        public ViewId​(Address coord_addr,
                      long id)
        Creates a ViewID with the coordinator address and the given Lamport timestamp.
        Parameters:
        coord_addr - - the address of the member that issued this view
        id - - the Lamport timestamp of the view
    • Method Detail

      • getId

        public long getId()
        returns the lamport time of the view
        Returns:
        the lamport time timestamp
      • getCoordAddress

        public Address getCoordAddress()
        returns the address of the member that issued this view
        Returns:
        the Address of the the issuer
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        public java.lang.Object clone()
        Cloneable interface Returns a new ViewID object containing the same address and lamport timestamp as this view
        Overrides:
        clone in class java.lang.Object
      • copy

        public ViewId copy()
        Old Copy method, deprecated because it is substituted by clone()
      • compareTo

        public int compareTo​(java.lang.Object other)
        Establishes an order between 2 ViewIds. First compare on id. Compare on coord_addr only if necessary (i.e. ids are equal) !
        Specified by:
        compareTo in interface java.lang.Comparable
        Returns:
        0 for equality, value less than 0 if smaller, greater than 0 if greater.
      • compare

        public int compare​(java.lang.Object o)
        Old Compare
      • equals

        public boolean equals​(java.lang.Object other_view)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • 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
      • writeTo

        public void writeTo​(java.io.DataOutputStream out)
                     throws java.io.IOException
        Description copied from interface: Streamable
        Write the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed
        Specified by:
        writeTo in interface Streamable
        Throws:
        java.io.IOException
      • readFrom

        public void readFrom​(java.io.DataInputStream in)
                      throws java.io.IOException,
                             java.lang.IllegalAccessException,
                             java.lang.InstantiationException
        Description copied from interface: Streamable
        Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
        Specified by:
        readFrom in interface Streamable
        Throws:
        java.io.IOException
        java.lang.IllegalAccessException
        java.lang.InstantiationException
      • serializedSize

        public int serializedSize()