LCOV - code coverage report
Current view: top level - src/client/rpc - forward_management.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 23 27 85.2 %
Date: 2024-04-23 00:09:24 Functions: 1 1 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' POSIX interface.
      12             : 
      13             :   GekkoFS' POSIX interface is free software: you can redistribute it and/or
      14             :   modify it under the terms of the GNU Lesser General Public License as
      15             :   published by the Free Software Foundation, either version 3 of the License,
      16             :   or (at your option) any later version.
      17             : 
      18             :   GekkoFS' POSIX interface 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 Lesser General Public License for more details.
      22             : 
      23             :   You should have received a copy of the GNU Lesser General Public License
      24             :   along with GekkoFS' POSIX interface.  If not, see
      25             :   <https://www.gnu.org/licenses/>.
      26             : 
      27             :   SPDX-License-Identifier: LGPL-3.0-or-later
      28             : */
      29             : 
      30             : #include <client/rpc/forward_management.hpp>
      31             : #include <client/logging.hpp>
      32             : #include <client/preload_util.hpp>
      33             : #include <client/rpc/rpc_types.hpp>
      34             : 
      35             : namespace gkfs::rpc {
      36             : 
      37             : /**
      38             :  * Gets fs configuration information from the running daemon and transfers it to
      39             :  * the memory of the library
      40             :  * @return
      41             :  */
      42             : bool
      43         269 : forward_get_fs_config() {
      44             : 
      45         538 :     auto endp = CTX->hosts().at(CTX->local_host_id());
      46         538 :     gkfs::rpc::fs_config::output out;
      47             : 
      48         269 :     bool found = false;
      49         269 :     size_t idx = 0;
      50         269 :     while(!found && idx < CTX->hosts().size()) {
      51         269 :         try {
      52         269 :             LOG(DEBUG, "Retrieving file system configurations from daemon");
      53             :             // TODO(amiranda): add a post() with RPC_TIMEOUT to hermes so that
      54             :             // we can retry for RPC_TRIES (see old commits with margo)
      55             :             // TODO(amiranda): hermes will eventually provide a post(endpoint)
      56             :             // returning one result and a broadcast(endpoint_set) returning a
      57             :             // result_set. When that happens we can remove the .at(0) :/
      58         538 :             out = ld_network_service->post<gkfs::rpc::fs_config>(endp).get().at(
      59         269 :                     0);
      60         269 :             found = true;
      61           0 :         } catch(const std::exception& ex) {
      62           0 :             LOG(ERROR,
      63             :                 "Retrieving fs configurations from daemon, possible reattempt at peer: {}",
      64           0 :                 idx);
      65           0 :             endp = CTX->hosts().at(idx++);
      66             :         }
      67             :     }
      68             : 
      69         269 :     if(!found)
      70             :         return false;
      71             : 
      72         269 :     CTX->mountdir(out.mountdir());
      73         269 :     LOG(INFO, "Mountdir: '{}'", CTX->mountdir());
      74             : 
      75         269 :     CTX->fs_conf()->rootdir = out.rootdir();
      76         269 :     CTX->fs_conf()->atime_state = out.atime_state();
      77         269 :     CTX->fs_conf()->mtime_state = out.mtime_state();
      78         269 :     CTX->fs_conf()->ctime_state = out.ctime_state();
      79         269 :     CTX->fs_conf()->link_cnt_state = out.link_cnt_state();
      80         269 :     CTX->fs_conf()->blocks_state = out.blocks_state();
      81         269 :     CTX->fs_conf()->uid = out.uid();
      82         269 :     CTX->fs_conf()->gid = out.gid();
      83             : 
      84         538 :     LOG(DEBUG, "Got response with mountdir {}", out.mountdir());
      85             : 
      86             :     return true;
      87             : }
      88             : 
      89             : } // namespace gkfs::rpc

Generated by: LCOV version 1.16