Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/9917#discussion_r45803882
--- Diff: core/src/main/scala/org/apache/spark/rpc/netty/Dispatcher.scala
---
@@ -106,44 +106,39 @@ private[netty] class Dispatcher(nettyEnv:
NettyRpcEnv) extends Logging {
val iter = endpoints.keySet().iterator()
while (iter.hasNext) {
val name = iter.next
- postMessage(
- name,
- _ => message,
- () => { logWarning(s"Drop $message because $name has been
stopped") })
+ postMessage(name, message,
+ (e) => logWarning(s"Message $message dropped.", e))
}
}
/** Posts a message sent by a remote endpoint. */
def postRemoteMessage(message: RequestMessage, callback:
RpcResponseCallback): Unit = {
- def createMessage(sender: NettyRpcEndpointRef): InboxMessage = {
- val rpcCallContext =
- new RemoteNettyRpcCallContext(
- nettyEnv, sender, callback, message.senderAddress,
message.needReply)
- ContentMessage(message.senderAddress, message.content,
message.needReply, rpcCallContext)
- }
-
- def onEndpointStopped(): Unit = {
- callback.onFailure(
- new SparkException(s"Could not find ${message.receiver.name} or it
has been stopped"))
- }
+ val rpcCallContext =
+ new RemoteNettyRpcCallContext(nettyEnv, callback,
message.senderAddress)
+ val rpcMessage = RpcMessage(message.senderAddress, message.content,
rpcCallContext)
+ postMessage(message.receiver.name, rpcMessage,
+ (e) => callback.onFailure(e))
+ }
- postMessage(message.receiver.name, createMessage, onEndpointStopped)
+ /** Posts a one-way message sent by a remote endpoint. */
+ def postRemoteMessage(message: RequestMessage): Unit = {
+ postMessage(message.receiver.name,
OneWayMessage(message.senderAddress, message.content),
+ (e) => throw e)
}
/** Posts a message sent by a local endpoint. */
def postLocalMessage(message: RequestMessage, p: Promise[Any]): Unit = {
- def createMessage(sender: NettyRpcEndpointRef): InboxMessage = {
- val rpcCallContext =
- new LocalNettyRpcCallContext(sender, message.senderAddress,
message.needReply, p)
- ContentMessage(message.senderAddress, message.content,
message.needReply, rpcCallContext)
- }
-
- def onEndpointStopped(): Unit = {
- p.tryFailure(
- new SparkException(s"Could not find ${message.receiver.name} or it
has been stopped"))
- }
+ val rpcCallContext =
+ new LocalNettyRpcCallContext(message.senderAddress, p)
+ val rpcMessage = RpcMessage(message.senderAddress, message.content,
rpcCallContext)
+ postMessage(message.receiver.name, rpcMessage,
+ (e) => p.tryFailure(e))
+ }
- postMessage(message.receiver.name, createMessage, onEndpointStopped)
+ /** Posts a one-way message sent by a local endpoint. */
+ def postLocalMessage(message: RequestMessage): Unit = {
+ postMessage(message.receiver.name,
OneWayMessage(message.senderAddress, message.content),
+ (e) => throw e)
--- End diff --
the body of this method is identical to `postRemoteMessage`. Should we just
have a common `postMessage` method?
---
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]