{"action":"created","comment":{"url":"https://api.github.com/repos/baidu/tera/pulls/comments/48473951","id":48473951,"diff_hunk":"@@ -2092,40 +2110,38 @@ int32_t MetaOp(Client* client, int32_t argc, char** argv, ErrorCode* err) {\n     return 0;\n }\n \n-int32_t CompactOp(int32_t argc, char** argv) {\n-    if (argc != 6) {\n+int32_t CompactOp(Client* client, int32_t argc, char** argv, ErrorCode* err) {\n+    if (argc != 3) {\n         UsageMore(argv[0]);\n         return -1;\n     }\n \n-    CompactTabletRequest request;\n-    CompactTabletResponse response;\n-    request.set_sequence_id(0);\n-    request.set_tablet_name(argv[2]);\n-    request.mutable_key_range()->set_key_start(argv[3]);\n-    request.mutable_key_range()->set_key_end(argv[4]);\n-    tabletnode::TabletNodeClient client(argv[5]); // do not retry\n-\n-    if (!client.CompactTablet(&request, &response)) {\n-        std::cerr << \"rpc fail to connect [\" << client.GetConnectAddr()\n-            << \"] to compact table\" << std::endl;\n-        return -1;\n+    std::string tablename = argv[2];\n+    std::vector<TabletInfo> tablet_list;\n+    if (!client->GetTabletLocation(tablename, &tablet_list, err)) {\n+        LOG(ERROR) << \"fail to list tablets info: \" << tablename;\n+        return -3;\n     }\n \n-    if (response.status() != kTabletNodeOk) {\n-        std::cerr << \"fail to compact table, status: \"\n-            << StatusCodeToString(response.status()) << std::endl;\n-        return -1;\n+    int conc = FLAGS_concurrency;\n+    if (conc <= 0 || conc > 1000) {\n+        LOG(ERROR) << \"compact concurrency illegal: \" << conc;\n     }\n \n-    if (response.compact_status() != kTableCompacted) {\n-        std::cerr << \"fail to compact table, status: \"\n-            << StatusCodeToString(response.compact_status()) << std::endl;\n-        return -1;\n+    ThreadPool thread_pool(conc);\n+    std::vector<TabletInfo>::iterator tablet_it = tablet_list.begin();\n+    for (; tablet_it != tablet_list.end(); ++tablet_it) {\n+        ThreadPool::Task task =\n+                boost::bind(&CompactTablet, *tablet_it, FLAGS_lg);\n+        thread_pool.AddTask(task);","path":"src/teracli_main.cc","position":177,"original_position":177,"commit_id":"714ea59f2f63d7ed98938023da001ff449bdf6de","original_commit_id":"714ea59f2f63d7ed98938023da001ff449bdf6de","user":{"login":"00k","id":9716419,"avatar_url":"https://avatars.githubusercontent.com/u/9716419?v=3","gravatar_id":"","url":"https://api.github.com/users/00k","html_url":"https://github.com/00k","followers_url":"https://api.github.com/users/00k/followers","following_url":"https://api.github.com/users/00k/following{/other_user}","gists_url":"https://api.github.com/users/00k/gists{/gist_id}","starred_url":"https://api.github.com/users/00k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/00k/subscriptions","organizations_url":"https://api.github.com/users/00k/orgs","repos_url":"https://api.github.com/users/00k/repos","events_url":"https://api.github.com/users/00k/events{/privacy}","received_events_url":"https://api.github.com/users/00k/received_events","type":"User","site_admin":false},"body":"compact在ts那边是异步返回，不需要搞线程池","created_at":"2015-12-28T11:04:29Z","updated_at":"2015-12-28T11:04:29Z","html_url":"https://github.com/baidu/tera/pull/649#discussion_r48473951","pull_request_url":"https://api.github.com/repos/baidu/tera/pulls/649","_links":{"self":{"href":"https://api.github.com/repos/baidu/tera/pulls/comments/48473951"},"html":{"href":"https://github.com/baidu/tera/pull/649#discussion_r48473951"},"pull_request":{"href":"https://api.github.com/repos/baidu/tera/pulls/649"}}},"pull_request":{"url":"https://api.github.com/repos/baidu/tera/pulls/649","id":54639417,"html_url":"https://github.com/baidu/tera/pull/649","diff_url":"https://github.com/baidu/tera/pull/649.diff","patch_url":"https://github.com/baidu/tera/pull/649.patch","issue_url":"https://api.github.com/repos/baidu/tera/issues/649","number":649,"state":"open","locked":false,"title":"support teracli-compact-table #648","user":{"login":"xupeilin","id":11419707,"avatar_url":"https://avatars.githubusercontent.com/u/11419707?v=3","gravatar_id":"","url":"https://api.github.com/users/xupeilin","html_url":"https://github.com/xupeilin","followers_url":"https://api.github.com/users/xupeilin/followers","following_url":"https://api.github.com/users/xupeilin/following{/other_user}","gists_url":"https://api.github.com/users/xupeilin/gists{/gist_id}","starred_url":"https://api.github.com/users/xupeilin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xupeilin/subscriptions","organizations_url":"https://api.github.com/users/xupeilin/orgs","repos_url":"https://api.github.com/users/xupeilin/repos","events_url":"https://api.github.com/users/xupeilin/events{/privacy}","received_events_url":"https://api.github.com/users/xupeilin/received_events","type":"User","site_admin":false},"body":"#648","created_at":"2015-12-28T08:32:38Z","updated_at":"2015-12-28T11:04:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7713aef8b14b94d53bf570c547447f6fe468641d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/baidu/tera/pulls/649/commits","review_comments_url":"https://api.github.com/repos/baidu/tera/pulls/649/comments","review_comment_url":"https://api.github.com/repos/baidu/tera/pulls/comments{/number}","comments_url":"https://api.github.com/repos/baidu/tera/issues/649/comments","statuses_url":"https://api.github.com/repos/baidu/tera/statuses/714ea59f2f63d7ed98938023da001ff449bdf6de","head":{"label":"xupeilin:teracli-compact","ref":"teracli-compact","sha":"714ea59f2f63d7ed98938023da001ff449bdf6de","user":{"login":"xupeilin","id":11419707,"avatar_url":"https://avatars.githubusercontent.com/u/11419707?v=3","gravatar_id":"","url":"https://api.github.com/users/xupeilin","html_url":"https://github.com/xupeilin","followers_url":"https://api.github.com/users/xupeilin/followers","following_url":"https://api.github.com/users/xupeilin/following{/other_user}","gists_url":"https://api.github.com/users/xupeilin/gists{/gist_id}","starred_url":"https://api.github.com/users/xupeilin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xupeilin/subscriptions","organizations_url":"https://api.github.com/users/xupeilin/orgs","repos_url":"https://api.github.com/users/xupeilin/repos","events_url":"https://api.github.com/users/xupeilin/events{/privacy}","received_events_url":"https://api.github.com/users/xupeilin/received_events","type":"User","site_admin":false},"repo":{"id":32515161,"name":"tera","full_name":"xupeilin/tera","owner":{"login":"xupeilin","id":11419707,"avatar_url":"https://avatars.githubusercontent.com/u/11419707?v=3","gravatar_id":"","url":"https://api.github.com/users/xupeilin","html_url":"https://github.com/xupeilin","followers_url":"https://api.github.com/users/xupeilin/followers","following_url":"https://api.github.com/users/xupeilin/following{/other_user}","gists_url":"https://api.github.com/users/xupeilin/gists{/gist_id}","starred_url":"https://api.github.com/users/xupeilin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xupeilin/subscriptions","organizations_url":"https://api.github.com/users/xupeilin/orgs","repos_url":"https://api.github.com/users/xupeilin/repos","events_url":"https://api.github.com/users/xupeilin/events{/privacy}","received_events_url":"https://api.github.com/users/xupeilin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xupeilin/tera","description":"A distributed table storage system.","fork":true,"url":"https://api.github.com/repos/xupeilin/tera","forks_url":"https://api.github.com/repos/xupeilin/tera/forks","keys_url":"https://api.github.com/repos/xupeilin/tera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xupeilin/tera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xupeilin/tera/teams","hooks_url":"https://api.github.com/repos/xupeilin/tera/hooks","issue_events_url":"https://api.github.com/repos/xupeilin/tera/issues/events{/number}","events_url":"https://api.github.com/repos/xupeilin/tera/events","assignees_url":"https://api.github.com/repos/xupeilin/tera/assignees{/user}","branches_url":"https://api.github.com/repos/xupeilin/tera/branches{/branch}","tags_url":"https://api.github.com/repos/xupeilin/tera/tags","blobs_url":"https://api.github.com/repos/xupeilin/tera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xupeilin/tera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xupeilin/tera/git/refs{/sha}","trees_url":"https://api.github.com/repos/xupeilin/tera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xupeilin/tera/statuses/{sha}","languages_url":"https://api.github.com/repos/xupeilin/tera/languages","stargazers_url":"https://api.github.com/repos/xupeilin/tera/stargazers","contributors_url":"https://api.github.com/repos/xupeilin/tera/contributors","subscribers_url":"https://api.github.com/repos/xupeilin/tera/subscribers","subscription_url":"https://api.github.com/repos/xupeilin/tera/subscription","commits_url":"https://api.github.com/repos/xupeilin/tera/commits{/sha}","git_commits_url":"https://api.github.com/repos/xupeilin/tera/git/commits{/sha}","comments_url":"https://api.github.com/repos/xupeilin/tera/comments{/number}","issue_comment_url":"https://api.github.com/repos/xupeilin/tera/issues/comments{/number}","contents_url":"https://api.github.com/repos/xupeilin/tera/contents/{+path}","compare_url":"https://api.github.com/repos/xupeilin/tera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xupeilin/tera/merges","archive_url":"https://api.github.com/repos/xupeilin/tera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xupeilin/tera/downloads","issues_url":"https://api.github.com/repos/xupeilin/tera/issues{/number}","pulls_url":"https://api.github.com/repos/xupeilin/tera/pulls{/number}","milestones_url":"https://api.github.com/repos/xupeilin/tera/milestones{/number}","notifications_url":"https://api.github.com/repos/xupeilin/tera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xupeilin/tera/labels{/name}","releases_url":"https://api.github.com/repos/xupeilin/tera/releases{/id}","created_at":"2015-03-19T10:32:01Z","updated_at":"2015-05-07T13:57:33Z","pushed_at":"2015-12-28T10:43:09Z","git_url":"git://github.com/xupeilin/tera.git","ssh_url":"git@github.com:xupeilin/tera.git","clone_url":"https://github.com/xupeilin/tera.git","svn_url":"https://github.com/xupeilin/tera","homepage":"","size":14721,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"master"}},"base":{"label":"baidu:master","ref":"master","sha":"d319b2d9fa460affc612b2ddfb921bf6177753a6","user":{"login":"baidu","id":13245940,"avatar_url":"https://avatars.githubusercontent.com/u/13245940?v=3","gravatar_id":"","url":"https://api.github.com/users/baidu","html_url":"https://github.com/baidu","followers_url":"https://api.github.com/users/baidu/followers","following_url":"https://api.github.com/users/baidu/following{/other_user}","gists_url":"https://api.github.com/users/baidu/gists{/gist_id}","starred_url":"https://api.github.com/users/baidu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baidu/subscriptions","organizations_url":"https://api.github.com/users/baidu/orgs","repos_url":"https://api.github.com/users/baidu/repos","events_url":"https://api.github.com/users/baidu/events{/privacy}","received_events_url":"https://api.github.com/users/baidu/received_events","type":"Organization","site_admin":false},"repo":{"id":18129915,"name":"tera","full_name":"baidu/tera","owner":{"login":"baidu","id":13245940,"avatar_url":"https://avatars.githubusercontent.com/u/13245940?v=3","gravatar_id":"","url":"https://api.github.com/users/baidu","html_url":"https://github.com/baidu","followers_url":"https://api.github.com/users/baidu/followers","following_url":"https://api.github.com/users/baidu/following{/other_user}","gists_url":"https://api.github.com/users/baidu/gists{/gist_id}","starred_url":"https://api.github.com/users/baidu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baidu/subscriptions","organizations_url":"https://api.github.com/users/baidu/orgs","repos_url":"https://api.github.com/users/baidu/repos","events_url":"https://api.github.com/users/baidu/events{/privacy}","received_events_url":"https://api.github.com/users/baidu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/baidu/tera","description":"A distributed, elastic, structured database.","fork":false,"url":"https://api.github.com/repos/baidu/tera","forks_url":"https://api.github.com/repos/baidu/tera/forks","keys_url":"https://api.github.com/repos/baidu/tera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baidu/tera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baidu/tera/teams","hooks_url":"https://api.github.com/repos/baidu/tera/hooks","issue_events_url":"https://api.github.com/repos/baidu/tera/issues/events{/number}","events_url":"https://api.github.com/repos/baidu/tera/events","assignees_url":"https://api.github.com/repos/baidu/tera/assignees{/user}","branches_url":"https://api.github.com/repos/baidu/tera/branches{/branch}","tags_url":"https://api.github.com/repos/baidu/tera/tags","blobs_url":"https://api.github.com/repos/baidu/tera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baidu/tera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baidu/tera/git/refs{/sha}","trees_url":"https://api.github.com/repos/baidu/tera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baidu/tera/statuses/{sha}","languages_url":"https://api.github.com/repos/baidu/tera/languages","stargazers_url":"https://api.github.com/repos/baidu/tera/stargazers","contributors_url":"https://api.github.com/repos/baidu/tera/contributors","subscribers_url":"https://api.github.com/repos/baidu/tera/subscribers","subscription_url":"https://api.github.com/repos/baidu/tera/subscription","commits_url":"https://api.github.com/repos/baidu/tera/commits{/sha}","git_commits_url":"https://api.github.com/repos/baidu/tera/git/commits{/sha}","comments_url":"https://api.github.com/repos/baidu/tera/comments{/number}","issue_comment_url":"https://api.github.com/repos/baidu/tera/issues/comments{/number}","contents_url":"https://api.github.com/repos/baidu/tera/contents/{+path}","compare_url":"https://api.github.com/repos/baidu/tera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baidu/tera/merges","archive_url":"https://api.github.com/repos/baidu/tera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baidu/tera/downloads","issues_url":"https://api.github.com/repos/baidu/tera/issues{/number}","pulls_url":"https://api.github.com/repos/baidu/tera/pulls{/number}","milestones_url":"https://api.github.com/repos/baidu/tera/milestones{/number}","notifications_url":"https://api.github.com/repos/baidu/tera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baidu/tera/labels{/name}","releases_url":"https://api.github.com/repos/baidu/tera/releases{/id}","created_at":"2014-03-26T07:22:05Z","updated_at":"2015-12-23T11:13:33Z","pushed_at":"2015-12-28T08:32:38Z","git_url":"git://github.com/baidu/tera.git","ssh_url":"git@github.com:baidu/tera.git","clone_url":"https://github.com/baidu/tera.git","svn_url":"https://github.com/baidu/tera","homepage":"","size":16045,"stargazers_count":334,"watchers_count":334,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":108,"mirror_url":null,"open_issues_count":112,"forks":108,"open_issues":112,"watchers":334,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/baidu/tera/pulls/649"},"html":{"href":"https://github.com/baidu/tera/pull/649"},"issue":{"href":"https://api.github.com/repos/baidu/tera/issues/649"},"comments":{"href":"https://api.github.com/repos/baidu/tera/issues/649/comments"},"review_comments":{"href":"https://api.github.com/repos/baidu/tera/pulls/649/comments"},"review_comment":{"href":"https://api.github.com/repos/baidu/tera/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/baidu/tera/pulls/649/commits"},"statuses":{"href":"https://api.github.com/repos/baidu/tera/statuses/714ea59f2f63d7ed98938023da001ff449bdf6de"}}}}