Beispiel #1
0
        private long HandleEndOfLogCondition(
            DirectBuffer termBuffer,
            long termOffset,
            HeaderWriter header,
            int termLength,
            int termId)
        {
            int resultingOffset = FAILED;

            if (termOffset <= termLength)
            {
                resultingOffset = TRIPPED;

                if (termOffset < termLength)
                {
                    int offset        = (int)termOffset;
                    int paddingLength = termLength - offset;
                    header.Write(termBuffer, offset, paddingLength, termId);
                    FrameDescriptor.FrameType(termBuffer, offset, FrameDescriptor.PADDING_FRAME_TYPE);
                    FrameDescriptor.FrameLengthOrdered(termBuffer, offset, paddingLength);
                }
            }

            return(Pack(termId, resultingOffset));
        }
Beispiel #2
0
        /// <summary>
        /// Insert a packet of frames into the log at the appropriate offset as indicated by the term offset header.
        /// </summary>
        /// <param name="termBuffer"> into which the packet should be inserted. </param>
        /// <param name="offset">     offset in the term at which the packet should be inserted. </param>
        /// <param name="packet">     containing a sequence of frames. </param>
        /// <param name="length">     of the sequence of frames in bytes. </param>

        public static void Insert(DirectBuffer termBuffer, int offset, DirectBuffer packet, int length)
        {
            int firstFrameLength = packet.ReadInt32(0);

            packet.VolatileWriteInt32(0, 0);

            termBuffer.WriteBytes(offset, packet, 0, length);
            FrameDescriptor.FrameLengthOrdered(termBuffer, offset, firstFrameLength);
        }
Beispiel #3
0
 private static void ResetHeader(
     DirectBuffer logMetaDataBuffer,
     DirectBuffer termBuffer,
     int termOffset,
     int termId,
     int frameLength)
 {
     LogBufferDescriptor.ApplyDefaultHeader(logMetaDataBuffer, termBuffer, termOffset);
     FrameDescriptor.FrameType(termBuffer, termOffset, HeaderFlyweight.HDR_TYPE_PAD);
     FrameDescriptor.FrameTermOffset(termBuffer, termOffset);
     FrameDescriptor.FrameTermId(termBuffer, termOffset, termId);
     FrameDescriptor.FrameLengthOrdered(termBuffer, termOffset, frameLength);
 }