类io.netty.channel.kqueue.KQueueServerDomainSocketChannel源码实例Demo

下面列出了怎么用io.netty.channel.kqueue.KQueueServerDomainSocketChannel的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: reactor-netty   文件: DefaultLoopKQueue.java
@Override
@SuppressWarnings("unchecked")
public <CHANNEL extends Channel> CHANNEL getChannel(Class<CHANNEL> channelClass) {
	if (channelClass.equals(SocketChannel.class)) {
		return (CHANNEL) new KQueueSocketChannel();
	}
	if (channelClass.equals(ServerSocketChannel.class)) {
		return (CHANNEL) new KQueueServerSocketChannel();
	}
	if (channelClass.equals(DatagramChannel.class)) {
		return (CHANNEL) new KQueueDatagramChannel();
	}
	if (channelClass.equals(DomainSocketChannel.class)) {
		return (CHANNEL) new KQueueDomainSocketChannel();
	}
	if (channelClass.equals(ServerDomainSocketChannel.class)) {
		return (CHANNEL) new KQueueServerDomainSocketChannel();
	}
	throw new IllegalArgumentException("Unsupported channel type: " + channelClass.getSimpleName());
}
 
源代码2 项目: bazel   文件: HttpCacheClientTest.java
@Parameters
public static Collection createInputValues() {
  ArrayList<Object[]> parameters =
      new ArrayList<Object[]>(Arrays.asList(new Object[][] {{new InetTestServer()}}));

  if (Epoll.isAvailable()) {
    parameters.add(
        new Object[] {
          new UnixDomainServer(EpollServerDomainSocketChannel.class, EpollEventLoopGroup::new)
        });
  }

  if (KQueue.isAvailable()) {
    parameters.add(
        new Object[] {
          new UnixDomainServer(KQueueServerDomainSocketChannel.class, KQueueEventLoopGroup::new)
        });
  }

  return parameters;
}
 
源代码3 项目: serve   文件: Connector.java
public Class<? extends ServerChannel> getServerChannel() {
    if (useNativeIo && Epoll.isAvailable()) {
        return uds ? EpollServerDomainSocketChannel.class : EpollServerSocketChannel.class;
    } else if (useNativeIo && KQueue.isAvailable()) {
        return uds ? KQueueServerDomainSocketChannel.class : KQueueServerSocketChannel.class;
    }

    return NioServerSocketChannel.class;
}
 
源代码4 项目: servicetalk   文件: BuilderUtils.java
/**
 * Returns the correct {@link Class} to use with the given {@link EventLoopGroup}.
 *
 * @param group        the {@link EventLoopGroup} for which the class is needed
 * @param addressClass The class of the address that the server socket will be bound to.
 * @return the class that should be used for bootstrapping
 */
public static Class<? extends ServerChannel> serverChannel(EventLoopGroup group,
                                                           Class<? extends SocketAddress> addressClass) {
    if (useEpoll(group)) {
        return DomainSocketAddress.class.isAssignableFrom(addressClass) ? EpollServerDomainSocketChannel.class :
                EpollServerSocketChannel.class;
    } else if (useKQueue(group)) {
        return DomainSocketAddress.class.isAssignableFrom(addressClass) ? KQueueServerDomainSocketChannel.class :
                KQueueServerSocketChannel.class;
    } else {
        return NioServerSocketChannel.class;
    }
}
 
源代码5 项目: multi-model-server   文件: Connector.java
public Class<? extends ServerChannel> getServerChannel() {
    if (useNativeIo && Epoll.isAvailable()) {
        return uds ? EpollServerDomainSocketChannel.class : EpollServerSocketChannel.class;
    } else if (useNativeIo && KQueue.isAvailable()) {
        return uds ? KQueueServerDomainSocketChannel.class : KQueueServerSocketChannel.class;
    }

    return NioServerSocketChannel.class;
}
 
源代码6 项目: Jupiter   文件: SocketChannelProvider.java
@SuppressWarnings("unchecked")
@Override
public T newChannel() {
    switch (channelType) {
        case ACCEPTOR:
            switch (socketType) {
                case JAVA_NIO:
                    return (T) new NioServerSocketChannel();
                case NATIVE_EPOLL:
                    return (T) new EpollServerSocketChannel();
                case NATIVE_KQUEUE:
                    return (T) new KQueueServerSocketChannel();
                case NATIVE_EPOLL_DOMAIN:
                    return (T) new EpollServerDomainSocketChannel();
                case NATIVE_KQUEUE_DOMAIN:
                    return (T) new KQueueServerDomainSocketChannel();
                default:
                    throw new IllegalStateException("Invalid socket type: " + socketType);
            }
        case CONNECTOR:
            switch (socketType) {
                case JAVA_NIO:
                    return (T) new NioSocketChannel();
                case NATIVE_EPOLL:
                    return (T) new EpollSocketChannel();
                case NATIVE_KQUEUE:
                    return (T) new KQueueSocketChannel();
                case NATIVE_EPOLL_DOMAIN:
                    return (T) new EpollDomainSocketChannel();
                case NATIVE_KQUEUE_DOMAIN:
                    return (T) new KQueueDomainSocketChannel();
                default:
                    throw new IllegalStateException("Invalid socket type: " + socketType);
            }
        default:
            throw new IllegalStateException("Invalid channel type: " + channelType);
    }
}
 
源代码7 项目: selenium   文件: NettyClientTest.java
@Before
public void setupUnixDomainSocketServer() throws IOException, URISyntaxException {
  Class<? extends ServerDomainSocketChannel> channelType = null;

  if (Epoll.isAvailable()) {
    group = new EpollEventLoopGroup(2);
    channelType = EpollServerDomainSocketChannel.class;
  } else if (KQueue.isAvailable()) {
    group = new KQueueEventLoopGroup(2);
    channelType = KQueueServerDomainSocketChannel.class;
  }

  assumeThat(group).isNotNull();
  assumeThat(channelType).isNotNull();

  ServerBootstrap bootstrap = new ServerBootstrap()
    .group(group)
    .option(ChannelOption.SO_BACKLOG, 1024)
    .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
    .channel(channelType)
    .childHandler(new ChannelInitializer<DomainSocketChannel>() {
      @Override
      protected void initChannel(DomainSocketChannel ch) {
        ch.pipeline()
          .addLast("http-codec", new HttpServerCodec())
          .addLast("http-keep-alive", new HttpServerKeepAliveHandler())
          .addLast("http-aggregator", new HttpObjectAggregator(Integer.MAX_VALUE))
          .addLast(new SimpleChannelInboundHandler<FullHttpRequest>() {
            @Override
            protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) {
              byte[] bytes = responseText.get().getBytes(UTF_8);
              ByteBuf text = Unpooled.wrappedBuffer(bytes);
              FullHttpResponse res = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, text);
              res.headers().set(CONTENT_TYPE, MediaType.PLAIN_TEXT_UTF_8.toString());
              res.headers().set(CONTENT_LENGTH, bytes.length);

              ctx.writeAndFlush(res);
            }
          });
      }
    });

  Path temp = Files.createTempFile("domain-socket-test", "socket");
  Files.deleteIfExists(temp);

  SocketAddress address = new DomainSocketAddress(temp.toFile());
  future = bootstrap.bind(address);

  socket = new URI("unix", null, null, 0, temp.toString(), null, null);
}
 
 类所在包
 类方法
 同包方法