Home / Class/ Epoll Class — netty Architecture

Epoll Class — netty Architecture

Architecture documentation for the Epoll class in Epoll.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  02eb4829_d8ef_c827_fe57_d29f49c31e72["Epoll"]
  6d307f2e_00a5_b252_43a2_c6a291574e00["Epoll.java"]
  02eb4829_d8ef_c827_fe57_d29f49c31e72 -->|defined in| 6d307f2e_00a5_b252_43a2_c6a291574e00
  13cdd317_2150_c904_09b9_e435161847dc["isAvailable()"]
  02eb4829_d8ef_c827_fe57_d29f49c31e72 -->|method| 13cdd317_2150_c904_09b9_e435161847dc
  e48ace05_a851_1451_e0d5_3f0fd14e92df["ensureAvailability()"]
  02eb4829_d8ef_c827_fe57_d29f49c31e72 -->|method| e48ace05_a851_1451_e0d5_3f0fd14e92df
  1aabcc54_9922_7c80_beb1_0c2c62ade18d["Throwable()"]
  02eb4829_d8ef_c827_fe57_d29f49c31e72 -->|method| 1aabcc54_9922_7c80_beb1_0c2c62ade18d
  c53fb2c8_727e_d506_5332_b1676ac44632["isTcpFastOpenClientSideAvailable()"]
  02eb4829_d8ef_c827_fe57_d29f49c31e72 -->|method| c53fb2c8_727e_d506_5332_b1676ac44632
  fd917330_ed6c_ddf5_0476_b7668424aac4["isTcpFastOpenServerSideAvailable()"]
  02eb4829_d8ef_c827_fe57_d29f49c31e72 -->|method| fd917330_ed6c_ddf5_0476_b7668424aac4
  56aa3300_be86_aedb_6973_a019f89739d2["Epoll()"]
  02eb4829_d8ef_c827_fe57_d29f49c31e72 -->|method| 56aa3300_be86_aedb_6973_a019f89739d2

Relationship Graph

Source Code

transport-classes-epoll/src/main/java/io/netty/channel/epoll/Epoll.java lines 28–127

public final class Epoll {

    private static final Throwable UNAVAILABILITY_CAUSE;

    static {
        Throwable cause = null;

        if (SystemPropertyUtil.getBoolean("io.netty.transport.noNative", false)) {
            cause = new UnsupportedOperationException(
                    "Native transport was explicit disabled with -Dio.netty.transport.noNative=true");
        } else {
            FileDescriptor epollFd = null;
            FileDescriptor eventFd = null;
            try {
                epollFd = Native.newEpollCreate();
                eventFd = Native.newEventFd();
            } catch (Throwable t) {
                cause = t;
            } finally {
                if (epollFd != null) {
                    try {
                        epollFd.close();
                    } catch (Exception ignore) {
                        // ignore
                    }
                }
                if (eventFd != null) {
                    try {
                        eventFd.close();
                    } catch (Exception ignore) {
                        // ignore
                    }
                }
            }
        }
        if (cause != null) {
            InternalLogger logger = InternalLoggerFactory.getInstance(Epoll.class);
            if (logger.isTraceEnabled()) {
                logger.debug("Epoll support is not available", cause);
            } else if (logger.isDebugEnabled()) {
                logger.debug("Epoll support is not available: {}", cause.getMessage());
            }
        }
        UNAVAILABILITY_CAUSE = cause;
    }

    /**
     * Returns {@code true} if and only if the <a href="https://netty.io/wiki/native-transports.html">{@code
     * netty-transport-native-epoll}</a> is available.
     */
    public static boolean isAvailable() {
        return UNAVAILABILITY_CAUSE == null;
    }

    /**
     * Ensure that <a href="https://netty.io/wiki/native-transports.html">{@code netty-transport-native-epoll}</a> is
     * available.
     *
     * @throws UnsatisfiedLinkError if unavailable
     */
    public static void ensureAvailability() {
        if (UNAVAILABILITY_CAUSE != null) {
            throw (Error) new UnsatisfiedLinkError(
                    "failed to load the required native library").initCause(UNAVAILABILITY_CAUSE);
        }
    }

    /**
     * Returns the cause of unavailability of <a href="https://netty.io/wiki/native-transports.html">
     * {@code netty-transport-native-epoll}</a>.
     *
     * @return the cause if unavailable. {@code null} if available.
     */
    public static Throwable unavailabilityCause() {
        return UNAVAILABILITY_CAUSE;
    }

    /**
     * Returns {@code true} if the epoll native transport is both {@linkplain #isAvailable() available} and supports
     * {@linkplain ChannelOption#TCP_FASTOPEN_CONNECT client-side TCP FastOpen}.
     *

Frequently Asked Questions

What is the Epoll class?
Epoll is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/Epoll.java.
Where is Epoll defined?
Epoll is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/Epoll.java at line 28.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free