本文整理了Java中org.jboss.netty.channel.Channels.fireExceptionCaught()
方法的一些代码示例,展示了Channels.fireExceptionCaught()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Channels.fireExceptionCaught()
方法的具体详情如下:
包路径:org.jboss.netty.channel.Channels
类名称:Channels
方法名:fireExceptionCaught
[英]Sends a "exceptionCaught" event to the first ChannelUpstreamHandler in the ChannelPipeline of the specified Channel.
[中]将“exceptionCaught”事件发送到指定通道的ChannelPipeline中的第一个ChannelUpstreamHandler。
代码示例来源:origin: io.netty/netty
private static void bind(
OioClientSocketChannel channel, ChannelFuture future,
SocketAddress localAddress) {
try {
channel.socket.bind(localAddress);
future.setSuccess();
fireChannelBound(channel, channel.getLocalAddress());
} catch (Throwable t) {
future.setFailure(t);
fireExceptionCaught(channel, t);
}
}
代码示例来源:origin: io.netty/netty
private void discard(ChannelHandlerContext ctx, boolean fireNow) {
ClosedChannelException cause = null;
for (;;) {
MessageEvent currentEvent = this.currentEvent;
if (this.currentEvent == null) {
currentEvent = queue.poll();
} else {
this.currentEvent = null;
}
if (currentEvent == null) {
break;
}
Object m = currentEvent.getMessage();
if (m instanceof ChunkedInput) {
closeInput((ChunkedInput) m);
}
// Trigger a ClosedChannelException
if (cause == null) {
cause = new ClosedChannelException();
}
currentEvent.getFuture().setFailure(cause);
}
if (cause != null) {
if (fireNow) {
fireExceptionCaught(ctx.getChannel(), cause);
} else {
fireExceptionCaughtLater(ctx.getChannel(), cause);
}
}
}
代码示例来源:origin: io.netty/netty
private static void bind(
NioClientSocketChannel channel, ChannelFuture future,
SocketAddress localAddress) {
try {
channel.channel.socket().bind(localAddress);
channel.boundManually = true;
channel.setBound();
future.setSuccess();
fireChannelBound(channel, channel.getLocalAddress());
} catch (Throwable t) {
future.setFailure(t);
fireExceptionCaught(channel, t);
}
}
代码示例来源:origin: io.netty/netty
static void disconnect(OioDatagramChannel channel, ChannelFuture future) {
boolean connected = channel.isConnected();
boolean iothread = isIoThread(channel);
try {
channel.socket.disconnect();
future.setSuccess();
if (connected) {
// Notify.
if (iothread) {
fireChannelDisconnected(channel);
} else {
fireChannelDisconnectedLater(channel);
}
}
} catch (Throwable t) {
future.setFailure(t);
if (iothread) {
fireExceptionCaught(channel, t);
} else {
fireExceptionCaughtLater(channel, t);
}
}
}
}
代码示例来源:origin: io.netty/netty
final int size = futures.size();
for (int i = 0; i < size; i ++) {
futures.get(i).setFailure(cause);
fireExceptionCaught(ctx, cause);
代码示例来源:origin: io.netty/netty
if (out == null) {
Exception e = new ClosedChannelException();
future.setFailure(e);
if (iothread) {
fireExceptionCaught(channel, e);
} else {
fireExceptionCaughtLater(channel, e);
t = new ClosedChannelException();
future.setFailure(t);
if (iothread) {
fireExceptionCaught(channel, t);
} else {
fireExceptionCaughtLater(channel, t);
代码示例来源:origin: io.netty/netty
/**
* Fail all buffered writes that are left. See
* <a href="https://github.com/netty/netty/issues/308>#308</a> for more details.
*/
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
Throwable cause = null;
for (;;) {
MessageEvent ev = queue.poll();
if (ev == null) {
break;
}
if (cause == null) {
cause = new ClosedChannelException();
}
ev.getFuture().setFailure(cause);
}
if (cause != null) {
Channels.fireExceptionCaught(ctx.getChannel(), cause);
}
super.channelClosed(ctx, e);
}
代码示例来源:origin: io.netty/netty
static void disconnect(NioDatagramChannel channel, ChannelFuture future) {
boolean connected = channel.isConnected();
boolean iothread = isIoThread(channel);
try {
channel.getDatagramChannel().disconnect();
future.setSuccess();
if (connected) {
if (iothread) {
fireChannelDisconnected(channel);
} else {
fireChannelDisconnectedLater(channel);
}
}
} catch (Throwable t) {
future.setFailure(t);
if (iothread) {
fireExceptionCaught(channel, t);
} else {
fireExceptionCaughtLater(channel, t);
}
}
}
代码示例来源:origin: io.netty/netty
private void processSelectedKeys(Set<SelectionKey> selectedKeys) {
// check if the set is empty and if so just return to not create garbage by
// creating a new Iterator every time even if there is nothing to process.
// See https://github.com/netty/netty/issues/597
if (selectedKeys.isEmpty()) {
return;
}
for (Iterator<SelectionKey> i = selectedKeys.iterator(); i.hasNext();) {
SelectionKey k = i.next();
i.remove();
if (!k.isValid()) {
close(k);
continue;
}
try {
if (k.isConnectable()) {
connect(k);
}
} catch (Throwable t) {
NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment();
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: io.netty/netty
future.setFailure(t);
if (iothread) {
fireExceptionCaught(channel, t);
} else {
fireExceptionCaughtLater(channel, t);
代码示例来源:origin: io.netty/netty
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));
}
}
}
});
代码示例来源:origin: io.netty/netty
future.setFailure(t);
if (iothread) {
fireExceptionCaught(channel, t);
} else {
fireExceptionCaughtLater(channel, t);
代码示例来源:origin: io.netty/netty
private static void processConnectTimeout(Set<SelectionKey> keys, long currentTimeNanos) {
for (SelectionKey k: keys) {
if (!k.isValid()) {
// Comment the close call again as it gave us major problems
// with ClosedChannelExceptions.
//
// See:
// * https://github.com/netty/netty/issues/142
// * https://github.com/netty/netty/issues/138
//
// close(k);
continue;
}
NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment();
if (ch.connectDeadlineNanos > 0 &&
currentTimeNanos >= ch.connectDeadlineNanos) {
// Create a new ConnectException everytime and not cache it as otherwise we end up with
// using the wrong remoteaddress in the ConnectException message.
//
// See https://github.com/netty/netty/issues/2713
ConnectException cause =
new ConnectTimeoutException("connection timed out: " + ch.requestedRemoteAddress);
ch.connectFuture.setFailure(cause);
fireExceptionCaught(ch, cause);
ch.worker.close(ch, succeededFuture(ch));
}
}
}
代码示例来源:origin: io.netty/netty
future.setFailure(cause);
fireExceptionCaught = true;
evt.getFuture().setFailure(cause);
fireExceptionCaught(channel, cause);
} else {
fireExceptionCaughtLater(channel, cause);
代码示例来源:origin: io.netty/netty
public void run() {
boolean bound = false;
boolean registered = false;
try {
channel.socket.socket().bind(localAddress, channel.getConfig().getBacklog());
bound = true;
future.setSuccess();
fireChannelBound(channel, channel.getLocalAddress());
channel.socket.register(selector, SelectionKey.OP_ACCEPT, channel);
registered = true;
} catch (Throwable t) {
future.setFailure(t);
fireExceptionCaught(channel, t);
} finally {
if (!registered && bound) {
close(channel, future);
}
}
}
}
代码示例来源:origin: io.netty/netty
future.setFailure(t);
if (iothread) {
fireExceptionCaught(channel, t);
} else {
fireExceptionCaughtLater(channel, t);
代码示例来源:origin: io.netty/netty
private static void close(OioServerSocketChannel channel, ChannelFuture future) {
boolean bound = channel.isBound();
try {
channel.socket.close();
// Make sure the boss thread is not running so that that the future
// is notified after a new connection cannot be accepted anymore.
// See NETTY-256 for more information.
channel.shutdownLock.lock();
try {
if (channel.setClosed()) {
future.setSuccess();
if (bound) {
fireChannelUnbound(channel);
}
fireChannelClosed(channel);
} else {
future.setSuccess();
}
} finally {
channel.shutdownLock.unlock();
}
} catch (Throwable t) {
future.setFailure(t);
fireExceptionCaught(channel, t);
}
}
代码示例来源:origin: io.netty/netty
future.setFailure(t);
if (iothread) {
fireExceptionCaught(channel, t);
} else {
fireExceptionCaughtLater(channel, t);
代码示例来源:origin: io.netty/netty
private static void bind(DefaultLocalServerChannel channel, ChannelFuture future, LocalAddress localAddress) {
try {
if (!LocalChannelRegistry.register(localAddress, channel)) {
throw new ChannelException("address already in use: " + localAddress);
}
if (!channel.bound.compareAndSet(false, true)) {
throw new ChannelException("already bound");
}
channel.localAddress = localAddress;
future.setSuccess();
fireChannelBound(channel, localAddress);
} catch (Throwable t) {
LocalChannelRegistry.unregister(localAddress);
future.setFailure(t);
fireExceptionCaught(channel, t);
}
}
代码示例来源:origin: io.netty/netty
this.currentEvent = null;
currentEvent.getFuture().setFailure(t);
if (fireNow) {
fireExceptionCaught(ctx, t);
} else {
fireExceptionCaughtLater(ctx, t);
内容来源于网络,如有侵权,请联系作者删除!