Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CC004200C34 for ; Mon, 27 Feb 2017 21:25:30 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CA957160B60; Mon, 27 Feb 2017 20:25:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 21359160B5B for ; Mon, 27 Feb 2017 21:25:29 +0100 (CET) Received: (qmail 520 invoked by uid 500); 27 Feb 2017 20:25:29 -0000 Mailing-List: contact reviews-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@spark.apache.org Received: (qmail 509 invoked by uid 99); 27 Feb 2017 20:25:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Feb 2017 20:25:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 06E46DFB0E; Mon, 27 Feb 2017 20:25:29 +0000 (UTC) From: mgummelt To: reviews@spark.apache.org Reply-To: reviews@spark.apache.org References: In-Reply-To: Subject: [GitHub] spark pull request #17031: [SPARK-19702][MESOS] Add suppress/revive support ... Content-Type: text/plain Message-Id: <20170227202529.06E46DFB0E@git1-us-west.apache.org> Date: Mon, 27 Feb 2017 20:25:29 +0000 (UTC) archived-at: Mon, 27 Feb 2017 20:25:31 -0000 Github user mgummelt commented on a diff in the pull request: https://github.com/apache/spark/pull/17031#discussion_r103303283 --- Diff: resource-managers/mesos/src/main/scala/org/apache/spark/scheduler/cluster/mesos/MesosClusterScheduler.scala --- @@ -737,13 +735,75 @@ private[spark] class MesosClusterScheduler( if (index != -1) { pendingRetryDrivers.remove(index) pendingRetryDriversState.expunge(id) + suppressOrRevive() true } else { false } } - def getQueuedDriversSize: Int = queuedDrivers.size - def getLaunchedDriversSize: Int = launchedDrivers.size - def getPendingRetryDriversSize: Int = pendingRetryDrivers.size + private def copyBuffer(buffer: ArrayBuffer[MesosDriverDescription]): + ArrayBuffer[MesosDriverDescription] = { + val newBuffer = new ArrayBuffer[MesosDriverDescription](buffer.size) + buffer.copyToBuffer(newBuffer) + newBuffer + } + + /** + * Check if the task state is a recoverable state that we can relaunch the task. + * Task state like TASK_ERROR are not relaunchable state since it wasn't able + * to be validated by Mesos. + */ + private def isFailure(state: MesosTaskState): Boolean = { + state == MesosTaskState.TASK_FAILED || + state == MesosTaskState.TASK_LOST + } + + private def shouldSuppress: Boolean = { + return queuedDrivers.isEmpty && pendingRetryDrivers.isEmpty + } + + private def suppressOrRevive(): Unit = { + if (shouldSuppress && !isSuppressed) { + logInfo("Suppressing Offers.") + driver.suppressOffers() + isSuppressed = true + } else if (!shouldSuppress && isSuppressed) { + logInfo("Reviving Offers.") + driver.reviveOffers() + isSuppressed = false + } + } + + /** + * Escape args for Unix-like shells, unless already quoted by the user. + * Based on: http://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html + * and http://www.grymoire.com/Unix/Quote.html + * + * @param value argument + * @return escaped argument + */ + private[scheduler] def shellEscape(value: String): String = { + val WrappedInQuotes = """^(".+"|'.+')$""".r + val ShellSpecialChars = (""".*([ '<>&|\?\*;!#\\(\)"$`]).*""").r --- End diff -- see above --- 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