You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/08/02 15:29:59 UTC

[GitHub] [spark] tgravescs commented on a change in pull request #25047: [WIP][SPARK-27371][CORE] Support GPU-aware resources scheduling in Standalone

tgravescs commented on a change in pull request #25047: [WIP][SPARK-27371][CORE] Support GPU-aware resources scheduling in Standalone
URL: https://github.com/apache/spark/pull/25047#discussion_r310143075
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/deploy/StandaloneResourceUtils.scala
 ##########
 @@ -0,0 +1,347 @@
+/*
+ * 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.deploy
+
+import java.io.{File, RandomAccessFile}
+import java.nio.channels.{FileLock, OverlappingFileLockException}
+import java.nio.file.Files
+
+import scala.collection.mutable
+import scala.util.Random
+import scala.util.control.NonFatal
+
+import org.json4s.{DefaultFormats, Extraction}
+import org.json4s.jackson.JsonMethods.{compact, parse, render}
+
+import org.apache.spark.{SparkConf, SparkException}
+import org.apache.spark.internal.Logging
+import org.apache.spark.internal.config.{SPARK_RESOURCES_COORDINATE, SPARK_RESOURCES_DIR}
+import org.apache.spark.resource.{ResourceAllocation, ResourceID, ResourceInformation, ResourceRequirement}
+import org.apache.spark.resource.ResourceUtils.{parseResourceRequirements, withResourcesJson}
+import org.apache.spark.util.Utils
+
+private[spark] object StandaloneResourceUtils extends Logging {
+  // These directory/files are used to coordinate the resources between
+  // the drivers/workers on the host in Spark Standalone.
+  val SPARK_RESOURCES_COORDINATE_DIR = "spark-resources"
+  val ALLOCATED_RESOURCES_FILE = "__allocated_resources__.json"
+  val RESOURCES_LOCK_FILE = "__allocated_resources__.lock"
+
+  /**
+   * Resource allocation used in Standalone only, which tracks assignments with
+   * worker/driver(client only) pid.
+   */
+  case class StandaloneResourceAllocation(pid: Int, allocations: Seq[ResourceAllocation]) {
+    // convert allocations to a resource information map
+    def toResourceInformationMap: Map[String, ResourceInformation] = {
+      allocations.map { allocation =>
+        allocation.id.resourceName -> allocation.toResourceInformation
+      }.toMap
+    }
+  }
+
+  /**
+   * Assign resources to workers/drivers from the same host to avoid address conflict.
 
 Review comment:
   assigns if the needs coordinate config is on

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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