Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1907#discussion_r16135674
  
    --- Diff: core/src/main/scala/org/apache/spark/network/netty/client.scala 
---
    @@ -0,0 +1,276 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.network.netty
    +
    +import java.net.InetSocketAddress
    +import java.util.concurrent.TimeoutException
    +
    +import io.netty.bootstrap.Bootstrap
    +import io.netty.buffer.{ByteBuf, PooledByteBufAllocator}
    +import io.netty.channel.socket.SocketChannel
    +import io.netty.channel._
    +import io.netty.channel.epoll.{EpollEventLoopGroup, EpollSocketChannel}
    +import io.netty.channel.nio.NioEventLoopGroup
    +import io.netty.channel.oio.OioEventLoopGroup
    +import io.netty.channel.socket.nio.NioSocketChannel
    +import io.netty.channel.socket.oio.OioSocketChannel
    +import io.netty.handler.codec.LengthFieldBasedFrameDecoder
    +import io.netty.handler.codec.string.StringEncoder
    +import io.netty.util.CharsetUtil
    +
    +import org.apache.spark.{Logging, SparkConf}
    +import org.apache.spark.util.Utils
    +
    +
    +/**
    + * Factory for creating [[BlockFetchingClient]] by using createClient. 
This factory reuses
    + * the worker thread pool for Netty.
    + *
    + * Concurrency: It is possible to have multiple instances of this class, 
but we should only use
    + * a single instance and use that to create multiple 
[[BlockFetchingClient]]s.
    + */
    +class BlockFetchingClientFactory(conf: SparkConf) {
    +
    +  /** IO mode: nio, oio, epoll, or auto (try epoll first and then nio). */
    +  val ioMode = conf.get("spark.shuffle.io.mode", "auto").toLowerCase
    +
    +  /** Connection timeout in secs. Default 60 secs. */
    +  val connectionTimeoutMs = 
conf.getInt("spark.shuffle.io.connectionTimeout", 60) * 1000
    +
    +  /** A thread factory so the threads are named (for debugging). */
    +  val threadFactory = Utils.namedThreadFactory("spark-shuffle-client")
    +
    +  /** The following two are instantiated by the [[init]] method, depending 
the [[ioMode]]. */
    +  var socketChannelClass: Class[_ <: Channel] = _
    +  var workerGroup: EventLoopGroup = _
    +
    +  init()
    +
    +  /** Initialize [[socketChannelClass]] and [[workerGroup]] based on the 
value of [[ioMode]]. */
    +  private def init(): Unit = {
    +    def initOio(): Unit = {
    +      socketChannelClass = classOf[OioSocketChannel]
    +      workerGroup = new OioEventLoopGroup(0, threadFactory)
    +    }
    +    def initNio(): Unit = {
    +      socketChannelClass = classOf[NioSocketChannel]
    +      workerGroup = new NioEventLoopGroup(0, threadFactory)
    +    }
    +    def initEpoll(): Unit = {
    +      socketChannelClass = classOf[EpollSocketChannel]
    +      workerGroup = new EpollEventLoopGroup(0, threadFactory)
    +    }
    +
    +    ioMode match {
    +      case "nio" => initNio()
    +      case "oio" => initOio()
    +      case "epoll" => initEpoll()
    +      case "auto" =>
    +        // For auto mode, first try epoll (only available on Linux), then 
nio.
    +        try {
    +          initEpoll()
    --- End diff --
    
    That class is actually not available on the version of Netty we use (it was 
added in June I believe).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to