//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRemoveChannelViaCallback() public virtual void ShouldRemoveChannelViaCallback() { // given AdvertisedSocketAddress address = new AdvertisedSocketAddress("localhost", 1984); ReconnectingChannels channels = new ReconnectingChannels(); channels.PutIfAbsent(address, mock(typeof(ReconnectingChannel))); IdleChannelReaperHandler reaper = new IdleChannelReaperHandler(channels); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.net.InetSocketAddress socketAddress = address.socketAddress(); InetSocketAddress socketAddress = address.SocketAddressConflict(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final io.netty.channel.Channel channel = mock(io.netty.channel.Channel.class); Channel channel = mock(typeof(Channel)); when(channel.remoteAddress()).thenReturn(socketAddress); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final io.netty.channel.ChannelHandlerContext context = mock(io.netty.channel.ChannelHandlerContext.class); ChannelHandlerContext context = mock(typeof(ChannelHandlerContext)); when(context.channel()).thenReturn(channel); // when reaper.UserEventTriggered(context, IdleStateEvent.ALL_IDLE_STATE_EVENT); // then assertNull(channels.Get(address)); }
public override SocketAddress ClientAddress() { return(_rawChannel.remoteAddress()); }
private void TryConnect() { lock (this) { if (_disposed) { return; } else if (_fChannel != null && !_fChannel.Done) { return; } _fChannel = _bootstrap.connect(_destination.socketAddress()); _channel = _fChannel.channel(); _fChannel.addListener((ChannelFuture f) => { if (!f.Success) { long millis = _connectionBackoff.Millis; _cappedLogger.warn("Failed to connect to: " + _destination.socketAddress() + ". Retrying in " + millis + " ms"); f.channel().eventLoop().schedule(this.tryConnect, millis, MILLISECONDS); _connectionBackoff.increment(); } else { _log.info("Connected: " + f.channel()); f.channel().closeFuture().addListener(closed => { _log.warn(string.Format("Lost connection to: {0} ({1})", _destination, _channel.remoteAddress())); _connectionBackoff = _connectionBackoffStrategy.newTimeout(); f.channel().eventLoop().schedule(this.tryConnect, 0, MILLISECONDS); }); } }); } }