{"action":"created","comment":{"url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/comments/25891551","id":25891551,"diff_hunk":"@@ -149,11 +156,14 @@ sparkR.init <- function(\n     }\n     f <- file(path, open='rb')\n     sparkRBackendPort <- readInt(f)\n+    monitorPort <- readInt(f)\n     close(f)\n     file.remove(path)\n-    if (length(sparkRBackendPort) == 0) {\n+    if (length(sparkRBackendPort) == 0 || sparkRBackendPort == 0 ||\n+        length(monitorPort) == 0 || monitorPort == 0) {\n       stop(\"JVM failed to launch\")\n     }\n+    assign(\".monitorConn\", socketConnection(port = monitorPort), envir = .sparkREnv)","path":"pkg/R/sparkR.R","position":36,"original_position":36,"commit_id":"3c7674f84da0440a14976531fd80bdca04fa7f76","original_commit_id":"3c7674f84da0440a14976531fd80bdca04fa7f76","user":{"login":"shivaram","id":143893,"avatar_url":"https://avatars.githubusercontent.com/u/143893?v=3","gravatar_id":"","url":"https://api.github.com/users/shivaram","html_url":"https://github.com/shivaram","followers_url":"https://api.github.com/users/shivaram/followers","following_url":"https://api.github.com/users/shivaram/following{/other_user}","gists_url":"https://api.github.com/users/shivaram/gists{/gist_id}","starred_url":"https://api.github.com/users/shivaram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shivaram/subscriptions","organizations_url":"https://api.github.com/users/shivaram/orgs","repos_url":"https://api.github.com/users/shivaram/repos","events_url":"https://api.github.com/users/shivaram/events{/privacy}","received_events_url":"https://api.github.com/users/shivaram/received_events","type":"User","site_admin":false},"body":"In addition to this, a couple of things can be removed now:\r\n- Line 217 (`reg.finalizer`) can be removed as we don't need `sparkR.stop` to be run when the R process exits\r\n- Line 28-37 can be refactored as follows: We check if a valid connection exists and if it doesn't we can just exit saying no connection to backend found (no need to reconnect). Also then we don't the `if` in Line 40 and the whole block can just go inside `if (connExists)`\r\n\r\n@sun-rui does this sound good ?","created_at":"2015-03-05T19:07:57Z","updated_at":"2015-03-05T19:07:57Z","html_url":"https://github.com/amplab-extras/SparkR-pkg/pull/196#discussion_r25891551","pull_request_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/196","_links":{"self":{"href":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/comments/25891551"},"html":{"href":"https://github.com/amplab-extras/SparkR-pkg/pull/196#discussion_r25891551"},"pull_request":{"href":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/196"}}},"pull_request":{"url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/196","id":30408000,"html_url":"https://github.com/amplab-extras/SparkR-pkg/pull/196","diff_url":"https://github.com/amplab-extras/SparkR-pkg/pull/196.diff","patch_url":"https://github.com/amplab-extras/SparkR-pkg/pull/196.patch","issue_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/issues/196","number":196,"state":"open","locked":false,"title":"[SPARKR-198] shutdown the JVM after R process die","user":{"login":"davies","id":40902,"avatar_url":"https://avatars.githubusercontent.com/u/40902?v=3","gravatar_id":"","url":"https://api.github.com/users/davies","html_url":"https://github.com/davies","followers_url":"https://api.github.com/users/davies/followers","following_url":"https://api.github.com/users/davies/following{/other_user}","gists_url":"https://api.github.com/users/davies/gists{/gist_id}","starred_url":"https://api.github.com/users/davies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davies/subscriptions","organizations_url":"https://api.github.com/users/davies/orgs","repos_url":"https://api.github.com/users/davies/repos","events_url":"https://api.github.com/users/davies/events{/privacy}","received_events_url":"https://api.github.com/users/davies/received_events","type":"User","site_admin":false},"body":"Create a tcp connection between R and JVM as heartbeat, The JVM will shutdown once this connection is closed by R (closed by OS if R process die)","created_at":"2015-03-03T20:10:56Z","updated_at":"2015-03-05T19:07:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"26aafd735d355b6786bb88b98fa287cd95ecc8f4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/196/commits","review_comments_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/196/comments","review_comment_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/issues/196/comments","statuses_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/statuses/3c7674f84da0440a14976531fd80bdca04fa7f76","head":{"label":"davies:die","ref":"die","sha":"3c7674f84da0440a14976531fd80bdca04fa7f76","user":{"login":"davies","id":40902,"avatar_url":"https://avatars.githubusercontent.com/u/40902?v=3","gravatar_id":"","url":"https://api.github.com/users/davies","html_url":"https://github.com/davies","followers_url":"https://api.github.com/users/davies/followers","following_url":"https://api.github.com/users/davies/following{/other_user}","gists_url":"https://api.github.com/users/davies/gists{/gist_id}","starred_url":"https://api.github.com/users/davies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davies/subscriptions","organizations_url":"https://api.github.com/users/davies/orgs","repos_url":"https://api.github.com/users/davies/repos","events_url":"https://api.github.com/users/davies/events{/privacy}","received_events_url":"https://api.github.com/users/davies/received_events","type":"User","site_admin":false},"repo":{"id":31027661,"name":"SparkR-pkg","full_name":"davies/SparkR-pkg","owner":{"login":"davies","id":40902,"avatar_url":"https://avatars.githubusercontent.com/u/40902?v=3","gravatar_id":"","url":"https://api.github.com/users/davies","html_url":"https://github.com/davies","followers_url":"https://api.github.com/users/davies/followers","following_url":"https://api.github.com/users/davies/following{/other_user}","gists_url":"https://api.github.com/users/davies/gists{/gist_id}","starred_url":"https://api.github.com/users/davies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davies/subscriptions","organizations_url":"https://api.github.com/users/davies/orgs","repos_url":"https://api.github.com/users/davies/repos","events_url":"https://api.github.com/users/davies/events{/privacy}","received_events_url":"https://api.github.com/users/davies/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/davies/SparkR-pkg","description":"R frontend for Spark","fork":true,"url":"https://api.github.com/repos/davies/SparkR-pkg","forks_url":"https://api.github.com/repos/davies/SparkR-pkg/forks","keys_url":"https://api.github.com/repos/davies/SparkR-pkg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/davies/SparkR-pkg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/davies/SparkR-pkg/teams","hooks_url":"https://api.github.com/repos/davies/SparkR-pkg/hooks","issue_events_url":"https://api.github.com/repos/davies/SparkR-pkg/issues/events{/number}","events_url":"https://api.github.com/repos/davies/SparkR-pkg/events","assignees_url":"https://api.github.com/repos/davies/SparkR-pkg/assignees{/user}","branches_url":"https://api.github.com/repos/davies/SparkR-pkg/branches{/branch}","tags_url":"https://api.github.com/repos/davies/SparkR-pkg/tags","blobs_url":"https://api.github.com/repos/davies/SparkR-pkg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/davies/SparkR-pkg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/davies/SparkR-pkg/git/refs{/sha}","trees_url":"https://api.github.com/repos/davies/SparkR-pkg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/davies/SparkR-pkg/statuses/{sha}","languages_url":"https://api.github.com/repos/davies/SparkR-pkg/languages","stargazers_url":"https://api.github.com/repos/davies/SparkR-pkg/stargazers","contributors_url":"https://api.github.com/repos/davies/SparkR-pkg/contributors","subscribers_url":"https://api.github.com/repos/davies/SparkR-pkg/subscribers","subscription_url":"https://api.github.com/repos/davies/SparkR-pkg/subscription","commits_url":"https://api.github.com/repos/davies/SparkR-pkg/commits{/sha}","git_commits_url":"https://api.github.com/repos/davies/SparkR-pkg/git/commits{/sha}","comments_url":"https://api.github.com/repos/davies/SparkR-pkg/comments{/number}","issue_comment_url":"https://api.github.com/repos/davies/SparkR-pkg/issues/comments{/number}","contents_url":"https://api.github.com/repos/davies/SparkR-pkg/contents/{+path}","compare_url":"https://api.github.com/repos/davies/SparkR-pkg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/davies/SparkR-pkg/merges","archive_url":"https://api.github.com/repos/davies/SparkR-pkg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/davies/SparkR-pkg/downloads","issues_url":"https://api.github.com/repos/davies/SparkR-pkg/issues{/number}","pulls_url":"https://api.github.com/repos/davies/SparkR-pkg/pulls{/number}","milestones_url":"https://api.github.com/repos/davies/SparkR-pkg/milestones{/number}","notifications_url":"https://api.github.com/repos/davies/SparkR-pkg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/davies/SparkR-pkg/labels{/name}","releases_url":"https://api.github.com/repos/davies/SparkR-pkg/releases{/id}","created_at":"2015-02-19T17:37:52Z","updated_at":"2015-02-25T08:33:46Z","pushed_at":"2015-03-05T18:00:09Z","git_url":"git://github.com/davies/SparkR-pkg.git","ssh_url":"git@github.com:davies/SparkR-pkg.git","clone_url":"https://github.com/davies/SparkR-pkg.git","svn_url":"https://github.com/davies/SparkR-pkg","homepage":"http://amplab-extras.github.io/SparkR-pkg","size":3855,"stargazers_count":0,"watchers_count":0,"language":"R","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"amplab-extras:master","ref":"master","sha":"773baf064c923d3f44ea8fdbb5d2f36194245040","user":{"login":"amplab-extras","id":6403540,"avatar_url":"https://avatars.githubusercontent.com/u/6403540?v=3","gravatar_id":"","url":"https://api.github.com/users/amplab-extras","html_url":"https://github.com/amplab-extras","followers_url":"https://api.github.com/users/amplab-extras/followers","following_url":"https://api.github.com/users/amplab-extras/following{/other_user}","gists_url":"https://api.github.com/users/amplab-extras/gists{/gist_id}","starred_url":"https://api.github.com/users/amplab-extras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplab-extras/subscriptions","organizations_url":"https://api.github.com/users/amplab-extras/orgs","repos_url":"https://api.github.com/users/amplab-extras/repos","events_url":"https://api.github.com/users/amplab-extras/events{/privacy}","received_events_url":"https://api.github.com/users/amplab-extras/received_events","type":"Organization","site_admin":false},"repo":{"id":15365789,"name":"SparkR-pkg","full_name":"amplab-extras/SparkR-pkg","owner":{"login":"amplab-extras","id":6403540,"avatar_url":"https://avatars.githubusercontent.com/u/6403540?v=3","gravatar_id":"","url":"https://api.github.com/users/amplab-extras","html_url":"https://github.com/amplab-extras","followers_url":"https://api.github.com/users/amplab-extras/followers","following_url":"https://api.github.com/users/amplab-extras/following{/other_user}","gists_url":"https://api.github.com/users/amplab-extras/gists{/gist_id}","starred_url":"https://api.github.com/users/amplab-extras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplab-extras/subscriptions","organizations_url":"https://api.github.com/users/amplab-extras/orgs","repos_url":"https://api.github.com/users/amplab-extras/repos","events_url":"https://api.github.com/users/amplab-extras/events{/privacy}","received_events_url":"https://api.github.com/users/amplab-extras/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/amplab-extras/SparkR-pkg","description":"R frontend for Spark","fork":false,"url":"https://api.github.com/repos/amplab-extras/SparkR-pkg","forks_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/forks","keys_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/teams","hooks_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/hooks","issue_events_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/issues/events{/number}","events_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/events","assignees_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/assignees{/user}","branches_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/branches{/branch}","tags_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/tags","blobs_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/git/refs{/sha}","trees_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/statuses/{sha}","languages_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/languages","stargazers_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/stargazers","contributors_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/contributors","subscribers_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/subscribers","subscription_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/subscription","commits_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/commits{/sha}","git_commits_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/git/commits{/sha}","comments_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/comments{/number}","issue_comment_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/issues/comments{/number}","contents_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/contents/{+path}","compare_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/merges","archive_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/downloads","issues_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/issues{/number}","pulls_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls{/number}","milestones_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/milestones{/number}","notifications_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/labels{/name}","releases_url":"https://api.github.com/repos/amplab-extras/SparkR-pkg/releases{/id}","created_at":"2013-12-21T21:16:54Z","updated_at":"2015-03-05T19:03:51Z","pushed_at":"2015-03-05T19:03:51Z","git_url":"git://github.com/amplab-extras/SparkR-pkg.git","ssh_url":"git@github.com:amplab-extras/SparkR-pkg.git","clone_url":"https://github.com/amplab-extras/SparkR-pkg.git","svn_url":"https://github.com/amplab-extras/SparkR-pkg","homepage":"http://amplab-extras.github.io/SparkR-pkg","size":5866,"stargazers_count":401,"watchers_count":401,"language":"R","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":143,"mirror_url":null,"open_issues_count":24,"forks":143,"open_issues":24,"watchers":401,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/196"},"html":{"href":"https://github.com/amplab-extras/SparkR-pkg/pull/196"},"issue":{"href":"https://api.github.com/repos/amplab-extras/SparkR-pkg/issues/196"},"comments":{"href":"https://api.github.com/repos/amplab-extras/SparkR-pkg/issues/196/comments"},"review_comments":{"href":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/196/comments"},"review_comment":{"href":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amplab-extras/SparkR-pkg/pulls/196/commits"},"statuses":{"href":"https://api.github.com/repos/amplab-extras/SparkR-pkg/statuses/3c7674f84da0440a14976531fd80bdca04fa7f76"}}}}