public boolean isOpen() { return channel.isOpen(); }
public boolean isOpen() { return channel.isOpen(); }
@Override public boolean isOpen() { return channel.isOpen(); }
/** * Closes the internal datagram channel used for sending and receiving DNS messages, and clears all DNS resource * records from the cache. Attempting to send a DNS query or to resolve a domain name will fail once this method * has been called. */ @Override public void close() { if (ch.isOpen()) { ch.close(); } }
@Override public boolean isAvailable() { return channel.isOpen() && channel.isActive(); } }
@Override public boolean isAvailable() { return channel.isOpen() && channel.isActive(); } }
@Override public void channelUnregistered(ChannelHandlerContext ctx) { ctx.fireChannelUnregistered(); // Remove all handlers sequentially if channel is closed and unregistered. if (!channel.isOpen()) { destroy(); } }
@Override public void channelUnregistered(ChannelHandlerContext ctx) { ctx.fireChannelUnregistered(); // Remove all handlers sequentially if channel is closed and unregistered. if (!channel.isOpen()) { destroy(); } }
protected abstract void run(ChannelHandlerContext ctx); }
@Override public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { ctx.fireChannelUnregistered(); // Remove all handlers sequentially if channel is closed and unregistered. if (!channel.isOpen()) { destroy(); } }
@Override public int getInterestOps() { // This might not be 100% right, but it's only used for printing // connection info in the netty implementation so it's probably ok. if (channel == null || !channel.isOpen()) { return 0; } int interestOps = 0; if (!throttled.get()) { interestOps |= SelectionKey.OP_READ; } if (!channel.isWritable()) { // OP_READ means "can read", but OP_WRITE means "cannot write", // it's weird. interestOps |= SelectionKey.OP_WRITE; } return interestOps; }
@Override public void close() { Channel rawChannel = rawChannel(); if ( rawChannel.isOpen() ) { rawChannel.close().syncUninterruptibly(); } }
@Override public Future<Void> sendCloseFrame(int statusCode, String reasonText) { if (channel.isOpen()) { return channel.writeAndFlush(new CloseWebSocketFrame(1000, "normal closure")); } return ImmediateEventExecutor.INSTANCE.newSucceededFuture(null); }
protected boolean isValidFromPool(PooledConnection conn) { return conn.isActive() && conn.getChannel().isOpen(); }
@Override public void exceptionCaught(ChannelHandlerContext chctx, final Throwable t) throws Exception { Channel ch = chctx.channel(); // Don't remove the connection at this point, or the handleClosed won't be called when channelInactive is called! C connection = getConnection(); if (connection != null) { context.executeFromIO(v -> { try { if (ch.isOpen()) { ch.close(); } } catch (Throwable ignore) { } connection.handleException(t); }); } else { ch.close(); } }
public static String channelInfoForLogging(Channel ch) { if (ch == null) { return "null"; } String channelInfo = ch.toString() + ", active=" + ch.isActive() + ", open=" + ch.isOpen() + ", registered=" + ch.isRegistered() + ", writable=" + ch.isWritable() + ", id=" + ch.id(); CurrentPassport passport = CurrentPassport.fromChannel(ch); return "Channel: " + channelInfo + ", Passport: " + String.valueOf(passport); } }
private static Channel channelMock( boolean open ) { Channel channel = mock( Channel.class ); when( channel.isOpen() ).thenReturn( open ); ChannelFuture channelFuture = mock( ChannelFuture.class ); when( channel.close() ).thenReturn( channelFuture ); return channel; } }
@Override public void sendResponse(ReplyHeader h, Record r, String tag, String cacheKey, Stat stat) throws IOException { // cacheKey and stat are used in caching, which is not // implemented here. Implementation example can be found in NIOServerCnxn. if (closingChannel || !channel.isOpen()) { return; } sendBuffer(serialize(h, r, tag, cacheKey, stat)); decrOutstandingAndCheckThrottle(h); }
protected boolean isValidFromPool(PooledConnection conn) { return conn.isActive() && conn.getChannel().isOpen(); }
public static String channelInfoForLogging(Channel ch) { if (ch == null) { return "null"; } String channelInfo = ch.toString() + ", active=" + ch.isActive() + ", open=" + ch.isOpen() + ", registered=" + ch.isRegistered() + ", writable=" + ch.isWritable() + ", id=" + ch.id(); CurrentPassport passport = CurrentPassport.fromChannel(ch); return "Channel: " + channelInfo + ", Passport: " + String.valueOf(passport); } }