| 1210 | } |
| 1211 | |
| 1212 | CliStatus AllDiff(const std::string& prefix_path) { |
| 1213 | int ret = DfsListDir(prefix_path, &g_tables); |
| 1214 | if (0 != ret) { |
| 1215 | LOG(ERROR) << "all check fail, get table path fail"; |
| 1216 | return CliStatus::kError; |
| 1217 | } |
| 1218 | |
| 1219 | if (g_tables.size() > 0) { |
| 1220 | // scan tablet meta and compare, thread pool parallel |
| 1221 | g_thread_count = g_tables.size(); |
| 1222 | const std::string gc_table("#trackable_gc_trash"); |
| 1223 | const std::string trash_table("#trash"); |
| 1224 | const std::string meta_table("meta"); |
| 1225 | const std::string stat_table("stat_table"); |
| 1226 | |
| 1227 | ThreadPool thread_pool(g_tables.size()); |
| 1228 | for (size_t i = 0; i < g_tables.size(); ++i) { |
| 1229 | LOG(INFO) << "table is:(" << g_tables[i] << ")"; |
| 1230 | if (g_tables[i] == gc_table || g_tables[i] == trash_table || g_tables[i] == meta_table || |
| 1231 | g_tables[i] == stat_table) { |
| 1232 | g_thread_count--; |
| 1233 | continue; |
| 1234 | } |
| 1235 | ThreadPool::Task task = std::bind(&ScanAndDiff, g_tables[i], prefix_path); |
| 1236 | thread_pool.AddTask(task); |
| 1237 | } |
| 1238 | |
| 1239 | while (g_thread_count > 0) { |
| 1240 | LOG(INFO) << get_time_str(time(NULL)) << " " << g_thread_count << "scan and diff ......"; |
| 1241 | sleep(5); |
| 1242 | } |
| 1243 | thread_pool.Stop(true); |
| 1244 | } |
| 1245 | |
| 1246 | if (g_diff_count == 0) { |
| 1247 | std::cout << "tables no diff" << std::endl; |
| 1248 | } else { |
| 1249 | std::cout << "table diff num:" << g_diff_count << ", check the details in ./meta.diff" |
| 1250 | << std::endl; |
| 1251 | } |
| 1252 | return CliStatus::kOk; |
| 1253 | } |
| 1254 | |
| 1255 | CliStatus TableDiff(const std::string& prefix_path, const std::string& table_name) { |
| 1256 | int ret = ScanAndDiff(table_name, prefix_path); |
no test coverage detected