Resolve "Missing module for MetadataDB"

This MR adds a GKFS_METADATA_MOD that can be used in a similar manner to GKFS_DATA_MOD. It also adds a "MetadataModule" logger that can be used to emit messages from the internal code of MetadataDB. This logger replaces the "MetadataDB" logger that was being instantiated in daemon.cpp but not used.

Closes #161 (closed)

Edited by Alberto Miranda

Merge request reports

Loading
+2 −0
Changes for include/daemon/backend/metadata/db.hpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#define GEKKOFS_METADATA_DB_HPP

#include <memory>
#include <spdlog/spdlog.h>
#include <rocksdb/db.h>
#include <daemon/backend/exceptions.hpp>
#include <tuple>
@@ -44,6 +45,7 @@ private:
    rdb::Options options;
    rdb::WriteOptions write_opts;
    std::string path;
    std::shared_ptr<spdlog::logger> log_;

    static void
    optimize_rocksdb_options(rdb::Options& options);
+70 −0
Changes for include/daemon/backend/metadata/metadata_module.hpp: 70 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
  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 <https://www.gnu.org/licenses/>.

  SPDX-License-Identifier: GPL-3.0-or-later
*/

#ifndef GEKKOFS_DAEMON_METADATA_LOGGING_HPP
#define GEKKOFS_DAEMON_METADATA_LOGGING_HPP

#include <spdlog/spdlog.h>

namespace gkfs::data {

class MetadataModule {

private:
    MetadataModule() = default;

    std::shared_ptr<spdlog::logger> 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<spdlog::logger>&
    log() const;

    void
    log(const std::shared_ptr<spdlog::logger>& log);
};

#define GKFS_METADATA_MOD                                                      \
    (static_cast<gkfs::data::MetadataModule*>(                                 \
            gkfs::data::MetadataModule::getInstance()))

} // namespace gkfs::data

#endif // GEKKOFS_DAEMON_METADATA_LOGGING_HPP
+17 −0
Changes for src/daemon/backend/data/CMakeLists.txt: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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
+17 −0
Changes for src/daemon/backend/metadata/CMakeLists.txt: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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
+8 −0
Changes for src/daemon/backend/metadata/db.cpp: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <daemon/backend/metadata/db.hpp>
#include <daemon/backend/metadata/merge.hpp>
#include <daemon/backend/exceptions.hpp>
#include <daemon/backend/metadata/metadata_module.hpp>

#include <common/metadata.hpp>
#include <common/path_util.hpp>
@@ -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();
Loading
Loading