LCOV - code coverage report
Current view: top level - include/daemon/classes - fs_data.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 5 100.0 %
Date: 2024-04-30 13:21:35 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   Copyright 2018-2024, Barcelona Supercomputing Center (BSC), Spain
       3             :   Copyright 2015-2024, Johannes Gutenberg Universitaet Mainz, Germany
       4             : 
       5             :   This software was partially supported by the
       6             :   EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
       7             : 
       8             :   This software was partially supported by the
       9             :   ADA-FS project under the SPPEXA project funded by the DFG.
      10             : 
      11             :   This file is part of GekkoFS.
      12             : 
      13             :   GekkoFS is free software: you can redistribute it and/or modify
      14             :   it under the terms of the GNU General Public License as published by
      15             :   the Free Software Foundation, either version 3 of the License, or
      16             :   (at your option) any later version.
      17             : 
      18             :   GekkoFS is distributed in the hope that it will be useful,
      19             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      20             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      21             :   GNU General Public License for more details.
      22             : 
      23             :   You should have received a copy of the GNU General Public License
      24             :   along with GekkoFS.  If not, see <https://www.gnu.org/licenses/>.
      25             : 
      26             :   SPDX-License-Identifier: GPL-3.0-or-later
      27             : */
      28             : 
      29             : #ifndef LFS_FS_DATA_H
      30             : #define LFS_FS_DATA_H
      31             : 
      32             : #include <daemon/daemon.hpp>
      33             : 
      34             : #include <unordered_map>
      35             : #include <map>
      36             : #include <functional> //std::hash
      37             : #include <string_view>
      38             : 
      39             : /* Forward declarations */
      40             : namespace gkfs {
      41             : namespace metadata {
      42             : class MetadataDB;
      43             : }
      44             : 
      45             : namespace data {
      46             : class ChunkStorage;
      47             : }
      48             : 
      49             : /* Forward declarations */
      50             : namespace utils {
      51             : class Stats;
      52             : }
      53             : 
      54             : namespace daemon {
      55             : 
      56             : class FsData {
      57             : 
      58             : private:
      59          33 :     FsData() = default;
      60             : 
      61             :     // logger
      62             :     std::shared_ptr<spdlog::logger> spdlogger_;
      63             : 
      64             :     // paths
      65             :     std::string rootdir_{};
      66             :     std::string rootdir_suffix_{};
      67             :     std::string mountdir_{};
      68             :     std::string metadir_{};
      69             : 
      70             :     // RPC management
      71             :     std::string rpc_protocol_{};
      72             :     std::string bind_addr_{};
      73             :     std::string hosts_file_{};
      74             :     bool use_auto_sm_;
      75             : 
      76             :     // Database
      77             :     std::shared_ptr<gkfs::metadata::MetadataDB> mdb_;
      78             :     std::string dbbackend_;
      79             : 
      80             :     // Parallax
      81             :     unsigned long long parallax_size_md_ = 8589934592ull;
      82             : 
      83             :     // Storage backend
      84             :     std::shared_ptr<gkfs::data::ChunkStorage> storage_;
      85             : 
      86             :     // configurable metadata
      87             :     bool atime_state_;
      88             :     bool mtime_state_;
      89             :     bool ctime_state_;
      90             :     bool link_cnt_state_;
      91             :     bool blocks_state_;
      92             : 
      93             :     // Statistics
      94             :     std::shared_ptr<gkfs::utils::Stats> stats_;
      95             :     bool enable_stats_ = false;
      96             :     bool enable_chunkstats_ = false;
      97             :     bool enable_prometheus_ = false;
      98             :     std::string stats_file_;
      99             : 
     100             :     // Prometheus
     101          33 :     std::string prometheus_gateway_ = gkfs::config::stats::prometheus_gateway;
     102             : 
     103             : public:
     104             :     static FsData*
     105       22707 :     getInstance() {
     106       22707 :         static FsData instance;
     107       22707 :         return &instance;
     108             :     }
     109             : 
     110             :     FsData(FsData const&) = delete;
     111             : 
     112             :     void
     113             :     operator=(FsData const&) = delete;
     114             : 
     115             :     // getter/setter
     116             : 
     117             :     const std::shared_ptr<spdlog::logger>&
     118             :     spdlogger() const;
     119             : 
     120             :     void
     121             :     spdlogger(const std::shared_ptr<spdlog::logger>& spdlogger_);
     122             : 
     123             :     const std::string&
     124             :     rootdir() const;
     125             : 
     126             :     void
     127             :     rootdir(const std::string& rootdir_);
     128             : 
     129             :     const std::string&
     130             :     rootdir_suffix() const;
     131             : 
     132             :     void
     133             :     rootdir_suffix(const std::string& rootdir_suffix_);
     134             : 
     135             :     const std::string&
     136             :     mountdir() const;
     137             : 
     138             :     void
     139             :     mountdir(const std::string& mountdir_);
     140             : 
     141             :     const std::string&
     142             :     metadir() const;
     143             : 
     144             :     void
     145             :     metadir(const std::string& metadir_);
     146             : 
     147             :     std::string_view
     148             :     dbbackend() const;
     149             : 
     150             :     void
     151             :     dbbackend(const std::string& dbbackend_);
     152             : 
     153             :     const std::shared_ptr<gkfs::metadata::MetadataDB>&
     154             :     mdb() const;
     155             : 
     156             :     void
     157             :     mdb(const std::shared_ptr<gkfs::metadata::MetadataDB>& mdb);
     158             : 
     159             :     void
     160             :     close_mdb();
     161             : 
     162             :     const std::shared_ptr<gkfs::data::ChunkStorage>&
     163             :     storage() const;
     164             : 
     165             :     void
     166             :     storage(const std::shared_ptr<gkfs::data::ChunkStorage>& storage);
     167             : 
     168             :     const std::string&
     169             :     rpc_protocol() const;
     170             : 
     171             :     void
     172             :     rpc_protocol(const std::string& rpc_protocol);
     173             : 
     174             :     const std::string&
     175             :     bind_addr() const;
     176             : 
     177             :     void
     178             :     bind_addr(const std::string& addr);
     179             : 
     180             :     const std::string&
     181             :     hosts_file() const;
     182             : 
     183             :     bool
     184             :     use_auto_sm() const;
     185             : 
     186             :     void
     187             :     use_auto_sm(bool use_auto_sm);
     188             : 
     189             :     void
     190             :     hosts_file(const std::string& lookup_file);
     191             : 
     192             :     bool
     193             :     atime_state() const;
     194             : 
     195             :     void
     196             :     atime_state(bool atime_state);
     197             : 
     198             :     bool
     199             :     mtime_state() const;
     200             : 
     201             :     void
     202             :     mtime_state(bool mtime_state);
     203             : 
     204             :     bool
     205             :     ctime_state() const;
     206             : 
     207             :     void
     208             :     ctime_state(bool ctime_state);
     209             : 
     210             :     bool
     211             :     link_cnt_state() const;
     212             : 
     213             :     void
     214             :     link_cnt_state(bool link_cnt_state);
     215             : 
     216             :     bool
     217             :     blocks_state() const;
     218             : 
     219             :     void
     220             :     blocks_state(bool blocks_state);
     221             : 
     222             :     unsigned long long
     223             :     parallax_size_md() const;
     224             : 
     225             :     void
     226             :     parallax_size_md(unsigned int size_md);
     227             : 
     228             :     const std::shared_ptr<gkfs::utils::Stats>&
     229             :     stats() const;
     230             : 
     231             :     void
     232             :     stats(const std::shared_ptr<gkfs::utils::Stats>& stats);
     233             : 
     234             :     void
     235             :     close_stats();
     236             : 
     237             :     bool
     238             :     enable_stats() const;
     239             : 
     240             :     void
     241             :     enable_stats(bool enable_stats);
     242             : 
     243             :     bool
     244             :     enable_chunkstats() const;
     245             : 
     246             :     void
     247             :     enable_chunkstats(bool enable_chunkstats);
     248             : 
     249             :     bool
     250             :     enable_prometheus() const;
     251             : 
     252             :     void
     253             :     enable_prometheus(bool enable_prometheus);
     254             : 
     255             :     const std::string&
     256             :     stats_file() const;
     257             : 
     258             :     void
     259             :     stats_file(const std::string& stats_file);
     260             : 
     261             :     const std::string&
     262             :     prometheus_gateway() const;
     263             : 
     264             :     void
     265             :     prometheus_gateway(const std::string& prometheus_gateway_);
     266             : };
     267             : 
     268             : 
     269             : } // namespace daemon
     270             : } // namespace gkfs
     271             : 
     272             : #endif // LFS_FS_DATA_H

Generated by: LCOV version 1.16