spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenghao-intel <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-12196][Core] Store blocks in storage de...
Date Wed, 09 Dec 2015 14:39:36 GMT
Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10225#discussion_r47097655
  
    --- Diff: core/src/main/scala/org/apache/spark/storage/DiskBlockManager.scala ---
    @@ -80,6 +77,65 @@ private[spark] class DiskBlockManager(blockManager: BlockManager, conf:
SparkCon
         new File(subDir, filename)
       }
     
    +  def getFileDefault(filename: String): File = {
    +    _getFile(filename, localDirs)
    +  }
    +  var getFile = getFileDefault _
    +
    +  private val hierarchyStore = conf.getOption("spark.storage.hierarchyStore")
    +  if (hierarchyStore.isDefined) {
    +    val HSLayers: Array[(String, Long)] =
    +      hierarchyStore.get.trim.split(",").map {
    +        s => val x = s.trim.split(" +")
    +          (x(0), Utils.byteStringAsGb(x(1)))
    +      }
    +    val HSLayerDirs: Array[Array[File]] = HSLayers.map(
    +      s => localDirs.filter(_.getPath().toLowerCase().containsSlice(s._1))
    +    )
    +    val lastLayer = localDirs.filter {
    +      dir => var found = false
    +        for(dirs <- HSLayerDirs if !found)
    +          if (dirs.contains(dir)) found = true
    +        !found
    +    }
    +    val (finalHSLayers, finalHSLayerDirs) = if (!lastLayer.isEmpty) {
    +      (HSLayers :+ ("Backup Storage", 0.toLong), HSLayerDirs :+ lastLayer)
    +    } else {
    +      val len = HSLayers.length
    +      (HSLayers.take(len-1) :+ (HSLayers(len-1)._1, -1.toLong), HSLayerDirs)
    +    }
    +    for (i <- 0 until finalHSLayers.length) {
    +      val s = finalHSLayers(i)
    +      logInfo("Layer: %s, Threshold: %dGB".format(s._1, s._2))
    +      finalHSLayerDirs(i).foreach {
    +        x => logInfo("\t%s".format(x.getPath()))
    +      }
    +    }
    +
    +    def getFileHierarchy(filename: String): File = {
    +      // serach existing file in each layer
    +      var candidateFiles = new scala.collection.immutable.HashMap[Int, File]
    +      for ((dirs, i) <- finalHSLayerDirs.zipWithIndex if !dirs.isEmpty) {
    +        val file = _getFile(filename, dirs)
    +        if (file.exists())
    +          return file
    +        candidateFiles += (i -> file)
    +      }
    +
    +      // if not found, return file from the upper layer with enough usable space 
    +      for ((dirs, i) <- finalHSLayerDirs.zipWithIndex if !dirs.isEmpty) {
    +        val dir = dirs(Utils.nonNegativeHash(filename) % dirs.length)
    +        val usableSpace = dir.getUsableSpace() >> 30
    +        if (usableSpace >= finalHSLayers(i)._2)
    +          return candidateFiles(i)
    +      }
    +
    +      null
    --- End diff --
    
    throw exception with meaningful msg?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message