Loading ifs/CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -147,8 +147,9 @@ include_directories( ${INCLUDE_DIR} ) # Global components add_subdirectory(src/global) # Daemon add_subdirectory(src/daemon) # Client library add_subdirectory(src/preload) ifs/include/daemon/classes/fs_data.hpp +7 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ /* Forward declarations */ class MetadataDB; class ChunkStorage; class Distributor; #include <unordered_map> #include <functional> //std::hash Loading Loading @@ -45,6 +46,8 @@ private: std::shared_ptr<MetadataDB> mdb_; // Storage backend std::shared_ptr<ChunkStorage> storage_; // Distributor std::shared_ptr<Distributor> distributor_; // configurable metadata bool atime_state_; Loading Loading @@ -121,6 +124,10 @@ public: void storage(const std::shared_ptr<ChunkStorage>& storage); void distributor(std::shared_ptr<Distributor> d); std::shared_ptr<Distributor> distributor() const; const std::string& hosts_raw() const; void hosts_raw(const std::string& hosts_raw); Loading ifs/include/global/rpc/distributor.hpp 0 → 100644 +46 −0 Original line number Diff line number Diff line #ifndef IFS_RPC_DISTRIBUTOR_HPP #define IFS_RPC_DISTRIBUTOR_HPP #include <vector> #include <string> #include <numeric> using ChunkID = unsigned int; using Host = unsigned int; class Distributor { public: virtual Host localhost() const = 0; virtual Host locate_data(const std::string& path, const ChunkID& chnk_id) const = 0; virtual Host locate_file_metadata(const std::string& path) const = 0; virtual std::vector<Host> locate_directory_metadata(const std::string& path) const = 0; }; class SimpleHashDistributor : public Distributor { private: Host localhost_; unsigned int hosts_size_; std::vector<Host> all_hosts_; std::hash<std::string> str_hash; public: SimpleHashDistributor(Host localhost, unsigned int hosts_size); Host localhost() const override; Host locate_data(const std::string& path, const ChunkID& chnk_id) const override; Host locate_file_metadata(const std::string& path) const override; std::vector<Host> locate_directory_metadata(const std::string& path) const override; }; class LocalOnlyDistributor : public Distributor { private: Host localhost_; public: LocalOnlyDistributor(Host localhost); Host localhost() const override; Host locate_data(const std::string& path, const ChunkID& chnk_id) const override; Host locate_file_metadata(const std::string& path) const override; std::vector<Host> locate_directory_metadata(const std::string& path) const override; }; #endif //IFS_RPC_LOCATOR_HPP ifs/include/global/rpc/rpc_utils.hpp +0 −4 Original line number Diff line number Diff line Loading @@ -51,8 +51,4 @@ hg_bool_t bool_to_merc_bool(bool state); bool is_handle_sm(margo_instance_id mid, const hg_addr_t& addr); size_t adafs_hash_path(const std::string& to_hash, const size_t host_size); size_t adafs_hash_path_chunk(const std::string& path, const size_t chunk_id, const size_t host_size); #endif //IFS_RPC_UTILS_HPP ifs/include/preload/preload_context.hpp +5 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ /* Forward declarations */ class OpenFileMap; class Distributor; class PreloadContext { Loading @@ -15,6 +16,7 @@ class PreloadContext { std::shared_ptr<spdlog::logger> log_; std::shared_ptr<OpenFileMap> ofm_; std::shared_ptr<Distributor> distributor_; std::string mountdir_; public: Loading @@ -35,6 +37,9 @@ class PreloadContext { bool relativize_path(std::string& path) const; const std::shared_ptr<OpenFileMap>& file_map() const; void distributor(std::shared_ptr<Distributor> distributor); std::shared_ptr<Distributor> distributor() const; }; Loading Loading
ifs/CMakeLists.txt +2 −1 Original line number Diff line number Diff line Loading @@ -147,8 +147,9 @@ include_directories( ${INCLUDE_DIR} ) # Global components add_subdirectory(src/global) # Daemon add_subdirectory(src/daemon) # Client library add_subdirectory(src/preload)
ifs/include/daemon/classes/fs_data.hpp +7 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ /* Forward declarations */ class MetadataDB; class ChunkStorage; class Distributor; #include <unordered_map> #include <functional> //std::hash Loading Loading @@ -45,6 +46,8 @@ private: std::shared_ptr<MetadataDB> mdb_; // Storage backend std::shared_ptr<ChunkStorage> storage_; // Distributor std::shared_ptr<Distributor> distributor_; // configurable metadata bool atime_state_; Loading Loading @@ -121,6 +124,10 @@ public: void storage(const std::shared_ptr<ChunkStorage>& storage); void distributor(std::shared_ptr<Distributor> d); std::shared_ptr<Distributor> distributor() const; const std::string& hosts_raw() const; void hosts_raw(const std::string& hosts_raw); Loading
ifs/include/global/rpc/distributor.hpp 0 → 100644 +46 −0 Original line number Diff line number Diff line #ifndef IFS_RPC_DISTRIBUTOR_HPP #define IFS_RPC_DISTRIBUTOR_HPP #include <vector> #include <string> #include <numeric> using ChunkID = unsigned int; using Host = unsigned int; class Distributor { public: virtual Host localhost() const = 0; virtual Host locate_data(const std::string& path, const ChunkID& chnk_id) const = 0; virtual Host locate_file_metadata(const std::string& path) const = 0; virtual std::vector<Host> locate_directory_metadata(const std::string& path) const = 0; }; class SimpleHashDistributor : public Distributor { private: Host localhost_; unsigned int hosts_size_; std::vector<Host> all_hosts_; std::hash<std::string> str_hash; public: SimpleHashDistributor(Host localhost, unsigned int hosts_size); Host localhost() const override; Host locate_data(const std::string& path, const ChunkID& chnk_id) const override; Host locate_file_metadata(const std::string& path) const override; std::vector<Host> locate_directory_metadata(const std::string& path) const override; }; class LocalOnlyDistributor : public Distributor { private: Host localhost_; public: LocalOnlyDistributor(Host localhost); Host localhost() const override; Host locate_data(const std::string& path, const ChunkID& chnk_id) const override; Host locate_file_metadata(const std::string& path) const override; std::vector<Host> locate_directory_metadata(const std::string& path) const override; }; #endif //IFS_RPC_LOCATOR_HPP
ifs/include/global/rpc/rpc_utils.hpp +0 −4 Original line number Diff line number Diff line Loading @@ -51,8 +51,4 @@ hg_bool_t bool_to_merc_bool(bool state); bool is_handle_sm(margo_instance_id mid, const hg_addr_t& addr); size_t adafs_hash_path(const std::string& to_hash, const size_t host_size); size_t adafs_hash_path_chunk(const std::string& path, const size_t chunk_id, const size_t host_size); #endif //IFS_RPC_UTILS_HPP
ifs/include/preload/preload_context.hpp +5 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ /* Forward declarations */ class OpenFileMap; class Distributor; class PreloadContext { Loading @@ -15,6 +16,7 @@ class PreloadContext { std::shared_ptr<spdlog::logger> log_; std::shared_ptr<OpenFileMap> ofm_; std::shared_ptr<Distributor> distributor_; std::string mountdir_; public: Loading @@ -35,6 +37,9 @@ class PreloadContext { bool relativize_path(std::string& path) const; const std::shared_ptr<OpenFileMap>& file_map() const; void distributor(std::shared_ptr<Distributor> distributor); std::shared_ptr<Distributor> distributor() const; }; Loading