AbstractNioUnsafe Class — netty Architecture
Architecture documentation for the AbstractNioUnsafe class in AbstractNioChannel.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 60188589_9b31_b825_db5f_7e5167ad54a1["AbstractNioUnsafe"] 9ebed286_fd2b_0f44_ed7f_f94498c8773b["AbstractNioChannel.java"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|defined in| 9ebed286_fd2b_0f44_ed7f_f94498c8773b 52cb1857_2882_7fd9_866b_ec40ca61b7be["close()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| 52cb1857_2882_7fd9_866b_ec40ca61b7be 71e37fc0_acbb_f367_f9f6_1f546b8444b7["SelectableChannel()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| 71e37fc0_acbb_f367_f9f6_1f546b8444b7 961e6b73_3562_ad4c_959d_77b8829254dd["Channel()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| 961e6b73_3562_ad4c_959d_77b8829254dd f3370502_af32_7af0_6bff_8d702531e791["removeReadOp()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| f3370502_af32_7af0_6bff_8d702531e791 7ffc6a56_2e62_6b7e_705f_75d97f5f0b56["connect()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| 7ffc6a56_2e62_6b7e_705f_75d97f5f0b56 123c8fda_87a2_fec2_8833_5ca69a354b9a["fulfillConnectPromise()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| 123c8fda_87a2_fec2_8833_5ca69a354b9a 82689713_a74b_195b_07e2_42d37565a5fd["finishConnect()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| 82689713_a74b_195b_07e2_42d37565a5fd afd18d97_4155_10d7_5b22_fdfe463461e9["flush0()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| afd18d97_4155_10d7_5b22_fdfe463461e9 ee4ba70f_6432_ee95_0d18_6a00459e9126["forceFlush()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| ee4ba70f_6432_ee95_0d18_6a00459e9126 9bbdc096_10fa_ffe5_3b06_e50964915e0f["isFlushPending()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| 9bbdc096_10fa_ffe5_3b06_e50964915e0f f0fa666e_fa90_46ee_6be6_10964a525a9b["handle()"] 60188589_9b31_b825_db5f_7e5167ad54a1 -->|method| f0fa666e_fa90_46ee_6be6_10964a525a9b
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java lines 248–451
protected abstract class AbstractNioUnsafe extends AbstractUnsafe implements NioUnsafe, NioIoHandle {
@Override
public void close() {
close(voidPromise());
}
@Override
public SelectableChannel selectableChannel() {
return ch();
}
Channel channel() {
return AbstractNioChannel.this;
}
protected final void removeReadOp() {
IoRegistration registration = registration();
// Check first if the key is still valid as it may be canceled as part of the deregistration
// from the EventLoop
// See https://github.com/netty/netty/issues/2104
if (!registration.isValid()) {
return;
}
removeAndSubmit(readOps);
}
@Override
public final SelectableChannel ch() {
return javaChannel();
}
@Override
public final void connect(
final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) {
// Don't mark the connect promise as uncancellable as in fact we can cancel it as it is using
// non-blocking io.
if (promise.isDone() || !ensureOpen(promise)) {
return;
}
try {
if (connectPromise != null) {
// Already a connect in process.
throw new ConnectionPendingException();
}
boolean wasActive = isActive();
if (doConnect(remoteAddress, localAddress)) {
fulfillConnectPromise(promise, wasActive);
} else {
connectPromise = promise;
requestedRemoteAddress = remoteAddress;
// Schedule connect timeout.
final int connectTimeoutMillis = config().getConnectTimeoutMillis();
if (connectTimeoutMillis > 0) {
connectTimeoutFuture = eventLoop().schedule(new Runnable() {
@Override
public void run() {
ChannelPromise connectPromise = AbstractNioChannel.this.connectPromise;
if (connectPromise != null && !connectPromise.isDone()
&& connectPromise.tryFailure(new ConnectTimeoutException(
"connection timed out after " + connectTimeoutMillis + " ms: " +
remoteAddress))) {
close(voidPromise());
}
}
}, connectTimeoutMillis, TimeUnit.MILLISECONDS);
}
promise.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
// If the connect future is cancelled we also cancel the timeout and close the
// underlying socket.
if (future.isCancelled()) {
if (connectTimeoutFuture != null) {
connectTimeoutFuture.cancel(false);
}
connectPromise = null;
close(voidPromise());
Source
Frequently Asked Questions
What is the AbstractNioUnsafe class?
AbstractNioUnsafe is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java.
Where is AbstractNioUnsafe defined?
AbstractNioUnsafe is defined in transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java at line 248.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free