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.AbstractConnectionHandlerAbstractConnectionHandler.SendInfo
 
- 
 - 
Field SummaryFields 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.AbstractConnectionHandlerACKCLOSE, 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 SummaryConstructors Constructor Description InputConnectionHandler(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> nonfunc)Create a new input connection handler.
 - 
Method SummaryAll 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.AbstractConnectionHandlerackReceived, 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.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface jadex.bridge.component.streams.IAbstractConnectionHandlergetNonFunctionalProperties, notifyInited, sendInit, setConnection
 
- 
 
- 
- 
- 
Field Detail- 
rseqnoprotected int rseqno The last in order received sequence number.
 - 
maxseqnoprotected int maxseqno The highest yet (may be out of order) received sequence number.
 - 
maxackseqnoprotected int maxackseqno The highest yet (may be out of order) acknowledged sequence number (only used to trigger new acks every x messages).
 - 
maxbufprotected int maxbuf The maximum buffer size for out of order packets.
 - 
maxstoredprotected int maxstored The maximum bytes of data that can be stored in connection (without being consumed).
 - 
dataprotected 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.
 - 
lastackprotected int lastack The last in order sequence number acknowledged.
 - 
ackcntprotected int ackcnt The number of received elements after which an ack is sent.
 - 
datatimerprotected java.util.TimerTask datatimer The current timer.
 - 
lastseqnoprotected int lastseqno The last sequence number.
 
- 
 - 
Constructor Detail- 
InputConnectionHandlerpublic InputConnectionHandler(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> nonfunc) Create a new input connection handler.
 
- 
 - 
Method Detail- 
closeReceivedpublic void closeReceived(int seqno) From initiator. Called when a close message was received. participant acks and closes- Parameters:
- seqno- The last data packet.
 
 - 
doClosepublic IFuture<java.lang.Void> doClose() Called from connection. Initiates closing procedure (is different for initiator and participant).- Specified by:
- doClosein interface- IAbstractConnectionHandler
- Overrides:
- doClosein class- AbstractConnectionHandler
 
 - 
addDatapublic void addData(int seqnumber, byte[] dat)Called from message service. Uses: data- Parameters:
- data- The new data.
 
 - 
forwardDataprotected void forwardData(byte[] data) Forward the data to the input connection.
 - 
getSequenceNumberpublic int getSequenceNumber() Get the last received sequence number.- Returns:
- the sequence number.
 
 - 
getNextReceivedSequenceNumberpublic int getNextReceivedSequenceNumber() Get the next received sequence number.- Returns:
- the sequence number.
 
 - 
createDataTimerpublic void createDataTimer(long acktimeout) Create a new data ack timer. Sends an ack automatically after some timeout.
 - 
sendDataAckprotected void sendDataAck() Send ack data.
 - 
sendDataAckprotected void sendDataAck(int startseqno, int endseqno, boolean stop)
 - 
getInputConnectionpublic InputConnection getInputConnection() Get the input connection.- Returns:
- The input connection.
 
 - 
isStopprotected boolean isStop() Test if stop is activated (too much data arrived).
 - 
notifyDataReadpublic void notifyDataRead() Called by connection when user read some data so that other side can continue to send.- Specified by:
- notifyDataReadin interface- IInputConnectionHandler
 
 
- 
 
-