Exemplo n.º 1
0
 public void Add(Subscription subscription)
 {
     List<Subscription> subscriptions;
     if (!_subscriptionsByStreamIdMap.TryGetValue(subscription.StreamId, out subscriptions))
     {
         subscriptions = new List<Subscription>();
         _subscriptionsByStreamIdMap[subscription.StreamId] = subscriptions;
     }
     
     subscriptions.Add(subscription);
 }
Exemplo n.º 2
0
        public void Remove(Subscription subscription)
        {
            int streamId = subscription.StreamId;

            List<Subscription> subscriptions;
            if (_subscriptionsByStreamIdMap.TryGetValue(streamId, out subscriptions))
            {
                if (subscriptions.Remove(subscription) && subscriptions.Count == 0)
                {
                    _subscriptionsByStreamIdMap.Remove(streamId);
                }
            }
        }
Exemplo n.º 3
0
        public void Setup()
        {
            AtomicReadBuffer = new UnsafeBuffer(new byte[READ_BUFFER_CAPACITY]);
            Conductor = A.Fake<ClientConductor>();
            FragmentHandler = A.Fake<FragmentHandler>();
            ImageOneMock = A.Fake<Image>();
            ImageTwoMock = A.Fake<Image>();
            Header = A.Fake<Header>();

            A.CallTo(() => Header.Flags).Returns(FLAGS);

            Subscription = new Subscription(Conductor, CHANNEL, STREAM_ID_1, SUBSCRIPTION_CORRELATION_ID);
            A.CallTo(() => Conductor.ReleaseSubscription(Subscription));
        }
Exemplo n.º 4
0
        /// <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);
        }