|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread com.ericsson.otp.erlang.AbstractConnection com.ericsson.otp.erlang.OtpConnection
public class OtpConnection
Maintains a connection between a Java process and a remote Erlang, Java or C node. The object maintains connection state and allows data to be sent to and received from the peer.
Once a connection is established between the local node and a remote node, the connection object can be used to send and receive messages between the nodes and make rpc calls (assuming that the remote node is a real Erlang node).
The various receive methods are all blocking and will return only when a valid message has been received or an exception is raised.
If an exception occurs in any of the methods in this class, the connection will be closed and must be explicitely reopened in order to resume communication with the peer.
It is not possible to create an instance of this class directly.
OtpConnection objects are returned by OtpSelf.connect()
and OtpSelf.accept()
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected GenericQueue |
queue
|
protected OtpSelf |
self
|
Fields inherited from class com.ericsson.otp.erlang.AbstractConnection |
---|
ChallengeAck, ChallengeReply, ChallengeStatus, connected, cookieOk, ctrlThreshold, defaultLevel, exit2Tag, exit2TTTag, exitTag, exitTTTag, groupLeaderTag, handshakeThreshold, headerLen, linkTag, localNode, passThrough, peer, random, regSendTag, regSendTTTag, sendCookie, sendTag, sendThreshold, sendTTTag, socket, traceLevel, unlinkTag, version |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Method Summary | |
---|---|
void |
deliver(java.lang.Exception e)
Deliver communication exceptions to the recipient. |
void |
deliver(OtpMsg msg)
Deliver messages to the recipient. |
void |
exit(OtpErlangPid dest,
OtpErlangObject reason)
Send an exit signal to a remote process. |
void |
link(OtpErlangPid dest)
Create a link between the local node and the specified process on the remote node. |
int |
msgCount()
Return the number of messages currently waiting in the receive queue for this connection. |
OtpPeer |
peer()
Get information about the node at the peer end of this connection. |
OtpErlangObject |
receive()
Receive a message from a remote process. |
OtpErlangObject |
receive(long timeout)
Receive a message from a remote process. |
OtpInputStream |
receiveBuf()
Receive a raw (still encoded) message from a remote process. |
OtpInputStream |
receiveBuf(long timeout)
Receive a raw (still encoded) message from a remote process. |
OtpMsg |
receiveMsg()
Receive a messge complete with sender and recipient information. |
OtpMsg |
receiveMsg(long timeout)
Receive a messge complete with sender and recipient information. |
OtpErlangObject |
receiveRPC()
Receive an RPC reply from the remote Erlang node. |
OtpSelf |
self()
Get information about the node at the local end of this connection. |
void |
send(OtpErlangPid dest,
OtpErlangObject msg)
Send a message to a process on a remote node. |
void |
send(java.lang.String dest,
OtpErlangObject msg)
Send a message to a named process on a remote node. |
void |
sendBuf(OtpErlangPid dest,
OtpOutputStream payload)
Send a pre-encoded message to a process on a remote node. |
void |
sendBuf(java.lang.String dest,
OtpOutputStream payload)
Send a pre-encoded message to a named process on a remote node. |
void |
sendRPC(java.lang.String mod,
java.lang.String fun,
OtpErlangList args)
Send an RPC request to the remote Erlang node. |
void |
sendRPC(java.lang.String mod,
java.lang.String fun,
OtpErlangObject[] args)
Send an RPC request to the remote Erlang node. |
void |
unlink(OtpErlangPid dest)
Remove a link between the local node and the specified process on the remote node. |
Methods inherited from class com.ericsson.otp.erlang.AbstractConnection |
---|
close, do_send, do_send, doAccept, doConnect, finalize, genChallenge, genDigest, getFlags, getTraceLevel, headerType, isConnected, read2BytePackage, readSock, recvChallenge, recvChallengeAck, recvChallengeReply, recvName, recvStatus, run, sendBuf, sendBuf, sendChallenge, sendChallengeAck, sendChallengeReply, sendExit, sendExit2, sendLink, sendName, sendStatus, sendUnlink, setFlags, setTraceLevel |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected OtpSelf self
protected GenericQueue queue
Method Detail |
---|
public void deliver(java.lang.Exception e)
AbstractConnection
deliver
in class AbstractConnection
public void deliver(OtpMsg msg)
AbstractConnection
deliver
in class AbstractConnection
public OtpPeer peer()
Node
representing the peer node.public OtpSelf self()
Node
representing the local node.public int msgCount()
public OtpErlangObject receive() throws java.io.IOException, OtpErlangExit, OtpAuthException
If the remote node sends a message that cannot be decoded properly, the connection is closed and the method throws an exception.
java.io.IOException
- if the connection is not active or a communication
error occurs.
OtpErlangExit
- if an exit signal is received from a process on the
peer node.
OtpAuthException
- if the remote node sends a message containing an
invalid cookie.public OtpErlangObject receive(long timeout) throws java.lang.InterruptedException, java.io.IOException, OtpErlangExit, OtpAuthException
If the remote node sends a message that cannot be decoded properly, the connection is closed and the method throws an exception.
timeout
- the time in milliseconds that this operation will block.
Specify 0 to poll the queue.
java.io.IOException
- if the connection is not active or a communication
error occurs.
OtpErlangExit
- if an exit signal is received from a process on the
peer node.
OtpAuthException
- if the remote node sends a message containing an
invalid cookie.
java.lang.InterruptedException
- if no message if the method times out before a message
becomes available.public OtpInputStream receiveBuf() throws java.io.IOException, OtpErlangExit, OtpAuthException
If the remote node sends a message that cannot be decoded properly, the connection is closed and the method throws an exception.
java.io.IOException
- if the connection is not active or a communication
error occurs.
OtpErlangExit
- if an exit signal is received from a process on the
peer node, or if the connection is lost for any
reason.
OtpAuthException
- if the remote node sends a message containing an
invalid cookie.public OtpInputStream receiveBuf(long timeout) throws java.lang.InterruptedException, java.io.IOException, OtpErlangExit, OtpAuthException
If the remote node sends a message that cannot be decoded properly, the connection is closed and the method throws an exception.
timeout
- the time in milliseconds that this operation will block.
Specify 0 to poll the queue.
java.io.IOException
- if the connection is not active or a communication
error occurs.
OtpErlangExit
- if an exit signal is received from a process on the
peer node, or if the connection is lost for any
reason.
OtpAuthException
- if the remote node sends a message containing an
invalid cookie.
java.lang.InterruptedException
- if no message if the method times out before a message
becomes available.public OtpMsg receiveMsg() throws java.io.IOException, OtpErlangExit, OtpAuthException
OtpMsg
containing the header information about
the sender and recipient, as well as the actual message contents.
java.io.IOException
- if the connection is not active or a communication
error occurs.
OtpErlangExit
- if an exit signal is received from a process on the
peer node, or if the connection is lost for any
reason.
OtpAuthException
- if the remote node sends a message containing an
invalid cookie.public OtpMsg receiveMsg(long timeout) throws java.lang.InterruptedException, java.io.IOException, OtpErlangExit, OtpAuthException
timeout
- the time in milliseconds that this operation will block.
Specify 0 to poll the queue.
OtpMsg
containing the header information about
the sender and recipient, as well as the actual message contents.
java.io.IOException
- if the connection is not active or a communication
error occurs.
OtpErlangExit
- if an exit signal is received from a process on the
peer node, or if the connection is lost for any
reason.
OtpAuthException
- if the remote node sends a message containing an
invalid cookie.
java.lang.InterruptedException
- if no message if the method times out before a message
becomes available.public void send(OtpErlangPid dest, OtpErlangObject msg) throws java.io.IOException
dest
- the Erlang PID of the remote process.msg
- the message to send.
java.io.IOException
- if the connection is not active or a communication
error occurs.public void send(java.lang.String dest, OtpErlangObject msg) throws java.io.IOException
dest
- the name of the remote process.msg
- the message to send.
java.io.IOException
- if the connection is not active or a communication
error occurs.public void sendBuf(java.lang.String dest, OtpOutputStream payload) throws java.io.IOException
dest
- the name of the remote process.payload
- the encoded message to send.
java.io.IOException
- if the connection is not active or a communication
error occurs.public void sendBuf(OtpErlangPid dest, OtpOutputStream payload) throws java.io.IOException
dest
- the Erlang PID of the remote process.payload
- the encoded message to send.
java.io.IOException
- if the connection is not active or a communication
error occurs.public void sendRPC(java.lang.String mod, java.lang.String fun, OtpErlangObject[] args) throws java.io.IOException
{ self, { call, Mod, Fun, Args, user } }
Note that this method has unpredicatble results if the remote node is not an Erlang node.
mod
- the name of the Erlang module containing the function to
be called.fun
- the name of the function to call.args
- an array of Erlang terms, to be used as arguments to the
function.
java.io.IOException
- if the connection is not active or a communication
error occurs.public void sendRPC(java.lang.String mod, java.lang.String fun, OtpErlangList args) throws java.io.IOException
{ self, { call, Mod, Fun, Args, user } }
Note that this method has unpredicatble results if the remote node is not an Erlang node.
mod
- the name of the Erlang module containing the function to
be called.fun
- the name of the function to call.args
- a list of Erlang terms, to be used as arguments to the
function.
java.io.IOException
- if the connection is not active or a communication
error occurs.public OtpErlangObject receiveRPC() throws java.io.IOException, OtpErlangExit, OtpAuthException
{ rex, Term }
java.io.IOException
- if the connection is not active or a communication
error occurs.
OtpErlangExit
- if an exit signal is received from a process on the
peer node.
OtpAuthException
- if the remote node sends a message containing an
invalid cookie.public void link(OtpErlangPid dest) throws java.io.IOException
unlink()
to remove the link.
dest
- the Erlang PID of the remote process.
java.io.IOException
- if the connection is not active or a communication
error occurs.public void unlink(OtpErlangPid dest) throws java.io.IOException
link()
.
dest
- the Erlang PID of the remote process.
java.io.IOException
- if the connection is not active or a communication
error occurs.public void exit(OtpErlangPid dest, OtpErlangObject reason) throws java.io.IOException
dest
- the Erlang PID of the remote process.reason
- an Erlang term describing the exit reason.
java.io.IOException
- if the connection is not active or a communication
error occurs.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |