Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnStreamOfInstalledProtocolsForChannelsThatHaveCompletedHandshake()
        public virtual void ShouldReturnStreamOfInstalledProtocolsForChannelsThatHaveCompletedHandshake()
        {
            // given
            _reconnectingChannels.putIfAbsent(_to1, _channel1);
            _reconnectingChannels.putIfAbsent(_to2, _channel2);
            ProtocolStack protocolStack1 = new ProtocolStack(TestProtocols_TestApplicationProtocols.RAFT_3, emptyList());
            ProtocolStack protocolStack2 = new ProtocolStack(TestProtocols_TestApplicationProtocols.RAFT_2, emptyList());

            Mockito.when(_channel1.installedProtocolStack()).thenReturn(protocolStack1);
            Mockito.when(_channel2.installedProtocolStack()).thenReturn(protocolStack2);

            // when
            Stream <Pair <AdvertisedSocketAddress, ProtocolStack> > installedProtocols = _reconnectingChannels.installedProtocols();

            // then
            Stream <Pair <AdvertisedSocketAddress, ProtocolStack> > sorted = installedProtocols.sorted(System.Collections.IComparer.comparing(p => p.first().Hostname));

            assertThat(sorted, contains(Pair.of(_to1, protocolStack1), Pair.of(_to2, protocolStack2)));
        }
Exemplo n.º 2
0
        private Channel Channel(AdvertisedSocketAddress destination)
        {
            ReconnectingChannel channel = _channels.get(destination);

            if (channel == null)
            {
                channel = new ReconnectingChannel(_bootstrap, _eventLoopGroup.next(), destination, _log);
                channel.Start();
                ReconnectingChannel existingNonBlockingChannel = _channels.putIfAbsent(destination, channel);

                if (existingNonBlockingChannel != null)
                {
                    channel.Dispose();
                    channel = existingNonBlockingChannel;
                }
                else
                {
                    _log.info("Creating channel to: [%s] ", destination);
                }
            }

            return(channel);
        }