io.netty.channel.Channel.bytesBeforeWritable()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(260)

本文整理了Java中io.netty.channel.Channel.bytesBeforeWritable()方法的一些代码示例,展示了Channel.bytesBeforeWritable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Channel.bytesBeforeWritable()方法的具体详情如下:
包路径:io.netty.channel.Channel
类名称:Channel
方法名:bytesBeforeWritable

Channel.bytesBeforeWritable介绍

[英]Get how many bytes must be drained from underlying buffers until #isWritable() returns true. This quantity will always be non-negative. If #isWritable() is true then 0.
[中]获取在#isWritable()返回true之前必须从基础缓冲区中释放多少字节。该数量始终为非负。如果#isWritable()为真,则为0。

代码示例

代码示例来源:origin: YeautyYE/netty-websocket-spring-boot-starter

/**
 * Get how many bytes must be drained from underlying buffers until {@link #isWritable()} returns {@code true}.
 * This quantity will always be non-negative. If {@link #isWritable()} is {@code true} then 0.
 */
public long bytesBeforeWritable() {
  return channel.bytesBeforeWritable();
}

代码示例来源:origin: com.aliyun.angelia/angelia-remoting

@Override
public long bytesBeforeWritable() {
  return channel.bytesBeforeWritable();
}

代码示例来源:origin: com.aliyun.angelia/angelia-remoting

@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
  LOG.warn("Channel {} channelWritabilityChanged event triggered - bytesBeforeUnwritable:{},bytesBeforeWritable:{}", ctx.channel(),
    ctx.channel().bytesBeforeUnwritable(), ctx.channel().bytesBeforeWritable());
}

代码示例来源:origin: com.aliyun.angelia/angelia-remoting

@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
  LOG.warn("Channel {} channelWritabilityChanged event triggered - bytesBeforeUnwritable:{},bytesBeforeWritable:{}", ctx.channel(),
    ctx.channel().bytesBeforeUnwritable(), ctx.channel().bytesBeforeWritable());
}

代码示例来源:origin: com.aliyun.angelia/angelia-remoting

@Override
public void invokeAsync(final RemotingContext context, final AsyncHandler handler) {
  String addr = context.getAddress();
  final Channel channel = this.createIfAbsent(addr);
  if (channel != null && channel.isActive()) {
    // We support Netty's channel-level backpressure thereby respecting slow receivers on the other side.
    if (!channel.isWritable()) {
      // Note: It's up to the layer above a transport to decide whether or not to requeue a canceled write.
      LOG.warn("Channel statistics - bytesBeforeUnwritable:{},bytesBeforeWritable:{}", channel.bytesBeforeUnwritable(), channel.bytesBeforeWritable());
    }
    context.setChannel(new NettyChannelImpl(channel));
    this.invokeAsyncWithInterceptor(context, handler);
  } else {
    this.closeChannel(addr, channel);
  }
}

代码示例来源:origin: com.aliyun.angelia/angelia-remoting

@Override
public void invokeOneWay(final RemotingContext context) {
  String addr = context.getAddress();
  final Channel channel = this.createIfAbsent(addr);
  if (channel != null && channel.isActive()) {
    if (!channel.isWritable()) {
      //if (this.clientConfig.isSocketFlowControl()) {
      LOG.warn("Channel statistics - bytesBeforeUnwritable:{},bytesBeforeWritable:{}", channel.bytesBeforeUnwritable(), channel.bytesBeforeWritable());
      //throw new ServiceInvocationFailureException(String.format("Channel[%s] is not writable now", channel.toString()));
    }
    context.setChannel(new NettyChannelImpl(channel));
    this.invokeOnewayWithInterceptor(context);
  } else {
    this.closeChannel(addr, channel);
  }
}

相关文章