159 std::string base_path;
161 bool skip_geo =
false;
162 namespace po = boost::program_options;
164 po::options_description desc(
"Options");
165 desc.add_options()(
"help,h",
"Print help messages ")(
167 po::value<std::string>(&base_path)->required(),
168 "Directory path to HeavyDB catalogs")(
"force,f",
169 "Force overwriting of existing HeavyDB "
170 "instance")(
"skip-geo",
171 "Skip inserting sample geo data");
173 desc.add_options()(
"enable-thrift-logs",
176 ->implicit_value(
true),
177 "Enable writing messages directly from thrift to stdout/stderr.");
180 desc.add(log_options.get_options());
182 po::positional_options_description positionalOptions;
183 positionalOptions.add(
"data", 1);
185 po::variables_map vm;
188 po::store(po::command_line_parser(argc, argv)
190 .positional(positionalOptions)
193 if (vm.count(
"help")) {
197 if (vm.count(
"force")) {
200 if (vm.count(
"skip-geo")) {
204 }
catch (boost::program_options::error& e) {
205 std::cerr <<
"Usage Error: " << e.what() << std::endl;
210 apache::thrift::GlobalOutput.setOutputFunction([](
const char* msg) {});
213 if (!boost::filesystem::exists(base_path)) {
214 std::cerr <<
"Catalog basepath " + base_path +
" does not exist.\n";
218 if (boost::filesystem::exists(catalogs_path)) {
220 boost::filesystem::remove_all(catalogs_path);
222 std::cerr <<
"HeavyDB catalogs directory already exists at " + catalogs_path +
223 ". Use -f to force reinitialization.\n";
228 if (boost::filesystem::exists(data_path)) {
230 boost::filesystem::remove_all(data_path);
232 std::cerr <<
"HeavyDB data directory already exists at " + data_path +
233 ". Use -f to force reinitialization.\n";
238 if (boost::filesystem::exists(lockfiles_path)) {
240 boost::filesystem::remove_all(lockfiles_path);
242 std::cerr <<
"HeavyDB lockfiles directory already exists at " + lockfiles_path +
243 ". Use -f to force reinitialization.\n";
248 if (boost::filesystem::exists(lockfiles_path2)) {
250 boost::filesystem::remove_all(lockfiles_path2);
252 std::cerr <<
"HeavyDB lockfiles catalogs directory already exists at " +
253 lockfiles_path2 +
". Use -f to force reinitialization.\n";
258 if (boost::filesystem::exists(lockfiles_path3)) {
260 boost::filesystem::remove_all(lockfiles_path3);
262 std::cerr <<
"HeavyDB lockfiles data directory already exists at " +
263 lockfiles_path3 +
". Use -f to force reinitialization.\n";
268 if (boost::filesystem::exists(export_path)) {
270 boost::filesystem::remove_all(export_path);
272 std::cerr <<
"HeavyDB export directory already exists at " + export_path +
273 ". Use -f to force reinitialization.\n";
278 if (boost::filesystem::exists(disk_cache_path)) {
280 boost::filesystem::remove_all(disk_cache_path);
282 std::cerr <<
"HeavyDB disk cache already exists at " + disk_cache_path +
283 ". Use -f to force reinitialization.\n";
288 if (!boost::filesystem::create_directory(catalogs_path)) {
289 std::cerr <<
"Cannot create " + shared::kCatalogDirectoryName +
" subdirectory under "
290 << base_path << std::endl;
292 if (!boost::filesystem::create_directory(lockfiles_path)) {
293 std::cerr <<
"Cannot create " + shared::kLockfilesDirectoryName +
294 " subdirectory under "
295 << base_path << std::endl;
297 if (!boost::filesystem::create_directory(lockfiles_path2)) {
298 std::cerr <<
"Cannot create " + shared::kLockfilesDirectoryName +
"/" +
299 shared::kCatalogDirectoryName +
" subdirectory under "
300 << base_path << std::endl;
302 if (!boost::filesystem::create_directory(lockfiles_path3)) {
303 std::cerr <<
"Cannot create " + shared::kLockfilesDirectoryName +
"/" +
304 shared::kDataDirectoryName +
" subdirectory under "
305 << base_path << std::endl;
307 if (!boost::filesystem::create_directory(export_path)) {
308 std::cerr <<
"Cannot create " + shared::kDefaultExportDirName +
" subdirectory under "
309 << base_path << std::endl;
312 log_options.set_base_path(base_path);
317 auto dummy = std::make_shared<Data_Namespace::DataMgr>(
318 data_path, sys_parms,
nullptr,
false, 0);
320 std::make_shared<Calcite>(-1,
CALCITEPORT, base_path, 1024, 5000,
true,
"");
323 sys_cat.init(base_path, dummy, {}, calcite,
true,
false, {});
325 }
catch (std::exception& e) {
326 std::cerr <<
"Exception: " << e.what() <<
"\n";
const std::string kDataDirectoryName
const std::string kDefaultDiskCacheDirName
const std::string kDefaultExportDirName
static SysCatalog & instance()
void init(LogOptions const &log_opts)
static void loadGeo(std::string base_path)
const std::string kCatalogDirectoryName
const std::string kLockfilesDirectoryName
bool g_enable_thrift_logs