public class Connection extends Object
OtpConnection
and allows automatic re-connects using a
ConnectionPolicy
object.Constructor and Description |
---|
Connection(OtpSelf self,
ConnectionPolicy connectionPolicy)
Creates a new connection between the a self node and one of the
remoteNodes, selected by the connectionPolicy.
|
Connection(OtpSelf self,
PeerNode remote)
Creates a new connection using the given nodes and a default connection
policy.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection to the remote node.
|
OtpErlangObject |
doRPC(String mod,
String fun,
OtpErlangList args)
Sends the given RPC and waits for a result.
|
OtpErlangObject |
doRPC(String mod,
String fun,
OtpErlangObject[] args)
Sends the given RPC and waits for a result.
|
OtpConnection |
getConnection()
Gets the encapsulated OTP connection object.
|
PeerNode |
getRemote()
Gets the remote node connected to.
|
OtpSelf |
getSelf()
Gets the local node used for the connection.
|
void |
sendRPC(String mod,
String fun,
OtpErlangList args)
Sends the given RPC and returns immediately.
|
void |
sendRPC(String mod,
String fun,
OtpErlangObject[] args)
Sends the given RPC and returns immediately.
|
public Connection(OtpSelf self, PeerNode remote) throws UnknownHostException, IOException, OtpAuthException
self
- the local noderemote
- the remote node to connect toUnknownHostException
- if the remote host could not be foundIOException
- if it was not possible to connect to the remote nodeOtpAuthException
- if the connection was refused by the remote nodepublic Connection(OtpSelf self, ConnectionPolicy connectionPolicy) throws UnknownHostException, IOException, OtpAuthException
self
- the local nodeconnectionPolicy
- the connection policy to useUnknownHostException
- if the remote host could not be foundIOException
- if it was not possible to connect to the remote nodeOtpAuthException
- if the connection was refused by the remote nodepublic OtpErlangObject doRPC(String mod, String fun, OtpErlangList args) throws ConnectionException
mod
- the module of the function to callfun
- the function to callargs
- the function's argumentsConnectionException
- if the connection is not active, a communication error
occurs, an exit signal is received from a process on the
peer node or the remote node sends a message containing an
invalid cookiepublic OtpErlangObject doRPC(String mod, String fun, OtpErlangObject[] args) throws ConnectionException
mod
- the module of the function to callfun
- the function to callargs
- the function's argumentsConnectionException
- if the connection is not active, a communication error
occurs, an exit signal is received from a process on the
peer node or the remote node sends a message containing an
invalid cookiepublic void sendRPC(String mod, String fun, OtpErlangList args) throws ConnectionException
mod
- the module of the function to callfun
- the function to callargs
- the function's argumentsConnectionException
- if the connection is not active, a communication error
occurs, an exit signal is received from a process on the
peer node or the remote node sends a message containing an
invalid cookiepublic void sendRPC(String mod, String fun, OtpErlangObject[] args) throws ConnectionException
mod
- the module of the function to callfun
- the function to callargs
- the function's argumentsConnectionException
- if the connection is not active, a communication error
occurs, an exit signal is received from a process on the
peer node or the remote node sends a message containing an
invalid cookiepublic void close()
public OtpSelf getSelf()
public PeerNode getRemote()
public OtpConnection getConnection()