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/05/07 22:58:39 UTC

[GitHub] [spark] mengxr commented on a change in pull request #24374: [WIP][SPARK-27366][CORE] Support GPU Resources in Spark job scheduling

mengxr commented on a change in pull request #24374: [WIP][SPARK-27366][CORE] Support GPU Resources in Spark job scheduling
URL: https://github.com/apache/spark/pull/24374#discussion_r281857271
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/scheduler/SchedulerResourceInformation.scala
 ##########
 @@ -0,0 +1,68 @@
+/*
+ * 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.scheduler
+
+import scala.collection.mutable.ArrayBuffer
+
+import org.apache.spark.ResourceInformation
+import org.apache.spark.annotation.Evolving
+import org.apache.spark.internal.Logging
+
+/**
+ * Class to hold information about a type of Resource used by the scheduler. This
+ * is a separate class from the ResourceInformation because here its mutable because the
+ * scheduler has to update the count and addresses based on what its assigned and
+ * what is available.
+ */
+@Evolving
+private[spark] class SchedulerResourceInformation(
+    private val name: String,
+    private val units: String,
+    private var count: Long,
+    private val addresses: ArrayBuffer[String] = ArrayBuffer.empty) extends Logging {
+
+  def getName(): String = name
+  def getUnits(): String = units
+  def getCount(): Long = count
+
+  def decCount(cnt: Long): Unit = {
+    count -= cnt
+  }
+
+  def incCount(cnt: Long): Unit = {
+    count += cnt
+  }
+
+  def getAddresses(): ArrayBuffer[String] = addresses
+
+  def addAddresses(addrs: Array[String]): Unit = {
 
 Review comment:
   * The public interface should only offer `acquire(num: Int): Option[Seq[String]]`.
   * When the task finishes, it should call `release(addresses: Seq[String])`, where you should verify the addresses are valid.
   

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