io.netty.channel.epoll.Epoll类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(519)

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

Epoll介绍

[英]Tells if netty-transport-native-epoll is supported.
[中]告知是否支持netty-transport-native-epoll

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public boolean isAvailable() {
 return Epoll.isAvailable();
}

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public Throwable unavailabilityCause() {
 return Epoll.unavailabilityCause();
}

代码示例来源:origin: apache/zookeeper

/**
 * If {@link Epoll#isAvailable()} <code>== true</code>, returns
 * {@link EpollSocketChannel}, otherwise returns {@link NioSocketChannel}.
 * @return a socket channel class.
 */
public static Class<? extends SocketChannel> nioOrEpollSocketChannel() {
  if (Epoll.isAvailable()) {
    return EpollSocketChannel.class;
  } else {
    return NioSocketChannel.class;
  }
}

代码示例来源:origin: io.vertx/vertx-core

@Override
public Throwable unavailabilityCause() {
 return Epoll.unavailabilityCause();
}

代码示例来源:origin: apache/zookeeper

/**
   * If {@link Epoll#isAvailable()} <code>== true</code>, returns
   * {@link EpollServerSocketChannel}, otherwise returns
   * {@link NioServerSocketChannel}.
   * @return a server socket channel class.
   */
  public static Class<? extends ServerSocketChannel> nioOrEpollServerSocketChannel() {
    if (Epoll.isAvailable()) {
      return EpollServerSocketChannel.class;
    } else {
      return NioServerSocketChannel.class;
    }
  }
}

代码示例来源:origin: line/armeria

private static boolean isEpollAvailable() {
  // Netty epoll transport does not work with WSL (Windows Sybsystem for Linux) yet.
  // TODO(trustin): Re-enable on WSL if https://github.com/Microsoft/WSL/issues/1982 is resolved.
  return Epoll.isAvailable() && !HAS_WSLENV;
}

代码示例来源:origin: fengjiachun/Jupiter

/**
 * The native socket transport for Linux using JNI.
 */
public static boolean isNativeEPollAvailable() {
  return Epoll.isAvailable();
}

代码示例来源:origin: fengjiachun/Jupiter

/**
 * The native socket transport for Linux using JNI.
 */
public static boolean isNativeEPollAvailable() {
  return Epoll.isAvailable();
}

代码示例来源:origin: alibaba/fescar

/**
 * Enable epoll boolean.
 *
 * @return the boolean
 */
public static boolean enableEpoll() {
  return NettyBaseConfig.SERVER_CHANNEL_CLAZZ.equals(EpollServerSocketChannel.class)
    && Epoll.isAvailable();
}

代码示例来源:origin: apache/pulsar

public static void enableTriggeredMode(ServerBootstrap bootstrap) {
    if (Epoll.isAvailable()) {
      bootstrap.childOption(EpollChannelOption.EPOLL_MODE, EpollMode.LEVEL_TRIGGERED);
    }
  }
}

代码示例来源:origin: Alluxio/alluxio

private static boolean checkNettyEpollAvailable() {
 if (!Epoll.isAvailable()) {
  LOG.info("EPOLL is not available, will use NIO");
  return false;
 }
 try {
  EpollChannelOption.class.getField("EPOLL_MODE");
  LOG.info("EPOLL_MODE is available");
  return true;
 } catch (Throwable e) {
  LOG.warn("EPOLL_MODE is not supported in netty with version < 4.0.26.Final, will use NIO");
  return false;
 }
}

代码示例来源:origin: apache/incubator-shardingsphere

private EventLoopGroup createEventLoopGroup() {
  return Epoll.isAvailable() ? new EpollEventLoopGroup(1) : new NioEventLoopGroup(1);
}

代码示例来源:origin: apache/incubator-shardingsphere

private EventLoopGroup createEventLoopGroup() {
  return Epoll.isAvailable() ? new EpollEventLoopGroup(1) : new NioEventLoopGroup(1);
}

代码示例来源:origin: apache/zookeeper

/**
 * If {@link Epoll#isAvailable()} <code>== true</code>, returns a new
 * {@link EpollEventLoopGroup}, otherwise returns a new
 * {@link NioEventLoopGroup}.
 * @return a new {@link EventLoopGroup}.
 */
public static EventLoopGroup newNioOrEpollEventLoopGroup() {
  if (Epoll.isAvailable()) {
    return new EpollEventLoopGroup();
  } else {
    return new NioEventLoopGroup();
  }
}

代码示例来源:origin: Graylog2/graylog2-server

private NettyTransportType detectPlatform() {
  if (Epoll.isAvailable()) {
    LOG.debug("Using epoll for Netty transport.");
    return NettyTransportType.EPOLL;
  } else if (KQueue.isAvailable()) {
    LOG.debug("Using kqueue for Netty transport.");
    return NettyTransportType.KQUEUE;
  } else {
    LOG.debug("Using NIO for Netty transport.");
    return NettyTransportType.NIO;
  }
}

代码示例来源:origin: apache/pulsar

/**
 * @return an EventLoopGroup suitable for the current platform
 */
public static EventLoopGroup newEventLoopGroup(int nThreads, ThreadFactory threadFactory) {
  if (Epoll.isAvailable()) {
    return new EpollEventLoopGroup(nThreads, threadFactory);
  } else {
    // Fallback to NIO
    return new NioEventLoopGroup(nThreads, threadFactory);
  }
}

代码示例来源:origin: apache/rocketmq

private boolean useEpoll() {
  return RemotingUtil.isLinuxPlatform()
    && nettyServerConfig.isUseEpollNativeSelector()
    && Epoll.isAvailable();
}

代码示例来源:origin: blynkkk/blynk-server

private TransportTypeHolder(int workerThreads) {
  if (Epoll.isAvailable()) {
    log.info("Using native epoll transport.");
    bossGroup = new EpollEventLoopGroup(1);
    workerGroup = new EpollEventLoopGroup(workerThreads);
    channelClass = EpollServerSocketChannel.class;
  } else {
    bossGroup = new NioEventLoopGroup(1);
    workerGroup = new NioEventLoopGroup(workerThreads);
    channelClass = NioServerSocketChannel.class;
  }
}

代码示例来源:origin: jooby-project/jooby

private EventLoopGroup eventLoop(final int threads, final String name) {
 log.debug("netty.threads.{}({})", name, threads);
 if (Epoll.isAvailable()) {
  return new EpollEventLoopGroup(threads, new DefaultThreadFactory("epoll-" + name, false));
 }
 return new NioEventLoopGroup(threads, new DefaultThreadFactory("nio-" + name, false));
}

代码示例来源:origin: wildfly/wildfly

if (useEpoll && Epoll.isAvailable()) {
  if (useGlobalWorkerPool) {
   group = SharedEventLoopGroup.getInstance((threadFactory -> new EpollEventLoopGroup(remotingThreads, threadFactory)));

相关文章