Package org.jgroups

Class ViewId

java.lang.Object
org.jgroups.ViewId
All Implemented Interfaces:
Comparable<ViewId>, Constructable<ViewId>, SizeStreamable, Streamable

public class ViewId extends Object implements Comparable<ViewId>, SizeStreamable, Constructable<ViewId>
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.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Address
     
    protected long
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    int
    Establishes an order between 2 ViewIds.
    int
    Establishes an order between 2 ViewIds.
     
    Supplier<? extends ViewId>
    Creates an instance of the class implementing this interface
    boolean
    equals(Object other)
     
    Returns the address of the member that issued this view
    long
    returns the lamport time of the view
    int
     
    void
    Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
    int
    Returns the size (in bytes) of the marshalled object
     
    void
    Write the entire state of the current object (including superclasses) to outstream.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • creator

      protected Address creator
    • id

      protected long id
  • Constructor Details

    • ViewId

      public ViewId()
    • ViewId

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

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

    • create

      public Supplier<? extends ViewId> create()
      Description copied from interface: Constructable
      Creates an instance of the class implementing this interface
      Specified by:
      create in interface Constructable<ViewId>
    • getCreator

      public Address getCreator()
      Returns the address of the member that issued this view
      Returns:
      the Address of the the creator
    • getId

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

      public String toString()
      Overrides:
      toString in class Object
    • copy

      public ViewId copy()
    • compareTo

      public int compareTo(ViewId other)
      Establishes an order between 2 ViewIds. The comparison is done on the IDs, if they are equal, we use the creator.
      Specified by:
      compareTo in interface Comparable<ViewId>
      Returns:
      0 for equality, value less than 0 if smaller, greater than 0 if greater.
    • compareToIDs

      public int compareToIDs(ViewId other)
      Establishes an order between 2 ViewIds. Note that we compare only on IDs !
      Returns:
      0 for equality, value less than 0 if smaller, greater than 0 if greater.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • writeTo

      public void writeTo(DataOutput out) throws 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:
      IOException
    • readFrom

      public void readFrom(DataInput in) throws IOException, ClassNotFoundException
      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:
      IOException
      ClassNotFoundException
    • serializedSize

      public int serializedSize()
      Description copied from interface: SizeStreamable
      Returns the size (in bytes) of the marshalled object
      Specified by:
      serializedSize in interface SizeStreamable