{"action":"created","comment":{"url":"https://api.github.com/repos/apache/flink/pulls/comments/24072529","id":24072529,"diff_hunk":"@@ -25,48 +25,82 @@ import org.apache.flink.runtime.jobgraph.JobID\n import org.apache.flink.runtime.messages.ArchiveMessages._\n import org.apache.flink.runtime.messages.JobManagerMessages._\n \n+import scala.collection.mutable.LinkedHashMap\n+import scala.ref.SoftReference\n+\n class MemoryArchivist(private val max_entries: Int) extends Actor with ActorLogMessages with\n ActorLogging {\n   /**\n    * Map of execution graphs belonging to recently started jobs with the time stamp of the last\n-   * received job event.\n+   * received job event. The insert order is preserved through a LinkedHashMap.\n    */\n-  val graphs = collection.mutable.HashMap[JobID, ExecutionGraph]()\n-  val lru = collection.mutable.Queue[JobID]()\n+  val graphs = LinkedHashMap[JobID, SoftReference[ExecutionGraph]]()\n \n   override def receiveWithLogMessages: Receive = {\n+    /* Receive Execution Graph to archive */\n     case ArchiveExecutionGraph(jobID, graph) => {\n-      graphs.update(jobID, graph)\n+      // wrap graph inside a soft reference\n+      graphs.update(jobID, new SoftReference(graph))\n+\n+      // clear all execution edges of the graph\n+      val iter = graph.getAllExecutionVertices().iterator()\n+      while (iter.hasNext) {\n+        iter.next().clearExecutionEdges()\n+      }\n+\n       cleanup(jobID)\n     }\n \n     case RequestArchivedJobs => {\n-      sender ! ArchivedJobs(graphs.values)\n+      sender ! ArchivedJobs(getAllGraphs())\n     }\n \n     case RequestJob(jobID) => {\n-      graphs.get(jobID) match {\n-        case Some(graph) => sender ! JobFound(jobID, graph)\n-        case None => sender ! JobNotFound(jobID)\n+      getGraph(jobID) match {","path":"flink-runtime/src/main/scala/org/apache/flink/runtime/jobmanager/MemoryArchivist.scala","position":43,"original_position":43,"commit_id":"baa04e386b70d3c928ceb07e78e50016f20520f0","original_commit_id":"baa04e386b70d3c928ceb07e78e50016f20520f0","user":{"login":"tillrohrmann","id":5756858,"avatar_url":"https://avatars.githubusercontent.com/u/5756858?v=3","gravatar_id":"","url":"https://api.github.com/users/tillrohrmann","html_url":"https://github.com/tillrohrmann","followers_url":"https://api.github.com/users/tillrohrmann/followers","following_url":"https://api.github.com/users/tillrohrmann/following{/other_user}","gists_url":"https://api.github.com/users/tillrohrmann/gists{/gist_id}","starred_url":"https://api.github.com/users/tillrohrmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillrohrmann/subscriptions","organizations_url":"https://api.github.com/users/tillrohrmann/orgs","repos_url":"https://api.github.com/users/tillrohrmann/repos","events_url":"https://api.github.com/users/tillrohrmann/events{/privacy}","received_events_url":"https://api.github.com/users/tillrohrmann/received_events","type":"User","site_admin":false},"body":"Ah I see, because of the soft ref. Why not letting getGraph return an Option type instead of null. Null values are evil. [Tony Hoares multi-billion dollar mistake] (http://en.wikipedia.org/wiki/Tony_Hoare#Quotations)","created_at":"2015-02-04T09:54:14Z","updated_at":"2015-02-04T09:54:14Z","html_url":"https://github.com/apache/flink/pull/344#discussion_r24072529","pull_request_url":"https://api.github.com/repos/apache/flink/pulls/344","_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/comments/24072529"},"html":{"href":"https://github.com/apache/flink/pull/344#discussion_r24072529"},"pull_request":{"href":"https://api.github.com/repos/apache/flink/pulls/344"}}},"pull_request":{"url":"https://api.github.com/repos/apache/flink/pulls/344","id":28051553,"html_url":"https://github.com/apache/flink/pull/344","diff_url":"https://github.com/apache/flink/pull/344.diff","patch_url":"https://github.com/apache/flink/pull/344.patch","issue_url":"https://api.github.com/repos/apache/flink/issues/344","number":344,"state":"open","locked":false,"title":"[FLINK-1442] Reduce memory consumption of archived execution graph","user":{"login":"mxm","id":837221,"avatar_url":"https://avatars.githubusercontent.com/u/837221?v=3","gravatar_id":"","url":"https://api.github.com/users/mxm","html_url":"https://github.com/mxm","followers_url":"https://api.github.com/users/mxm/followers","following_url":"https://api.github.com/users/mxm/following{/other_user}","gists_url":"https://api.github.com/users/mxm/gists{/gist_id}","starred_url":"https://api.github.com/users/mxm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxm/subscriptions","organizations_url":"https://api.github.com/users/mxm/orgs","repos_url":"https://api.github.com/users/mxm/repos","events_url":"https://api.github.com/users/mxm/events{/privacy}","received_events_url":"https://api.github.com/users/mxm/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-26T19:09:40Z","updated_at":"2015-02-04T09:54:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0caafa4377412d8f49a3f1ac68980d6afbe08c14","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/flink/pulls/344/commits","review_comments_url":"https://api.github.com/repos/apache/flink/pulls/344/comments","review_comment_url":"https://api.github.com/repos/apache/flink/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/flink/issues/344/comments","statuses_url":"https://api.github.com/repos/apache/flink/statuses/baa04e386b70d3c928ceb07e78e50016f20520f0","head":{"label":"mxm:flink-1442","ref":"flink-1442","sha":"baa04e386b70d3c928ceb07e78e50016f20520f0","user":{"login":"mxm","id":837221,"avatar_url":"https://avatars.githubusercontent.com/u/837221?v=3","gravatar_id":"","url":"https://api.github.com/users/mxm","html_url":"https://github.com/mxm","followers_url":"https://api.github.com/users/mxm/followers","following_url":"https://api.github.com/users/mxm/following{/other_user}","gists_url":"https://api.github.com/users/mxm/gists{/gist_id}","starred_url":"https://api.github.com/users/mxm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxm/subscriptions","organizations_url":"https://api.github.com/users/mxm/orgs","repos_url":"https://api.github.com/users/mxm/repos","events_url":"https://api.github.com/users/mxm/events{/privacy}","received_events_url":"https://api.github.com/users/mxm/received_events","type":"User","site_admin":false},"repo":{"id":25965625,"name":"flink","full_name":"mxm/flink","owner":{"login":"mxm","id":837221,"avatar_url":"https://avatars.githubusercontent.com/u/837221?v=3","gravatar_id":"","url":"https://api.github.com/users/mxm","html_url":"https://github.com/mxm","followers_url":"https://api.github.com/users/mxm/followers","following_url":"https://api.github.com/users/mxm/following{/other_user}","gists_url":"https://api.github.com/users/mxm/gists{/gist_id}","starred_url":"https://api.github.com/users/mxm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxm/subscriptions","organizations_url":"https://api.github.com/users/mxm/orgs","repos_url":"https://api.github.com/users/mxm/repos","events_url":"https://api.github.com/users/mxm/events{/privacy}","received_events_url":"https://api.github.com/users/mxm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mxm/flink","description":"Mirror of Apache Flink","fork":true,"url":"https://api.github.com/repos/mxm/flink","forks_url":"https://api.github.com/repos/mxm/flink/forks","keys_url":"https://api.github.com/repos/mxm/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mxm/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mxm/flink/teams","hooks_url":"https://api.github.com/repos/mxm/flink/hooks","issue_events_url":"https://api.github.com/repos/mxm/flink/issues/events{/number}","events_url":"https://api.github.com/repos/mxm/flink/events","assignees_url":"https://api.github.com/repos/mxm/flink/assignees{/user}","branches_url":"https://api.github.com/repos/mxm/flink/branches{/branch}","tags_url":"https://api.github.com/repos/mxm/flink/tags","blobs_url":"https://api.github.com/repos/mxm/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mxm/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mxm/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/mxm/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mxm/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/mxm/flink/languages","stargazers_url":"https://api.github.com/repos/mxm/flink/stargazers","contributors_url":"https://api.github.com/repos/mxm/flink/contributors","subscribers_url":"https://api.github.com/repos/mxm/flink/subscribers","subscription_url":"https://api.github.com/repos/mxm/flink/subscription","commits_url":"https://api.github.com/repos/mxm/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/mxm/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/mxm/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/mxm/flink/issues/comments/{number}","contents_url":"https://api.github.com/repos/mxm/flink/contents/{+path}","compare_url":"https://api.github.com/repos/mxm/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mxm/flink/merges","archive_url":"https://api.github.com/repos/mxm/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mxm/flink/downloads","issues_url":"https://api.github.com/repos/mxm/flink/issues{/number}","pulls_url":"https://api.github.com/repos/mxm/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/mxm/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/mxm/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mxm/flink/labels{/name}","releases_url":"https://api.github.com/repos/mxm/flink/releases{/id}","created_at":"2014-10-30T10:24:48Z","updated_at":"2015-01-21T13:29:07Z","pushed_at":"2015-02-03T15:10:00Z","git_url":"git://github.com/mxm/flink.git","ssh_url":"git@github.com:mxm/flink.git","clone_url":"https://github.com/mxm/flink.git","svn_url":"https://github.com/mxm/flink","homepage":null,"size":40048,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"6067833fb6ad6c11a121d8654d7ca147cc909f05","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":20587599,"name":"flink","full_name":"apache/flink","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/flink","description":"Mirror of Apache Flink","fork":false,"url":"https://api.github.com/repos/apache/flink","forks_url":"https://api.github.com/repos/apache/flink/forks","keys_url":"https://api.github.com/repos/apache/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/flink/teams","hooks_url":"https://api.github.com/repos/apache/flink/hooks","issue_events_url":"https://api.github.com/repos/apache/flink/issues/events{/number}","events_url":"https://api.github.com/repos/apache/flink/events","assignees_url":"https://api.github.com/repos/apache/flink/assignees{/user}","branches_url":"https://api.github.com/repos/apache/flink/branches{/branch}","tags_url":"https://api.github.com/repos/apache/flink/tags","blobs_url":"https://api.github.com/repos/apache/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/flink/languages","stargazers_url":"https://api.github.com/repos/apache/flink/stargazers","contributors_url":"https://api.github.com/repos/apache/flink/contributors","subscribers_url":"https://api.github.com/repos/apache/flink/subscribers","subscription_url":"https://api.github.com/repos/apache/flink/subscription","commits_url":"https://api.github.com/repos/apache/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/flink/issues/comments/{number}","contents_url":"https://api.github.com/repos/apache/flink/contents/{+path}","compare_url":"https://api.github.com/repos/apache/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/flink/merges","archive_url":"https://api.github.com/repos/apache/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/flink/downloads","issues_url":"https://api.github.com/repos/apache/flink/issues{/number}","pulls_url":"https://api.github.com/repos/apache/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/flink/labels{/name}","releases_url":"https://api.github.com/repos/apache/flink/releases{/id}","created_at":"2014-06-07T07:00:10Z","updated_at":"2015-02-03T21:17:14Z","pushed_at":"2015-02-03T16:13:55Z","git_url":"git://github.com/apache/flink.git","ssh_url":"git@github.com:apache/flink.git","clone_url":"https://github.com/apache/flink.git","svn_url":"https://github.com/apache/flink","homepage":null,"size":2377431,"stargazers_count":267,"watchers_count":267,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":139,"mirror_url":"git://git.apache.org/incubator-flink.git","open_issues_count":32,"forks":139,"open_issues":32,"watchers":267,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/344"},"html":{"href":"https://github.com/apache/flink/pull/344"},"issue":{"href":"https://api.github.com/repos/apache/flink/issues/344"},"comments":{"href":"https://api.github.com/repos/apache/flink/issues/344/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/flink/pulls/344/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/flink/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/flink/pulls/344/commits"},"statuses":{"href":"https://api.github.com/repos/apache/flink/statuses/baa04e386b70d3c928ceb07e78e50016f20520f0"}}}}