|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jgroup.core.MemberTable
public class MemberTable
This class is an helper utility that provides application developers
with additional information about members of their current view. It
can be used as a hash table, to associate application-dependent
information to member identifier. Furthermore, it can be used to
obtain information about the state of a member identifier with
respect to both the current view and previous installed views (for
example, method getStatus
may be used to discover which
members survived from the previous view). The table also maintains
information about the relative position of a member identifier in the
member identifier array associated to the last installed view.
The table maintains information about a member until it crashes. A
member is declared crashed when a member identifier from the same
endpoint, but with an higher incarnation identifier is inserted in
the table. This means that the JVM hosting the member has crashed,
and a new one has started. The state of crashed members is set to
CRASHED
. The information associated to the member is
maintained until the next view change, after which the member
identifier and all its associated information is removed from the
table.
This class implements the MembershipListener
interface,
so it may be passed to the MembershipService
to be
notified whenever a view change occurs. Otherwise, the application
developer may take care of updating the table by explicitly calling
method viewChange
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface jgroup.core.MembershipListener |
---|
MembershipListener.AllowDuplicateViews |
Field Summary | |
---|---|
static int |
CRASHED
State assigned to members that have been declared crashed because a member identifier from the same endpoint but with a new incarnation number has been inserted in the table. |
static int |
MERGING
State assigned to members that merged the view after a previous partitioning |
static int |
NEWMEMBER
State assigned to new members |
static int |
NOTMEMBER
State assigned to member identifiers not included in the table |
static int |
PARTITIONED
State assigned to partitioned members for which no information is available. |
static int |
RECOVERING
State assigned to member identifiers whose incarnation number is greater than the incarnation number of other members previously contained in the table. |
static int |
SURVIVED
State assigned to members that survived from the previous view |
Constructor Summary | |
---|---|
MemberTable()
Build a new empty MemberTable . |
Method Summary | |
---|---|
java.lang.Object[] |
elements()
Returns an array containing the values associated to all members contained in this MemberTable , including members
crashed or partitioned. |
java.lang.Object |
get(MemberId id)
Returns the value associated by this MemberTable to
the specified member id. |
int |
getIndex(MemberId id)
Returns the position of the specified member identifier in the last view for which method viewChange has been
called; return -1 if the member is not member of that view. |
int |
getStatus(MemberId id)
Returns the status associated with this member identifier. |
void |
hasLeft()
No effect. |
boolean |
isMember(MemberId id)
Returns true if the specified member identifier is member of the last view for which method viewChange
has been called; return false otherwise. |
MemberId[] |
members()
Returns an array containing the identifiers of all members contained in this MemberTable , including members
crashed or partitioned. |
void |
prepareChange()
No effect. |
void |
put(MemberId id,
java.lang.Object value)
Associates object value to the specified member
identifier. |
void |
readExternal(java.io.ObjectInput in)
|
void |
remove(MemberId id)
|
java.lang.String |
toString()
|
java.lang.String |
toString(MemberId id)
|
void |
viewChange(View view)
Update the information in the table with the information maintained in the new view. |
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int NOTMEMBER
public static final int PARTITIONED
public static final int CRASHED
public static final int RECOVERING
public static final int SURVIVED
public static final int MERGING
public static final int NEWMEMBER
Constructor Detail |
---|
public MemberTable()
MemberTable
. Also used as the
default constructor for externalization.
Method Detail |
---|
public int getStatus(MemberId id)
public int getIndex(MemberId id)
viewChange
has been
called; return -1 if the member is not member of that view.
public void put(MemberId id, java.lang.Object value)
value
to the specified member
identifier. This association is maintained in the table until it
is explicitly removed from the table, or the member is declared
crashed. Values may be retrieved using method get
.
id
- The member identifer to which the value
should be
associated.value
- The value to associate with the given member.
java.lang.IllegalArgumentException
- If the specified member identifier does not exist within this
member table.public java.lang.Object get(MemberId id)
MemberTable
to
the specified member id. Returns null if the map contains no
mapping for this member id. A return value of null does not
necessarily indicate that the map contains no mapping for the key;
it is possible that the map explicitly maps the key to null.
id
- The member identifier used as key.
MemberTable
.public void remove(MemberId id)
public java.lang.Object[] elements()
MemberTable
, including members
crashed or partitioned. The array is sorted according to the member
index in the most recent view; the crashed and partitioned members
are placed at the end of the array with no particular order.
public MemberId[] members()
MemberTable
, including members
crashed or partitioned.
public boolean isMember(MemberId id)
viewChange
has been called; return false otherwise.
id
- the member whose membership is to be tested.public java.lang.String toString(MemberId id)
public java.lang.String toString()
toString
in class java.lang.Object
public void viewChange(View view)
viewChange
in interface MembershipListener
view
- The new view that has been installed.MembershipService
public void hasLeft()
hasLeft
in interface MembershipListener
MembershipService
public void prepareChange()
prepareChange
in interface MembershipListener
MembershipService
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |