diff --git a/include/daemon/backend/metadata/db.hpp b/include/daemon/backend/metadata/db.hpp index f5b6e600f19a44d7f0778e65e8b97214d79772f0..874c7e8920fe76e8ca2119ad938afb51c0d76e52 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 0000000000000000000000000000000000000000..1ed0abe7b6a3d774494e2b9caa1f18a469fedc13 --- /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 14355531534a6131c20ffa6e6349cc7301ec9f87..8005ffa5deb56b6b6dcaf5e0d5d731b427348d18 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 0000000000000000000000000000000000000000..195f609282e4d37e6fc51855b67fd5db44e0dc46 --- /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 50795377ad2f2dafc82e4dfb499fe6572c01c00e..826ec5c35ce8242250f6d5cf8860c990de59f4ce 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 d04c8d91eedeca305c6758ca79687193c18fc865..91451f016045981f2560571ce1f052552d5984e1 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 9389d3557fd2d92094d491afdfc59e721cb1a562..53a094533ccb40910f96cfe074d6ec45228547a4 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 0000000000000000000000000000000000000000..28344898ccdc76751aef8ea2bccf4fbc9717b3b6 --- /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 319c6547d78a23280dc9609d2626f49dcff53f13..9ad7c52fa05c2c7512ded6412e40a524938768d2 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 77cc2c861d5d533cd59af30fbfa21f8a846c83b7..d51b2dc6de2ab39c31a58cc615fbfa92318d6e18 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