Commit f6ba5693 authored by Marc Vef's avatar Marc Vef
Browse files

namespace added: gkfs::data

parent 847d1e6c
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,9 @@ namespace spdlog {
    class logger;
    class logger;
}
}


namespace gkfs {
namespace data {

struct ChunkStat {
struct ChunkStat {
    unsigned long chunk_size;
    unsigned long chunk_size;
    unsigned long chunk_total;
    unsigned long chunk_total;
@@ -73,4 +76,7 @@ public:
    ChunkStat chunk_stat() const;
    ChunkStat chunk_stat() const;
};
};


} // namespace data
} // namespace gkfs

#endif //GEKKOFS_CHUNK_STORAGE_HPP
#endif //GEKKOFS_CHUNK_STORAGE_HPP
+7 −4
Original line number Original line Diff line number Diff line
@@ -22,9 +22,12 @@ namespace gkfs {
namespace metadata {
namespace metadata {
class MetadataDB;
class MetadataDB;
}
}
}


namespace data {
class ChunkStorage;
class ChunkStorage;
}
}



#include <unordered_map>
#include <unordered_map>
#include <map>
#include <map>
@@ -49,7 +52,7 @@ private:
    // Database
    // Database
    std::shared_ptr<gkfs::metadata::MetadataDB> mdb_;
    std::shared_ptr<gkfs::metadata::MetadataDB> mdb_;
    // Storage backend
    // Storage backend
    std::shared_ptr<ChunkStorage> storage_;
    std::shared_ptr<gkfs::data::ChunkStorage> storage_;


    // configurable metadata
    // configurable metadata
    bool atime_state_;
    bool atime_state_;
@@ -92,9 +95,9 @@ public:


    void close_mdb();
    void close_mdb();


    const std::shared_ptr<ChunkStorage>& storage() const;
    const std::shared_ptr<gkfs::data::ChunkStorage>& storage() const;


    void storage(const std::shared_ptr<ChunkStorage>& storage);
    void storage(const std::shared_ptr<gkfs::data::ChunkStorage>& storage);


    const std::string& bind_addr() const;
    const std::string& bind_addr() const;


+7 −1
Original line number Original line Diff line number Diff line
@@ -25,6 +25,9 @@ extern "C" {
namespace bfs = boost::filesystem;
namespace bfs = boost::filesystem;
using namespace std;
using namespace std;


namespace gkfs {
namespace data {

string ChunkStorage::absolute(const string& internal_path) const {
string ChunkStorage::absolute(const string& internal_path) const {
    assert(gkfs::path::is_relative(internal_path));
    assert(gkfs::path::is_relative(internal_path));
    return root_path + '/' + internal_path;
    return root_path + '/' + internal_path;
@@ -214,3 +217,6 @@ ChunkStat ChunkStorage::chunk_stat() const {
            bytes_total / chunksize,
            bytes_total / chunksize,
            bytes_free / chunksize};
            bytes_free / chunksize};
}
}

} // namespace data
} // namespace gkfs
 No newline at end of file
+2 −2
Original line number Original line Diff line number Diff line
@@ -37,11 +37,11 @@ void FsData::close_mdb() {
    mdb_.reset();
    mdb_.reset();
}
}


const std::shared_ptr<ChunkStorage>& FsData::storage() const {
const std::shared_ptr<gkfs::data::ChunkStorage>& FsData::storage() const {
    return storage_;
    return storage_;
}
}


void FsData::storage(const std::shared_ptr<ChunkStorage>& storage) {
void FsData::storage(const std::shared_ptr<gkfs::data::ChunkStorage>& storage) {
    storage_ = storage;
    storage_ = storage;
}
}


+2 −1
Original line number Original line Diff line number Diff line
@@ -58,7 +58,8 @@ void init_environment() {
    GKFS_DATA->spdlogger()->debug("{}() Initializing storage backend: '{}'", __func__, chunk_storage_path);
    GKFS_DATA->spdlogger()->debug("{}() Initializing storage backend: '{}'", __func__, chunk_storage_path);
    bfs::create_directories(chunk_storage_path);
    bfs::create_directories(chunk_storage_path);
    try {
    try {
        GKFS_DATA->storage(std::make_shared<ChunkStorage>(chunk_storage_path, gkfs::config::rpc::chunksize));
        GKFS_DATA->storage(
                std::make_shared<gkfs::data::ChunkStorage>(chunk_storage_path, gkfs::config::rpc::chunksize));
    } catch (const std::exception& e) {
    } catch (const std::exception& e) {
        GKFS_DATA->spdlogger()->error("{}() Failed to initialize storage backend: {}", __func__, e.what());
        GKFS_DATA->spdlogger()->error("{}() Failed to initialize storage backend: {}", __func__, e.what());
        throw;
        throw;