Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(FQDN): Update src/nfs/nfs.thrift related code #1991

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 26 additions & 33 deletions src/nfs/nfs_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
#include "fmt/core.h"
#include "nfs/nfs_code_definition.h"
#include "nfs/nfs_node.h"
#include "runtime/rpc/dns_resolver.h"
#include "runtime/rpc/dns_resolver.h" // IWYU pragma: keep
#include "runtime/rpc/rpc_host_port.h"
#include "utils/blob.h"
#include "utils/command_manager.h"
#include "utils/filesystem.h"
Expand Down Expand Up @@ -137,35 +138,32 @@ void nfs_client_impl::begin_remote_copy(std::shared_ptr<remote_copy_request> &rc
{
user_request_ptr req(new user_request());
req->high_priority = rci->high_priority;
req->file_size_req.source = dsn::dns_resolver::instance().resolve_address(rci->source);
SET_IP_AND_HOST_PORT_BY_DNS(req->file_size_req, source, rci->source);
req->file_size_req.dst_dir = rci->dest_dir;
req->file_size_req.file_list = rci->files;
req->file_size_req.source_dir = rci->source_dir;
req->file_size_req.overwrite = rci->overwrite;
req->file_size_req.__set_source_disk_tag(rci->source_disk_tag);
req->file_size_req.__set_dest_disk_tag(rci->dest_disk_tag);
req->file_size_req.__set_pid(rci->pid);
req->file_size_req.__set_hp_source(rci->source);
req->nfs_task = nfs_task;
req->is_finished = false;

async_nfs_get_file_size(
req->file_size_req,
[=](error_code err, get_file_size_response &&resp) {
end_get_file_size(err, std::move(resp), req);
},
std::chrono::milliseconds(FLAGS_rpc_timeout_ms),
dsn::dns_resolver::instance().resolve_address(req->file_size_req.hp_source));
async_nfs_get_file_size(req->file_size_req,
[=](error_code err, get_file_size_response &&resp) {
end_get_file_size(err, std::move(resp), req);
},
std::chrono::milliseconds(FLAGS_rpc_timeout_ms),
req->file_size_req.source);
}

void nfs_client_impl::end_get_file_size(::dsn::error_code err,
const ::dsn::service::get_file_size_response &resp,
const user_request_ptr &ureq)
{
if (err != ::dsn::ERR_OK) {
LOG_ERROR("[nfs_service] remote get file size failed, source = {}({}), dir = {}, err = {}",
ureq->file_size_req.hp_source,
ureq->file_size_req.source,
LOG_ERROR("[nfs_service] remote get file size failed, source = {}, dir = {}, err = {}",
FMT_HOST_PORT_AND_IP(ureq->file_size_req, source),
ureq->file_size_req.source_dir,
err);
ureq->nfs_task->enqueue(err, 0);
Expand All @@ -174,9 +172,8 @@ void nfs_client_impl::end_get_file_size(::dsn::error_code err,

err = dsn::error_code(resp.error);
if (err != ::dsn::ERR_OK) {
LOG_ERROR("[nfs_service] remote get file size failed, source = {}({}), dir = {}, err = {}",
ureq->file_size_req.hp_source,
ureq->file_size_req.source,
LOG_ERROR("[nfs_service] remote get file size failed, source = {}, dir = {}, err = {}",
FMT_HOST_PORT_AND_IP(ureq->file_size_req, source),
ureq->file_size_req.source_dir,
err);
ureq->nfs_task->enqueue(err, 0);
Expand Down Expand Up @@ -296,7 +293,7 @@ void nfs_client_impl::continue_copy()
}

copy_request copy_req;
copy_req.source = ureq->file_size_req.source;
SET_OBJ_IP_AND_HOST_PORT(copy_req, source, ureq->file_size_req, source);
copy_req.file_name = req->file_ctx->file_name;
copy_req.offset = req->offset;
copy_req.size = req->size;
Expand All @@ -306,7 +303,6 @@ void nfs_client_impl::continue_copy()
copy_req.is_last = req->is_last;
copy_req.__set_source_disk_tag(ureq->file_size_req.source_disk_tag);
copy_req.__set_pid(ureq->file_size_req.pid);
copy_req.__set_hp_source(ureq->file_size_req.hp_source);
req->remote_copy_task =
async_nfs_copy(copy_req,
[=](error_code err, copy_response &&resp) {
Expand All @@ -320,8 +316,7 @@ void nfs_client_impl::continue_copy()
}
},
std::chrono::milliseconds(FLAGS_rpc_timeout_ms),
dsn::dns_resolver::instance().resolve_address(
req->file_ctx->user_req->file_size_req.hp_source));
req->file_ctx->user_req->file_size_req.source);
} else {
--ureq->concurrent_copy_count;
--_concurrent_copy_request_count;
Expand Down Expand Up @@ -354,17 +349,16 @@ void nfs_client_impl::end_copy(::dsn::error_code err,
METRIC_VAR_INCREMENT(nfs_client_copy_failed_requests);

if (!fc->user_req->is_finished) {
const auto &hp = fc->user_req->file_size_req.hp_source;
host_port hp;
GET_HOST_PORT(fc->user_req->file_size_req, source, hp);
if (reqc->retry_count > 0) {
LOG_WARNING(
"[nfs_service] remote copy failed, source = {}({}), dir = {}, file = {}, "
"err = {}, retry_count = {}",
hp,
fc->user_req->file_size_req.source,
fc->user_req->file_size_req.source_dir,
fc->file_name,
err,
reqc->retry_count);
LOG_WARNING("[nfs_service] remote copy failed, source = {}, dir = {}, file = {}, "
"err = {}, retry_count = {}",
FMT_HOST_PORT_AND_IP(fc->user_req->file_size_req, source),
fc->user_req->file_size_req.source_dir,
fc->file_name,
err,
reqc->retry_count);

// retry copy
reqc->retry_count--;
Expand All @@ -376,10 +370,9 @@ void nfs_client_impl::end_copy(::dsn::error_code err,
else
_copy_requests_low.push_retry(reqc);
} else {
LOG_ERROR("[nfs_service] remote copy failed, source = {}({}), dir = {}, file = {}, "
LOG_ERROR("[nfs_service] remote copy failed, source = {}, dir = {}, file = {}, "
"err = {}, retry_count = {}",
hp,
fc->user_req->file_size_req.source,
FMT_HOST_PORT_AND_IP(fc->user_req->file_size_req, source),
fc->user_req->file_size_req.source_dir,
fc->file_name,
err,
Expand Down
Loading