org.jgroups

Class View

public class View extends Object implements Externalizable, Cloneable, Streamable

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.
Field Summary
protected Vectormembers
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.
protected ViewIdvid
Constructor Summary
View()
creates an empty view, should not be used
View(ViewId vid, Vector members)
Creates a new view
View(Address creator, long id, Vector members)
Creates a new view
Method Summary
Objectclone()
creates a copy of this view
booleancontainsMember(Address mbr)
returns true, if this view contains a certain member
booleanequals(Object obj)
AddressgetCreator()
returns the creator of this view if this view was created with the empty constructur, null will be returned
VectorgetMembers()
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.
ViewIdgetVid()
returns the view ID of this view if this view was created with the empty constructur, null will be returned
StringprintDetails()
debug only
voidreadExternal(ObjectInput in)
voidreadFrom(DataInputStream in)
intserializedSize()
intsize()
returns the number of members in this view
StringtoString()
voidwriteExternal(ObjectOutput out)
voidwriteTo(DataOutputStream out)

Field Detail

members

protected 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.

vid

protected ViewId vid

Constructor Detail

View

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

View

public View(ViewId vid, 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, 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

clone

public Object clone()
creates a copy of this view

Returns: a copy of 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

equals

public boolean equals(Object obj)

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 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

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

printDetails

public String printDetails()
debug only

readExternal

public void readExternal(ObjectInput in)

readFrom

public void readFrom(DataInputStream in)

serializedSize

public int serializedSize()

size

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

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

toString

public String toString()

writeExternal

public void writeExternal(ObjectOutput out)

writeTo

public void writeTo(DataOutputStream out)
Copyright ? 1998-2005 Bela Ban. All Rights Reserved.