Commit 9349e366 authored by Marc Vef's avatar Marc Vef
Browse files

Proxy: Remove optimization added

parent 7e7e789e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ int
forward_stat_proxy(const std::string& path, std::string& attr);

int
forward_remove_proxy(const std::string& path);
forward_remove_proxy(const std::string& path, bool rm_dir);

int
forward_decr_size_proxy(const std::string& path, size_t length);
+11 −3
Original line number Diff line number Diff line
@@ -3121,7 +3121,8 @@ struct remove_proxy {
        hermes::detail::post_to_mercury(ExecutionContext*);

    public:
        input(const std::string& path) : m_path(path) {}
        input(const std::string& path, bool rm_dir)
            : m_path(path), m_rm_dir(rm_dir) {}

        input(input&& rhs) = default;

@@ -3138,14 +3139,21 @@ struct remove_proxy {
            return m_path;
        }

        explicit input(const rpc_rm_node_in_t& other) : m_path(other.path) {}
        bool
        rm_dir() const {
            return m_rm_dir;
        }

        explicit input(const rpc_rm_node_in_t& other)
            : m_path(other.path), m_rm_dir(other.rm_dir) {}

        explicit operator rpc_rm_node_in_t() {
            return {m_path.c_str()};
            return {m_path.c_str(), m_rm_dir};
        }

    private:
        std::string m_path;
        bool m_rm_dir;
    };

    class output {
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ std::pair<int, std::string>
forward_stat(const std::string& path);

int
forward_remove(const std::string& path);
forward_remove(const std::string& path, bool rm_dir);

int
forward_decr_size(const std::string& path, size_t length);
+9 −4
Original line number Diff line number Diff line
@@ -365,7 +365,8 @@ gkfs_remove(const std::string& path) {
                    return -1;
                }
            }
            auto err = gkfs::rpc::forward_remove(new_path, CTX->get_replicas());
            auto err = gkfs::rpc::forward_remove(new_path, false,
                                                 CTX->get_replicas());
            if(err) {
                errno = err;
                return -1;
@@ -376,7 +377,7 @@ gkfs_remove(const std::string& path) {
#endif // HAS_SYMLINKS
    int err = 0;
    if(gkfs::config::proxy::fwd_remove && CTX->use_proxy()) {
        err = gkfs::rpc::forward_remove_proxy(path);
        err = gkfs::rpc::forward_remove_proxy(path, false);
    } else {
        err = gkfs::rpc::forward_remove(path, false, CTX->get_replicas());
    }
@@ -478,7 +479,11 @@ gkfs_rename(const string& old_path, const string& new_path) {
                return -1;
            }
            // Delete old file
            err = gkfs::rpc::forward_remove(old_path, CTX->get_replicas());
            auto is_dir = false;
            if(S_ISDIR(md_old->mode()))
                is_dir = true;
            err = gkfs::rpc::forward_remove(old_path, is_dir,
                                            CTX->get_replicas());
            if(err) {
                errno = err;
                return -1;
@@ -1363,7 +1368,7 @@ gkfs_rmdir(const std::string& path) {
    }
#endif
    if(gkfs::config::proxy::fwd_remove && CTX->use_proxy()) {
        err = gkfs::rpc::forward_remove_proxy(path);
        err = gkfs::rpc::forward_remove_proxy(path, true);
    } else {
        err = gkfs::rpc::forward_remove(path, true, CTX->get_replicas());
    }
+3 −2
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ forward_stat_proxy(const std::string& path, string& attr) {
}

int
forward_remove_proxy(const std::string& path) {
forward_remove_proxy(const std::string& path, bool rm_dir) {
    auto endp = CTX->proxy_host();

    try {
@@ -88,7 +88,8 @@ forward_remove_proxy(const std::string& path) {
        // TODO(amiranda): hermes will eventually provide a post(endpoint)
        // returning one result and a broadcast(endpoint_set) returning a
        // result_set. When that happens we can remove the .at(0) :/
        auto out = ld_proxy_service->post<gkfs::rpc::remove_proxy>(endp, path)
        auto out = ld_proxy_service
                           ->post<gkfs::rpc::remove_proxy>(endp, path, rm_dir)
                           .get()
                           .at(0);
        LOG(DEBUG, "Got response success: {}", out.err());
Loading