Package jadex.bridge.component.streams
Class OutputConnectionHandler
- java.lang.Object
- 
- jadex.bridge.component.streams.AbstractConnectionHandler
- 
- jadex.bridge.component.streams.OutputConnectionHandler
 
 
- 
- All Implemented Interfaces:
- IAbstractConnectionHandler,- IOutputConnectionHandler
 
 public class OutputConnectionHandler extends AbstractConnectionHandler implements IOutputConnectionHandler The output connection handler.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classOutputConnectionHandler.DataSendInfoInfo about a sent but not yet acknowledged data message.- 
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.TimerTaskacktimerThe acknowledgement timer.protected booleanclosereqflagClose request flag (when a closereq message was received).protected booleanclosesentFlag if close was already sent.protected intmaxqueuedThe max number of messages that can be sending concurrently (i.e.protected intmaxsendThe max number of packets that can be sent without an ack is received.protected Future<java.lang.Void>mpfutThe current multipacket future (shared by all write requests that put data in the same multi packet).protected intmpmaxsizeThe packet size to collect (in bytes).protected longmpsendtimeoutThe max delay before a multipacket is sent (even if not full).protected java.util.TimerTaskmpsendtimerThe multipacket send timer.protected intmpsizeThe current multipacket size.protected java.util.List<byte[]>multipacketThe collected data for a packet.protected booleanmultipacketsFlag if multipackets should be used.protected intqueuecntThe number of sending messages (i.e.protected Future<java.lang.Integer>readyfutureFuture used in waitForReady().protected java.util.Map<java.lang.Integer,OutputConnectionHandler.DataSendInfo>sentThe data sent (not acknowledged).protected intseqnumberThe current sequence number.protected Tuple2<java.lang.Boolean,java.lang.Integer>stopflagStop flag (is sent in ack from input side) to signal that the rceiver is flooded with data).protected java.util.List<Tuple2<StreamPacket,Future<java.lang.Void>>>tosendThe data to send.- 
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 OutputConnectionHandler(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> nonfunc)Create a new handler.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidackDataReceived(AckInfo ackinfo)Called from message service.protected IFuture<java.lang.Void>addMultipacket(byte[] data)Called internally.protected IFuture<java.lang.Void>addMultiPacketChunk(byte[] data)Called internally.protected voidcheckClose()voidcheckResend()Check resending of unacknowledged messages.protected voidcheckWaitForReady()voidcloseRequestReceived()Received a request to close the connection.protected java.util.TimerTaskcreateBulkAckTimer(java.lang.Object id)Triggers resends of packets if no ack has been received in acktimeout.protected voidcreateMultipacketSendTimer(int seqno)This timer automatically sends non-full multipackets after mpsendtimeout has occurred.IFuture<java.lang.Void>doClose()Called from connection.protected IFuture<java.lang.Void>doSendData(StreamPacket task)voidflush()Flush the data.intgetNextSequenceNumber()Get The next seqnumber.OutputConnectiongetOutputConnection()Get the output connection.intgetSequenceNumber()Get the seqnumber.booleanisCloseRequested()Get the closereq.protected booleanisDataAckFinished()Tests if the data processing of the connection is finished.protected booleanisDataSendFinished()Tests if the data processing of the connection is finished.protected booleanisSendAllowed()protected booleanisStop()voidnotifyInited()IFuture<java.lang.Void>send(byte[] dat)Called from connection.protected IFuture<java.lang.Void>sendAcknowledgedMultiPacket()Called internally.IFuture<java.lang.Void>sendData(StreamPacket task)Send or resend a data message.protected voidsendStored()Called internally.voidsetClosed()Set the connection closed.IFuture<java.lang.Integer>waitForReady()Wait until the connection is ready for the next write.- 
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, 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, sendInit, setConnection
 
- 
 
- 
- 
- 
Field Detail- 
sentprotected java.util.Map<java.lang.Integer,OutputConnectionHandler.DataSendInfo> sent The data sent (not acknowledged).
 - 
tosendprotected java.util.List<Tuple2<StreamPacket,Future<java.lang.Void>>> tosend The data to send.
 - 
seqnumberprotected int seqnumber The current sequence number.
 - 
maxsendprotected int maxsend The max number of packets that can be sent without an ack is received.
 - 
maxqueuedprotected int maxqueued The max number of messages that can be sending concurrently (i.e. passed to message service but sending not yet completed).
 - 
ackcntprotected int ackcnt The number of received elements after which an ack is sent.
 - 
queuecntprotected int queuecnt The number of sending messages (i.e. passed to message service but sending not yet completed).
 - 
acktimerprotected java.util.TimerTask acktimer The acknowledgement timer.
 - 
multipacketsprotected boolean multipackets Flag if multipackets should be used.
 - 
mpmaxsizeprotected int mpmaxsize The packet size to collect (in bytes).
 - 
multipacketprotected java.util.List<byte[]> multipacket The collected data for a packet.
 - 
mpsizeprotected int mpsize The current multipacket size.
 - 
mpfutprotected Future<java.lang.Void> mpfut The current multipacket future (shared by all write requests that put data in the same multi packet).
 - 
mpsendtimeoutprotected long mpsendtimeout The max delay before a multipacket is sent (even if not full).
 - 
mpsendtimerprotected java.util.TimerTask mpsendtimer The multipacket send timer.
 - 
closereqflagprotected boolean closereqflag Close request flag (when a closereq message was received).
 - 
stopflagprotected Tuple2<java.lang.Boolean,java.lang.Integer> stopflag Stop flag (is sent in ack from input side) to signal that the rceiver is flooded with data).
 - 
