165 std::string base_path;
167 bool skip_geo =
false;
168 namespace po = boost::program_options;
170 po::options_description desc(
"Options");
171 desc.add_options()(
"help,h",
"Print help messages ")(
173 po::value<std::string>(&base_path)->required(),
174 "Directory path to HeavyDB catalogs")(
"force,f",
175 "Force overwriting of existing HeavyDB "
176 "instance")(
"skip-geo",
177 "Skip inserting sample geo data");
179 desc.add_options()(
"enable-thrift-logs",
182 ->implicit_value(
true),
183 "Enable writing messages directly from thrift to stdout/stderr.");
186 desc.add(log_options.get_options());
188 po::positional_options_description positionalOptions;
189 positionalOptions.add(
"data", 1);
191 po::variables_map vm;
194 po::store(po::command_line_parser(argc, argv)
196 .positional(positionalOptions)
199 if (vm.count(
"help")) {
203 if (vm.count(
"force")) {
206 if (vm.count(
"skip-geo")) {
210 }
catch (boost::program_options::error& e) {
211 std::cerr <<
"Usage Error: " << e.what() << std::endl;
216 apache::thrift::GlobalOutput.setOutputFunction([](
const char* msg) {});
219 if (!boost::filesystem::exists(base_path)) {
220 std::cerr <<
"Catalog basepath " + base_path +
" does not exist.\n";
224 if (boost::filesystem::exists(catalogs_path)) {
226 boost::filesystem::remove_all(catalogs_path);
228 std::cerr <<
"HeavyDB catalogs directory already exists at " + catalogs_path +
229 ". Use -f to force reinitialization.\n";
234 if (boost::filesystem::exists(data_path)) {
236 boost::filesystem::remove_all(data_path);
238 std::cerr <<
"HeavyDB data directory already exists at " + data_path +
239 ". Use -f to force reinitialization.\n";
244 if (boost::filesystem::exists(lockfiles_path)) {
246 boost::filesystem::remove_all(lockfiles_path);
248 std::cerr <<
"HeavyDB lockfiles directory already exists at " + lockfiles_path +
249 ". Use -f to force reinitialization.\n";
254 if (boost::filesystem::exists(lockfiles_path2)) {
256 boost::filesystem::remove_all(lockfiles_path2);
258 std::cerr <<
"HeavyDB lockfiles catalogs directory already exists at " +
259 lockfiles_path2 +
". Use -f to force reinitialization.\n";
264 if (boost::filesystem::exists(lockfiles_path3)) {
266 boost::filesystem::remove_all(lockfiles_path3);
268 std::cerr <<
"HeavyDB lockfiles data directory already exists at " +
269 lockfiles_path3 +
". Use -f to force reinitialization.\n";
274 if (boost::filesystem::exists(export_path)) {
276 boost::filesystem::remove_all(export_path);
278 std::cerr <<
"HeavyDB export directory already exists at " + export_path +
279 ". Use -f to force reinitialization.\n";
284 if (boost::filesystem::exists(disk_cache_path)) {
286 boost::filesystem::remove_all(disk_cache_path);
288 std::cerr <<
"HeavyDB disk cache already exists at " + disk_cache_path +
289 ". Use -f to force reinitialization.\n";
294 if (!boost::filesystem::create_directory(catalogs_path)) {
295 std::cerr <<
"Cannot create " + shared::kCatalogDirectoryName +
" subdirectory under "
296 << base_path << std::endl;
298 if (!boost::filesystem::create_directory(lockfiles_path)) {
299 std::cerr <<
"Cannot create " + shared::kLockfilesDirectoryName +
300 " subdirectory under "
301 << base_path << std::endl;
303 if (!boost::filesystem::create_directory(lockfiles_path2)) {
304 std::cerr <<
"Cannot create " + shared::kLockfilesDirectoryName +
"/" +
305 shared::kCatalogDirectoryName +
" subdirectory under "
306 << base_path << std::endl;
308 if (!boost::filesystem::create_directory(lockfiles_path3)) {
309 std::cerr <<
"Cannot create " + shared::kLockfilesDirectoryName +
"/" +
310 shared::kDataDirectoryName +
" subdirectory under "
311 << base_path << std::endl;
313 if (!boost::filesystem::create_directory(export_path)) {
314 std::cerr <<
"Cannot create " + shared::kDefaultExportDirName +
" subdirectory under "
315 << base_path << std::endl;
318 log_options.set_base_path(base_path);
323 auto dummy = std::make_shared<Data_Namespace::DataMgr>(
324 data_path, sys_parms,
nullptr,
false, 0);
326 std::make_shared<Calcite>(-1,
CALCITEPORT, base_path, 1024, 5000,
true,
"");
329 sys_cat.init(base_path, dummy, {}, calcite,
true,
false, {});
331 }
catch (std::exception& e) {
332 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