1#include <list>
2#include <Storages/MergeTree/ReplicatedMergeTreeLogEntry.h>
3#include <Common/ZooKeeper/ZooKeeper.h>
4#include <boost/program_options.hpp>
5
6
7int main(int argc, char ** argv)
8try
9{
10 boost::program_options::options_description desc("Allowed options");
11 desc.add_options()
12 ("help,h", "produce help message")
13 ("address,a", boost::program_options::value<std::string>()->required(),
14 "addresses of ZooKeeper instances, comma separated. Example: example01e.yandex.ru:2181")
15 ("path,p", boost::program_options::value<std::string>()->required(), "path of replica queue to insert node (without trailing slash)")
16 ("name,n", boost::program_options::value<std::string>()->required(), "name of part to download")
17 ;
18
19 boost::program_options::variables_map options;
20 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), options);
21
22 if (options.count("help"))
23 {
24 std::cout << "Insert log entry to replication queue to download part from any replica." << std::endl;
25 std::cout << "Usage: " << argv[0] << " [options]" << std::endl;
26 std::cout << desc << std::endl;
27 return 1;
28 }
29
30 std::string path = options.at("path").as<std::string>();
31 std::string name = options.at("name").as<std::string>();
32
33 zkutil::ZooKeeper zookeeper(options.at("address").as<std::string>());
34
35 DB::ReplicatedMergeTreeLogEntry entry;
36 entry.type = DB::ReplicatedMergeTreeLogEntry::MERGE_PARTS;
37 entry.source_parts = {name};
38 entry.new_part_name = name;
39
40 zookeeper.create(path + "/queue-", entry.toString(), zkutil::CreateMode::PersistentSequential);
41 return 0;
42}
43catch (const Poco::Exception & e)
44{
45 std::cerr << DB::getCurrentExceptionMessage(true) << '\n';
46 throw;
47}
48