Commit 91cb233f authored by Marc Vef's avatar Marc Vef
Browse files

Adding env variables for bw throttle

parent 6a659634
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -187,6 +187,9 @@ environment variable.

GKFS_RPC_PROTOCOL defaults to ofi+sockets, and can be used for other RPC protocols

GKFS_THROTTLE_BW_HAVE bytes of available bandwidth
GKFS_THROTTLE_BW_SHOULD bytes to throttle available bandwidth to

### Acknowledgment

This software was partially supported by the EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).
+3 −0
Original line number Diff line number Diff line
@@ -49,6 +49,9 @@ private:

    std::string root_path_;
    size_t chunksize_;
    bool throttle_enabled_ = false;
    uint64_t throttle_bw_have_; // in bytes
    uint64_t throttle_bw_should_; // in bytes

    inline std::string absolute(const std::string& internal_path) const;

+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ namespace gkfs {
namespace env {

static constexpr auto HOSTS_FILE = ADD_PREFIX("HOSTS_FILE");
static constexpr auto THROTTLE_BW_HAVE = ADD_PREFIX("THROTTLE_BW_HAVE");
static constexpr auto THROTTLE_BW_SHOULD = ADD_PREFIX("THROTTLE_BW_SHOULD");

} // namespace env
} // namespace gkfs
+15 −1
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include <boost/filesystem.hpp>
#include <spdlog/spdlog.h>
#include <config.hpp>
#include <global/env_util.hpp>
#include <daemon/env.hpp>

extern "C" {
#include <sys/statfs.h>
@@ -85,7 +87,19 @@ ChunkStorage::ChunkStorage(string& path, const size_t chunksize) :
    auto test_file_path = "/.__chunk_dir_test"s;
    init_chunk_space(test_file_path);
    destroy_chunk_space(test_file_path);
    log_->debug("{}() Chunk storage initialized with path: '{}'", __func__, root_path_);
    // set throttle
    auto throttle_have_str = gkfs::env::get_var(gkfs::env::THROTTLE_BW_HAVE, "0");
    throttle_bw_have_ = std::strtoul(throttle_have_str.c_str(), nullptr, 10);
    auto throttle_should_str = gkfs::env::get_var(gkfs::env::THROTTLE_BW_SHOULD, "0");
    throttle_bw_should_ = std::strtoul(throttle_should_str.c_str(), nullptr, 10);
    if (throttle_bw_have_ != 0 && throttle_bw_should_ != 0) {
        throttle_enabled_ = true;
        log_->info("{}() Throttle enabled: have '{}' should '{}' in bytes", __func__, throttle_bw_have_,
                   throttle_bw_should_);
    }


    log_->info("{}() Chunk storage initialized with path: '{}'", __func__, root_path_);
}

/**