Class OutputConnectionHandler

    • Field Detail

      • seqnumber

        protected int seqnumber
        The current sequence number.
      • maxsend

        protected int maxsend
        The max number of packets that can be sent without an ack is received.
      • maxqueued

        protected int maxqueued
        The max number of messages that can be sending concurrently (i.e. passed to message service but sending not yet completed).
      • ackcnt

        protected int ackcnt
        The number of received elements after which an ack is sent.
      • queuecnt

        protected int queuecnt
        The number of sending messages (i.e. passed to message service but sending not yet completed).
      • acktimer

        protected java.util.TimerTask acktimer
        The acknowledgement timer.
      • multipackets

        protected boolean multipackets
        Flag if multipackets should be used.
      • mpmaxsize

        protected int mpmaxsize
        The packet size to collect (in bytes).
      • multipacket

        protected java.util.List<byte[]> multipacket
        The collected data for a packet.
      • mpsize

        protected int mpsize
        The current multipacket size.
      • mpfut

        protected Future<java.lang.Void> mpfut
        The current multipacket future (shared by all write requests that put data in the same multi packet).
      • mpsendtimeout

        protected long mpsendtimeout
        The max delay before a multipacket is sent (even if not full).
      • mpsendtimer

        protected java.util.TimerTask mpsendtimer
        The multipacket send timer.
      • closereqflag

        protected boolean closereqflag
        Close request flag (when a closereq message was received).
      • stopflag

        protected 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).
      • closesent

        protected boolean closesent
        Flag if close was already sent.
      • readyfuture

        protected Future<java.lang.Integer> readyfuture
        Future used in waitForReady().
    • Constructor Detail

      • OutputConnectionHandler

        public OutputConnectionHandler​(IInternalAccess component,
                                       java.util.Map<java.lang.String,​java.lang.Object> nonfunc)
        Create a new handler.
    • Method Detail

      • closeRequestReceived

        public void closeRequestReceived()
        Received a request to close the connection.
      • ackDataReceived

        public void ackDataReceived​(AckInfo ackinfo)
        Called from message service. Uses: sent, lastack
      • waitForReady

        public IFuture<java.lang.Integer> waitForReady()
        Wait until the connection is ready for the next write.
        Specified by:
        waitForReady in 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.
      • checkWaitForReady

        protected void checkWaitForReady()
      • sendStored

        protected void sendStored()
        Called internally. Uses: sent, tosend
      • addMultipacket

        protected IFuture<java.lang.Void> addMultipacket​(byte[] data)
        Called internally. Add data to a multi packet.
      • addMultiPacketChunk

        protected IFuture<java.lang.Void> addMultiPacketChunk​(byte[] data)
        Called internally. Add data chunk.
        Parameters:
        data - The data.
      • sendAcknowledgedMultiPacket

        protected IFuture<java.lang.Void> sendAcknowledgedMultiPacket()
        Called internally. Send a multi packet.
      • sendData

        public IFuture<java.lang.Void> sendData​(StreamPacket task)
        Send or resend a data message.
      • createBulkAckTimer

        protected 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.
      • isSendAllowed

        protected boolean isSendAllowed()
      • isStop

        protected boolean isStop()
      • isCloseRequested

        public boolean isCloseRequested()
        Get the closereq.
        Returns:
        The closereq.
      • isDataSendFinished

        protected boolean isDataSendFinished()
        Tests if the data processing of the connection is finished.
      • isDataAckFinished

        protected boolean isDataAckFinished()
        Tests if the data processing of the connection is finished.
      • setClosed

        public void setClosed()
        Set the connection closed.
      • getOutputConnection

        public OutputConnection getOutputConnection()
        Get the output connection.
        Returns:
        The connection.
      • getSequenceNumber

        public int getSequenceNumber()
        Get the seqnumber.
        Returns:
        the seqnumber.
      • getNextSequenceNumber

        public int getNextSequenceNumber()
        Get The next seqnumber.
        Returns:
        The next seqnumber.
      • createMultipacketSendTimer

        protected void createMultipacketSendTimer​(int seqno)
        This timer automatically sends non-full multipackets after mpsendtimeout has occurred.
      • checkClose

        protected void checkClose()
      • checkResend

        public void checkResend()
        Check resending of unacknowledged messages.