//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static byte[] chunk(int maxChunkSize, byte[][] messages) throws java.io.IOException public static sbyte[] Chunk(int maxChunkSize, sbyte[][] messages) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final ByteBuffer outputBuffer = ByteBuffer.allocate(1024 * 8); ByteBuffer outputBuffer = ByteBuffer.allocate(1024 * 8); Channel ch = mock(typeof(Channel)); when(ch.alloc()).thenReturn(UnpooledByteBufAllocator.DEFAULT); when(ch.writeAndFlush(any(), Null)).then(inv => { ByteBuf buf = inv.getArgument(0); outputBuffer.limit(outputBuffer.position() + buf.readableBytes()); buf.readBytes(outputBuffer); buf.release(); return(null); }); int maxBufferSize = maxChunkSize + CHUNK_HEADER_SIZE; ChunkedOutput @out = new ChunkedOutput(ch, maxBufferSize, maxBufferSize, TransportThrottleGroup.NO_THROTTLE); foreach (sbyte[] message in messages) { @out.BeginMessage(); @out.WriteBytes(message, 0, message.Length); @out.MessageSucceeded(); } @out.Flush(); @out.Dispose(); sbyte[] bytes = new sbyte[outputBuffer.limit()]; outputBuffer.position(0); outputBuffer.get(bytes); return(bytes); }
//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 BoltChannel(string id, string connector, Channel rawChannel) { this._id = id; this._connectTime = DateTimeHelper.CurrentUnixTimeMillis(); this._connector = connector; this._rawChannel = rawChannel; this._info = CreateConnectionInfo(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private boolean canConnect() throws InterruptedException private bool CanConnect() { ListenSocketAddress socketAddress = _server.address(); ChannelFuture channelFuture = _bootstrap.connect(socketAddress.Hostname, socketAddress.Port); _channel = channelFuture.channel(); return(channelFuture.await().Success); }
public override void Close() { Channel rawChannel = rawChannel(); if (rawChannel.Open) { rawChannel.close().syncUninterruptibly(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotCloseUnderlyingChannelWhenItIsClosed() internal virtual void ShouldNotCloseUnderlyingChannelWhenItIsClosed() { Channel channel = ChannelMock(false); BoltChannel boltChannel = new BoltChannel("bolt-1", "bolt", channel); boltChannel.Close(); verify(channel, never()).close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldCloseUnderlyingChannelWhenItIsOpen() internal virtual void ShouldCloseUnderlyingChannelWhenItIsOpen() { Channel channel = ChannelMock(true); BoltChannel boltChannel = new BoltChannel("bolt-1", "bolt", channel); boltChannel.Close(); verify(channel).close(); }
private static Channel ChannelMock(bool open) { Channel channel = mock(typeof(Channel)); when(channel.Open).thenReturn(open); ChannelFuture channelFuture = mock(typeof(ChannelFuture)); when(channel.close()).thenReturn(channelFuture); return(channel); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private <O extends org.neo4j.causalclustering.protocol.ProtocolInstaller_Orientation, BUILDER extends NettyPipelineBuilder<O,BUILDER>> BUILDER create(io.netty.channel.Channel channel, BUILDER nettyPipelineBuilder) throws Exception private BUILDER Create <O, BUILDER>(Channel channel, BUILDER nettyPipelineBuilder) where O : Org.Neo4j.causalclustering.protocol.ProtocolInstaller_Orientation where BUILDER : NettyPipelineBuilder <O, BUILDER> { int i = 0; foreach (ChannelHandler handler in _wrapper.handlersFor(channel)) { nettyPipelineBuilder.add(string.Format("{0}_{1:D}", _wrapper.name(), i), handler); i++; } return(nettyPipelineBuilder); }
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); }); } }); } }
public override void Acquire(Channel channel) { }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public ServerNettyPipelineBuilder server(io.netty.channel.Channel channel, org.neo4j.logging.Log log) throws Exception public virtual ServerNettyPipelineBuilder Server(Channel channel, Log log) { return(Create(channel, NettyPipelineBuilder.Server(channel.pipeline(), log))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public ClientNettyPipelineBuilder client(io.netty.channel.Channel channel, org.neo4j.logging.Log log) throws Exception public virtual ClientNettyPipelineBuilder Client(Channel channel, Log log) { return(Create(channel, NettyPipelineBuilder.Client(channel.pipeline(), log))); }
public override void Uninstall(Channel channel) { }
public override void Release(Channel channel) { }
private BoltChannel NewBoltChannel(Channel ch) { return(new BoltChannel(_connectionTracker.newConnectionId(_connector), _connector, ch)); }
public virtual void Uninstall(Channel channel) { _writeThrottle.uninstall(channel); }
public SimpleNettyChannel(io.netty.channel.Channel channel, Log log) { this._channel = channel; this._log = log; }