{"action":"created","comment":{"url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/comments/73975864","id":73975864,"diff_hunk":"@@ -5,56 +5,59 @@ import (\n \t\"metricscollector/db\"\n \t\"metricscollector/metrics\"\n \n+\t\"code.cloudfoundry.org/clock\"\n \t\"code.cloudfoundry.org/lager\"\n+\n \t\"time\"\n )\n \n type AppPoller struct {\n-\tlogger   lager.Logger\n-\tappId    string\n-\tinterval time.Duration\n-\tcfc      cf.CfClient\n-\tnoaa     NoaaConsumer\n-\tdatabase db.DB\n-\tticker   *time.Ticker\n-\tdoneChan chan bool\n+\tappId        string\n+\tpollInterval int\n+\tlogger       lager.Logger\n+\tcfc          cf.CfClient\n+\tnoaa         NoaaConsumer\n+\tdatabase     db.DB\n+\tpclock       clock.Clock\n+\tticker       clock.Ticker\n+\tdoneChan     chan bool\n }\n \n-func NewAppPoller(logger lager.Logger, appId string, interval time.Duration, cfc cf.CfClient, noaa NoaaConsumer, database db.DB) *AppPoller {\n+func NewAppPoller(appId string, pollInterval int, logger lager.Logger, cfc cf.CfClient, noaa NoaaConsumer, database db.DB, pclcok clock.Clock) *AppPoller {\n \treturn &AppPoller{\n-\t\tlogger:   logger,\n-\t\tappId:    appId,\n-\t\tinterval: interval,\n-\t\tcfc:      cfc,\n-\t\tnoaa:     noaa,\n-\t\tdatabase: database,\n-\t\tdoneChan: make(chan bool),\n+\t\tappId:        appId,\n+\t\tpollInterval: pollInterval,\n+\t\tlogger:       logger,\n+\t\tcfc:          cfc,\n+\t\tnoaa:         noaa,\n+\t\tdatabase:     database,\n+\t\tpclock:       pclcok,\n+\t\tdoneChan:     make(chan bool),\n \t}\n \n }\n \n func (ap *AppPoller) Start() {\n-\tap.ticker = time.NewTicker(ap.interval)\n+\tap.ticker = ap.pclock.NewTicker(time.Duration(ap.pollInterval) * time.Second)\n \tgo ap.startPollMetrics()\n \n-\tap.logger.Info(\"app-poller-started\", lager.Data{\"appid\": ap.appId})\n+\tap.logger.Info(\"app-poller-started\", lager.Data{\"appid\": ap.appId, \"poll-interval\": ap.pollInterval})\n }\n \n func (ap *AppPoller) Stop() {\n \tif ap.ticker != nil {\n \t\tap.ticker.Stop()\n-\t\tap.doneChan <- true\n+\t\tclose(ap.doneChan)\n \t}\n \tap.logger.Info(\"app-poller-stopped\", lager.Data{\"appid\": ap.appId})\n }\n \n func (ap *AppPoller) startPollMetrics() {\n-\tap.pollMetric()\n \tfor {\n \t\tselect {\n \t\tcase <-ap.doneChan:\n \t\t\treturn\n-\t\tcase <-ap.ticker.C:\n+\t\tcase <-ap.ticker.C():\n \t\t\tap.pollMetric()","path":"src/metricscollector/collector/apppoller.go","position":null,"original_position":78,"commit_id":"241c0891ead6b46a283a9700bb3a7b9cdfddd442","original_commit_id":"241c0891ead6b46a283a9700bb3a7b9cdfddd442","user":{"login":"boyang9527","id":5013402,"avatar_url":"https://avatars.githubusercontent.com/u/5013402?v=3","gravatar_id":"","url":"https://api.github.com/users/boyang9527","html_url":"https://github.com/boyang9527","followers_url":"https://api.github.com/users/boyang9527/followers","following_url":"https://api.github.com/users/boyang9527/following{/other_user}","gists_url":"https://api.github.com/users/boyang9527/gists{/gist_id}","starred_url":"https://api.github.com/users/boyang9527/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boyang9527/subscriptions","organizations_url":"https://api.github.com/users/boyang9527/orgs","repos_url":"https://api.github.com/users/boyang9527/repos","events_url":"https://api.github.com/users/boyang9527/events{/privacy}","received_events_url":"https://api.github.com/users/boyang9527/received_events","type":"User","site_admin":false},"body":"moved back to beginning of the loop to ensure immediate poll","created_at":"2016-08-08T23:36:53Z","updated_at":"2016-08-08T23:36:53Z","html_url":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/60#discussion_r73975864","pull_request_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/60","_links":{"self":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/comments/73975864"},"html":{"href":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/60#discussion_r73975864"},"pull_request":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/60"}}},"pull_request":{"url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/60","id":79423113,"html_url":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/60","diff_url":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/60.diff","patch_url":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/60.patch","issue_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/60","number":60,"state":"open","locked":false,"title":"watch app changes in policy db and start/stop collecting metrics of t…","user":{"login":"boyang9527","id":5013402,"avatar_url":"https://avatars.githubusercontent.com/u/5013402?v=3","gravatar_id":"","url":"https://api.github.com/users/boyang9527","html_url":"https://github.com/boyang9527","followers_url":"https://api.github.com/users/boyang9527/followers","following_url":"https://api.github.com/users/boyang9527/following{/other_user}","gists_url":"https://api.github.com/users/boyang9527/gists{/gist_id}","starred_url":"https://api.github.com/users/boyang9527/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boyang9527/subscriptions","organizations_url":"https://api.github.com/users/boyang9527/orgs","repos_url":"https://api.github.com/users/boyang9527/repos","events_url":"https://api.github.com/users/boyang9527/events{/privacy}","received_events_url":"https://api.github.com/users/boyang9527/received_events","type":"User","site_admin":false},"body":"…he apps\r\n\r\n[#119505033]\r\n\r\n- changed the db.GetAppIds to return a map  instead of array\r\n- add configs for collector\r\n- add apppoller to poll app metrics periodically\r\n- add collector to refresh apps, and start/stop app polling\r\n- test cases for apppoller and collector\r\n\r\nThe following is not included, will be addressed in next user story\r\n\r\n- share auto-generated fakes( cf_client, noaa, and db)","created_at":"2016-07-29T20:57:12Z","updated_at":"2016-08-08T23:36:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a15d8491e28f9dab58a6287c285f40a07a4a20a7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/60/commits","review_comments_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/60/comments","review_comment_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/60/comments","statuses_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/statuses/241c0891ead6b46a283a9700bb3a7b9cdfddd442","head":{"label":"boyang9527:story5033","ref":"story5033","sha":"241c0891ead6b46a283a9700bb3a7b9cdfddd442","user":{"login":"boyang9527","id":5013402,"avatar_url":"https://avatars.githubusercontent.com/u/5013402?v=3","gravatar_id":"","url":"https://api.github.com/users/boyang9527","html_url":"https://github.com/boyang9527","followers_url":"https://api.github.com/users/boyang9527/followers","following_url":"https://api.github.com/users/boyang9527/following{/other_user}","gists_url":"https://api.github.com/users/boyang9527/gists{/gist_id}","starred_url":"https://api.github.com/users/boyang9527/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boyang9527/subscriptions","organizations_url":"https://api.github.com/users/boyang9527/orgs","repos_url":"https://api.github.com/users/boyang9527/repos","events_url":"https://api.github.com/users/boyang9527/events{/privacy}","received_events_url":"https://api.github.com/users/boyang9527/received_events","type":"User","site_admin":false},"repo":{"id":56274020,"name":"app-autoscaler","full_name":"boyang9527/app-autoscaler","owner":{"login":"boyang9527","id":5013402,"avatar_url":"https://avatars.githubusercontent.com/u/5013402?v=3","gravatar_id":"","url":"https://api.github.com/users/boyang9527","html_url":"https://github.com/boyang9527","followers_url":"https://api.github.com/users/boyang9527/followers","following_url":"https://api.github.com/users/boyang9527/following{/other_user}","gists_url":"https://api.github.com/users/boyang9527/gists{/gist_id}","starred_url":"https://api.github.com/users/boyang9527/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boyang9527/subscriptions","organizations_url":"https://api.github.com/users/boyang9527/orgs","repos_url":"https://api.github.com/users/boyang9527/repos","events_url":"https://api.github.com/users/boyang9527/events{/privacy}","received_events_url":"https://api.github.com/users/boyang9527/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/boyang9527/app-autoscaler","description":"Auto Scaling for CF Applications","fork":true,"url":"https://api.github.com/repos/boyang9527/app-autoscaler","forks_url":"https://api.github.com/repos/boyang9527/app-autoscaler/forks","keys_url":"https://api.github.com/repos/boyang9527/app-autoscaler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/boyang9527/app-autoscaler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/boyang9527/app-autoscaler/teams","hooks_url":"https://api.github.com/repos/boyang9527/app-autoscaler/hooks","issue_events_url":"https://api.github.com/repos/boyang9527/app-autoscaler/issues/events{/number}","events_url":"https://api.github.com/repos/boyang9527/app-autoscaler/events","assignees_url":"https://api.github.com/repos/boyang9527/app-autoscaler/assignees{/user}","branches_url":"https://api.github.com/repos/boyang9527/app-autoscaler/branches{/branch}","tags_url":"https://api.github.com/repos/boyang9527/app-autoscaler/tags","blobs_url":"https://api.github.com/repos/boyang9527/app-autoscaler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/boyang9527/app-autoscaler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/boyang9527/app-autoscaler/git/refs{/sha}","trees_url":"https://api.github.com/repos/boyang9527/app-autoscaler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/boyang9527/app-autoscaler/statuses/{sha}","languages_url":"https://api.github.com/repos/boyang9527/app-autoscaler/languages","stargazers_url":"https://api.github.com/repos/boyang9527/app-autoscaler/stargazers","contributors_url":"https://api.github.com/repos/boyang9527/app-autoscaler/contributors","subscribers_url":"https://api.github.com/repos/boyang9527/app-autoscaler/subscribers","subscription_url":"https://api.github.com/repos/boyang9527/app-autoscaler/subscription","commits_url":"https://api.github.com/repos/boyang9527/app-autoscaler/commits{/sha}","git_commits_url":"https://api.github.com/repos/boyang9527/app-autoscaler/git/commits{/sha}","comments_url":"https://api.github.com/repos/boyang9527/app-autoscaler/comments{/number}","issue_comment_url":"https://api.github.com/repos/boyang9527/app-autoscaler/issues/comments{/number}","contents_url":"https://api.github.com/repos/boyang9527/app-autoscaler/contents/{+path}","compare_url":"https://api.github.com/repos/boyang9527/app-autoscaler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/boyang9527/app-autoscaler/merges","archive_url":"https://api.github.com/repos/boyang9527/app-autoscaler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/boyang9527/app-autoscaler/downloads","issues_url":"https://api.github.com/repos/boyang9527/app-autoscaler/issues{/number}","pulls_url":"https://api.github.com/repos/boyang9527/app-autoscaler/pulls{/number}","milestones_url":"https://api.github.com/repos/boyang9527/app-autoscaler/milestones{/number}","notifications_url":"https://api.github.com/repos/boyang9527/app-autoscaler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/boyang9527/app-autoscaler/labels{/name}","releases_url":"https://api.github.com/repos/boyang9527/app-autoscaler/releases{/id}","deployments_url":"https://api.github.com/repos/boyang9527/app-autoscaler/deployments","created_at":"2016-04-14T22:31:10Z","updated_at":"2016-04-14T22:31:12Z","pushed_at":"2016-08-06T04:48:08Z","git_url":"git://github.com/boyang9527/app-autoscaler.git","ssh_url":"git@github.com:boyang9527/app-autoscaler.git","clone_url":"https://github.com/boyang9527/app-autoscaler.git","svn_url":"https://github.com/boyang9527/app-autoscaler","homepage":"","size":1460,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"cloudfoundry-incubator:develop","ref":"develop","sha":"0598fd9801801c7b056435683c0d92d3085fe2e4","user":{"login":"cloudfoundry-incubator","id":5680605,"avatar_url":"https://avatars.githubusercontent.com/u/5680605?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudfoundry-incubator","html_url":"https://github.com/cloudfoundry-incubator","followers_url":"https://api.github.com/users/cloudfoundry-incubator/followers","following_url":"https://api.github.com/users/cloudfoundry-incubator/following{/other_user}","gists_url":"https://api.github.com/users/cloudfoundry-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudfoundry-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudfoundry-incubator/subscriptions","organizations_url":"https://api.github.com/users/cloudfoundry-incubator/orgs","repos_url":"https://api.github.com/users/cloudfoundry-incubator/repos","events_url":"https://api.github.com/users/cloudfoundry-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/cloudfoundry-incubator/received_events","type":"Organization","site_admin":false},"repo":{"id":55270767,"name":"app-autoscaler","full_name":"cloudfoundry-incubator/app-autoscaler","owner":{"login":"cloudfoundry-incubator","id":5680605,"avatar_url":"https://avatars.githubusercontent.com/u/5680605?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudfoundry-incubator","html_url":"https://github.com/cloudfoundry-incubator","followers_url":"https://api.github.com/users/cloudfoundry-incubator/followers","following_url":"https://api.github.com/users/cloudfoundry-incubator/following{/other_user}","gists_url":"https://api.github.com/users/cloudfoundry-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudfoundry-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudfoundry-incubator/subscriptions","organizations_url":"https://api.github.com/users/cloudfoundry-incubator/orgs","repos_url":"https://api.github.com/users/cloudfoundry-incubator/repos","events_url":"https://api.github.com/users/cloudfoundry-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/cloudfoundry-incubator/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudfoundry-incubator/app-autoscaler","description":"Auto Scaling for CF Applications","fork":false,"url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler","forks_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/forks","keys_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/teams","hooks_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/hooks","issue_events_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/events{/number}","events_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/events","assignees_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/assignees{/user}","branches_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/branches{/branch}","tags_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/tags","blobs_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/languages","stargazers_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/stargazers","contributors_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/contributors","subscribers_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/subscribers","subscription_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/subscription","commits_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/contents/{+path}","compare_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/merges","archive_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/downloads","issues_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues{/number}","pulls_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/labels{/name}","releases_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/releases{/id}","deployments_url":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/deployments","created_at":"2016-04-02T00:47:11Z","updated_at":"2016-07-05T09:36:15Z","pushed_at":"2016-08-08T12:57:51Z","git_url":"git://github.com/cloudfoundry-incubator/app-autoscaler.git","ssh_url":"git@github.com:cloudfoundry-incubator/app-autoscaler.git","clone_url":"https://github.com/cloudfoundry-incubator/app-autoscaler.git","svn_url":"https://github.com/cloudfoundry-incubator/app-autoscaler","homepage":"","size":1579,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":6,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/60"},"html":{"href":"https://github.com/cloudfoundry-incubator/app-autoscaler/pull/60"},"issue":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/60"},"comments":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/issues/60/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/60/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/pulls/60/commits"},"statuses":{"href":"https://api.github.com/repos/cloudfoundry-incubator/app-autoscaler/statuses/241c0891ead6b46a283a9700bb3a7b9cdfddd442"}}}}
{"actor":{"display_login":"boyang9527"}}