internal Publication(ClientConductor clientConductor, string channel, int streamId, int sessionId, IReadablePosition positionLimit, LogBuffers logBuffers, long registrationId) { var buffers = logBuffers.AtomicBuffers(); var logMetaDataBuffer = buffers[LogBufferDescriptor.LOG_META_DATA_SECTION_INDEX]; for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++) { _termAppenders[i] = new TermAppender(buffers[i], buffers[i + LogBufferDescriptor.PARTITION_COUNT]); } var termLength = logBuffers.TermLength(); _maxPayloadLength = LogBufferDescriptor.MtuLength(logMetaDataBuffer) - DataHeaderFlyweight.HEADER_LENGTH; MaxMessageLength = FrameDescriptor.ComputeMaxMessageLength(termLength); _clientConductor = clientConductor; Channel = channel; StreamId = streamId; SessionId = sessionId; InitialTermId = LogBufferDescriptor.InitialTermId(logMetaDataBuffer); _logMetaDataBuffer = logMetaDataBuffer; RegistrationId = registrationId; _positionLimit = positionLimit; _logBuffers = logBuffers; _positionBitsToShift = IntUtil.NumberOfTrailingZeros(termLength); _headerWriter = new HeaderWriter(LogBufferDescriptor.DefaultFrameHeader(logMetaDataBuffer)); }
/// <summary> /// Construct a new image over a log to represent a stream of messages from a <seealso cref="Publication"/>. /// </summary> /// <param name="subscription"> to which this <seealso cref="Image"/> belongs. </param> /// <param name="sessionId"> of the stream of messages. </param> /// <param name="subscriberPosition"> for indicating the position of the subscriber in the stream. </param> /// <param name="logBuffers"> containing the stream of messages. </param> /// <param name="errorHandler"> to be called if an error occurs when polling for messages. </param> /// <param name="sourceIdentity"> of the source sending the stream of messages. </param> /// <param name="correlationId"> of the request to the media driver. </param> public Image(Subscription subscription, int sessionId, IPosition subscriberPosition, LogBuffers logBuffers, ErrorHandler errorHandler, string sourceIdentity, long correlationId) { Subscription = subscription; SessionId = sessionId; _subscriberPosition = subscriberPosition; _logBuffers = logBuffers; _errorHandler = errorHandler; SourceIdentity = sourceIdentity; CorrelationId = correlationId; var buffers = logBuffers.AtomicBuffers(); Array.Copy(buffers, 0, _termBuffers, 0, LogBufferDescriptor.PARTITION_COUNT); var termLength = logBuffers.TermLength(); _termLengthMask = termLength - 1; _positionBitsToShift = IntUtil.NumberOfTrailingZeros(termLength); _header = new Header(LogBufferDescriptor.InitialTermId(buffers[LogBufferDescriptor.LOG_META_DATA_SECTION_INDEX]), _positionBitsToShift); }