jgroup.relacs.types
Class MemberIdImpl

java.lang.Object
  extended by jgroup.relacs.types.MemberIdImpl
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Comparable<MemberId>, MemberId

public final class MemberIdImpl
extends java.lang.Object
implements MemberId

Implementation of the jgroup.core.MemberId interface.

Since:
Jgroup 0.9
Author:
Alberto Montresor, Hein Meling
See Also:
Serialized Form

Field Summary
static int SIZE
           
 
Constructor Summary
MemberIdImpl()
          Default constructor for externalization
MemberIdImpl(EndPoint endpoint, int incarnation, EndPoint localEndPoint, int count)
          Builds a new MemberId with the specified arguments.
MemberIdImpl(EndPoint endpoint, int incarnation, LocalId localId)
          Builds a new MemberId with the specified arguments.
 
Method Summary
 int compareTo(MemberId member)
          Compares this member with the given member for the purpose of sorting.
 boolean equals(java.lang.Object obj)
          Compares two MemberIdImpls for content equality.
 java.lang.String getCanonicalHostName()
          Returns the canonical hostname associated with the JVM on which the member is running.
 EndPoint getEndPoint()
          Returns the EndPoint (IP, port) of the java virtual machine hosting this member.
 LocalId getLocalId()
          Returns a LocalId object used to distinguish this particular member from other members of the same group hosted in the same Java virtual machine.
 int getServerPort()
          Returns the server port associated with this member host.
 net.jini.jeri.Endpoint getTcpEndpoint()
          Returns the TcpEndpoint of this member.
 int hashCode()
          Returns a hashcode for the MemberId.
 boolean isNeighbour(MemberId obj)
          Returns true if and only if this member id and the specified member id have the same IP address and the same incarnation time; i.e., if they are hosted in the same virtual machine.
 boolean isNewer(MemberId obj)
          Returns true if and only if the IP addresses of this member id and the specified id are the same, and the incarnation time of the former is greater than the incarnation time of the latter; in other words, if the Java virtual machine hosting the specified member id has crashed and then recovered.
 void readExternal(java.io.ObjectInput in)
          Restores the content of this object from the marshalled data contained in the specified input stream.
 java.lang.String toString()
          Returns a string representation of the object.
 void writeExternal(java.io.ObjectOutput out)
          Marshals the content of this object to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SIZE

public static final int SIZE
See Also:
Constant Field Values
Constructor Detail

MemberIdImpl

public MemberIdImpl()
Default constructor for externalization


MemberIdImpl

public MemberIdImpl(EndPoint endpoint,
                    int incarnation,
                    EndPoint localEndPoint,
                    int count)
Builds a new MemberId with the specified arguments.


MemberIdImpl

public MemberIdImpl(EndPoint endpoint,
                    int incarnation,
                    LocalId localId)
Builds a new MemberId with the specified arguments.

Method Detail

getEndPoint

public EndPoint getEndPoint()
Description copied from interface: MemberId
Returns the EndPoint (IP, port) of the java virtual machine hosting this member.

Specified by:
getEndPoint in interface MemberId

getTcpEndpoint

public net.jini.jeri.Endpoint getTcpEndpoint()
Description copied from interface: MemberId
Returns the TcpEndpoint of this member.

Specified by:
getTcpEndpoint in interface MemberId

getLocalId

public LocalId getLocalId()
Description copied from interface: MemberId
Returns a LocalId object used to distinguish this particular member from other members of the same group hosted in the same Java virtual machine.

Specified by:
getLocalId in interface MemberId

getCanonicalHostName

public java.lang.String getCanonicalHostName()
Description copied from interface: MemberId
Returns the canonical hostname associated with the JVM on which the member is running.

Specified by:
getCanonicalHostName in interface MemberId

getServerPort

public int getServerPort()
Description copied from interface: MemberId
Returns the server port associated with this member host. The server port is computed deterministically, based on the the host port number and the member number.

Specified by:
getServerPort in interface MemberId

isNewer

public boolean isNewer(MemberId obj)
Description copied from interface: MemberId
Returns true if and only if the IP addresses of this member id and the specified id are the same, and the incarnation time of the former is greater than the incarnation time of the latter; in other words, if the Java virtual machine hosting the specified member id has crashed and then recovered.

Specified by:
isNewer in interface MemberId

isNeighbour

public boolean isNeighbour(MemberId obj)
Description copied from interface: MemberId
Returns true if and only if this member id and the specified member id have the same IP address and the same incarnation time; i.e., if they are hosted in the same virtual machine.

Specified by:
isNeighbour in interface MemberId

compareTo

public int compareTo(MemberId member)
Compares this member with the given member for the purpose of sorting. This is used to define th partial order for all the members in a group.

Specified by:
compareTo in interface java.lang.Comparable<MemberId>
Returns:
Returns a positive value if and only if this EndPoint is greater than the given one, or this EndPoint is equal to the given one and this local id is greater than the given one.

We return zero if the members have the same id; that is the same EndPoint and the same localId. We do not consider the incarnation value.

Otherwise, we returns a negative value.

See Also:
MemberId

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Returns a hashcode for the MemberId. Two MemberIds will have the same hashcode if they are equal with respect to their content.

Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode

equals

public boolean equals(java.lang.Object obj)
Compares two MemberIdImpls for content equality.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to compare with
Returns:
True if these objects are equal; false otherwise.

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Restores the content of this object from the marshalled data contained in the specified input stream.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - the stream to be read
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Marshals the content of this object to the specified output stream.

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - the stream to be written
Throws:
java.io.IOException


Copyright © 1998-2006 The Jgroup/ARM development team. All Rights Reserved.