{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/pd/pulls/comments/107153825","pull_request_review_id":28108062,"id":107153825,"diff_hunk":"@@ -316,6 +316,10 @@ type clusterInfo struct {\n \tmeta    *metapb.Cluster\n \tstores  *storesInfo\n \tregions *regionsInfo\n+\n+\t// For test cases.\n+\tfakeLeaderCount map[uint64]int // storeID -> leader count.","path":"server/cache.go","position":6,"original_position":6,"commit_id":"fee7ed534a968aed1811171c09ce46a3940e9424","original_commit_id":"fee7ed534a968aed1811171c09ce46a3940e9424","user":{"login":"siddontang","id":1080370,"avatar_url":"https://avatars1.githubusercontent.com/u/1080370?v=3","gravatar_id":"","url":"https://api.github.com/users/siddontang","html_url":"https://github.com/siddontang","followers_url":"https://api.github.com/users/siddontang/followers","following_url":"https://api.github.com/users/siddontang/following{/other_user}","gists_url":"https://api.github.com/users/siddontang/gists{/gist_id}","starred_url":"https://api.github.com/users/siddontang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siddontang/subscriptions","organizations_url":"https://api.github.com/users/siddontang/orgs","repos_url":"https://api.github.com/users/siddontang/repos","events_url":"https://api.github.com/users/siddontang/events{/privacy}","received_events_url":"https://api.github.com/users/siddontang/received_events","type":"User","site_admin":false},"body":"Hi @coocood \r\n\r\nDo you have any better way to mock the leader and region count in test? ","created_at":"2017-03-21T13:32:49Z","updated_at":"2017-03-21T13:32:50Z","html_url":"https://github.com/pingcap/pd/pull/575#discussion_r107153825","pull_request_url":"https://api.github.com/repos/pingcap/pd/pulls/575","_links":{"self":{"href":"https://api.github.com/repos/pingcap/pd/pulls/comments/107153825"},"html":{"href":"https://github.com/pingcap/pd/pull/575#discussion_r107153825"},"pull_request":{"href":"https://api.github.com/repos/pingcap/pd/pulls/575"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/pd/pulls/575","id":111695162,"html_url":"https://github.com/pingcap/pd/pull/575","diff_url":"https://github.com/pingcap/pd/pull/575.diff","patch_url":"https://github.com/pingcap/pd/pull/575.patch","issue_url":"https://api.github.com/repos/pingcap/pd/issues/575","number":575,"state":"open","locked":false,"title":"clusterInfo: calculate leaderCount/regionCount from cache.","user":{"login":"disksing","id":12077877,"avatar_url":"https://avatars2.githubusercontent.com/u/12077877?v=3","gravatar_id":"","url":"https://api.github.com/users/disksing","html_url":"https://github.com/disksing","followers_url":"https://api.github.com/users/disksing/followers","following_url":"https://api.github.com/users/disksing/following{/other_user}","gists_url":"https://api.github.com/users/disksing/gists{/gist_id}","starred_url":"https://api.github.com/users/disksing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/disksing/subscriptions","organizations_url":"https://api.github.com/users/disksing/orgs","repos_url":"https://api.github.com/users/disksing/repos","events_url":"https://api.github.com/users/disksing/events{/privacy}","received_events_url":"https://api.github.com/users/disksing/received_events","type":"User","site_admin":false},"body":"cc @nolouch \r\n\r\nThis PR aims to optimize balance speed by always using region cache to calculate a store's leaderCount and regionCount, which will be more up to date compared to reading it from StoreHeartbeat.\r\n\r\nThe main modify is whenever we get a `storeInfo` from `clusterInfo`, we setup its leaderCount and regionCount by calculating them from region cache.\r\n\r\nHowever, some tests rely on manually setting leaderCount/regionCount, so `setFakeLeaderCount` and `setFakeRegionCont` are introduced to keep them working properly.","created_at":"2017-03-21T03:14:44Z","updated_at":"2017-03-21T13:32:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b70ad3114cac8299e549cf539c5430de2ceaf55b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/pd/pulls/575/commits","review_comments_url":"https://api.github.com/repos/pingcap/pd/pulls/575/comments","review_comment_url":"https://api.github.com/repos/pingcap/pd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/pd/issues/575/comments","statuses_url":"https://api.github.com/repos/pingcap/pd/statuses/fee7ed534a968aed1811171c09ce46a3940e9424","head":{"label":"pingcap:disksing/leader-count-2","ref":"disksing/leader-count-2","sha":"fee7ed534a968aed1811171c09ce46a3940e9424","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars0.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":53311716,"name":"pd","full_name":"pingcap/pd","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars0.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/pd","description":"Placement driver for TiKV","fork":false,"url":"https://api.github.com/repos/pingcap/pd","forks_url":"https://api.github.com/repos/pingcap/pd/forks","keys_url":"https://api.github.com/repos/pingcap/pd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/pd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/pd/teams","hooks_url":"https://api.github.com/repos/pingcap/pd/hooks","issue_events_url":"https://api.github.com/repos/pingcap/pd/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/pd/events","assignees_url":"https://api.github.com/repos/pingcap/pd/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/pd/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/pd/tags","blobs_url":"https://api.github.com/repos/pingcap/pd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/pd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/pd/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/pd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/pd/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/pd/languages","stargazers_url":"https://api.github.com/repos/pingcap/pd/stargazers","contributors_url":"https://api.github.com/repos/pingcap/pd/contributors","subscribers_url":"https://api.github.com/repos/pingcap/pd/subscribers","subscription_url":"https://api.github.com/repos/pingcap/pd/subscription","commits_url":"https://api.github.com/repos/pingcap/pd/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/pd/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/pd/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/pd/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/pd/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/pd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/pd/merges","archive_url":"https://api.github.com/repos/pingcap/pd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/pd/downloads","issues_url":"https://api.github.com/repos/pingcap/pd/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/pd/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/pd/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/pd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/pd/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/pd/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/pd/deployments","created_at":"2016-03-07T09:13:06Z","updated_at":"2017-03-21T10:46:13Z","pushed_at":"2017-03-21T10:36:27Z","git_url":"git://github.com/pingcap/pd.git","ssh_url":"git@github.com:pingcap/pd.git","clone_url":"https://github.com/pingcap/pd.git","svn_url":"https://github.com/pingcap/pd","homepage":"","size":5325,"stargazers_count":43,"watchers_count":43,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":43,"forks":24,"open_issues":43,"watchers":43,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"0d76dacf4ca5b58ab073bd7c91aad3897b3c3c93","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars0.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":53311716,"name":"pd","full_name":"pingcap/pd","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars0.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/pd","description":"Placement driver for TiKV","fork":false,"url":"https://api.github.com/repos/pingcap/pd","forks_url":"https://api.github.com/repos/pingcap/pd/forks","keys_url":"https://api.github.com/repos/pingcap/pd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/pd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/pd/teams","hooks_url":"https://api.github.com/repos/pingcap/pd/hooks","issue_events_url":"https://api.github.com/repos/pingcap/pd/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/pd/events","assignees_url":"https://api.github.com/repos/pingcap/pd/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/pd/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/pd/tags","blobs_url":"https://api.github.com/repos/pingcap/pd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/pd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/pd/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/pd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/pd/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/pd/languages","stargazers_url":"https://api.github.com/repos/pingcap/pd/stargazers","contributors_url":"https://api.github.com/repos/pingcap/pd/contributors","subscribers_url":"https://api.github.com/repos/pingcap/pd/subscribers","subscription_url":"https://api.github.com/repos/pingcap/pd/subscription","commits_url":"https://api.github.com/repos/pingcap/pd/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/pd/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/pd/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/pd/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/pd/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/pd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/pd/merges","archive_url":"https://api.github.com/repos/pingcap/pd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/pd/downloads","issues_url":"https://api.github.com/repos/pingcap/pd/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/pd/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/pd/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/pd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/pd/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/pd/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/pd/deployments","created_at":"2016-03-07T09:13:06Z","updated_at":"2017-03-21T10:46:13Z","pushed_at":"2017-03-21T10:36:27Z","git_url":"git://github.com/pingcap/pd.git","ssh_url":"git@github.com:pingcap/pd.git","clone_url":"https://github.com/pingcap/pd.git","svn_url":"https://github.com/pingcap/pd","homepage":"","size":5325,"stargazers_count":43,"watchers_count":43,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":43,"forks":24,"open_issues":43,"watchers":43,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/pd/pulls/575"},"html":{"href":"https://github.com/pingcap/pd/pull/575"},"issue":{"href":"https://api.github.com/repos/pingcap/pd/issues/575"},"comments":{"href":"https://api.github.com/repos/pingcap/pd/issues/575/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/pd/pulls/575/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/pd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/pd/pulls/575/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/pd/statuses/fee7ed534a968aed1811171c09ce46a3940e9424"}}}}
{"actor":{"display_login":"siddontang"}}