Search in sources :

Example 1 with EpollEventLoopGroup

use of io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup in project sofa-rpc by sofastack.

the class TripleServer method constructWorkerEventLoopGroup.

private EventLoopGroup constructWorkerEventLoopGroup() {
    int workerThreads = serverConfig.getIoThreads();
    workerThreads = workerThreads <= 0 ? Runtime.getRuntime().availableProcessors() * 2 : workerThreads;
    NamedThreadFactory threadName = new NamedThreadFactory("SEV-WORKER-" + serverConfig.getPort(), serverConfig.isDaemon());
    EventLoopGroup workerGroup = serverConfig.isEpoll() ? new EpollEventLoopGroup(workerThreads, threadName) : new NioEventLoopGroup(workerThreads, threadName);
    return workerGroup;
}
Also used : EventLoopGroup(io.grpc.netty.shaded.io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoopGroup) EpollEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup) NamedThreadFactory(com.alipay.sofa.rpc.common.struct.NamedThreadFactory) EpollEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup) NioEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoopGroup)

Example 2 with EpollEventLoopGroup

use of io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup in project grpc-spring-boot-starter by yidongnan.

the class ShadedNettyGrpcServerFactory method newServerBuilder.

@Override
protected NettyServerBuilder newServerBuilder() {
    final String address = getAddress();
    final int port = getPort();
    if (address.startsWith(DOMAIN_SOCKET_ADDRESS_PREFIX)) {
        final String path = GrpcUtils.extractDomainSocketAddressPath(address);
        return NettyServerBuilder.forAddress(new DomainSocketAddress(path)).channelType(EpollServerDomainSocketChannel.class).bossEventLoopGroup(new EpollEventLoopGroup(1)).workerEventLoopGroup(new EpollEventLoopGroup());
    } else if (ANY_IP_ADDRESS.equals(address)) {
        return NettyServerBuilder.forPort(port);
    } else {
        return NettyServerBuilder.forAddress(new InetSocketAddress(InetAddresses.forString(address), port));
    }
}
Also used : EpollEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup) InetSocketAddress(java.net.InetSocketAddress) DomainSocketAddress(io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress)

Example 3 with EpollEventLoopGroup

use of io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup in project grpc-spring-boot-starter by yidongnan.

the class ShadedNettyChannelFactory method newChannelBuilder.

@Override
protected NettyChannelBuilder newChannelBuilder(final String name) {
    final GrpcChannelProperties properties = getPropertiesFor(name);
    URI address = properties.getAddress();
    if (address == null) {
        address = URI.create(name);
    }
    if (DOMAIN_SOCKET_ADDRESS_SCHEME.equals(address.getScheme())) {
        final String path = GrpcUtils.extractDomainSocketAddressPath(address.toString());
        return NettyChannelBuilder.forAddress(new DomainSocketAddress(path)).channelType(EpollDomainSocketChannel.class).eventLoopGroup(new EpollEventLoopGroup());
    } else {
        return NettyChannelBuilder.forTarget(address.toString()).defaultLoadBalancingPolicy(properties.getDefaultLoadBalancingPolicy());
    }
}
Also used : EpollEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup) EpollDomainSocketChannel(io.grpc.netty.shaded.io.netty.channel.epoll.EpollDomainSocketChannel) DomainSocketAddress(io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress) URI(java.net.URI) GrpcChannelProperties(net.devh.boot.grpc.client.config.GrpcChannelProperties)

Example 4 with EpollEventLoopGroup

use of io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup in project sofa-rpc by sofastack.

the class TripleServer method constructBossEventLoopGroup.

/**
 * default as bolt
 *
 * @return
 */
private EventLoopGroup constructBossEventLoopGroup() {
    NamedThreadFactory threadName = new NamedThreadFactory("SEV-BOSS-" + serverConfig.getPort(), serverConfig.isDaemon());
    EventLoopGroup bossGroup = serverConfig.isEpoll() ? new EpollEventLoopGroup(1, threadName) : new NioEventLoopGroup(1, threadName);
    return bossGroup;
}
Also used : EventLoopGroup(io.grpc.netty.shaded.io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoopGroup) EpollEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup) NamedThreadFactory(com.alipay.sofa.rpc.common.struct.NamedThreadFactory) EpollEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup) NioEventLoopGroup(io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoopGroup)

Aggregations

EpollEventLoopGroup (io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup)4 NamedThreadFactory (com.alipay.sofa.rpc.common.struct.NamedThreadFactory)2 EventLoopGroup (io.grpc.netty.shaded.io.netty.channel.EventLoopGroup)2 NioEventLoopGroup (io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoopGroup)2 DomainSocketAddress (io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress)2 EpollDomainSocketChannel (io.grpc.netty.shaded.io.netty.channel.epoll.EpollDomainSocketChannel)1 InetSocketAddress (java.net.InetSocketAddress)1 URI (java.net.URI)1 GrpcChannelProperties (net.devh.boot.grpc.client.config.GrpcChannelProperties)1