Fixing benchmarks build on non-linux systems.

This commit is contained in:
nmittler 2015-05-14 16:36:01 -07:00
parent 8f537e3ec6
commit c4c6c145af
3 changed files with 38 additions and 19 deletions

View File

@ -32,16 +32,20 @@ configurations {
}
dependencies {
compile project(':grpc-core'),
project(':grpc-netty'),
project(':grpc-okhttp'),
project(':grpc-stub'),
project(':grpc-integration-testing'),
libraries.junit,
libraries.mockito,
libraries.hdrhistogram,
libraries.netty_tcnative,
libraries.netty_transport_native_epoll
List deps = [project(':grpc-core'),
project(':grpc-netty'),
project(':grpc-okhttp'),
project(':grpc-stub'),
project(':grpc-integration-testing'),
libraries.junit,
libraries.mockito,
libraries.hdrhistogram]
if (osdetector.os == "linux") {
// These are only available on linux.
deps += [libraries.netty_tcnative, libraries.netty_transport_native_epoll]
}
compile deps
alpnboot alpnboot_package_name
}

View File

@ -72,8 +72,6 @@ import io.grpc.transport.netty.NegotiationType;
import io.grpc.transport.netty.NettyChannelBuilder;
import io.grpc.transport.okhttp.OkHttpChannelBuilder;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.ssl.SslContext;
@ -201,8 +199,18 @@ public class AsyncClient {
final EventLoopGroup group;
final Class<? extends io.netty.channel.Channel> channelType;
if (config.nettyNativeTransport) {
group = new EpollEventLoopGroup();
channelType = EpollSocketChannel.class;
try {
// These classes are only available on linux.
Class<?> groupClass = Class.forName("io.netty.channel.epoll.EpollEventLoopGroup");
@SuppressWarnings("unchecked")
Class<? extends io.netty.channel.Channel> channelClass =
(Class<? extends io.netty.channel.Channel>) Class.forName(
"io.netty.channel.epoll.EpollSocketChannel");
group = (EventLoopGroup) groupClass.newInstance();
channelType = channelClass;
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
group = new NioEventLoopGroup();
channelType = NioSocketChannel.class;

View File

@ -50,8 +50,6 @@ import io.grpc.transport.netty.GrpcSslContexts;
import io.grpc.transport.netty.NettyServerBuilder;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ServerChannel;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollServerSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.ssl.SslContext;
@ -104,9 +102,18 @@ public class AsyncServer {
final EventLoopGroup worker;
final Class<? extends ServerChannel> channelType;
if (nettyNativeTransport) {
boss = new EpollEventLoopGroup();
worker = new EpollEventLoopGroup();
channelType = EpollServerSocketChannel.class;
try {
// These classes are only available on linux.
Class<?> groupClass = Class.forName("io.netty.channel.epoll.EpollEventLoopGroup");
@SuppressWarnings("unchecked")
Class<? extends ServerChannel> channelClass = (Class<? extends ServerChannel>)
Class.forName("io.netty.channel.epoll.EpollServerSocketChannel");
boss = (EventLoopGroup) groupClass.newInstance();
worker = (EventLoopGroup) groupClass.newInstance();
channelType = channelClass;
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
boss = new NioEventLoopGroup();
worker = new NioEventLoopGroup();