Repository: incubator-s2graph Updated Branches: refs/heads/master c6b34cdad -> e9bb727f1
[S2GRAPH-55]: Add param to enable epoll event loop in experimental netty http server Add netty transport option. Netty experimental server can run with native transport ex) sbt 'project s2rest_netty' run -Dconfig.file=../real.conf -Dnetty.transport=native JIRA: [S2GRAPH-55] https://issues.apache.org/jira/browse/S2GRAPH-55 Pull Request: Closes #38 Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/e9bb727f Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/e9bb727f Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/e9bb727f Branch: refs/heads/master Commit: e9bb727f1909d9d326a31a326c0949d600b5de81 Parents: c6b34cd Author: daewon <[email protected]> Authored: Thu Mar 17 17:04:23 2016 +0900 Committer: daewon <[email protected]> Committed: Thu Mar 17 17:04:23 2016 +0900 ---------------------------------------------------------------------- CHANGES | 2 ++ .../org/apache/s2graph/rest/netty/Server.scala | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9bb727f/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index eeaa6e1..e1109e2 100644 --- a/CHANGES +++ b/CHANGES @@ -61,6 +61,8 @@ Release 0.12.1 - unreleased S2GRAPH-53: Refactor Storage to decide which serializer/deserializer for IndexEdge/SnapshotEdge/Vertex (Committed by DOYUNG YOON). + S2GRAPH-55: Add param to enable epoll event loop in experimental netty http server (Committed by daewon). + BUG FIXES S2GRAPH-18: Query Option "interval" is Broken. http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/e9bb727f/s2rest_netty/src/main/scala/org/apache/s2graph/rest/netty/Server.scala ---------------------------------------------------------------------- diff --git a/s2rest_netty/src/main/scala/org/apache/s2graph/rest/netty/Server.scala b/s2rest_netty/src/main/scala/org/apache/s2graph/rest/netty/Server.scala index 5eac0ba..e980fc5 100644 --- a/s2rest_netty/src/main/scala/org/apache/s2graph/rest/netty/Server.scala +++ b/s2rest_netty/src/main/scala/org/apache/s2graph/rest/netty/Server.scala @@ -25,6 +25,7 @@ import com.typesafe.config.ConfigFactory import io.netty.bootstrap.ServerBootstrap import io.netty.buffer.{ByteBuf, Unpooled} import io.netty.channel._ +import io.netty.channel.epoll.{EpollServerSocketChannel, EpollEventLoopGroup} import io.netty.channel.nio.NioEventLoopGroup import io.netty.channel.socket.SocketChannel import io.netty.channel.socket.nio.NioServerSocketChannel @@ -177,6 +178,7 @@ object NettyServer extends App { val config = ConfigFactory.load() val port = Try(config.getInt("http.port")).recover { case _ => 9000 }.get + val transport = Try(config.getString("netty.transport")).recover { case _ => "jdk" }.get // init s2graph with config val s2graph = new Graph(config)(ec) @@ -186,16 +188,21 @@ object NettyServer extends App { var isHealthy = config.getBooleanWithFallback("app.health.on", true) logger.info(s"starts with num of thread: $numOfThread, ${threadPool.getClass.getSimpleName}") + logger.info(s"transport: $transport") // Configure the server. - val bossGroup: EventLoopGroup = new NioEventLoopGroup(1) - val workerGroup: EventLoopGroup = new NioEventLoopGroup() + val (bossGroup, workerGroup, channelClass) = transport match { + case "native" => + (new EpollEventLoopGroup(1), new EpollEventLoopGroup(), classOf[EpollServerSocketChannel]) + case _ => + (new NioEventLoopGroup(1), new NioEventLoopGroup(), classOf[NioServerSocketChannel]) + } try { val b: ServerBootstrap = new ServerBootstrap() - b.option(ChannelOption.SO_BACKLOG, Int.box(2048)) + .option(ChannelOption.SO_BACKLOG, Int.box(2048)) - b.group(bossGroup, workerGroup).channel(classOf[NioServerSocketChannel]) + b.group(bossGroup, workerGroup).channel(channelClass) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer[SocketChannel] { override def initChannel(ch: SocketChannel) { @@ -206,6 +213,7 @@ object NettyServer extends App { } }) + // for check server is started logger.info(s"Listening for HTTP on /0.0.0.0:$port") val ch: Channel = b.bind(port).sync().channel() ch.closeFuture().sync()
