Skip to content

Commit 1394de6

Browse files
committed
[SPARK-6980] Moved MessagePrefix to createRpcTimeoutException directly
1 parent 1517721 commit 1394de6

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

core/src/main/scala/org/apache/spark/rpc/RpcEnv.scala

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,16 @@ private[rpc] class RpcTimeoutException(message: String, cause: TimeoutException)
197197
* Associates a timeout with a description so that a when a TimeoutException occurs, additional
198198
* context about the timeout can be amended to the exception message.
199199
* @param timeout timeout duration in seconds
200-
* @param description description to be displayed in a timeout exception
200+
* @param conf the configuration parameter that controls this timeout
201201
*/
202-
private[spark] class RpcTimeout(timeout: FiniteDuration, description: String) {
202+
private[spark] class RpcTimeout(timeout: FiniteDuration, val conf: String) {
203203

204204
/** Get the timeout duration */
205205
def duration: FiniteDuration = timeout
206206

207-
/** Get the message associated with this timeout */
208-
def message: String = description
209-
210207
/** Amends the standard message of TimeoutException to include the description */
211208
private def createRpcTimeoutException(te: TimeoutException): RpcTimeoutException = {
212-
new RpcTimeoutException(te.getMessage() + " " + description, te)
209+
new RpcTimeoutException(te.getMessage() + ". This timeout is controlled by " + conf, te)
213210
}
214211

215212
/**
@@ -244,8 +241,6 @@ private[spark] class RpcTimeout(timeout: FiniteDuration, description: String) {
244241

245242
private[spark] object RpcTimeout {
246243

247-
private[this] val messagePrefix = "This timeout is controlled by "
248-
249244
/**
250245
* Lookup the timeout property in the configuration and create
251246
* a RpcTimeout with the property key in the description.
@@ -255,7 +250,7 @@ private[spark] object RpcTimeout {
255250
*/
256251
def apply(conf: SparkConf, timeoutProp: String): RpcTimeout = {
257252
val timeout = { conf.getTimeAsSeconds(timeoutProp) seconds }
258-
new RpcTimeout(timeout, messagePrefix + timeoutProp)
253+
new RpcTimeout(timeout, timeoutProp)
259254
}
260255

261256
/**
@@ -268,7 +263,7 @@ private[spark] object RpcTimeout {
268263
*/
269264
def apply(conf: SparkConf, timeoutProp: String, defaultValue: String): RpcTimeout = {
270265
val timeout = { conf.getTimeAsSeconds(timeoutProp, defaultValue) seconds }
271-
new RpcTimeout(timeout, messagePrefix + timeoutProp)
266+
new RpcTimeout(timeout, timeoutProp)
272267
}
273268

274269
/**
@@ -292,6 +287,6 @@ private[spark] object RpcTimeout {
292287
}
293288
val finalProp = foundProp.getOrElse(timeoutPropList.head, defaultValue)
294289
val timeout = { Utils.timeStringAsSeconds(finalProp._2) seconds }
295-
new RpcTimeout(timeout, messagePrefix + finalProp._1)
290+
new RpcTimeout(timeout, finalProp._1)
296291
}
297292
}

core/src/test/scala/org/apache/spark/rpc/RpcEnvSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ abstract class RpcEnvSuite extends SparkFunSuite with BeforeAndAfterAll {
569569
val defaultDurationSeconds = 1
570570
val rt3 = RpcTimeout(conf, Seq(defaultProp), defaultDurationSeconds.toString + "s")
571571
assert( defaultDurationSeconds === rt3.duration.toSeconds )
572-
assert( rt3.message.contains(defaultProp) )
572+
assert( rt3.conf.contains(defaultProp) )
573573

574574
// Try to construct RpcTimeout with an unconfigured property
575575
intercept[Throwable] {

0 commit comments

Comments
 (0)