Skip to content

Commit

Permalink
Fixing benchmarks build on non-linux systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmittler committed May 14, 2015
1 parent 8f537e3 commit c4c6c14
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
24 changes: 14 additions & 10 deletions benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 12 additions & 4 deletions benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
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;
Expand Down Expand Up @@ -201,8 +199,18 @@ private Channel newChannel() throws IOException {
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;
Expand Down
17 changes: 12 additions & 5 deletions benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
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;
Expand Down Expand Up @@ -104,9 +102,18 @@ public void run(String[] args) throws Exception {
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();
Expand Down

0 comments on commit c4c6c14

Please sign in to comment.