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

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

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

ChannelFuture.setFailure介绍

暂无

代码示例

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

@Override
  public void operationComplete(ChannelFuture f)
      throws Exception {
    if (!cf.isDone()) {
      cf.setFailure(new ClosedChannelException());
    }
  }
});

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

private void processConnectTimeout(Set<SelectionKey> keys, long currentTimeNanos) {
  ConnectException cause = null;
  for (SelectionKey k: keys) {
    if (!k.isValid()) {
      continue;
    }
    SctpClientChannel ch = (SctpClientChannel) k.attachment();
    if (ch.connectDeadlineNanos > 0 &&
        currentTimeNanos >= ch.connectDeadlineNanos) {
      if (cause == null) {
        cause = new ConnectException("connection timed out");
      }
      ch.connectFuture.setFailure(cause);
      fireExceptionCaught(ch, cause);
      ch.worker.close(ch, succeededFuture(ch));
    }
  }
}

代码示例来源:origin: stackoverflow.com

public ChannelFuture handshake() {
   ...
   if (exception == null) { // Began handshake successfully.
     try {
       final ChannelFuture hsFuture = handshakeFuture;
       wrapNonAppData(ctx, channel).addListener(new ChannelFutureListener() {
         public void operationComplete(ChannelFuture future) throws Exception {
           if (!future.isSuccess()) {
             Throwable cause = future.getCause();
             hsFuture.setFailure(cause);
             fireExceptionCaught(ctx, cause);
             if (closeOnSSLException) {
               Channels.close(ctx, future(channel));
             }
           } else {
             hsFuture.setSuccess();
           }
         }
       });
     } catch (SSLException e) {

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

private void connect(SelectionKey k) {
  SctpClientChannel ch = (SctpClientChannel) k.attachment();
  try {
    if (ch.channel.finishConnect()) {
      k.cancel();
      ch.worker.register(ch, ch.connectFuture);
    }
  } catch (Throwable t) {
    ch.connectFuture.setFailure(t);
    fireExceptionCaught(ch, t);
    k.cancel(); // Some JDK implementations run into an infinite loop without this.
    ch.worker.close(ch, succeededFuture(ch));
  }
}

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

private void unbindAddress(
    SctpServerChannelImpl channel, ChannelFuture future,
    InetAddress localAddress) {
  try {
    channel.serverChannel.unbindAddress(localAddress);
    future.setSuccess();
  } catch (Throwable t) {
    future.setFailure(t);
    fireExceptionCaught(channel, t);
  }
}

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

private void unbindAddress(
    SctpClientChannel channel, ChannelFuture future,
    InetAddress localAddress) {
  try {
    channel.channel.unbindAddress(localAddress);
    future.setSuccess();
  } catch (Throwable t) {
    future.setFailure(t);
    fireExceptionCaught(channel, t);
  }
}

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

private void bindAddress(
    SctpClientChannel channel, ChannelFuture future,
    InetAddress localAddress) {
  try {
    channel.channel.bindAddress(localAddress);
    future.setSuccess();
  } catch (Throwable t) {
    future.setFailure(t);
    fireExceptionCaught(channel, t);
  }
}

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

private void bindAddress(
    SctpServerChannelImpl channel, ChannelFuture future,
    InetAddress localAddress) {
  try {
    channel.serverChannel.bindAddress(localAddress);
    future.setSuccess();
  } catch (Throwable t) {
    future.setFailure(t);
    fireExceptionCaught(channel, t);
  }
}

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

future.setFailure(cce);
  fireExceptionCaught(channel, cce);
} catch (Throwable t) {
  future.setFailure(t);
  fireExceptionCaught(channel, t);

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

channel.currentWriteEvent = null;
evt = null;
future.setFailure(cause);
fireExceptionCaught = true;
    break;
  evt.getFuture().setFailure(cause);
  fireExceptionCaught = true;

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

private void connect(
    final SctpClientChannel channel, final ChannelFuture cf,
    SocketAddress remoteAddress) {
  try {
    if (channel.channel.connect(remoteAddress)) {
      channel.worker.register(channel, cf);
    } else {
      channel.getCloseFuture().addListener(new ChannelFutureListener() {
        @Override
        public void operationComplete(ChannelFuture f)
            throws Exception {
          if (!cf.isDone()) {
            cf.setFailure(new ClosedChannelException());
          }
        }
      });
      cf.addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
      channel.connectFuture = cf;
      boss.register(channel);
    }
  } catch (Throwable t) {
    cf.setFailure(t);
    fireExceptionCaught(channel, t);
    channel.worker.close(channel, succeededFuture(channel));
  }
}

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

private void bind(
    SctpClientChannel channel, ChannelFuture future,
    SocketAddress localAddress) {
  try {
    channel.channel.bind(localAddress);
    channel.boundManually = true;
    channel.setBound();
    future.setSuccess();
    fireChannelBound(channel, channel.getLocalAddress());
  } catch (Throwable t) {
    future.setFailure(t);
    fireExceptionCaught(channel, t);
  }
}

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

future.setFailure(t);
fireExceptionCaught(channel, t);

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

if (localAddress == null || remoteAddress == null) {
  if (future != null) {
    future.setFailure(new ClosedChannelException());
    future.setFailure(e);

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

void close(SctpChannelImpl channel, ChannelFuture future) {
  boolean connected = channel.isConnected();
  boolean bound = channel.isBound();
  try {
    channel.channel.close();
    cancelledKeys++;
    if (channel.setClosed()) {
      future.setSuccess();
      if (connected) {
        fireChannelDisconnected(channel);
      }
      if (bound) {
        fireChannelUnbound(channel);
      }
      cleanUpWriteBuffer(channel);
      fireChannelClosed(channel);
    } else {
      future.setSuccess();
    }
  } catch (Throwable t) {
    future.setFailure(t);
    fireExceptionCaught(channel, t);
  }
}

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

private void bind(
    SctpServerChannelImpl channel, ChannelFuture future,
    SocketAddress localAddress) {
  boolean bound = false;
  boolean bossStarted = false;
  try {
    channel.serverChannel.bind(localAddress, channel.getConfig().getBacklog());
    bound = true;
    channel.setBound();
    future.setSuccess();
    fireChannelBound(channel, channel.getLocalAddress());
    Executor bossExecutor =
      ((SctpServerSocketChannelFactory) channel.getFactory()).bossExecutor;
    DeadLockProofWorker.start(bossExecutor, new Boss(channel));
    bossStarted = true;
  } catch (Throwable t) {
    future.setFailure(t);
    fireExceptionCaught(channel, t);
  } finally {
    if (!bossStarted && bound) {
      close(channel, future);
    }
  }
}

代码示例来源:origin: org.jboss.errai.io.netty/netty-transport-sctp

buf = null;
evt = null;
future.setFailure(t);
fireExceptionCaught(channel, t);
if (t instanceof IOException) {

相关文章