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-23 00:09:24 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             :     bool enable_forwarding_ = false;
      99             :     std::string stats_file_;
     100             : 
     101             :     // Prometheus
     102          33 :     std::string prometheus_gateway_ = gkfs::config::stats::prometheus_gateway;
     103             : 
     104             : public:
     105             :     static FsData*
     106       22807 :     getInstance() {
     107       22807 :         static FsData instance;
     108       22807 :         return &instance;
     109             :     }
     110             : 
     111             :     FsData(FsData const&) = delete;
     112             : 
     113             :     void
     114             :     operator=(FsData const&) = delete;
     115             : 
     116             :     // getter/setter
     117             : 
     118             :     const std::shared_ptr<spdlog::logger>&
     119             :     spdlogger() const;
     120             : 
     121             :     void
     122             :     spdlogger(const std::shared_ptr<spdlog::logger>& spdlogger_);
     123             : 
     124             :     const std::string&
     125             :     rootdir() const;
     126             : 
     127             :     void
     128             :     rootdir(const std::string& rootdir_);
     129             : 
     130             :     const std::string&
     131             :     rootdir_suffix() const;
     132             : 
     133             :     void
     134             :     rootdir_suffix(const std::string& rootdir_suffix_);
     135             : 
     136             :     const std::string&
     137             :     mountdir() const;
     138             : 
     139             :     void
     140             :     mountdir(const std::string& mountdir_);
     141             : 
     142             :     const std::string&
     143             :     metadir() const;
     144             : 
     145             :     void
     146             :     metadir(const std::string& metadir_);
     147             : 
     148             :     std::string_view
     149             :     dbbackend() const;
     150             : 
     151             :     void
     152             :     dbbackend(const std::string& dbbackend_);
     153             : 
     154             :     const std::shared_ptr<gkfs::metadata::MetadataDB>&
     155             :     mdb() const;
     156             : 
     157             :     void
     158             :     mdb(const std::shared_ptr<gkfs::metadata::MetadataDB>& mdb);
     159             : 
     160             :     void
     161             :     close_mdb();
     162             : 
     163             :     const std::shared_ptr<gkfs::data::ChunkStorage>&
     164             :     storage() const;
     165             : 
     166             :     void
     167             :     storage(const std::shared_ptr<gkfs::data::ChunkStorage>& storage);
     168             : 
     169             :     const std::string&
     170             :     rpc_protocol() const;
     171             : 
     172             :     void
     173             :     rpc_protocol(const std::string& rpc_protocol);
     174             : 
     175             :     const std::string&
     176             :     bind_addr() const;
     177             : 
     178             :     void
     179             :     bind_addr(const std::string& addr);
     180             : 
     181             :     const std::string&
     182             :     hosts_file() const;
     183             : 
     184             :     bool
     185             :     use_auto_sm() const;
     186             : 
     187             :     void
     188             :     use_auto_sm(bool use_auto_sm);
     189             : 
     190             :     void
     191             :     hosts_file(const std::string& lookup_file);
     192             : 
     193             :     bool
     194             :     atime_state() const;
     195             : 
     196             :     void
     197             :     atime_state(bool atime_state);
     198             : 
     199             :     bool
     200             :     mtime_state() const;
     201             : 
     202             :     void
     203             :     mtime_state(bool mtime_state);
     204             : 
     205             :     bool
     206             :     ctime_state() const;
     207             : 
     208             :     void
     209             :     ctime_state(bool ctime_state);
     210             : 
     211             :     bool
     212             :     link_cnt_state() const;
     213             : 
     214             :     void
     215             :     link_cnt_state(bool link_cnt_state);
     216             : 
     217             :     bool
     218             :     blocks_state() const;
     219             : 
     220             :     void
     221             :     blocks_state(bool blocks_state);
     222             : 
     223             :     unsigned long long
     224             :     parallax_size_md() const;
     225             : 
     226             :     void
     227             :     parallax_size_md(unsigned int size_md);
     228             : 
     229             :     const std::shared_ptr<gkfs::utils::Stats>&
     230             :     stats() const;
     231             : 
     232             :     void
     233             :     stats(const std::shared_ptr<gkfs::utils::Stats>& stats);
     234             : 
     235             :     void
     236             :     close_stats();
     237             : 
     238             :     bool
     239             :     enable_stats() const;
     240             : 
     241             :     void
     242             :     enable_stats(bool enable_stats);
     243             : 
     244             :     bool
     245             :     enable_chunkstats() const;
     246             : 
     247             :     void
     248             :     enable_chunkstats(bool enable_chunkstats);
     249             : 
     250             :     bool
     251             :     enable_forwarding() const;
     252             : 
     253             :     void
     254             :     enable_forwarding(bool enable_forwarding);
     255             : 
     256             :     bool
     257             :     enable_prometheus() const;
     258             : 
     259             :     void
     260             :     enable_prometheus(bool enable_prometheus);
     261             : 
     262             :     const std::string&
     263             :     stats_file() const;
     264             : 
     265             :     void
     266             :     stats_file(const std::string& stats_file);
     267             : 
     268             :     const std::string&
     269             :     prometheus_gateway() const;
     270             : 
     271             :     void
     272             :     prometheus_gateway(const std::string& prometheus_gateway_);
     273             : };
     274             : 
     275             : 
     276             : } // namespace daemon
     277             : } // namespace gkfs
     278             : 
     279             : #endif // LFS_FS_DATA_H

Generated by: LCOV version 1.16