Class AbstractNode
- All Implemented Interfaces:
OtpTransportFactory
- Direct Known Subclasses:
OtpLocalNode
,OtpPeer
Represents an OTP node.
About nodenames: Erlang nodenames consist of two components, an alivename and a hostname separated by '@'. Additionally, there are two nodename formats: short and long. Short names are of the form "alive@hostname", while long names are of the form "alive@host.fully.qualified.domainname". Erlang has special requirements regarding the use of the short and long formats, in particular they cannot be mixed freely in a network of communicating nodes, however Jinterface makes no distinction. See the Erlang documentation for more information about nodenames.
The constructors for the AbstractNode classes will create names exactly as you provide them as long as the name contains '@'. If the string you provide contains no '@', it will be treated as an alivename and the name of the local host will be appended, resulting in a shortname. Nodenames longer than 255 characters will be truncated without warning.
Upon initialization, this class attempts to read the file .erlang.cookie in the user's home directory, and uses the trimmed first line of the file as the default cookie by those constructors lacking a cookie argument. If for any reason the file cannot be found or read, the default cookie will be set to the empty string (""). The location of a user's home directory is determined using the system property "user.home", which may not be automatically set on all platforms.
Instances of this class cannot be created directly, use one of the subclasses instead.
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractNode
(OtpTransportFactory transportFactory) protected
AbstractNode
(String node) Create a node with the given name and default cookie and transport factory.protected
AbstractNode
(String node, OtpTransportFactory transportFactory) Create a node with the given name, transport factory and the default cookie.protected
AbstractNode
(String name, String cookie) Create a node with the given name, cookie and default transport factory.protected
AbstractNode
(String name, String cookie, OtpTransportFactory transportFactory) Create a node with the given name, cookie and transport factory. -
Method Summary
Modifier and TypeMethodDescriptionalive()
Get the alivename part of the hostname.cookie()
Get the authorization cookie used by this node.createServerTransport
(int port) Create instance ofOtpServerTransport
createTransport
(String addr, int port) Create instance ofOtpTransport
createTransport
(InetAddress addr, int port) Create instance ofOtpTransport
host()
Get the hostname part of the nodename.node()
Get the name of this node.Set the authorization cookie used by this node.toString()
-
Constructor Details
-
AbstractNode
-
AbstractNode
Create a node with the given name and default cookie and transport factory. -
AbstractNode
Create a node with the given name, transport factory and the default cookie. -
AbstractNode
Create a node with the given name, cookie and default transport factory. -
AbstractNode
Create a node with the given name, cookie and transport factory.
-
-
Method Details
-
node
Get the name of this node.- Returns:
- the name of the node represented by this object.
-
host
Get the hostname part of the nodename. Nodenames are composed of two parts, an alivename and a hostname, separated by '@'. This method returns the part of the nodename following the '@'.- Returns:
- the hostname component of the nodename.
-
alive
Get the alivename part of the hostname. Nodenames are composed of two parts, an alivename and a hostname, separated by '@'. This method returns the part of the nodename preceding the '@'.- Returns:
- the alivename component of the nodename.
-
cookie
Get the authorization cookie used by this node.- Returns:
- the authorization cookie used by this node.
-
setCookie
Set the authorization cookie used by this node.- Returns:
- the previous authorization cookie used by this node.
-
toString
-
createTransport
Description copied from interface:OtpTransportFactory
Create instance ofOtpTransport
- Specified by:
createTransport
in interfaceOtpTransportFactory
- Parameters:
addr
- host name or IP address stringport
- port number- Returns:
- new socket object
- Throws:
IOException
-
createTransport
Description copied from interface:OtpTransportFactory
Create instance ofOtpTransport
- Specified by:
createTransport
in interfaceOtpTransportFactory
- Parameters:
addr
- peer addressport
- port number- Returns:
- new socket object
- Throws:
IOException
-
createServerTransport
Description copied from interface:OtpTransportFactory
Create instance ofOtpServerTransport
- Specified by:
createServerTransport
in interfaceOtpTransportFactory
- Parameters:
port
- port number to listen on- Returns:
- new socket object
- Throws:
IOException
-