Verified Commit 667277a0 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Code cleanup

parent 145f53e6
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -62,10 +62,7 @@ class PreloadContext {
    std::vector<std::string> mountdir_components_;
    std::string mountdir_;

#if 1 // TODO(amiranda): remove
    std::vector<hg_addr_t> hosts_;
#endif
    std::vector<hermes::endpoint> hosts2_;
    std::vector<hermes::endpoint> hosts_;
    uint64_t local_host_id_;

    bool interception_enabled_;
@@ -89,13 +86,8 @@ class PreloadContext {
    void cwd(const std::string& path);
    const std::string& cwd() const;

#if 1 // TODO(amiranda) remove
    const std::vector<hg_addr_t>& hosts() const;
    void hosts(const std::vector<hg_addr_t>& addrs);
#endif

    const std::vector<hermes::endpoint>& hosts2() const;
    void hosts2(const std::vector<hermes::endpoint>& addrs);
    const std::vector<hermes::endpoint>& hosts() const;
    void hosts(const std::vector<hermes::endpoint>& addrs);
    void clear_hosts();


+4 −15
Original line number Diff line number Diff line
@@ -58,27 +58,16 @@ const std::string& PreloadContext::cwd() const {
    return cwd_;
}

#if 1 // TODO(amiranda) remove
const std::vector<hg_addr_t>& PreloadContext::hosts() const {
const std::vector<hermes::endpoint>& PreloadContext::hosts() const {
    return hosts_;
}

void PreloadContext::hosts(const std::vector<hg_addr_t>& addrs) {
    hosts_ = addrs;
}

#endif

const std::vector<hermes::endpoint>& PreloadContext::hosts2() const {
    return hosts2_;
}

void PreloadContext::hosts2(const std::vector<hermes::endpoint>& endpoints) {
    hosts2_ = endpoints;
void PreloadContext::hosts(const std::vector<hermes::endpoint>& endpoints) {
    hosts_ = endpoints;
}

void PreloadContext::clear_hosts() {
    hosts2_.clear();
    hosts_.clear();
}

uint64_t PreloadContext::local_host_id() const {
+4 −8
Original line number Diff line number Diff line
@@ -160,10 +160,9 @@ void load_hosts() {

    auto local_hostname = get_my_hostname(true);
    bool local_host_found = false;
    vector<hg_addr_t> addrs(hosts.size()); // TODO(amiranda) remove

    std::vector<hermes::endpoint> addrs2;
    addrs2.reserve(hosts.size());
    std::vector<hermes::endpoint> addrs;
    addrs.reserve(hosts.size());

    vector<uint64_t> host_ids(hosts.size());
    // populate vector with [0, ..., host_size - 1]
@@ -185,8 +184,8 @@ void load_hosts() {

        auto endp = ::lookup_endpoint(uri);

        auto it = std::next(addrs2.begin(), id);
        addrs2.emplace(it, endp);
        auto it = std::next(addrs.begin(), id);
        addrs.emplace(it, endp);

        if (!local_host_found && hostname == local_hostname) {
            CTX->log()->debug("{}() Found local host: {}", __func__, hostname);
@@ -201,8 +200,5 @@ void load_hosts() {
        CTX->local_host_id(0);
    }

#if 1 // TODO(amiranda) remove
    CTX->hosts(addrs);
#endif
    CTX->hosts2(addrs2);
}
+6 −6
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ ssize_t write(const string& path, const void* buf, const bool append_flag,
            total_chunk_size -= chnk_rpad(offset + write_size, CHUNKSIZE);
        }

        auto endp = CTX->hosts2().at(target);
        auto endp = CTX->hosts().at(target);

        try {

@@ -133,7 +133,7 @@ ssize_t write(const string& path, const void* buf, const bool append_flag,
                // a potential offset
                chnk_lpad(offset, CHUNKSIZE),
                target,
                CTX->hosts2().size(),
                CTX->hosts().size(),
                // number of chunks handled by that destination
                target_chnks[target].size(),
                // chunk start id of this write
@@ -284,7 +284,7 @@ ssize_t read(const string& path, void* buf, const off64_t offset, const size_t r
            total_chunk_size -= chnk_rpad(offset + read_size, CHUNKSIZE);
        }

        auto endp = CTX->hosts2().at(target);
        auto endp = CTX->hosts().at(target);

        try {

@@ -296,7 +296,7 @@ ssize_t read(const string& path, void* buf, const off64_t offset, const size_t r
                // a potential offset
                chnk_lpad(offset, CHUNKSIZE),
                target,
                CTX->hosts2().size(),
                CTX->hosts().size(),
                // number of chunks handled by that destination
                target_chnks[target].size(),
                // chunk start id of this write
@@ -384,7 +384,7 @@ int trunc_data(const std::string& path, size_t current_size, size_t new_size) {

    for (const auto& host: hosts) {

        auto endp = CTX->hosts2().at(host);
        auto endp = CTX->hosts().at(host);

        try {
            CTX->log()->debug("{}() Sending RPC ...", __func__);
@@ -440,7 +440,7 @@ ChunkStat chunk_stat() {

    std::vector<hermes::rpc_handle<gkfs::rpc::chunk_stat>> handles;

    for (const auto& endp : CTX->hosts2()) {
    for (const auto& endp : CTX->hosts()) {
        try {
            CTX->log()->trace("{}() Sending RPC to host: {}", 
                              __func__, endp.to_string());
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ namespace rpc_send {
 */
bool get_fs_config() {

    auto endp = CTX->hosts2().at(CTX->local_host_id());
    auto endp = CTX->hosts().at(CTX->local_host_id());
    gkfs::rpc::fs_config::output out;

    try {
Loading