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

    https://github.com/apache/spark/pull/8880#discussion_r46485612
  
    --- Diff: 
core/src/main/scala/org/apache/spark/shuffle/BlockStoreShuffleReader.scala ---
    @@ -48,14 +50,25 @@ private[spark] class BlockStoreShuffleReader[K, C](
           // Note: we use getSizeAsMb when no suffix is provided for backwards 
compatibility
           SparkEnv.get.conf.getSizeAsMb("spark.reducer.maxSizeInFlight", 
"48m") * 1024 * 1024)
     
    -    // Wrap the streams for compression based on configuration
    -    val wrappedStreams = blockFetcherItr.map { case (blockId, inputStream) 
=>
    -      blockManager.wrapForCompression(blockId, inputStream)
    -    }
    -
         val ser = Serializer.getSerializer(dep.serializer)
         val serializerInstance = ser.newInstance()
     
    +    // Wrap the streams for compression and encryption based on 
configuration
    +    val wrappedStreams = blockFetcherItr.map { case (blockId, inputStream) 
=>
    +      val sparkConf = blockManager.conf
    +      if (CryptoConf.isShuffleEncrypted(sparkConf)) {
    +        if (SparkHadoopUtil.get.isYarnMode()) {
    +          val cis = CryptoStreamUtils.createCryptoInputStream(inputStream, 
sparkConf)
    +          blockManager.wrapForCompression(blockId, cis)
    +        } else {
    +          logError("Shuffle encryption is only supported in Yarn mode!")
    --- End diff --
    
    It might be better to put this check in `SparkContext`'s constructor. e.g., 
after this line:
    
        if (master == "yarn-client") System.setProperty("SPARK_YARN_MODE", 
"true")
    
    After that line, `SparkHadoopUtil.get.isYarnMode()` will return the right 
thing.


---
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