org.javagroups
Class View

java.lang.Object
  extended byorg.javagroups.View
All Implemented Interfaces:
java.lang.Cloneable, java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
MergeView

public class View
extends java.lang.Object
implements java.io.Externalizable, java.lang.Cloneable

A view is a local representation of the current membership of a group Only one view is installed in a channel at a time Views contain the address of its creator, an ID and a list of member addresses These adresses are ordered, and the first address is always the coordinator of the view This way, each member of the group knows who the new coordinator will be if the current one crashes or leaves the group. The views are sent between members using the VIEW_CHANGE event.

See Also:
Serialized Form

Field Summary
protected  java.util.Vector members
          A list containing all the members of the view This list is always ordered, with the coordinator being the first member.
protected  ViewId vid
           
 
Constructor Summary
View()
          creates an empty view, should not be used
View(Address creator, long id, java.util.Vector members)
          Creates a new view
View(ViewId vid, java.util.Vector members)
          Creates a new view
 
Method Summary
 java.lang.Object clone()
          creates a copy of this view
 boolean containsMember(Address mbr)
          returns true, if this view contains a certain member
 Address getCreator()
          returns the creator of this view if this view was created with the empty constructur, null will be returned
 java.util.Vector getMembers()
          Returns a reference to the List of members (ordered) Do NOT change this list, hence your will invalidate the view Make a copy if you have to modify it.
 ViewId getVid()
          returns the view ID of this view if this view was created with the empty constructur, null will be returned
 java.lang.String printDetails()
          debug only
 void readExternal(java.io.ObjectInput in)
           
 int size()
          returns the number of members in this view
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vid

protected ViewId vid

members

protected java.util.Vector members
A list containing all the members of the view This list is always ordered, with the coordinator being the first member. the second member will be the new coordinator if the current one disappears or leaves the group.

Constructor Detail

View

public View()
creates an empty view, should not be used


View

public View(ViewId vid,
            java.util.Vector members)
Creates a new view

Parameters:
vid - The view id of this view (can not be null)
members - Contains a list of all the members in the view, can be empty but not null.

View

public View(Address creator,
            long id,
            java.util.Vector members)
Creates a new view

Parameters:
creator - The creator of this view (can not be null)
id - The lamport timestamp of this view
members - Contains a list of all the members in the view, can be empty but not null.
Method Detail

getVid

public ViewId getVid()
returns the view ID of this view if this view was created with the empty constructur, null will be returned

Returns:
the view ID of this view

getCreator

public Address getCreator()
returns the creator of this view if this view was created with the empty constructur, null will be returned

Returns:
the creator of this view in form of an Address object

getMembers

public java.util.Vector getMembers()
Returns a reference to the List of members (ordered) Do NOT change this list, hence your will invalidate the view Make a copy if you have to modify it.

Returns:
a reference to the ordered list of members in this view

containsMember

public boolean containsMember(Address mbr)
returns true, if this view contains a certain member

Parameters:
mbr - - the address of the member,
Returns:
true if this view contains the member, false if it doesn't if the argument mbr is null, this operation returns false

size

public int size()
returns the number of members in this view

Returns:
the number of members in this view 0..n

clone

public java.lang.Object clone()
creates a copy of this view

Returns:
a copy of this view

printDetails

public java.lang.String printDetails()
debug only


toString

public java.lang.String toString()

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


Copyright © 2001,2002 www.javagroups.com . All Rights Reserved.