|
|
@ -41,6 +41,19 @@ class RequestBase {
|
|
|
|
virtual ~RequestBase() {}
|
|
|
|
virtual ~RequestBase() {}
|
|
|
|
virtual void Process() = 0;
|
|
|
|
virtual void Process() = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string Status2String(const std::string& method) {
|
|
|
|
|
|
|
|
std::string status = "Process";
|
|
|
|
|
|
|
|
if (status_ == FINISH) {
|
|
|
|
|
|
|
|
status = "Finish";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::ostringstream s;
|
|
|
|
|
|
|
|
s << method << " name:[" << GetReqName() << "]"
|
|
|
|
|
|
|
|
<< ", ep:[" << ctx_.peer() << "]"
|
|
|
|
|
|
|
|
<< " " << status << " using req_id:" << req_id_;
|
|
|
|
|
|
|
|
return s.str();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CallStatus Status() const {
|
|
|
|
CallStatus Status() const {
|
|
|
|
std::lock_guard<std::mutex> l(status_mu_);
|
|
|
|
std::lock_guard<std::mutex> l(status_mu_);
|
|
|
|
return status_;
|
|
|
|
return status_;
|
|
|
@ -272,7 +285,7 @@ void AsyncGRPCServer::TryToRegisterNewOne(const std::string& rpc_name,
|
|
|
|
int req_id) {
|
|
|
|
int req_id) {
|
|
|
|
std::unique_lock<std::mutex> lock(cq_mutex_);
|
|
|
|
std::unique_lock<std::mutex> lock(cq_mutex_);
|
|
|
|
if (is_shut_down_) {
|
|
|
|
if (is_shut_down_) {
|
|
|
|
VLOG(3) << "shutdown, do not TryToRegisterNewSendOne";
|
|
|
|
LOG(WARNING) << "shutdown, do not TryToRegisterNewSendOne";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -306,14 +319,14 @@ void AsyncGRPCServer::HandleRequest(
|
|
|
|
bool ok = false;
|
|
|
|
bool ok = false;
|
|
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
VLOG(3) << "HandleRequest " << rpc_name << " wait next";
|
|
|
|
VLOG(4) << "HandleRequest " << rpc_name << " wait next";
|
|
|
|
if (!cq->Next(&tag, &ok)) {
|
|
|
|
if (!cq->Next(&tag, &ok)) {
|
|
|
|
LOG(INFO) << "CompletionQueue " << rpc_name << " shutdown!";
|
|
|
|
LOG(INFO) << "CompletionQueue " << rpc_name << " shutdown!";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int req_id = static_cast<int>(reinterpret_cast<intptr_t>(tag));
|
|
|
|
int req_id = static_cast<int>(reinterpret_cast<intptr_t>(tag));
|
|
|
|
VLOG(3) << "HandleRequest " << rpc_name << ", req_id:" << req_id
|
|
|
|
VLOG(4) << "HandleRequest " << rpc_name << ", req_id:" << req_id
|
|
|
|
<< " get next";
|
|
|
|
<< " get next";
|
|
|
|
|
|
|
|
|
|
|
|
auto& reqs = rpc_reqs_[rpc_name];
|
|
|
|
auto& reqs = rpc_reqs_[rpc_name];
|
|
|
@ -324,22 +337,21 @@ void AsyncGRPCServer::HandleRequest(
|
|
|
|
base = reqs[req_id];
|
|
|
|
base = reqs[req_id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VLOG(3) << base->Status2String(rpc_name);
|
|
|
|
|
|
|
|
|
|
|
|
// reference:
|
|
|
|
// reference:
|
|
|
|
// https://github.com/tensorflow/tensorflow/issues/5596
|
|
|
|
// https://github.com/tensorflow/tensorflow/issues/5596
|
|
|
|
// https://groups.google.com/forum/#!topic/grpc-io/xftlRy-IQwM
|
|
|
|
// https://groups.google.com/forum/#!topic/grpc-io/xftlRy-IQwM
|
|
|
|
// https://groups.google.com/forum/#!topic/grpc-io/ywATt88Ef_I
|
|
|
|
// https://groups.google.com/forum/#!topic/grpc-io/ywATt88Ef_I
|
|
|
|
if (!ok) {
|
|
|
|
if (!ok) {
|
|
|
|
LOG(WARNING) << "completion queue:" << rpc_name
|
|
|
|
LOG(WARNING) << "completion queue:" << rpc_name
|
|
|
|
<< " recv no regular event:argument name["
|
|
|
|
<< " recv no regular event"
|
|
|
|
<< base->GetReqName() << "]";
|
|
|
|
<< " context:" << base->Status2String(rpc_name);
|
|
|
|
TryToRegisterNewOne(rpc_name, req_id);
|
|
|
|
TryToRegisterNewOne(rpc_name, req_id);
|
|
|
|
delete base;
|
|
|
|
delete base;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VLOG(3) << "queue id:" << rpc_name << ", req_id:" << req_id
|
|
|
|
|
|
|
|
<< ", status:" << base->Status();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (base->Status()) {
|
|
|
|
switch (base->Status()) {
|
|
|
|
case PROCESS: {
|
|
|
|
case PROCESS: {
|
|
|
|
base->Process();
|
|
|
|
base->Process();
|
|
|
|