Skip to content

Commit

Permalink
Rename E_CLIENT_REJECTED to E_CLIENT_SERVER_INCOMPATIBLE.
Browse files Browse the repository at this point in the history
  • Loading branch information
CPWstatic committed Sep 29, 2021
1 parent 05e9cd0 commit 0de4fb0
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 99 deletions.
191 changes: 96 additions & 95 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,101 +574,102 @@ void MetaClient::getResponse(Request req,
folly::RWSpinLock::ReadHolder holder(&hostLock_);
host = toLeader ? leader_ : active_;
}
folly::via(evb,
[host,
evb,
req = std::move(req),
remoteFunc = std::move(remoteFunc),
respGen = std::move(respGen),
pro = std::move(pro),
toLeader,
retry,
retryLimit,
this]() mutable {
auto client = clientsMan_->client(host, evb, false, FLAGS_meta_client_timeout_ms);
VLOG(1) << "Send request to meta " << host;
remoteFunc(client, req)
.via(evb)
.then([host,
req = std::move(req),
remoteFunc = std::move(remoteFunc),
respGen = std::move(respGen),
pro = std::move(pro),
toLeader,
retry,
retryLimit,
evb,
this](folly::Try<RpcResponse>&& t) mutable {
// exception occurred during RPC
if (t.hasException()) {
if (toLeader) {
updateLeader();
} else {
updateActive();
}
if (retry < retryLimit) {
evb->runAfterDelay(
[req = std::move(req),
remoteFunc = std::move(remoteFunc),
respGen = std::move(respGen),
pro = std::move(pro),
toLeader,
retry,
retryLimit,
this]() mutable {
getResponse(std::move(req),
std::move(remoteFunc),
std::move(respGen),
std::move(pro),
toLeader,
retry + 1,
retryLimit);
},
FLAGS_meta_client_retry_interval_secs * 1000);
return;
} else {
LOG(ERROR) << "Send request to " << host << ", exceed retry limit";
pro.setValue(Status::Error("RPC failure in MetaClient: %s",
t.exception().what().c_str()));
}
return;
}

auto&& resp = t.value();
if (resp.get_code() == nebula::cpp2::ErrorCode::SUCCEEDED) {
// succeeded
pro.setValue(respGen(std::move(resp)));
return;
} else if (resp.get_code() == nebula::cpp2::ErrorCode::E_LEADER_CHANGED) {
updateLeader(resp.get_leader());
if (retry < retryLimit) {
evb->runAfterDelay(
[req = std::move(req),
remoteFunc = std::move(remoteFunc),
respGen = std::move(respGen),
pro = std::move(pro),
toLeader,
retry,
retryLimit,
this]() mutable {
getResponse(std::move(req),
std::move(remoteFunc),
std::move(respGen),
std::move(pro),
toLeader,
retry + 1,
retryLimit);
},
FLAGS_meta_client_retry_interval_secs * 1000);
return;
}
} else if (resp.get_code() == nebula::cpp2::ErrorCode::E_CLIENT_REJECTED) {
pro.setValue(respGen(std::move(resp)));
return;
}
pro.setValue(this->handleResponse(resp));
}); // then
}); // via
folly::via(
evb,
[host,
evb,
req = std::move(req),
remoteFunc = std::move(remoteFunc),
respGen = std::move(respGen),
pro = std::move(pro),
toLeader,
retry,
retryLimit,
this]() mutable {
auto client = clientsMan_->client(host, evb, false, FLAGS_meta_client_timeout_ms);
VLOG(1) << "Send request to meta " << host;
remoteFunc(client, req)
.via(evb)
.then([host,
req = std::move(req),
remoteFunc = std::move(remoteFunc),
respGen = std::move(respGen),
pro = std::move(pro),
toLeader,
retry,
retryLimit,
evb,
this](folly::Try<RpcResponse>&& t) mutable {
// exception occurred during RPC
if (t.hasException()) {
if (toLeader) {
updateLeader();
} else {
updateActive();
}
if (retry < retryLimit) {
evb->runAfterDelay(
[req = std::move(req),
remoteFunc = std::move(remoteFunc),
respGen = std::move(respGen),
pro = std::move(pro),
toLeader,
retry,
retryLimit,
this]() mutable {
getResponse(std::move(req),
std::move(remoteFunc),
std::move(respGen),
std::move(pro),
toLeader,
retry + 1,
retryLimit);
},
FLAGS_meta_client_retry_interval_secs * 1000);
return;
} else {
LOG(ERROR) << "Send request to " << host << ", exceed retry limit";
pro.setValue(
Status::Error("RPC failure in MetaClient: %s", t.exception().what().c_str()));
}
return;
}

auto&& resp = t.value();
if (resp.get_code() == nebula::cpp2::ErrorCode::SUCCEEDED) {
// succeeded
pro.setValue(respGen(std::move(resp)));
return;
} else if (resp.get_code() == nebula::cpp2::ErrorCode::E_LEADER_CHANGED) {
updateLeader(resp.get_leader());
if (retry < retryLimit) {
evb->runAfterDelay(
[req = std::move(req),
remoteFunc = std::move(remoteFunc),
respGen = std::move(respGen),
pro = std::move(pro),
toLeader,
retry,
retryLimit,
this]() mutable {
getResponse(std::move(req),
std::move(remoteFunc),
std::move(respGen),
std::move(pro),
toLeader,
retry + 1,
retryLimit);
},
FLAGS_meta_client_retry_interval_secs * 1000);
return;
}
} else if (resp.get_code() == nebula::cpp2::ErrorCode::E_CLIENT_SERVER_INCOMPATIBLE) {
pro.setValue(respGen(std::move(resp)));
return;
}
pro.setValue(this->handleResponse(resp));
}); // then
}); // via
}

