Github user BryanCutler commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6205#discussion_r31776161
  
    --- Diff: core/src/main/scala/org/apache/spark/rpc/RpcEnv.scala ---
    @@ -182,3 +185,130 @@ private[spark] object RpcAddress {
         RpcAddress(host, port)
       }
     }
    +
    +
    +/**
    + * An exception thrown if RpcTimeout modifies a [[TimeoutException]].
    + */
    +private[rpc] class RpcTimeoutException(message: String)
    +  extends TimeoutException(message)
    +
    +
    +/**
    + * Associates a timeout with a description so that a when a 
TimeoutException occurs, additional
    + * context about the timeout can be amended to the exception message.
    + * @param timeout timeout duration in seconds
    + * @param description description to be displayed in a timeout exception
    + */
    +private[spark] class RpcTimeout(timeout: FiniteDuration, description: 
String) {
    +
    +  /** Get the timeout duration */
    +  def duration: FiniteDuration = timeout
    +
    +  /** Get the message associated with this timeout */
    +  def message: String = description
    +
    +  /** Amends the standard message of TimeoutException to include the 
description */
    +  def createRpcTimeoutException(te: TimeoutException): RpcTimeoutException 
= {
    +    new RpcTimeoutException(te.getMessage() + " " + description)
    +  }
    +
    +  /**
    +   * Add a callback to the given Future so that if it completes as failed 
with a TimeoutException
    +   * then the timeout description is added to the message
    +   */
    +  def addMessageIfTimeout[T](future: Future[T]): Future[T] = {
    +    future.recover {
    +      // Add a warning message if Future is passed to 
addMessageIfTimeoutTest more than once
    +      case rte: RpcTimeoutException => throw new 
RpcTimeoutException(rte.getMessage() +
    +        " (Future has multiple calls to 
RpcTimeout.addMessageIfTimeoutTest)")
    +      // Any other TimeoutException get converted to a RpcTimeoutException 
with modified message
    --- End diff --
    
    I noticed that it's ends up pretty easy to call this function multiple 
times on the same future, and it basically keeps chaining together `recover` 
callbacks.  This won't cause an error, but maybe not ideal, so I though adding 
a warning might help.  Actually, as I'm typing this I realized that this 
warning message could get added multiple times too, so maybe it's best to just 
take this out.  Uggh, haha!


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to