MCPcopy Create free account
hub / github.com/ByConity/ByConity / main

Function main

utils/zookeeper-cli/zookeeper-cli.cpp:58–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57
58int main(int argc, char ** argv)
59{
60 try
61 {
62 if (argc != 2)
63 {
64 std::cerr << "usage: " << argv[0] << " hosts" << std::endl;
65 return 2;
66 }
67
68 Poco::AutoPtr<Poco::ConsoleChannel> channel = new Poco::ConsoleChannel(std::cerr);
69 Poco::Logger::root().setChannel(channel);
70 Poco::Logger::root().setLevel("trace");
71
72 zkutil::ZooKeeper zk(argv[1]);
73 LineReader lr({}, false, {"\\"}, {});
74
75 do
76 {
77 const auto & line = lr.readLine(":3 ", ":3 ");
78 if (line.empty())
79 break;
80
81 try
82 {
83 std::stringstream ss(line); // STYLE_CHECK_ALLOW_STD_STRING_STREAM
84
85 std::string cmd;
86 ss >> cmd;
87
88 if (cmd == "q" || cmd == "quit" || cmd == "exit" || cmd == ":q")
89 break;
90
91 std::string path;
92 ss >> path;
93 if (cmd == "ls")
94 {
95 std::string w;
96 ss >> w;
97 bool watch = w == "w";
98 zkutil::EventPtr event = watch ? std::make_shared<Poco::Event>() : nullptr;
99 std::vector<std::string> v = zk.getChildren(path, nullptr, event);
100 for (const auto & child : v)
101 std::cout << child << std::endl;
102 if (watch)
103 waitForWatch(event);
104 }
105 else if (cmd == "create")
106 {
107 DB::ReadBufferFromString in(line);
108
109 std::string path_ignored;
110 std::string data;
111 std::string mode;
112
113 DB::assertString("create", in);
114 DB::skipWhitespaceIfAny(in);
115 readMaybeQuoted(path_ignored, in);

Callers

nothing calls this directly

Calls 15

waitForWatchFunction · 0.85
skipWhitespaceIfAnyFunction · 0.85
readMaybeQuotedFunction · 0.85
readUntilSpaceFunction · 0.85
printStatFunction · 0.85
setChannelMethod · 0.80
getChildrenMethod · 0.80
displayTextMethod · 0.80
assertStringFunction · 0.50
readTextFunction · 0.50
setLevelMethod · 0.45
readLineMethod · 0.45

Tested by

no test coverage detected