예제 #1
0
        /// <summary>
        /// Append pre-formatted block of message fragments into the term buffer.
        /// <para>
        /// <em>WARNING: This is internal API used by {@code ExclusivePublication#offerBlock} method.</em>
        /// </para>
        /// </summary>
        /// <param name="termId">     for the current term. </param>
        /// <param name="termOffset"> in the term at which to append. </param>
        /// <param name="buffer">     which contains block of messages. </param>
        /// <param name="offset">     within the buffer at which the block begins. </param>
        /// <param name="length">     of the block in bytes (always aligned). </param>
        /// <returns> the resulting offset of the term after success otherwise <seealso cref="FAILED"/>. </returns>
        public int AppendBlock(int termId, int termOffset, IMutableDirectBuffer buffer, int offset, int length)
        {
            int resultingOffset    = termOffset + length;
            int lengthOfFirstFrame = buffer.GetInt(offset, ByteOrder.LittleEndian);

            buffer.PutInt(offset, 0, ByteOrder.LittleEndian);
            _termBuffer.PutBytes(termOffset, buffer, offset, length);
            FrameDescriptor.FrameLengthOrdered(_termBuffer, termOffset, lengthOfFirstFrame);
            PutRawTailOrdered(termId, resultingOffset);

            return(resultingOffset);
        }
        private void CheckFirstFrame(IMutableDirectBuffer buffer, int offset)
        {
            int frameType       = HeaderFlyweight.HDR_TYPE_DATA;
            int blockTermOffset = buffer.GetInt(offset + DataHeaderFlyweight.TERM_OFFSET_FIELD_OFFSET,
                                                ByteOrder.LittleEndian);
            int blockSessionId =
                buffer.GetInt(offset + DataHeaderFlyweight.SESSION_ID_FIELD_OFFSET, ByteOrder.LittleEndian);
            int blockStreamId =
                buffer.GetInt(offset + DataHeaderFlyweight.STREAM_ID_FIELD_OFFSET, ByteOrder.LittleEndian);
            int blockTermId    = buffer.GetInt(offset + DataHeaderFlyweight.TERM_ID_FIELD_OFFSET, ByteOrder.LittleEndian);
            int blockFrameType = buffer.GetShort(offset + HeaderFlyweight.TYPE_FIELD_OFFSET, ByteOrder.LittleEndian) &
                                 0xFFFF;

            if (blockTermOffset != _termOffset || blockSessionId != SessionId || blockStreamId != StreamId ||
                blockTermId != _termId || frameType != blockFrameType)
            {
                throw new ArgumentException("improperly formatted block:" + " termOffset=" + blockTermOffset +
                                            " (expected=" + _termOffset + ")," + " sessionId=" + blockSessionId +
                                            " (expected=" + SessionId + ")," + " streamId=" + blockStreamId +
                                            " (expected=" + StreamId + ")," + " termId=" + blockTermId +
                                            " (expected=" + _termId + ")," + " frameType=" + blockFrameType +
                                            " (expected=" + frameType + ")");
            }
        }
예제 #3
0
 /// <summary>
 /// return session id field
 /// </summary>
 /// <returns> session id field </returns>
 public int SessionId()
 {
     return(_buffer.GetInt(_offset + SESSION_ID_OFFSET));
 }
예제 #4
0
 /// <summary>
 /// return stream id field
 /// </summary>
 /// <returns> stream id field </returns>
 public int StreamId()
 {
     return(buffer.GetInt(offset + STREAM_ID_FIELD_OFFSET));
 }
예제 #5
0
 /// <summary>
 /// Error code for the command.
 /// </summary>
 /// <returns> error code for the command </returns>
 public ErrorCode ErrorCode()
 {
     return((ErrorCode)_buffer.GetInt(_offset + ERROR_CODE_OFFSET));
 }
예제 #6
0
 /// <summary>
 /// The counter id
 /// </summary>
 /// <returns> counter id </returns>
 public int CounterId()
 {
     return(buffer.GetInt(offset + COUNTER_ID_OFFSET));
 }
 /// <summary>
 /// The channel status counter id
 /// </summary>
 /// <returns> channel status counter id </returns>
 public int ChannelStatusCounterId()
 {
     return(buffer.GetInt(offset + CHANNEL_STATUS_INDICATOR_ID_OFFSET));
 }