Package jadex.bridge.component.streams
Class InputConnectionHandler
- java.lang.Object
-
- jadex.bridge.component.streams.AbstractConnectionHandler
-
- jadex.bridge.component.streams.InputConnectionHandler
-
- All Implemented Interfaces:
IAbstractConnectionHandler,IInputConnectionHandler
public class InputConnectionHandler extends AbstractConnectionHandler implements IInputConnectionHandler
Handler that sits between connection and message service. Is used by connection to forward user requests. Is used by the message service to signal arrived messages.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jadex.bridge.component.streams.AbstractConnectionHandler
AbstractConnectionHandler.SendInfo
-
-
Field Summary
Fields Modifier and Type Field Description protected intackcntThe number of received elements after which an ack is sent.protected java.util.Map<java.lang.Integer,Tuple2<byte[],java.lang.Boolean>>dataThe data (stored here only as long as it is out of order or incomplete).protected java.util.TimerTaskdatatimerThe current timer.protected intlastackThe last in order sequence number acknowledged.protected intlastseqnoThe last sequence number.protected intmaxackseqnoThe highest yet (may be out of order) acknowledged sequence number (only used to trigger new acks every x messages).protected intmaxbufThe maximum buffer size for out of order packets.protected intmaxseqnoThe highest yet (may be out of order) received sequence number.protected intmaxstoredThe maximum bytes of data that can be stored in connection (without being consumed).protected intrseqnoThe last in order received sequence number.-
Fields inherited from class jadex.bridge.component.streams.AbstractConnectionHandler
ACKCLOSE, ACKCLOSE_INPUT_INITIATOR, ACKCLOSE_OUTPUT_PARTICIPANT, ACKCLOSEREQ, ACKCLOSEREQ_INPUT_PARTICIPANT, ACKCLOSEREQ_OUTPUT_INITIATOR, ACKDATA, ACKDATA_INPUT_INITIATOR, ACKDATA_OUTPUT_PARTICIPANT, ACKINIT, ACKINIT_INPUT_PARTICIPANT, ACKINIT_OUTPUT_PARTICIPANT, acktimeout, ALIVE, ALIVE_INITIATOR, ALIVE_PARTICIPANT, alivetime, CLOSE, CLOSE_INPUT_PARTICIPANT, CLOSE_OUTPUT_INITIATOR, CLOSEREQ, CLOSEREQ_INPUT_INITIATOR, CLOSEREQ_OUTPUT_PARTICIPANT, component, con, DATA, DATA_INPUT_PARTICIPANT, DATA_OUTPUT_INITIATOR, EMPTY_BYTE_ARRAY, INIT, INIT_INPUT_INITIATOR, INIT_OUTPUT_INITIATOR, leasetime, maxresends, MESSAGE_TYPE_STREAM, MESSAGETYPES, nonfunc, timer, unacked
-
-
Constructor Summary
Constructors Constructor Description InputConnectionHandler(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> nonfunc)Create a new input connection handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddData(int seqnumber, byte[] dat)Called from message service.voidcloseReceived(int seqno)From initiator.voidcreateDataTimer(long acktimeout)Create a new data ack timer.IFuture<java.lang.Void>doClose()Called from connection.protected voidforwardData(byte[] data)Forward the data to the input connection.InputConnectiongetInputConnection()Get the input connection.intgetNextReceivedSequenceNumber()Get the next received sequence number.intgetSequenceNumber()Get the last received sequence number.protected booleanisStop()Test if stop is activated (too much data arrived).voidnotifyDataRead()Called by connection when user read some data so that other side can continue to send.protected voidsendDataAck()Send ack data.protected voidsendDataAck(int startseqno, int endseqno, boolean stop)-
Methods inherited from class jadex.bridge.component.streams.AbstractConnectionHandler
ackReceived, close, createAckTimer, createTask, createTask, getComponent, getConnection, getConnectionId, getExecutionFeature, getLeasetime, getMessageFeature, getMessageType, getMessageType, getNonFunctionalProperties, initReceived, isClosed, isConnectionAlive, notifyInited, scheduleStep, sendAcknowledgedMessage, sendAlive, sendInit, sendTask, setAliveTime, setConnection, setNonFunctionalProperties, waitForRealDelay
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jadex.bridge.component.streams.IAbstractConnectionHandler
getNonFunctionalProperties, notifyInited, sendInit, setConnection
-
-
-
-
Field Detail
-
rseqno
protected int rseqno
The last in order received sequence number.
-
maxseqno
protected int maxseqno
The highest yet (may be out of order) received sequence number.
-
maxackseqno
protected int maxackseqno
The highest yet (may be out of order) acknowledged sequence number (only used to trigger new acks every x messages).
-
maxbuf
protected int maxbuf
The maximum buffer size for out of order packets.
-
maxstored
protected int maxstored
The maximum bytes of data that can be stored in connection (without being consumed).
-
data
protected java.util.Map<java.lang.Integer,Tuple2<byte[],java.lang.Boolean>> data
The data (stored here only as long as it is out of order or incomplete). Ready data will be forwarded to the connection. Also remembers if an acknowledgement has been sent.
-
lastack
protected int lastack
The last in order sequence number acknowledged.
-
ackcnt
protected int ackcnt
The number of received elements after which an ack is sent.
-
datatimer
protected java.util.TimerTask datatimer
The current timer.
-
lastseqno
protected int lastseqno
The last sequence number.
-
-
Constructor Detail
-
InputConnectionHandler
public InputConnectionHandler(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> nonfunc)
Create a new input connection handler.
-
-
Method Detail
-
closeReceived
public void closeReceived(int seqno)
From initiator. Called when a close message was received. participant acks and closes- Parameters:
seqno- The last data packet.
-
doClose
public IFuture<java.lang.Void> doClose()
Called from connection. Initiates closing procedure (is different for initiator and participant).- Specified by:
doClosein interfaceIAbstractConnectionHandler- Overrides:
doClosein classAbstractConnectionHandler
-
addData
public void addData(int seqnumber, byte[] dat)Called from message service. Uses: data- Parameters:
data- The new data.
-
forwardData
protected void forwardData(byte[] data)
Forward the data to the input connection.
-
getSequenceNumber
public int getSequenceNumber()
Get the last received sequence number.- Returns:
- the sequence number.
-
getNextReceivedSequenceNumber
public int getNextReceivedSequenceNumber()
Get the next received sequence number.- Returns:
- the sequence number.
-
createDataTimer
public void createDataTimer(long acktimeout)
Create a new data ack timer. Sends an ack automatically after some timeout.
-
sendDataAck
protected void sendDataAck()
Send ack data.
-
sendDataAck
protected void sendDataAck(int startseqno, int endseqno, boolean stop)
-
getInputConnection
public InputConnection getInputConnection()
Get the input connection.- Returns:
- The input connection.
-
isStop
protected boolean isStop()
Test if stop is activated (too much data arrived).
-
notifyDataRead
public void notifyDataRead()
Called by connection when user read some data so that other side can continue to send.- Specified by:
notifyDataReadin interfaceIInputConnectionHandler
-
-