closesentprotected boolean closesent Flag if close was already sent.
 - 
readyfutureprotected Future<java.lang.Integer> readyfuture Future used in waitForReady().
 
- 
 - 
Constructor Detail- 
OutputConnectionHandlerpublic OutputConnectionHandler(IInternalAccess component, java.util.Map<java.lang.String,java.lang.Object> nonfunc) Create a new handler.
 
- 
 - 
Method Detail- 
closeRequestReceivedpublic void closeRequestReceived() Received a request to close the connection.
 - 
ackDataReceivedpublic void ackDataReceived(AckInfo ackinfo) Called from message service. Uses: sent, lastack
 - 
notifyInitedpublic void notifyInited() - Specified by:
- notifyInitedin interface- IAbstractConnectionHandler
- Overrides:
- notifyInitedin class- AbstractConnectionHandler
 
 - 
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
 
 - 
sendpublic IFuture<java.lang.Void> send(byte[] dat) Called from connection. Uses: sent, tosend- Specified by:
- sendin interface- IOutputConnectionHandler
 
 - 
flushpublic void flush() Flush the data.- Specified by:
- flushin interface- IOutputConnectionHandler
 
 - 
waitForReadypublic IFuture<java.lang.Integer> waitForReady() Wait until the connection is ready for the next write.- Specified by:
- waitForReadyin interface- IOutputConnectionHandler
- Returns:
- Calls future when next data can be written. Provides a value of how much data should be given to the connection for best performance.
 
 - 
checkWaitForReadyprotected void checkWaitForReady() 
 - 
doSendDataprotected IFuture<java.lang.Void> doSendData(StreamPacket task) 
 - 
sendStoredprotected void sendStored() Called internally. Uses: sent, tosend
 - 
addMultipacketprotected IFuture<java.lang.Void> addMultipacket(byte[] data) Called internally. Add data to a multi packet.
 - 
addMultiPacketChunkprotected IFuture<java.lang.Void> addMultiPacketChunk(byte[] data) Called internally. Add data chunk.- Parameters:
- data- The data.
 
 - 
sendAcknowledgedMultiPacketprotected IFuture<java.lang.Void> sendAcknowledgedMultiPacket() Called internally. Send a multi packet.
 - 
sendDatapublic IFuture<java.lang.Void> sendData(StreamPacket task) Send or resend a data message.
 - 
createBulkAckTimerprotected java.util.TimerTask createBulkAckTimer(java.lang.Object id) Triggers resends of packets if no ack has been received in acktimeout.- Parameters:
- id- The message id.
- Returns:
- The timer.
 
 - 
isSendAllowedprotected boolean isSendAllowed() 
 - 
isStopprotected boolean isStop() 
 - 
isCloseRequestedpublic boolean isCloseRequested() Get the closereq.- Returns:
- The closereq.
 
 - 
isDataSendFinishedprotected boolean isDataSendFinished() Tests if the data processing of the connection is finished.
 - 
isDataAckFinishedprotected boolean isDataAckFinished() Tests if the data processing of the connection is finished.
 - 
setClosedpublic void setClosed() Set the connection closed.
 - 
getOutputConnectionpublic OutputConnection getOutputConnection() Get the output connection.- Returns:
- The connection.
 
 - 
getSequenceNumberpublic int getSequenceNumber() Get the seqnumber.- Returns:
- the seqnumber.
 
 - 
getNextSequenceNumberpublic int getNextSequenceNumber() Get The next seqnumber.- Returns:
- The next seqnumber.
 
 - 
createMultipacketSendTimerprotected void createMultipacketSendTimer(int seqno) This timer automatically sends non-full multipackets after mpsendtimeout has occurred.
 - 
checkCloseprotected void checkClose() 
 - 
checkResendpublic void checkResend() Check resending of unacknowledged messages.
 
- 
 
-