Example #1
0
 public Server(T requestTarget, Configuration config, LogProvider logProvider, int frameLength, ProtocolVersion protocolVersion, TxChecksumVerifier txVerifier, Clock clock, ByteCounterMonitor byteCounterMonitor, RequestMonitor requestMonitor)
 {
     this._requestTarget = requestTarget;
     this._config        = config;
     this._frameLength   = frameLength;
     this._applicationProtocolVersion = protocolVersion.ApplicationProtocol;
     this._logProvider            = logProvider;
     this._msgLog                 = this._logProvider.getLog(this.GetType());
     this._txVerifier             = txVerifier;
     this._byteCounterMonitor     = byteCounterMonitor;
     this._requestMonitor         = requestMonitor;
     this._connectedSlaveChannels = new IdleChannelReaper(this, logProvider, clock, config.OldChannelThreshold);
     this._chunkSize              = config.ChunkSize;
     assertChunkSizeIsWithinFrameSize(_chunkSize, frameLength);
 }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCloseAnyRecentlyActiveChannels()
        public virtual void ShouldNotCloseAnyRecentlyActiveChannels()
        {
            // given
            FakeClock         clock             = Clocks.fakeClock();
            ChannelCloser     channelCloser     = mock(typeof(ChannelCloser));
            IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, _noLogging, clock, THRESHOLD);

            Channel channel = mock(typeof(Channel));

            idleChannelReaper.Add(channel, DummyRequestContext());

            // when
            idleChannelReaper.Run();

            // then
            verifyNoMoreInteractions(channelCloser);
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseAnyChannelsThatHaveBeenIdleForLongerThanThreshold()
        public virtual void ShouldCloseAnyChannelsThatHaveBeenIdleForLongerThanThreshold()
        {
            // given
            FakeClock         clock             = Clocks.fakeClock();
            ChannelCloser     channelCloser     = mock(typeof(ChannelCloser));
            IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, _noLogging, clock, THRESHOLD);

            Channel channel = mock(typeof(Channel));

            idleChannelReaper.Add(channel, DummyRequestContext());

            // when
            clock.Forward(THRESHOLD + 1, TimeUnit.MILLISECONDS);
            idleChannelReaper.Run();

            // then
            verify(channelCloser).tryToCloseChannel(channel);
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotTryToCloseAChannelThatWasRecentlyActive()
        public virtual void ShouldNotTryToCloseAChannelThatWasRecentlyActive()
        {
            // given
            FakeClock         clock             = Clocks.fakeClock();
            ChannelCloser     channelCloser     = mock(typeof(ChannelCloser));
            IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, _noLogging, clock, THRESHOLD);

            Channel        channel = mock(typeof(Channel));
            RequestContext request = DummyRequestContext();

            idleChannelReaper.Add(channel, request);

            // when
            clock.Forward(THRESHOLD + 100, TimeUnit.MILLISECONDS);
            idleChannelReaper.Update(channel);
            idleChannelReaper.Run();

            // then
            verifyNoMoreInteractions(channelCloser);
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCloseAChannelThatHasBeenIdleForMoreThanHalfThresholdButIsStillOpenConnectedAndBound()
        public virtual void ShouldNotCloseAChannelThatHasBeenIdleForMoreThanHalfThresholdButIsStillOpenConnectedAndBound()
        {
            // given
            FakeClock         clock             = Clocks.fakeClock();
            ChannelCloser     channelCloser     = mock(typeof(ChannelCloser));
            IdleChannelReaper idleChannelReaper = new IdleChannelReaper(channelCloser, _noLogging, clock, THRESHOLD);

            Channel channel = mock(typeof(Channel));

            idleChannelReaper.Add(channel, DummyRequestContext());
            when(channel.Open).thenReturn(true);
            when(channel.Connected).thenReturn(true);
            when(channel.Bound).thenReturn(true);

            // when
            clock.Forward(THRESHOLD / 2 + 10, TimeUnit.MILLISECONDS);
            idleChannelReaper.Run();

            // then
            verifyNoMoreInteractions(channelCloser);
        }