Class ReliableTcpConnection
- java.lang.Object
-
- org.objectweb.joram.client.jms.tcp.ReliableTcpConnection
-
public class ReliableTcpConnection extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classReliableTcpConnection.AckTimerTask(package private) static classReliableTcpConnection.NetOutputStream(package private) classReliableTcpConnection.Reader(package private) static classReliableTcpConnection.TcpMessage
-
Field Summary
Fields Modifier and Type Field Description private BufferedInputStreambisstatic intCONNECTstatic intCONNECTINGstatic intDEFAULT_WINDOW_SIZEstatic intINITprivate longinputCounterprivate ObjectinputLockprivate static org.objectweb.util.monolog.api.Loggerloggerprivate booleannoAckedQueueprivate ReliableTcpConnection.NetOutputStreamnosprivate longoutputCounterprivate ObjectoutputLockprivate Vector<ReliableTcpConnection.TcpMessage>pendingMessagesprivate ReliableTcpConnection.Readerreaderprivate LinkedBlockingQueue<byte[]>receiveQueueprivate Socketsockprivate intstatusprivate static String[]statusNamesprivate Timertimerprivate intunackCounterCounter of received messages that needs an acknowledge.static StringWINDOW_SIZE_PROP_NAMEprivate intwindowSizeMaximum number of non acknowledged messages
-
Constructor Summary
Constructors Constructor Description ReliableTcpConnection(Timer timer, boolean noAckedQueue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidackPendingMessages(long ackId)private voidaddPendingMessage(ReliableTcpConnection.TcpMessage msg)voidclose()private voiddoSend(long id, long ackId, org.objectweb.joram.shared.client.AbstractJmsMessage msg)private intgetStatus()voidinit(Socket sock)booleanisReaderRun()org.objectweb.joram.shared.client.AbstractJmsReplyreceive()voidsend(org.objectweb.joram.shared.client.AbstractJmsMessage request)private voidsetStatus(int status)
-
-
-
Field Detail
-
logger
private static final org.objectweb.util.monolog.api.Logger logger
-
INIT
public static final int INIT
- See Also:
- Constant Field Values
-
CONNECT
public static final int CONNECT
- See Also:
- Constant Field Values
-
CONNECTING
public static final int CONNECTING
- See Also:
- Constant Field Values
-
statusNames
private static final String[] statusNames
-
WINDOW_SIZE_PROP_NAME
public static String WINDOW_SIZE_PROP_NAME
-
DEFAULT_WINDOW_SIZE
public static int DEFAULT_WINDOW_SIZE
-
windowSize
private int windowSize
Maximum number of non acknowledged messages
-
unackCounter
private volatile int unackCounter
Counter of received messages that needs an acknowledge. The messages received are acknowledged each time a message is sent (sending of the stamp of the last message received). This counter is incremented when a message is received, and reseted when a message is sent (acknowledgment of all messages received). When the number of messages waiting an acknowledgment is too high (windowSize) an empty message is sent to explicitly acknowledge them. TODO (AF): This field should be synchronized, currently collisions may occur during counter increments. The consequence is that the actual value of the counter may be less than the actual value. In the current implementation this is not a problem.
-
inputCounter
private volatile long inputCounter
-
outputCounter
private long outputCounter
-
pendingMessages
private Vector<ReliableTcpConnection.TcpMessage> pendingMessages
-
sock
private Socket sock
-
nos
private ReliableTcpConnection.NetOutputStream nos
-
bis
private BufferedInputStream bis
-
inputLock
private Object inputLock
-
outputLock
private Object outputLock
-
status
private int status
-
timer
private Timer timer
-
noAckedQueue
private boolean noAckedQueue
-
receiveQueue
private LinkedBlockingQueue<byte[]> receiveQueue
-
reader
private ReliableTcpConnection.Reader reader
-
-
Constructor Detail
-
ReliableTcpConnection
public ReliableTcpConnection(Timer timer, boolean noAckedQueue)
-
-
Method Detail
-
setStatus
private void setStatus(int status)
-
getStatus
private final int getStatus()
-
init
public void init(Socket sock) throws IOException
- Throws:
IOException
-
send
public void send(org.objectweb.joram.shared.client.AbstractJmsMessage request) throws IOException- Throws:
IOException
-
doSend
private void doSend(long id, long ackId, org.objectweb.joram.shared.client.AbstractJmsMessage msg) throws IOException- Throws:
IOException
-
addPendingMessage
private void addPendingMessage(ReliableTcpConnection.TcpMessage msg)
-
ackPendingMessages
private void ackPendingMessages(long ackId)
-
receive
public org.objectweb.joram.shared.client.AbstractJmsReply receive() throws Exception- Throws:
Exception
-
isReaderRun
public boolean isReaderRun()
-
close
public void close()
-
-