|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jumpi.impl.connector.tcp.TcpConnection
A TcpConnection represents a peer to peer Socket connection between TcpDestination endpoints.
The TcpConnection is referenced by the remote TcpDestination. There is no concept of client or server on a TcpConnection, both endpoints are equivalent. Accepting a Socket or creating a Socket is the responsibility of the TcpConnector. The Socket options, i.e. read timeout, linger etc, are determined by the TcpConnector's configuration.
Data can be sent to the remote TcpDestination through the TcpConnection.
Data is continuously read from the remote TcpDestination by the
TcpConnection's reader task. This task uses a dedicated thread to read
data. Failure conditions when reading from or writing to the socket cause
the TcpConnection to be closed by the TcpConnector. See run()
.
A last used timestamp is kept on record for the TcpDestination. This timestamp is used to control caching policies by the TcpConnector.
Constructor Summary | |
TcpConnection(TcpConnector tcp,
Jumpi jumpi,
java.lang.String taskId,
TcpDestination dest,
java.net.Socket sock,
long flowcontrolTimeout)
Creates a new TcpConnection object. |
Method Summary | |
void |
close()
Close the TcpConnection, in doing so close the underlying Socket connection if it exists. |
int |
compareTo(java.lang.Object other)
Ordering function of TcpConnections, based on the last used timestamp. |
TcpDestination |
getDestination()
Return the remote peer TcpDestination to which this TcpConnection is associated. |
long |
getLastUsed()
Return the timestamp of the last send or receive operation. |
java.lang.String |
getTaskId()
A unique name for the task in the VM. |
boolean |
hasMatchedReceive()
Returns true if at least one message has been successfully received by the TcpConnector. |
boolean |
isLongRunning()
Returns true always indicating that the reader thread is used exclusively by the TcpConnection, potentially for long periods. |
boolean |
isSchedulable()
The reader thread is scheduled to run the Task as long as the TcpConnection is not closed. |
void |
run()
Read packeted data from the instance's Socket. |
void |
send(byte[] data)
Send data over the Socket to the remote peer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TcpConnection(TcpConnector tcp, Jumpi jumpi, java.lang.String taskId, TcpDestination dest, java.net.Socket sock, long flowcontrolTimeout)
tcp
- the TcpConnector parent.jumpi
- the Jumpi instance parent of TcpConnector.taskId
- the unique taskId for the reader task.dest
- the remote peer TcpDestination.sock
- the Socket associated with the TcpConnection.flowcontrolTimeout
- the timeout in millis for matching a received
message.Method Detail |
public int compareTo(java.lang.Object other)
compareTo
in interface Comparable
other
- the other TcpConnection.
public java.lang.String getTaskId()
getTaskId
in interface Task
public long getLastUsed()
public void send(byte[] data) throws java.lang.Exception
data
- the raw data.
java.lang.Exception
- if any error condition occurs.public void close()
public boolean isSchedulable()
isSchedulable
in interface Task
public boolean isLongRunning()
isLongRunning
in interface Task
public TcpDestination getDestination()
public void run()
run
in interface java.lang.Runnable
public boolean hasMatchedReceive()
|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |