From 9002ef4788fd7cec9b2f130dc3bedcc44e2a285d Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Thu, 1 Jul 2021 15:19:50 +0200 Subject: [PATCH] Create new GKFS_METADATA_MOD for MetadataDB --- include/daemon/backend/metadata/db.hpp | 2 + .../backend/metadata/metadata_module.hpp | 70 +++++++++++++++++++ src/daemon/CMakeLists.txt | 3 +- src/daemon/backend/CMakeLists.txt | 30 ++++++++ src/daemon/backend/data/CMakeLists.txt | 17 +++++ src/daemon/backend/metadata/CMakeLists.txt | 17 +++++ src/daemon/backend/metadata/db.cpp | 8 +++ .../backend/metadata/metadata_module.cpp | 43 ++++++++++++ src/daemon/daemon.cpp | 2 +- src/daemon/ops/metadentry.cpp | 3 +- 10 files changed, 191 insertions(+), 4 deletions(-) create mode 100644 include/daemon/backend/metadata/metadata_module.hpp create mode 100644 src/daemon/backend/CMakeLists.txt create mode 100644 src/daemon/backend/metadata/metadata_module.cpp diff --git a/include/daemon/backend/metadata/db.hpp b/include/daemon/backend/metadata/db.hpp index f5b6e600f..874c7e892 100644 --- a/include/daemon/backend/metadata/db.hpp +++ b/include/daemon/backend/metadata/db.hpp @@ -30,6 +30,7 @@ #define GEKKOFS_METADATA_DB_HPP #include +#include #include #include #include @@ -44,6 +45,7 @@ private: rdb::Options options; rdb::WriteOptions write_opts; std::string path; + std::shared_ptr log_; static void optimize_rocksdb_options(rdb::Options& options); diff --git a/include/daemon/backend/metadata/metadata_module.hpp b/include/daemon/backend/metadata/metadata_module.hpp new file mode 100644 index 000000000..1ed0abe7b --- /dev/null +++ b/include/daemon/backend/metadata/metadata_module.hpp @@ -0,0 +1,70 @@ +/* + Copyright 2018-2021, Barcelona Supercomputing Center (BSC), Spain + Copyright 2015-2021, Johannes Gutenberg Universitaet Mainz, Germany + + This software was partially supported by the + EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). + + This software was partially supported by the + ADA-FS project under the SPPEXA project funded by the DFG. + + This file is part of GekkoFS. + + GekkoFS is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GekkoFS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GekkoFS. If not, see . + + SPDX-License-Identifier: GPL-3.0-or-later +*/ + +#ifndef GEKKOFS_DAEMON_METADATA_LOGGING_HPP +#define GEKKOFS_DAEMON_METADATA_LOGGING_HPP + +#include + +namespace gkfs::data { + +class MetadataModule { + +private: + MetadataModule() = default; + + std::shared_ptr log_; + +public: + static constexpr const char* LOGGER_NAME = "MetadataModule"; + + static MetadataModule* + getInstance() { + static MetadataModule instance; + return &instance; + } + + MetadataModule(MetadataModule const&) = delete; + + void + operator=(MetadataModule const&) = delete; + + const std::shared_ptr& + log() const; + + void + log(const std::shared_ptr& log); +}; + +#define GKFS_METADATA_MOD \ + (static_cast( \ + gkfs::data::MetadataModule::getInstance())) + +} // namespace gkfs::data + +#endif // GEKKOFS_DAEMON_METADATA_LOGGING_HPP diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index 143555315..8005ffa5d 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -26,8 +26,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ -add_subdirectory(backend/metadata) -add_subdirectory(backend/data) +add_subdirectory(backend) set(DAEMON_SRC ../common/rpc/rpc_util.cpp diff --git a/src/daemon/backend/CMakeLists.txt b/src/daemon/backend/CMakeLists.txt new file mode 100644 index 000000000..195f60928 --- /dev/null +++ b/src/daemon/backend/CMakeLists.txt @@ -0,0 +1,30 @@ +################################################################################ +# Copyright 2018-2021, Barcelona Supercomputing Center (BSC), Spain # +# Copyright 2015-2021, Johannes Gutenberg Universitaet Mainz, Germany # +# # +# This software was partially supported by the # +# EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). # +# # +# This software was partially supported by the # +# ADA-FS project under the SPPEXA project funded by the DFG. # +# # +# This file is part of GekkoFS. # +# # +# GekkoFS is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# GekkoFS is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with GekkoFS. If not, see . # +# # +# SPDX-License-Identifier: GPL-3.0-or-later # +################################################################################ + +add_subdirectory(metadata) +add_subdirectory(data) diff --git a/src/daemon/backend/data/CMakeLists.txt b/src/daemon/backend/data/CMakeLists.txt index 50795377a..826ec5c35 100644 --- a/src/daemon/backend/data/CMakeLists.txt +++ b/src/daemon/backend/data/CMakeLists.txt @@ -26,6 +26,22 @@ # SPDX-License-Identifier: GPL-3.0-or-later # ################################################################################ +add_library(data_module + STATIC +) + +target_sources(data_module + PUBLIC + ${INCLUDE_DIR}/daemon/backend/data/data_module.hpp + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/data_module.cpp +) + +target_link_libraries(data_module + PUBLIC + spdlog +) + add_library(storage STATIC) target_sources(storage @@ -43,6 +59,7 @@ target_sources(storage target_link_libraries(storage PRIVATE spdlog + data_module # open issue for std::filesystem https://gitlab.kitware.com/cmake/cmake/-/issues/17834 stdc++fs -ldl diff --git a/src/daemon/backend/metadata/CMakeLists.txt b/src/daemon/backend/metadata/CMakeLists.txt index d04c8d91e..91451f016 100644 --- a/src/daemon/backend/metadata/CMakeLists.txt +++ b/src/daemon/backend/metadata/CMakeLists.txt @@ -39,8 +39,25 @@ target_sources(metadata_db ${CMAKE_CURRENT_LIST_DIR}/db.cpp ) +add_library(metadata_module + STATIC +) + +target_sources(metadata_module + PUBLIC + ${INCLUDE_DIR}/daemon/backend/metadata/metadata_module.hpp + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/metadata_module.cpp +) + +target_link_libraries(metadata_module + PUBLIC + spdlog +) + target_link_libraries(metadata_db # Required by RocksDB + metadata_module -ldl metadata RocksDB diff --git a/src/daemon/backend/metadata/db.cpp b/src/daemon/backend/metadata/db.cpp index 9389d3557..53a094533 100644 --- a/src/daemon/backend/metadata/db.cpp +++ b/src/daemon/backend/metadata/db.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,13 @@ namespace gkfs::metadata { * @param path where KV store data is stored */ MetadataDB::MetadataDB(const std::string& path) : path(path) { + + /* Get logger instance and set it for data module and chunk storage */ + GKFS_METADATA_MOD->log(spdlog::get(GKFS_METADATA_MOD->LOGGER_NAME)); + assert(GKFS_METADATA_MOD->log()); + log_ = spdlog::get(GKFS_METADATA_MOD->LOGGER_NAME); + assert(log_); + // Optimize RocksDB. This is the easiest way to get RocksDB to perform well options.IncreaseParallelism(); options.OptimizeLevelStyleCompaction(); diff --git a/src/daemon/backend/metadata/metadata_module.cpp b/src/daemon/backend/metadata/metadata_module.cpp new file mode 100644 index 000000000..28344898c --- /dev/null +++ b/src/daemon/backend/metadata/metadata_module.cpp @@ -0,0 +1,43 @@ +/* + Copyright 2018-2021, Barcelona Supercomputing Center (BSC), Spain + Copyright 2015-2021, Johannes Gutenberg Universitaet Mainz, Germany + + This software was partially supported by the + EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). + + This software was partially supported by the + ADA-FS project under the SPPEXA project funded by the DFG. + + This file is part of GekkoFS. + + GekkoFS is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + GekkoFS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GekkoFS. If not, see . + + SPDX-License-Identifier: GPL-3.0-or-later +*/ + +#include + +namespace gkfs::data { + +const std::shared_ptr& +MetadataModule::log() const { + return log_; +} + +void +MetadataModule::log(const std::shared_ptr& log) { + MetadataModule::log_ = log; +} + +} // namespace gkfs::data diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 319c6547d..9ad7c52fa 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -382,7 +382,7 @@ initialize_loggers() { auto logger_names = std::vector{ "main", - "MetadataDB", + "MetadataModule", "DataModule", }; diff --git a/src/daemon/ops/metadentry.cpp b/src/daemon/ops/metadentry.cpp index 77cc2c861..d51b2dc6d 100644 --- a/src/daemon/ops/metadentry.cpp +++ b/src/daemon/ops/metadentry.cpp @@ -29,6 +29,7 @@ #include #include #include +#include using namespace std; @@ -158,4 +159,4 @@ remove(const string& path) { } } -} // namespace gkfs::metadata +} // namespace gkfs::metadata \ No newline at end of file -- GitLab