{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/45803882","id":45803882,"diff_hunk":"@@ -106,44 +106,39 @@ private[netty] class Dispatcher(nettyEnv: NettyRpcEnv) extends Logging {\n     val iter = endpoints.keySet().iterator()\n     while (iter.hasNext) {\n       val name = iter.next\n-      postMessage(\n-        name,\n-        _ => message,\n-        () => { logWarning(s\"Drop $message because $name has been stopped\") })\n+      postMessage(name, message,\n+        (e) => logWarning(s\"Message $message dropped.\", e))\n     }\n   }\n \n   /** Posts a message sent by a remote endpoint. */\n   def postRemoteMessage(message: RequestMessage, callback: RpcResponseCallback): Unit = {\n-    def createMessage(sender: NettyRpcEndpointRef): InboxMessage = {\n-      val rpcCallContext =\n-        new RemoteNettyRpcCallContext(\n-          nettyEnv, sender, callback, message.senderAddress, message.needReply)\n-      ContentMessage(message.senderAddress, message.content, message.needReply, rpcCallContext)\n-    }\n-\n-    def onEndpointStopped(): Unit = {\n-      callback.onFailure(\n-        new SparkException(s\"Could not find ${message.receiver.name} or it has been stopped\"))\n-    }\n+    val rpcCallContext =\n+      new RemoteNettyRpcCallContext(nettyEnv, callback, message.senderAddress)\n+    val rpcMessage = RpcMessage(message.senderAddress, message.content, rpcCallContext)\n+    postMessage(message.receiver.name, rpcMessage,\n+     (e) => callback.onFailure(e))\n+  }\n \n-    postMessage(message.receiver.name, createMessage, onEndpointStopped)\n+  /** Posts a one-way message sent by a remote endpoint. */\n+  def postRemoteMessage(message: RequestMessage): Unit = {\n+    postMessage(message.receiver.name, OneWayMessage(message.senderAddress, message.content),\n+      (e) => throw e)\n   }\n \n   /** Posts a message sent by a local endpoint. */\n   def postLocalMessage(message: RequestMessage, p: Promise[Any]): Unit = {\n-    def createMessage(sender: NettyRpcEndpointRef): InboxMessage = {\n-      val rpcCallContext =\n-        new LocalNettyRpcCallContext(sender, message.senderAddress, message.needReply, p)\n-      ContentMessage(message.senderAddress, message.content, message.needReply, rpcCallContext)\n-    }\n-\n-    def onEndpointStopped(): Unit = {\n-      p.tryFailure(\n-        new SparkException(s\"Could not find ${message.receiver.name} or it has been stopped\"))\n-    }\n+    val rpcCallContext =\n+      new LocalNettyRpcCallContext(message.senderAddress, p)\n+    val rpcMessage = RpcMessage(message.senderAddress, message.content, rpcCallContext)\n+    postMessage(message.receiver.name, rpcMessage,\n+      (e) => p.tryFailure(e))\n+  }\n \n-    postMessage(message.receiver.name, createMessage, onEndpointStopped)\n+  /** Posts a one-way message sent by a local endpoint. */\n+  def postLocalMessage(message: RequestMessage): Unit = {\n+    postMessage(message.receiver.name, OneWayMessage(message.senderAddress, message.content),\n+      (e) => throw e)","path":"core/src/main/scala/org/apache/spark/rpc/netty/Dispatcher.scala","position":63,"original_position":63,"commit_id":"b00f4f0b118d68c913d64cff68c2db05e1d1e3e5","original_commit_id":"b00f4f0b118d68c913d64cff68c2db05e1d1e3e5","user":{"login":"andrewor14","id":2133137,"avatar_url":"https://avatars.githubusercontent.com/u/2133137?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewor14","html_url":"https://github.com/andrewor14","followers_url":"https://api.github.com/users/andrewor14/followers","following_url":"https://api.github.com/users/andrewor14/following{/other_user}","gists_url":"https://api.github.com/users/andrewor14/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewor14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewor14/subscriptions","organizations_url":"https://api.github.com/users/andrewor14/orgs","repos_url":"https://api.github.com/users/andrewor14/repos","events_url":"https://api.github.com/users/andrewor14/events{/privacy}","received_events_url":"https://api.github.com/users/andrewor14/received_events","type":"User","site_admin":false},"body":"the body of this method is identical to `postRemoteMessage`. Should we just have a common `postMessage` method?","created_at":"2015-11-24T22:23:36Z","updated_at":"2015-11-24T22:23:36Z","html_url":"https://github.com/apache/spark/pull/9917#discussion_r45803882","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/9917","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/45803882"},"html":{"href":"https://github.com/apache/spark/pull/9917#discussion_r45803882"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/9917"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/9917","id":51589051,"html_url":"https://github.com/apache/spark/pull/9917","diff_url":"https://github.com/apache/spark/pull/9917.diff","patch_url":"https://github.com/apache/spark/pull/9917.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/9917","number":9917,"state":"open","locked":false,"title":"[SPARK-11866] [network] [core] Make sure timed out RPCs are cleaned up.","user":{"login":"vanzin","id":1694083,"avatar_url":"https://avatars.githubusercontent.com/u/1694083?v=3","gravatar_id":"","url":"https://api.github.com/users/vanzin","html_url":"https://github.com/vanzin","followers_url":"https://api.github.com/users/vanzin/followers","following_url":"https://api.github.com/users/vanzin/following{/other_user}","gists_url":"https://api.github.com/users/vanzin/gists{/gist_id}","starred_url":"https://api.github.com/users/vanzin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanzin/subscriptions","organizations_url":"https://api.github.com/users/vanzin/orgs","repos_url":"https://api.github.com/users/vanzin/repos","events_url":"https://api.github.com/users/vanzin/events{/privacy}","received_events_url":"https://api.github.com/users/vanzin/received_events","type":"User","site_admin":false},"body":"This change does a couple of different things to make sure that the RpcEnv-level\r\ncode and the network library agree about the status of outstanding RPCs.\r\n\r\nFor RPCs that do not expect a reply (\"RpcEnv.send\"), support for one way\r\nmessages (hello CORBA!) was added to the network layer. This is a\r\n\"fire and forget\" message that does not require any state to be kept\r\nby the TransportClient; as a result, the RpcEnv 'Ack' message is not needed\r\nanymore.\r\n\r\nFor RPCs that do expect a reply (\"RpcEnv.ask\"), the network library now\r\nreturns the internal RPC id; if the RpcEnv layer decides to time out the\r\nRPC before the network layer does, it now asks the TransportClient to\r\nforget about the RPC, so that if the network-level timeout occurs, the\r\nclient is not killed.\r\n\r\nAs part of implementing the above, I cleaned up some of the code in the\r\nnetty rpc backend, removing types that were not necessary and factoring\r\nout some common code. Of interest is a slight change in the exceptions\r\nwhen posting messages to a stopped RpcEnv; that's mostly to avoid nasty\r\nerror messages from the local-cluster backend when shutting down, which\r\npollutes the terminal output.","created_at":"2015-11-23T22:19:52Z","updated_at":"2015-11-24T22:23:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9e0426d4ab13e4161894ed9bee956f6fec02cf9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/9917/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/9917/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/9917/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/b00f4f0b118d68c913d64cff68c2db05e1d1e3e5","head":{"label":"vanzin:SPARK-11866","ref":"SPARK-11866","sha":"b00f4f0b118d68c913d64cff68c2db05e1d1e3e5","user":{"login":"vanzin","id":1694083,"avatar_url":"https://avatars.githubusercontent.com/u/1694083?v=3","gravatar_id":"","url":"https://api.github.com/users/vanzin","html_url":"https://github.com/vanzin","followers_url":"https://api.github.com/users/vanzin/followers","following_url":"https://api.github.com/users/vanzin/following{/other_user}","gists_url":"https://api.github.com/users/vanzin/gists{/gist_id}","starred_url":"https://api.github.com/users/vanzin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanzin/subscriptions","organizations_url":"https://api.github.com/users/vanzin/orgs","repos_url":"https://api.github.com/users/vanzin/repos","events_url":"https://api.github.com/users/vanzin/events{/privacy}","received_events_url":"https://api.github.com/users/vanzin/received_events","type":"User","site_admin":false},"repo":{"id":18302272,"name":"spark","full_name":"vanzin/spark","owner":{"login":"vanzin","id":1694083,"avatar_url":"https://avatars.githubusercontent.com/u/1694083?v=3","gravatar_id":"","url":"https://api.github.com/users/vanzin","html_url":"https://github.com/vanzin","followers_url":"https://api.github.com/users/vanzin/followers","following_url":"https://api.github.com/users/vanzin/following{/other_user}","gists_url":"https://api.github.com/users/vanzin/gists{/gist_id}","starred_url":"https://api.github.com/users/vanzin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanzin/subscriptions","organizations_url":"https://api.github.com/users/vanzin/orgs","repos_url":"https://api.github.com/users/vanzin/repos","events_url":"https://api.github.com/users/vanzin/events{/privacy}","received_events_url":"https://api.github.com/users/vanzin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vanzin/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/vanzin/spark","forks_url":"https://api.github.com/repos/vanzin/spark/forks","keys_url":"https://api.github.com/repos/vanzin/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vanzin/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vanzin/spark/teams","hooks_url":"https://api.github.com/repos/vanzin/spark/hooks","issue_events_url":"https://api.github.com/repos/vanzin/spark/issues/events{/number}","events_url":"https://api.github.com/repos/vanzin/spark/events","assignees_url":"https://api.github.com/repos/vanzin/spark/assignees{/user}","branches_url":"https://api.github.com/repos/vanzin/spark/branches{/branch}","tags_url":"https://api.github.com/repos/vanzin/spark/tags","blobs_url":"https://api.github.com/repos/vanzin/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vanzin/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vanzin/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/vanzin/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vanzin/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/vanzin/spark/languages","stargazers_url":"https://api.github.com/repos/vanzin/spark/stargazers","contributors_url":"https://api.github.com/repos/vanzin/spark/contributors","subscribers_url":"https://api.github.com/repos/vanzin/spark/subscribers","subscription_url":"https://api.github.com/repos/vanzin/spark/subscription","commits_url":"https://api.github.com/repos/vanzin/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/vanzin/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/vanzin/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/vanzin/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/vanzin/spark/contents/{+path}","compare_url":"https://api.github.com/repos/vanzin/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vanzin/spark/merges","archive_url":"https://api.github.com/repos/vanzin/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vanzin/spark/downloads","issues_url":"https://api.github.com/repos/vanzin/spark/issues{/number}","pulls_url":"https://api.github.com/repos/vanzin/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/vanzin/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/vanzin/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vanzin/spark/labels{/name}","releases_url":"https://api.github.com/repos/vanzin/spark/releases{/id}","created_at":"2014-03-31T17:49:25Z","updated_at":"2015-09-23T22:03:10Z","pushed_at":"2015-11-24T22:01:06Z","git_url":"git://github.com/vanzin/spark.git","ssh_url":"git@github.com:vanzin/spark.git","clone_url":"https://github.com/vanzin/spark.git","svn_url":"https://github.com/vanzin/spark","homepage":null,"size":127168,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"c2467dadae8ce44010a912ee91c429310f8add65","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-11-24T21:50:14Z","pushed_at":"2015-11-24T22:14:23Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":386417,"stargazers_count":6332,"watchers_count":6332,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5824,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":368,"forks":5824,"open_issues":368,"watchers":6332,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/9917"},"html":{"href":"https://github.com/apache/spark/pull/9917"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/9917"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/9917/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/9917/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/9917/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/b00f4f0b118d68c913d64cff68c2db05e1d1e3e5"}}}}