public class AddressPair
extends java.lang.Object
implements java.io.Externalizable
The class contains two addresses, one of which represents the local node address while the other represents the address of the remote node.
By convention, the node which initiates a connection sends an INIT_STANDARD or INIT_CONVERSATION message. The node which accepts a connection processes that message and sends an INIT_REPLY message.
The member names of this class support this convention and represent addresses from the point of view of the node which sends the INIT_STANDARD or INIT_CONVERSATION message (nodeAddress represents the address of the node which sends the INIT message and remoteAddress represents the address of the node which sends the INIT_REPLY message).
Modifier and Type | Field and Description |
---|---|
private int |
nodeAddress
Stores local node address from the point of view of the node which
sends the initialization request message.
|
private int |
remoteAddress
Stores remote node address from the point of view of the node which
sends the initialization request message.
|
Constructor and Description |
---|
AddressPair()
Default constructor which instantiates an
AddressPair
object with both addresses set to 0. |
AddressPair(int node,
int remote)
Constructs an instance using two provided addresses.
|
Modifier and Type | Method and Description |
---|---|
(package private) int |
getNodeAddress()
Returns the local node address.
|
(package private) int |
getRemoteAddress()
Returns the remote node address.
|
void |
readExternal(java.io.ObjectInput in)
Replacement for the default object reading method.
|
(package private) void |
setNodeAddress(int address)
Sets the local node address.
|
(package private) void |
setRemoteAddress(int address)
Sets the remote node address.
|
(package private) void |
swapAddresses()
Convenience method to swap the local and remote addresses.
|
void |
writeExternal(java.io.ObjectOutput out)
Replacement for the default object writing method.
|
private int nodeAddress
private int remoteAddress
public AddressPair()
AddressPair
object with both addresses set to 0.AddressPair(int node, int remote)
node
- Local node address.remote
- Remote node address.int getNodeAddress()
int getRemoteAddress()
void setNodeAddress(int address)
address
- Address which will be set as the local node address.void setRemoteAddress(int address)
address
- Address which will be set as the remote node address.void swapAddresses()
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- The output destination to which fields will be saved.java.io.IOException
- In case of I/O errors.public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- Input source from which fields will be restored.java.io.IOException
- In case of I/O errors.java.lang.ClassNotFoundException
- If payload can't be instantiated.