Exemplo n.º 1
0
        public void SetUp()
        {
            RcvBuffer                     = new UnsafeBuffer(new byte[ALIGNED_FRAME_LENGTH]);
            DataHeader                    = new DataHeaderFlyweight();
            MockFragmentHandler           = A.Fake <IFragmentHandler>();
            MockControlledFragmentHandler = A.Fake <IControlledFragmentHandler>();
            Position     = A.Fake <IPosition>(options => options.Wrapping(new AtomicLongPosition()));
            LogBuffers   = A.Fake <LogBuffers>();
            ErrorHandler = A.Fake <ErrorHandler>();
            Subscription = A.Fake <Subscription>();

            TermBuffers = new UnsafeBuffer[LogBufferDescriptor.PARTITION_COUNT];

            DataHeader.Wrap(RcvBuffer);

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                TermBuffers[i] = new UnsafeBuffer(new byte[TERM_BUFFER_LENGTH]);
            }

            var logMetaDataBuffer = new UnsafeBuffer(new byte[LogBufferDescriptor.LOG_META_DATA_LENGTH]);

            A.CallTo(() => LogBuffers.DuplicateTermBuffers()).Returns(TermBuffers);
            A.CallTo(() => LogBuffers.TermLength()).Returns(TERM_BUFFER_LENGTH);
            A.CallTo(() => LogBuffers.MetaDataBuffer()).Returns(logMetaDataBuffer);
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            _sendBuffer        = new byte[SendBufferCapacity];
            _atomicSendBuffer  = new UnsafeBuffer(_sendBuffer);
            _logMetaDataBuffer = new UnsafeBuffer(new byte[LogBufferDescriptor.LOG_META_DATA_LENGTH]);
            _termBuffers       = new UnsafeBuffer[LogBufferDescriptor.PARTITION_COUNT];

            _conductor        = A.Fake <ClientConductor>();
            _logBuffers       = A.Fake <LogBuffers>();
            _publicationLimit = A.Fake <IReadablePosition>();

            A.CallTo(() => _publicationLimit.GetVolatile()).Returns(2 * SendBufferCapacity);
            A.CallTo(() => _logBuffers.DuplicateTermBuffers()).Returns(_termBuffers);
            A.CallTo(() => _logBuffers.TermLength()).Returns(LogBufferDescriptor.TERM_MIN_LENGTH);
            A.CallTo(() => _logBuffers.MetaDataBuffer()).Returns(_logMetaDataBuffer);

            LogBufferDescriptor.InitialTermId(_logMetaDataBuffer, TermID1);
            LogBufferDescriptor.MtuLength(_logMetaDataBuffer, MTU_LENGTH);
            LogBufferDescriptor.TermLength(_logMetaDataBuffer, LogBufferDescriptor.TERM_MIN_LENGTH);
            LogBufferDescriptor.PageSize(_logMetaDataBuffer, PAGE_SIZE);
            LogBufferDescriptor.IsConnected(_logMetaDataBuffer, false);

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                _termBuffers[i] = new UnsafeBuffer(new byte[LogBufferDescriptor.TERM_MIN_LENGTH]);
            }

            _publication = new ConcurrentPublication(
                _conductor,
                Channel,
                StreamID1,
                SessionID1,
                _publicationLimit,
                ChannelEndpointStatus.NO_ID_ALLOCATED,
                _logBuffers,
                CorrelationID,
                CorrelationID);

            LogBufferDescriptor.InitialiseTailWithTermId(_logMetaDataBuffer, PartionIndex, TermID1);

            A.CallTo(() => _conductor.ReleasePublication(_publication)).Invokes(() => _publication.InternalClose());
        }