MCPcopy Create free account
hub / github.com/baidu/tera / MetaBackUpOp

Function MetaBackUpOp

src/admincli.cc:1530–1563  ·  view source on GitHub ↗

backup [inmem] [backup_filename]

Source from the content-addressed store, hash-verified

1528
1529// backup [inmem] [backup_filename]
1530CliStatus MetaBackUpOp(Client* client, int32_t argc, std::string* argv, ErrorCode* err) {
1531 std::string filename;
1532 if ((argc == 3 || argc == 4) && argv[2] == "inmem") {
1533 if (argc == 3) {
1534 filename = "inmem_meta.bak_" + get_curtime_str();
1535 } else {
1536 filename = argv[3] + "_" + get_curtime_str();
1537 }
1538 std::shared_ptr<tera::ClientImpl> client_impl(
1539 (static_cast<ClientWrapper*>(client))->GetClientImpl());
1540 std::vector<std::string> arg_list;
1541 arg_list.push_back("backup");
1542 arg_list.push_back(filename);
1543 if (!client->CmdCtrl("meta", arg_list, NULL, NULL, err)) {
1544 LOG(ERROR) << "fail to backup meta";
1545 return CliStatus::kError;
1546 }
1547 } else if (argc == 2 || argc == 3) {
1548 scoped_ptr<tera::sdk::ClusterFinder> finder(tera::sdk::NewClusterFinder());
1549 const std::string meta_server = finder->RootTableAddr();
1550 if (argc == 2) {
1551 filename = "meta.bak_" + get_curtime_str();
1552 } else {
1553 filename = argv[2] + "_" + get_curtime_str();
1554 }
1555 common::ThreadPool thread_pool(1);
1556 std::string start_key("");
1557 std::string end_key("");
1558 MetaInternalOp(meta_server, &thread_pool, "backup", start_key, end_key, filename);
1559 } else {
1560 PrintCmdHelpInfo(argv[1]);
1561 }
1562 return CliStatus::kOk;
1563}
1564
1565// healthcheck [inmem] [start_key] [end_key]
1566CliStatus MetaHealthCheckOp(Client* client, int32_t argc, std::string* argv, ErrorCode* err) {

Callers

nothing calls this directly

Calls 8

get_curtime_strFunction · 0.85
NewClusterFinderFunction · 0.85
MetaInternalOpFunction · 0.85
GetClientImplMethod · 0.80
push_backMethod · 0.80
RootTableAddrMethod · 0.80
PrintCmdHelpInfoFunction · 0.70
CmdCtrlMethod · 0.45

Tested by

no test coverage detected