{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/pd/pulls/comments/77513062","id":77513062,"diff_hunk":"@@ -612,3 +612,73 @@ func (s *testClusterWorkerSuite) TestReportSplit(c *C) {\n \tc.Assert(op.Origin.GetPeers(), HasLen, 1)\n \tc.Assert(op.Origin.GetPeers()[0], DeepEquals, peer)\n }\n+\n+func (s *testClusterWorkerSuite) TestBalanceOperatorPriority(c *C) {\n+\tcluster, err := s.svr.GetRaftCluster()\n+\tc.Assert(err, IsNil)\n+\tbw := cluster.balancerWorker\n+\n+\terr = cluster.putConfig(&metapb.Cluster{\n+\t\tId:           s.clusterID,\n+\t\tMaxPeerCount: 1,\n+\t})\n+\tc.Assert(err, IsNil)\n+\n+\tleaderPd := mustGetLeader(c, s.client, s.svr.getLeaderPath())\n+\tconn, err := rpcConnect(leaderPd.GetAddr())\n+\tc.Assert(err, IsNil)\n+\tdefer conn.Close()\n+\n+\tregion, _ := cluster.getRegion([]byte{'a'})\n+\tc.Assert(region.GetPeers(), HasLen, 1)\n+\tleader := s.chooseRegionLeader(c, region)\n+\n+\t// region has enough replicas and no balance operator.\n+\tresp := heartbeatRegion(c, conn, s.clusterID, 0, region, leader)\n+\tc.Assert(resp, IsNil)\n+\n+\t// Add a balanceOP.\n+\tremovePeerOperator := newRemovePeerOperator(region.GetId(), leader)\n+\tbop := newBalanceOperator(region, balanceOP, removePeerOperator)\n+\tok := bw.addBalanceOperator(region.GetId(), bop)\n+\tc.Assert(ok, IsTrue)\n+\t// Add a balanceOP again will fail.\n+\tok = bw.addBalanceOperator(region.GetId(), bop)\n+\tc.Assert(ok, IsFalse)\n+\n+\t// Now we will get a balanceOP.\n+\tresp = heartbeatRegion(c, conn, s.clusterID, 0, region, leader)\n+\tc.Assert(resp, DeepEquals, removePeerOperator.ChangePeer)\n+\top := bw.getBalanceOperator(region.GetId())\n+\tc.Assert(op.Type, Equals, balanceOP)\n+\n+\terr = cluster.putConfig(&metapb.Cluster{\n+\t\tId:           s.clusterID,\n+\t\tMaxPeerCount: 3,\n+\t})\n+\tc.Assert(err, IsNil)\n+\n+\t// Now region doesn't have enough replicas, we will get a replicaOP.\n+\tresp = heartbeatRegion(c, conn, s.clusterID, 0, region, leader)\n+\tc.Assert(resp.GetChangeType(), Equals, raftpb.ConfChangeType_AddNode)\n+\top = bw.getBalanceOperator(region.GetId())\n+\t// replicaOP finishes immediately, so we op is nil here.","path":"server/cluster_worker_test.go","position":54,"original_position":54,"commit_id":"cf9defd137b45f130c9c34d1dd67cbfc1e4402f5","original_commit_id":"cf9defd137b45f130c9c34d1dd67cbfc1e4402f5","user":{"login":"qiuyesuifeng","id":1953644,"avatar_url":"https://avatars.githubusercontent.com/u/1953644?v=3","gravatar_id":"","url":"https://api.github.com/users/qiuyesuifeng","html_url":"https://github.com/qiuyesuifeng","followers_url":"https://api.github.com/users/qiuyesuifeng/followers","following_url":"https://api.github.com/users/qiuyesuifeng/following{/other_user}","gists_url":"https://api.github.com/users/qiuyesuifeng/gists{/gist_id}","starred_url":"https://api.github.com/users/qiuyesuifeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiuyesuifeng/subscriptions","organizations_url":"https://api.github.com/users/qiuyesuifeng/orgs","repos_url":"https://api.github.com/users/qiuyesuifeng/repos","events_url":"https://api.github.com/users/qiuyesuifeng/events{/privacy}","received_events_url":"https://api.github.com/users/qiuyesuifeng/received_events","type":"User","site_admin":false},"body":"so the op?","created_at":"2016-09-05T12:13:45Z","updated_at":"2016-09-05T12:13:45Z","html_url":"https://github.com/pingcap/pd/pull/308#discussion_r77513062","pull_request_url":"https://api.github.com/repos/pingcap/pd/pulls/308","_links":{"self":{"href":"https://api.github.com/repos/pingcap/pd/pulls/comments/77513062"},"html":{"href":"https://github.com/pingcap/pd/pull/308#discussion_r77513062"},"pull_request":{"href":"https://api.github.com/repos/pingcap/pd/pulls/308"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/pd/pulls/308","id":83786409,"html_url":"https://github.com/pingcap/pd/pull/308","diff_url":"https://github.com/pingcap/pd/pull/308.diff","patch_url":"https://github.com/pingcap/pd/pull/308.patch","issue_url":"https://api.github.com/repos/pingcap/pd/issues/308","number":308,"state":"open","locked":false,"title":"add admin operators.","user":{"login":"huachaohuang","id":7806468,"avatar_url":"https://avatars.githubusercontent.com/u/7806468?v=3","gravatar_id":"","url":"https://api.github.com/users/huachaohuang","html_url":"https://github.com/huachaohuang","followers_url":"https://api.github.com/users/huachaohuang/followers","following_url":"https://api.github.com/users/huachaohuang/following{/other_user}","gists_url":"https://api.github.com/users/huachaohuang/gists{/gist_id}","starred_url":"https://api.github.com/users/huachaohuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huachaohuang/subscriptions","organizations_url":"https://api.github.com/users/huachaohuang/orgs","repos_url":"https://api.github.com/users/huachaohuang/repos","events_url":"https://api.github.com/users/huachaohuang/events{/privacy}","received_events_url":"https://api.github.com/users/huachaohuang/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-02T11:29:00Z","updated_at":"2016-09-05T12:13:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a3df636171a2c27a264150c767b6b2b1edee3e6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/pd/pulls/308/commits","review_comments_url":"https://api.github.com/repos/pingcap/pd/pulls/308/comments","review_comment_url":"https://api.github.com/repos/pingcap/pd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/pd/issues/308/comments","statuses_url":"https://api.github.com/repos/pingcap/pd/statuses/cf9defd137b45f130c9c34d1dd67cbfc1e4402f5","head":{"label":"pingcap:huachaohuang/admin-operators","ref":"huachaohuang/admin-operators","sha":"cf9defd137b45f130c9c34d1dd67cbfc1e4402f5","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.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://avatars.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":"2016-08-27T15:19:47Z","pushed_at":"2016-09-05T11:59:16Z","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":3654,"stargazers_count":18,"watchers_count":18,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":20,"forks":5,"open_issues":20,"watchers":18,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"d627f70ac0af46ec2a2bce5dfe612b755b06872c","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.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://avatars.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":"2016-08-27T15:19:47Z","pushed_at":"2016-09-05T11:59:16Z","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":3654,"stargazers_count":18,"watchers_count":18,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":20,"forks":5,"open_issues":20,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/pd/pulls/308"},"html":{"href":"https://github.com/pingcap/pd/pull/308"},"issue":{"href":"https://api.github.com/repos/pingcap/pd/issues/308"},"comments":{"href":"https://api.github.com/repos/pingcap/pd/issues/308/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/pd/pulls/308/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/pd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/pd/pulls/308/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/pd/statuses/cf9defd137b45f130c9c34d1dd67cbfc1e4402f5"}}}}
{"actor":{"display_login":"qiuyesuifeng"}}