1#include <Common/ZooKeeper/ZooKeeper.h>
2#include <IO/ReadHelpers.h>
3
4
5int main(int argc, char ** argv)
6try
7{
8 zkutil::ZooKeeper zookeeper{"localhost:2181"};
9
10 auto nodes = zookeeper.getChildren("/tmp");
11
12 if (argc < 2)
13 {
14 std::cerr << "Usage: program num_threads\n";
15 return 1;
16 }
17
18 size_t num_threads = DB::parse<size_t>(argv[1]);
19 std::vector<std::thread> threads;
20 for (size_t i = 0; i < num_threads; ++i)
21 {
22 threads.emplace_back([&]
23 {
24 while (true)
25 {
26 std::vector<std::future<Coordination::GetResponse>> futures;
27 for (auto & node : nodes)
28 futures.push_back(zookeeper.asyncGet("/tmp/" + node));
29
30 for (auto & future : futures)
31 std::cerr << (future.get().data.empty() ? ',' : '.');
32 }
33 });
34 }
35
36 for (auto & thread : threads)
37 thread.join();
38
39 return 0;
40}
41catch (const Poco::Exception & e)
42{
43 std::cout << e.message() << std::endl;
44 return 1;
45}
46