Fixed the bug that Executor / Cli does not create directory for StorageManager.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c777a6a..3965851 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -792,6 +792,7 @@
glog
quickstep_catalog_CatalogRelation
quickstep_cli_Constants
+ quickstep_cli_DefaultsConfigurator
quickstep_cli_Flags
quickstep_cli_LineReader
quickstep_cli_PrintToScreen
diff --git a/cli/DefaultsConfigurator.cpp b/cli/DefaultsConfigurator.cpp
index 21b0af6..0e1f64c 100644
--- a/cli/DefaultsConfigurator.cpp
+++ b/cli/DefaultsConfigurator.cpp
@@ -41,10 +41,7 @@
namespace quickstep {
-void DefaultsConfigurator::InitializeDefaultDatabase(const string &storage_path, const string &catalog_path) {
- // TODO(jmp): Refactor the code in this file!
- LOG(INFO) << "Initializing the database, creating a new catalog file and storage directory";
-
+void DefaultsConfigurator::CreateDirectory(const std::string &storage_path) {
// Create the directory
// TODO(jmp): At some point, likely in C++-17, we will just have the
// filesystem path, and we can clean this up
@@ -54,11 +51,18 @@
<< "\nCheck if the directory already exists. If so, delete it or move it before initializing";
#else
{
- const string path_name = "mkdir " + storage_path;
+ const string path_name = "mkdir -p " + storage_path;
CHECK(!std::system(path_name.c_str()))
<< "Failed when attempting to create the directory: " << storage_path;
}
#endif // QUICKSTEP_OS_WINDOWS
+}
+
+void DefaultsConfigurator::InitializeDefaultDatabase(const string &storage_path, const string &catalog_path) {
+ // TODO(jmp): Refactor the code in this file!
+ LOG(INFO) << "Initializing the database, creating a new catalog file and storage directory";
+
+ CreateDirectory(storage_path);
// Create the default catalog file.
std::ofstream catalog_file(catalog_path.c_str());
diff --git a/cli/DefaultsConfigurator.hpp b/cli/DefaultsConfigurator.hpp
index 4b534d6..28d84b8 100644
--- a/cli/DefaultsConfigurator.hpp
+++ b/cli/DefaultsConfigurator.hpp
@@ -116,6 +116,13 @@
static void InitializeDefaultDatabase(const std::string &storage_path,
const std::string &catalog_path);
+ /**
+ * @brief Create the directory.
+ *
+ * @param storage_path The filesystem directory for StorageManager.
+ **/
+ static void CreateDirectory(const std::string &storage_path);
+
private:
/**
* @brief Private constructor to disable instantiation of the class.
diff --git a/cli/distributed/CMakeLists.txt b/cli/distributed/CMakeLists.txt
index 6a31895..93d3b5e 100644
--- a/cli/distributed/CMakeLists.txt
+++ b/cli/distributed/CMakeLists.txt
@@ -55,6 +55,7 @@
target_link_libraries(quickstep_cli_distributed_Executor
glog
quickstep_catalog_CatalogTypedefs
+ quickstep_cli_DefaultsConfigurator
quickstep_cli_Flags
quickstep_cli_InputParserUtil
quickstep_cli_distributed_Role
diff --git a/cli/distributed/Cli.cpp b/cli/distributed/Cli.cpp
index 9f48ecc..665ab9b 100644
--- a/cli/distributed/Cli.cpp
+++ b/cli/distributed/Cli.cpp
@@ -31,6 +31,7 @@
#include "catalog/CatalogRelation.hpp"
#include "cli/CliConfig.h" // For QUICKSTEP_USE_LINENOISE.
#include "cli/Constants.hpp"
+#include "cli/DefaultsConfigurator.hpp"
#include "cli/Flags.hpp"
#ifdef QUICKSTEP_USE_LINENOISE
@@ -112,6 +113,8 @@
bus_.RegisterClientAsSender(cli_id_, kBlockDomainRegistrationMessage);
bus_.RegisterClientAsReceiver(cli_id_, kBlockDomainRegistrationResponseMessage);
+ DefaultsConfigurator::CreateDirectory(FLAGS_storage_path);
+
client_id locator_client_id;
storage_manager_ = make_unique<StorageManager>(
FLAGS_storage_path,
diff --git a/cli/distributed/Executor.cpp b/cli/distributed/Executor.cpp
index 4ca5693..d8e63ce 100644
--- a/cli/distributed/Executor.cpp
+++ b/cli/distributed/Executor.cpp
@@ -24,6 +24,7 @@
#include <vector>
#include "catalog/CatalogTypedefs.hpp"
+#include "cli/DefaultsConfigurator.hpp"
#include "cli/Flags.hpp"
#include "cli/InputParserUtil.hpp"
#include "query_execution/BlockLocatorUtil.hpp"
@@ -76,6 +77,8 @@
worker_directory_ =
make_unique<WorkerDirectory>(worker_client_ids.size(), worker_client_ids, worker_numa_nodes);
+ DefaultsConfigurator::CreateDirectory(FLAGS_storage_path);
+
client_id locator_client_id;
storage_manager_ = make_unique<StorageManager>(
FLAGS_storage_path,