Class View
java.lang.Object
org.jgroups.View
- All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Streamable
- Direct Known Subclasses:
MergeView
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
- Version:
- $Id: View.java,v 1.18 2007/10/01 07:24:41 belaban Exp $
- Author:
- Bela Ban
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPayload(String key, Object value) Adds a key and value to the view.clone()creates a copy of this viewbooleancontainsMember(Address mbr) returns true, if this view contains a certain memberbooleanreturns the creator of this view if this view was created with the empty constructur, null will be returnedReturns 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.getPayload(String key) getVid()returns the view ID of this view if this view was created with the empty constructur, null will be returnedinthashCode()debug onlyvoidvoidRead the state of the current object (including superclasses) from instream Note that the input stream must not be closedintintsize()returns the number of members in this viewtoString()voidvoidwriteTo(DataOutputStream out) Write the entire state of the current object (including superclasses) to outstream.
-
Field Details
-
vid
-
members
-
payload
-
-
Constructor Details
-
View
public View()creates an empty view, should not be used -
View
-
View
-
-
Method Details
-
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
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
-
containsMember
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
-
hashCode
-
size
public int size()returns the number of members in this view- Returns:
- the number of members in this view 0..n
-
clone
-
printDetails
debug only -
addPayload
Adds a key and value to the view. Since the payloads will be shipped around *with* the view, so the keys and values need to be serializable. Note that the total serialized size of all keys and values cannot exceed 65000 bytes !- Parameters:
key-value-
-
getPayload
-
toString
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeTo
Description copied from interface:StreamableWrite the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed- Specified by:
writeToin interfaceStreamable- Throws:
IOException
-
readFrom
public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException Description copied from interface:StreamableRead the state of the current object (including superclasses) from instream Note that the input stream must not be closed- Specified by:
readFromin interfaceStreamable- Throws:
IOExceptionIllegalAccessExceptionInstantiationException
-
serializedSize
public int serializedSize()
-