{"action":"created","comment":{"url":"https://api.github.com/repos/mesosphere/marathon/pulls/comments/40312362","id":40312362,"diff_hunk":"@@ -1,45 +1,47 @@\n package mesosphere.marathon.tasks\n \n-import java.io._\n import javax.inject.Inject\n \n import mesosphere.marathon.MarathonConf\n import mesosphere.marathon.Protos._\n import mesosphere.marathon.metrics.Metrics\n-import mesosphere.marathon.state.{ PathId, StateMetrics, Timestamp }\n-import mesosphere.util.state.{ PersistentEntity, PersistentStore }\n+import mesosphere.marathon.state.{ EntityStore, MarathonTaskState, PathId, StateMetrics, Timestamp }\n import org.apache.mesos.Protos.{ TaskState, TaskStatus }\n import org.slf4j.LoggerFactory\n \n-import scala.collection.JavaConverters._\n import scala.collection._\n import scala.collection.concurrent.TrieMap\n import scala.collection.immutable.Set\n import scala.concurrent.{ Await, Future }\n \n class TaskTracker @Inject() (\n-    store: PersistentStore,\n+    store: EntityStore[MarathonTaskState],\n     config: MarathonConf,\n     val metrics: Metrics) extends StateMetrics {\n \n   import mesosphere.marathon.tasks.TaskTracker._\n   import mesosphere.util.ThreadPoolContext.context\n \n+  import scala.language.implicitConversions\n+\n   implicit val timeout = config.zkTimeoutDuration\n \n   private[this] val log = LoggerFactory.getLogger(getClass.getName)\n \n-  val PREFIX = \"task:\"\n   val ID_DELIMITER = \":\"\n \n   private[tasks] val apps = TrieMap[PathId, InternalApp]()\n \n-  private[tasks] def fetchFromState(id: String): Option[PersistentEntity] = timedRead {\n-    Await.result(store.load(id), timeout)\n+  private[tasks] def fetchFromState(id: String): Option[MarathonTask] = timedRead {\n+    val res = store.fetch(id).flatMap {\n+      case Some(taskState) => Future.successful(Some(taskState.toProto))","path":"src/main/scala/mesosphere/marathon/tasks/TaskTracker.scala","position":45,"original_position":45,"commit_id":"300bed60bdb61d4f75fa662c6e565b49b7f7c7e9","original_commit_id":"300bed60bdb61d4f75fa662c6e565b49b7f7c7e9","user":{"login":"aquamatthias","id":330485,"avatar_url":"https://avatars.githubusercontent.com/u/330485?v=3","gravatar_id":"","url":"https://api.github.com/users/aquamatthias","html_url":"https://github.com/aquamatthias","followers_url":"https://api.github.com/users/aquamatthias/followers","following_url":"https://api.github.com/users/aquamatthias/following{/other_user}","gists_url":"https://api.github.com/users/aquamatthias/gists{/gist_id}","starred_url":"https://api.github.com/users/aquamatthias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquamatthias/subscriptions","organizations_url":"https://api.github.com/users/aquamatthias/orgs","repos_url":"https://api.github.com/users/aquamatthias/repos","events_url":"https://api.github.com/users/aquamatthias/events{/privacy}","received_events_url":"https://api.github.com/users/aquamatthias/received_events","type":"User","site_admin":false},"body":"Both cases have Future.successful together with flatMap -> make a simple map.","created_at":"2015-09-24T12:21:16Z","updated_at":"2015-09-24T12:21:16Z","html_url":"https://github.com/mesosphere/marathon/pull/2305#discussion_r40312362","pull_request_url":"https://api.github.com/repos/mesosphere/marathon/pulls/2305","_links":{"self":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/comments/40312362"},"html":{"href":"https://github.com/mesosphere/marathon/pull/2305#discussion_r40312362"},"pull_request":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/2305"}}},"pull_request":{"url":"https://api.github.com/repos/mesosphere/marathon/pulls/2305","id":45884252,"html_url":"https://github.com/mesosphere/marathon/pull/2305","diff_url":"https://github.com/mesosphere/marathon/pull/2305.diff","patch_url":"https://github.com/mesosphere/marathon/pull/2305.patch","issue_url":"https://api.github.com/repos/mesosphere/marathon/issues/2305","number":2305,"state":"open","locked":false,"title":"Make TaskTracker use EntityStore","user":{"login":"meichstedt","id":414354,"avatar_url":"https://avatars.githubusercontent.com/u/414354?v=3","gravatar_id":"","url":"https://api.github.com/users/meichstedt","html_url":"https://github.com/meichstedt","followers_url":"https://api.github.com/users/meichstedt/followers","following_url":"https://api.github.com/users/meichstedt/following{/other_user}","gists_url":"https://api.github.com/users/meichstedt/gists{/gist_id}","starred_url":"https://api.github.com/users/meichstedt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meichstedt/subscriptions","organizations_url":"https://api.github.com/users/meichstedt/orgs","repos_url":"https://api.github.com/users/meichstedt/repos","events_url":"https://api.github.com/users/meichstedt/events{/privacy}","received_events_url":"https://api.github.com/users/meichstedt/received_events","type":"User","site_admin":false},"body":"Minimally invasive implementation to use EntityStore in TaskTracker. MarathonTask is generated and final and cannot directly extend MarathonState. To enable usage of the existing EntityStore and MarathonStore implementations, I added the MarathonTaskState wrapper, that is used to wrap a MarathonTask into a representation that can be used to parameterise EntityStore and MarathonStore.\r\n\r\nSuggested review order:\r\n1. MarathonTaskState\r\n1. TaskTracker\r\n1. MarathonModule\r\n1. everything else\r\n","created_at":"2015-09-24T11:05:38Z","updated_at":"2015-09-24T12:21:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71fb454067e51e935a9a14d450dc231de072d413","assignee":{"login":"aquamatthias","id":330485,"avatar_url":"https://avatars.githubusercontent.com/u/330485?v=3","gravatar_id":"","url":"https://api.github.com/users/aquamatthias","html_url":"https://github.com/aquamatthias","followers_url":"https://api.github.com/users/aquamatthias/followers","following_url":"https://api.github.com/users/aquamatthias/following{/other_user}","gists_url":"https://api.github.com/users/aquamatthias/gists{/gist_id}","starred_url":"https://api.github.com/users/aquamatthias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquamatthias/subscriptions","organizations_url":"https://api.github.com/users/aquamatthias/orgs","repos_url":"https://api.github.com/users/aquamatthias/repos","events_url":"https://api.github.com/users/aquamatthias/events{/privacy}","received_events_url":"https://api.github.com/users/aquamatthias/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/mesosphere/marathon/milestones/20","html_url":"https://github.com/mesosphere/marathon/milestones/0.12.0","labels_url":"https://api.github.com/repos/mesosphere/marathon/milestones/20/labels","id":1231438,"number":20,"title":"0.12.0","description":"RC-1 will be released on 2015-09-14","creator":{"login":"aquamatthias","id":330485,"avatar_url":"https://avatars.githubusercontent.com/u/330485?v=3","gravatar_id":"","url":"https://api.github.com/users/aquamatthias","html_url":"https://github.com/aquamatthias","followers_url":"https://api.github.com/users/aquamatthias/followers","following_url":"https://api.github.com/users/aquamatthias/following{/other_user}","gists_url":"https://api.github.com/users/aquamatthias/gists{/gist_id}","starred_url":"https://api.github.com/users/aquamatthias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquamatthias/subscriptions","organizations_url":"https://api.github.com/users/aquamatthias/orgs","repos_url":"https://api.github.com/users/aquamatthias/repos","events_url":"https://api.github.com/users/aquamatthias/events{/privacy}","received_events_url":"https://api.github.com/users/aquamatthias/received_events","type":"User","site_admin":false},"open_issues":75,"closed_issues":45,"state":"open","created_at":"2015-07-29T12:23:28Z","updated_at":"2015-09-24T12:06:57Z","due_on":"2015-09-27T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/mesosphere/marathon/pulls/2305/commits","review_comments_url":"https://api.github.com/repos/mesosphere/marathon/pulls/2305/comments","review_comment_url":"https://api.github.com/repos/mesosphere/marathon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mesosphere/marathon/issues/2305/comments","statuses_url":"https://api.github.com/repos/mesosphere/marathon/statuses/300bed60bdb61d4f75fa662c6e565b49b7f7c7e9","head":{"label":"mesosphere:me/fix_2282-minimally-invasive","ref":"me/fix_2282-minimally-invasive","sha":"300bed60bdb61d4f75fa662c6e565b49b7f7c7e9","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":10941409,"name":"marathon","full_name":"mesosphere/marathon","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/marathon","description":"Deploy and manage containers (including Docker) on top of Apache Mesos at scale.","fork":false,"url":"https://api.github.com/repos/mesosphere/marathon","forks_url":"https://api.github.com/repos/mesosphere/marathon/forks","keys_url":"https://api.github.com/repos/mesosphere/marathon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/marathon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/marathon/teams","hooks_url":"https://api.github.com/repos/mesosphere/marathon/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/marathon/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/marathon/events","assignees_url":"https://api.github.com/repos/mesosphere/marathon/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/marathon/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/marathon/tags","blobs_url":"https://api.github.com/repos/mesosphere/marathon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/marathon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/marathon/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/marathon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/marathon/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/marathon/languages","stargazers_url":"https://api.github.com/repos/mesosphere/marathon/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/marathon/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/marathon/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/marathon/subscription","commits_url":"https://api.github.com/repos/mesosphere/marathon/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/marathon/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/marathon/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/marathon/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/marathon/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/marathon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/marathon/merges","archive_url":"https://api.github.com/repos/mesosphere/marathon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/marathon/downloads","issues_url":"https://api.github.com/repos/mesosphere/marathon/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/marathon/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/marathon/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/marathon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/marathon/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/marathon/releases{/id}","created_at":"2013-06-25T14:56:34Z","updated_at":"2015-09-24T02:26:13Z","pushed_at":"2015-09-24T12:06:49Z","git_url":"git://github.com/mesosphere/marathon.git","ssh_url":"git@github.com:mesosphere/marathon.git","clone_url":"https://github.com/mesosphere/marathon.git","svn_url":"https://github.com/mesosphere/marathon","homepage":"https://mesosphere.github.io/marathon/","size":29316,"stargazers_count":1819,"watchers_count":1819,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":387,"mirror_url":null,"open_issues_count":329,"forks":387,"open_issues":329,"watchers":1819,"default_branch":"master"}},"base":{"label":"mesosphere:master","ref":"master","sha":"8b6542f59f4b2ece8af4e34b342612a8121bac1b","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":10941409,"name":"marathon","full_name":"mesosphere/marathon","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/marathon","description":"Deploy and manage containers (including Docker) on top of Apache Mesos at scale.","fork":false,"url":"https://api.github.com/repos/mesosphere/marathon","forks_url":"https://api.github.com/repos/mesosphere/marathon/forks","keys_url":"https://api.github.com/repos/mesosphere/marathon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/marathon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/marathon/teams","hooks_url":"https://api.github.com/repos/mesosphere/marathon/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/marathon/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/marathon/events","assignees_url":"https://api.github.com/repos/mesosphere/marathon/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/marathon/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/marathon/tags","blobs_url":"https://api.github.com/repos/mesosphere/marathon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/marathon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/marathon/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/marathon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/marathon/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/marathon/languages","stargazers_url":"https://api.github.com/repos/mesosphere/marathon/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/marathon/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/marathon/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/marathon/subscription","commits_url":"https://api.github.com/repos/mesosphere/marathon/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/marathon/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/marathon/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/marathon/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/marathon/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/marathon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/marathon/merges","archive_url":"https://api.github.com/repos/mesosphere/marathon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/marathon/downloads","issues_url":"https://api.github.com/repos/mesosphere/marathon/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/marathon/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/marathon/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/marathon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/marathon/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/marathon/releases{/id}","created_at":"2013-06-25T14:56:34Z","updated_at":"2015-09-24T02:26:13Z","pushed_at":"2015-09-24T12:06:49Z","git_url":"git://github.com/mesosphere/marathon.git","ssh_url":"git@github.com:mesosphere/marathon.git","clone_url":"https://github.com/mesosphere/marathon.git","svn_url":"https://github.com/mesosphere/marathon","homepage":"https://mesosphere.github.io/marathon/","size":29316,"stargazers_count":1819,"watchers_count":1819,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":387,"mirror_url":null,"open_issues_count":329,"forks":387,"open_issues":329,"watchers":1819,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/2305"},"html":{"href":"https://github.com/mesosphere/marathon/pull/2305"},"issue":{"href":"https://api.github.com/repos/mesosphere/marathon/issues/2305"},"comments":{"href":"https://api.github.com/repos/mesosphere/marathon/issues/2305/comments"},"review_comments":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/2305/comments"},"review_comment":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/2305/commits"},"statuses":{"href":"https://api.github.com/repos/mesosphere/marathon/statuses/300bed60bdb61d4f75fa662c6e565b49b7f7c7e9"}}}}