std::vector<SpaceIdName> MetaClient::toSpaceIdName(const std::vector<cpp2::IdName>& tIdNames) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/graph/Response.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
X(E_TASK_EXECUTION_FAILED, -3053) \
\
X(E_PLAN_IS_KILLED, -3060) \
X(E_CLIENT_REJECTED, -3061) \
X(E_CLIENT_SERVER_INCOMPATIBLE, -3061) \
\
X(E_UNKNOWN, -8000)

Expand Down
2 changes: 1 addition & 1 deletion src/graph/service/GraphService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ folly::Future<cpp2::VerifyClientVersionResp> GraphService::future_verifyClientVe
":", FLAGS_client_white_list, std::inserter(whiteList, whiteList.begin()));
cpp2::VerifyClientVersionResp resp;
if (FLAGS_enable_client_white_list && whiteList.find(req.get_version()) == whiteList.end()) {
resp.set_error_code(nebula::cpp2::ErrorCode::E_CLIENT_REJECTED);
resp.set_error_code(nebula::cpp2::ErrorCode::E_CLIENT_SERVER_INCOMPATIBLE);
resp.set_error_msg(folly::stringPrintf(
"Graph client version(%s) is not accepted, current graph client white list: %s.",
req.get_version().c_str(),
Expand Down
2 changes: 1 addition & 1 deletion src/interface/common.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ enum ErrorCode {
E_OUTDATED_EDGE = -3072,
E_WRITE_WRITE_CONFLICT = -3073,

E_CLIENT_REJECTED = -3061,
E_CLIENT_SERVER_INCOMPATIBLE = -3061,

E_UNKNOWN = -8000,
} (cpp.enum_strict)
2 changes: 1 addition & 1 deletion src/meta/processors/admin/VerifyClientVersionProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void VerifyClientVersionProcessor::process(const cpp2::VerifyClientVersionReq& r
folly::splitTo<std::string>(
":", FLAGS_client_white_list, std::inserter(whiteList, whiteList.begin()));
if (FLAGS_enable_client_white_list && whiteList.find(req.get_version()) == whiteList.end()) {
resp_.set_code(nebula::cpp2::ErrorCode::E_CLIENT_REJECTED);
resp_.set_code(nebula::cpp2::ErrorCode::E_CLIENT_SERVER_INCOMPATIBLE);
resp_.set_error_msg(folly::stringPrintf(
"Meta client version(%s) is not accepted, current meta client white list: %s.",
req.get_version().c_str(),
Expand Down

0 comments on commit 0de4fb0

Please sign in to comment.