提交 6f98ec3b 编写于 作者: W wangguibao

Fix BCLOUD.client

上级 b056ab7e
...@@ -11,6 +11,7 @@ CONFIGS('baidu/base/baidu-rpc@ci-base') ...@@ -11,6 +11,7 @@ CONFIGS('baidu/base/baidu-rpc@ci-base')
CONFIGS('baidu/third-party/gflags@v2.0.0@git_branch') CONFIGS('baidu/third-party/gflags@v2.0.0@git_branch')
CONFIGS('baidu/third-party/glog@v0.3.x@git_branch') CONFIGS('baidu/third-party/glog@v0.3.x@git_branch')
CONFIGS('baidu/third-party/opencv@master@git_branch') CONFIGS('baidu/third-party/opencv@master@git_branch')
CONFIGS('baidu/third-party/protobuf@2b7430d96aeff2bb624c8d52182ff5e4b9f7f18a@git_branch')
#sub directory #sub directory
Directory('pdcodegen') Directory('pdcodegen')
......
...@@ -116,7 +116,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -116,7 +116,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer.Print("#include \"predictor/framework/service_manager.h\"\n"); printer.Print("#include \"predictor/framework/service_manager.h\"\n");
} }
if (generate_stub) { if (generate_stub) {
printer.Print("#include <baidu::rpc/parallel_channel.h>\n"); printer.Print("#include <brpc/parallel_channel.h>\n");
printer.Print("#include \"sdk-cpp/include/factory.h\"\n"); printer.Print("#include \"sdk-cpp/include/factory.h\"\n");
printer.Print("#include \"sdk-cpp/include/stub.h\"\n"); printer.Print("#include \"sdk-cpp/include/stub.h\"\n");
printer.Print("#include \"sdk-cpp/include/stub_impl.h\"\n"); printer.Print("#include \"sdk-cpp/include/stub_impl.h\"\n");
...@@ -274,9 +274,9 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -274,9 +274,9 @@ class PdsCodeGenerator : public CodeGenerator {
google::protobuf::dots_to_colons(m->output_type()->full_name())); google::protobuf::dots_to_colons(m->output_type()->full_name()));
if (m->name() == "inference") { if (m->name() == "inference") {
printer->Print( printer->Print(
" baidu::rpc::ClosureGuard done_guard(done);\n" " brpc::ClosureGuard done_guard(done);\n"
" baidu::rpc::Controller* cntl = \n" " brpc::Controller* cntl = \n"
" static_cast<baidu::rpc::Controller*>(cntl_base);\n" " static_cast<brpc::Controller*>(cntl_base);\n"
" ::baidu::paddle_serving::predictor::InferService* svr = \n" " ::baidu::paddle_serving::predictor::InferService* svr = \n"
" " " "
"::baidu::paddle_serving::predictor::InferServiceManager::instance(" "::baidu::paddle_serving::predictor::InferServiceManager::instance("
...@@ -311,9 +311,9 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -311,9 +311,9 @@ class PdsCodeGenerator : public CodeGenerator {
} }
if (m->name() == "debug") { if (m->name() == "debug") {
printer->Print( printer->Print(
" baidu::rpc::ClosureGuard done_guard(done);\n" " brpc::ClosureGuard done_guard(done);\n"
" baidu::rpc::Controller* cntl = \n" " brpc::Controller* cntl = \n"
" static_cast<baidu::rpc::Controller*>(cntl_base);\n" " static_cast<brpc::Controller*>(cntl_base);\n"
" ::baidu::paddle_serving::predictor::InferService* svr = \n" " ::baidu::paddle_serving::predictor::InferService* svr = \n"
" " " "
"::baidu::paddle_serving::predictor::InferServiceManager::instance(" "::baidu::paddle_serving::predictor::InferServiceManager::instance("
...@@ -329,7 +329,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -329,7 +329,7 @@ class PdsCodeGenerator : public CodeGenerator {
"\"\]\";\n" "\"\]\";\n"
" LOG(INFO) << \" service_name=\[\" << \"$name$\" << \"\]\";\n" // NOLINT " LOG(INFO) << \" service_name=\[\" << \"$name$\" << \"\]\";\n" // NOLINT
" LOG(INFO) << \" log_id=\[\" << cntl->log_id() << \"\]\";\n" // NOLINT " LOG(INFO) << \" log_id=\[\" << cntl->log_id() << \"\]\";\n" // NOLINT
" base::IOBufBuilder debug_os;\n" " butil::IOBufBuilder debug_os;\n"
" int err_code = svr->inference(request, response, &debug_os);\n" " int err_code = svr->inference(request, response, &debug_os);\n"
" if (err_code != 0) {\n" " if (err_code != 0) {\n"
" LOG(WARNING)\n" " LOG(WARNING)\n"
...@@ -371,7 +371,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -371,7 +371,7 @@ class PdsCodeGenerator : public CodeGenerator {
const std::string& service_name, const std::string& service_name,
const std::string& class_name) const { const std::string& class_name) const {
printer->Print( printer->Print(
"class $name$_StubCallMapper : public baidu::rpc::CallMapper {\n" "class $name$_StubCallMapper : public brpc::CallMapper {\n"
"private:\n" "private:\n"
" uint32_t _package_size;\n" " uint32_t _package_size;\n"
" baidu::paddle_serving::sdk_cpp::Stub* _stub_handler;\n" " baidu::paddle_serving::sdk_cpp::Stub* _stub_handler;\n"
...@@ -389,7 +389,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -389,7 +389,7 @@ class PdsCodeGenerator : public CodeGenerator {
class_name); class_name);
printer->Print( printer->Print(
"baidu::rpc::SubCall default_map(\n" "brpc::SubCall default_map(\n"
" int channel_index,\n" " int channel_index,\n"
" const google::protobuf::MethodDescriptor* method,\n" " const google::protobuf::MethodDescriptor* method,\n"
" const google::protobuf::Message* request,\n" " const google::protobuf::Message* request,\n"
...@@ -409,7 +409,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -409,7 +409,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print("}\n"); printer->Print("}\n");
printer->Print( printer->Print(
"baidu::rpc::SubCall sub_package_map(\n" "brpc::SubCall sub_package_map(\n"
" int channel_index,\n" " int channel_index,\n"
" const google::protobuf::MethodDescriptor* method,\n" " const google::protobuf::MethodDescriptor* method,\n"
" const google::protobuf::Message* request,\n" " const google::protobuf::Message* request,\n"
...@@ -458,7 +458,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -458,7 +458,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print("}\n"); printer->Print("}\n");
printer->Print( printer->Print(
"baidu::rpc::SubCall Map(\n" "brpc::SubCall Map(\n"
" int channel_index,\n" " int channel_index,\n"
" const google::protobuf::MethodDescriptor* method,\n" " const google::protobuf::MethodDescriptor* method,\n"
" const google::protobuf::Message* request,\n" " const google::protobuf::Message* request,\n"
...@@ -473,8 +473,8 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -473,8 +473,8 @@ class PdsCodeGenerator : public CodeGenerator {
"return default_map(channel_index, method, request, response);\n"); "return default_map(channel_index, method, request, response);\n");
} else { } else {
printer->Print( printer->Print(
"base::Timer tt(base::Timer::STARTED);\n" "butil::Timer tt(butil::Timer::STARTED);\n"
"baidu::rpc::SubCall ret;\n" "brpc::SubCall ret;\n"
"if (_package_size == 0) {\n" "if (_package_size == 0) {\n"
" ret = default_map(channel_index, method, request, response);\n" " ret = default_map(channel_index, method, request, response);\n"
"} else {\n" "} else {\n"
...@@ -482,7 +482,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -482,7 +482,7 @@ class PdsCodeGenerator : public CodeGenerator {
"response);\n" "response);\n"
"}\n" "}\n"
"tt.stop();\n" "tt.stop();\n"
"if (ret.flags != baidu::rpc::SKIP_SUB_CHANNEL && ret.method != NULL) {\n" "if (ret.flags != brpc::SKIP_SUB_CHANNEL && ret.method != NULL) {\n"
" _stub_handler->update_latency(tt.u_elapsed(), \"pack_map\");\n" " _stub_handler->update_latency(tt.u_elapsed(), \"pack_map\");\n"
"}\n" "}\n"
"return ret;\n"); "return ret;\n");
...@@ -496,7 +496,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -496,7 +496,7 @@ class PdsCodeGenerator : public CodeGenerator {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
printer->Print( printer->Print(
"class $name$_StubResponseMerger : public baidu::rpc::ResponseMerger {\n" "class $name$_StubResponseMerger : public brpc::ResponseMerger {\n"
"private:\n" "private:\n"
" uint32_t _package_size;\n" " uint32_t _package_size;\n"
" baidu::paddle_serving::sdk_cpp::Stub* _stub_handler;\n" " baidu::paddle_serving::sdk_cpp::Stub* _stub_handler;\n"
...@@ -514,7 +514,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -514,7 +514,7 @@ class PdsCodeGenerator : public CodeGenerator {
class_name); class_name);
printer->Print( printer->Print(
"baidu::rpc::ResponseMerger::Result default_merge(\n" "brpc::ResponseMerger::Result default_merge(\n"
" google::protobuf::Message* response,\n" " google::protobuf::Message* response,\n"
" const google::protobuf::Message* sub_response) {\n" " const google::protobuf::Message* sub_response) {\n"
" baidu::paddle_serving::sdk_cpp::TracePackScope " " baidu::paddle_serving::sdk_cpp::TracePackScope "
...@@ -530,7 +530,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -530,7 +530,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print("}\n"); printer->Print("}\n");
printer->Print( printer->Print(
"baidu::rpc::ResponseMerger::Result sub_package_merge(\n" "brpc::ResponseMerger::Result sub_package_merge(\n"
" google::protobuf::Message* response,\n" " google::protobuf::Message* response,\n"
" const google::protobuf::Message* sub_response) {\n" " const google::protobuf::Message* sub_response) {\n"
" baidu::paddle_serving::sdk_cpp::TracePackScope " " baidu::paddle_serving::sdk_cpp::TracePackScope "
...@@ -546,22 +546,22 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -546,22 +546,22 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print("}\n"); printer->Print("}\n");
printer->Print( printer->Print(
"baidu::rpc::ResponseMerger::Result Merge(\n" "brpc::ResponseMerger::Result Merge(\n"
" google::protobuf::Message* response,\n" " google::protobuf::Message* response,\n"
" const google::protobuf::Message* sub_response) {\n", " const google::protobuf::Message* sub_response) {\n",
"name", "name",
class_name); class_name);
printer->Indent(); printer->Indent();
printer->Print( printer->Print(
"base::Timer tt(base::Timer::STARTED);\n" "butil::Timer tt(butil::Timer::STARTED);\n"
"baidu::rpc::ResponseMerger::Result ret;" "brpc::ResponseMerger::Result ret;"
"if (_package_size <= 0) {\n" "if (_package_size <= 0) {\n"
" ret = default_merge(response, sub_response);\n" " ret = default_merge(response, sub_response);\n"
"} else {\n" "} else {\n"
" ret = sub_package_merge(response, sub_response);\n" " ret = sub_package_merge(response, sub_response);\n"
"}\n" "}\n"
"tt.stop();\n" "tt.stop();\n"
"if (ret != baidu::rpc::ResponseMerger::FAIL) {\n" "if (ret != brpc::ResponseMerger::FAIL) {\n"
" _stub_handler->update_latency(tt.u_elapsed(), \"pack_merge\");\n" " _stub_handler->update_latency(tt.u_elapsed(), \"pack_merge\");\n"
"}\n" "}\n"
"return ret;\n"); "return ret;\n");
...@@ -580,7 +580,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -580,7 +580,7 @@ class PdsCodeGenerator : public CodeGenerator {
const std::string& class_name) const { const std::string& class_name) const {
printer->Print( printer->Print(
"if (channel_index > 0) { \n" "if (channel_index > 0) { \n"
" return baidu::rpc::SubCall::Skip();\n" " return brpc::SubCall::Skip();\n"
"}\n"); "}\n");
printer->Print( printer->Print(
"google::protobuf::Message* cur_res = " "google::protobuf::Message* cur_res = "
...@@ -591,14 +591,14 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -591,14 +591,14 @@ class PdsCodeGenerator : public CodeGenerator {
" if (cur_res == NULL) {\n" " if (cur_res == NULL) {\n"
" LOG(ERROR) << \"Failed new response item!\";\n" " LOG(ERROR) << \"Failed new response item!\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n" " _stub_handler->update_average(1, \"pack_fail\");\n"
" return baidu::rpc::SubCall::Bad();\n" " return brpc::SubCall::Bad();\n"
" }\n" " }\n"
" return baidu::rpc::SubCall(method, request, cur_res, " " return brpc::SubCall(method, request, cur_res, "
"baidu::rpc::DELETE_RESPONSE);\n" "brpc::DELETE_RESPONSE);\n"
"}\n"); "}\n");
"LOG(INFO) \n" "LOG(INFO) \n"
" << \"[default] Succ map, channel_index: \" << channel_index;\n"; " << \"[default] Succ map, channel_index: \" << channel_index;\n";
printer->Print("return baidu::rpc::SubCall(method, request, cur_res, 0);\n"); printer->Print("return brpc::SubCall(method, request, cur_res, 0);\n");
return true; return true;
} }
bool generate_paddle_serving_stub_default_merger( bool generate_paddle_serving_stub_default_merger(
...@@ -610,11 +610,11 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -610,11 +610,11 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print( printer->Print(
"try {\n" "try {\n"
" response->MergeFrom(*sub_response);\n" " response->MergeFrom(*sub_response);\n"
" return baidu::rpc::ResponseMerger::MERGED;\n" " return brpc::ResponseMerger::MERGED;\n"
"} catch (const std::exception& e) {\n" "} catch (const std::exception& e) {\n"
" LOG(ERROR) << \"Merge failed.\";\n" " LOG(ERROR) << \"Merge failed.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n" " _stub_handler->update_average(1, \"pack_fail\");\n"
" return baidu::rpc::ResponseMerger::FAIL;\n" " return brpc::ResponseMerger::FAIL;\n"
"}\n"); "}\n");
return true; return true;
} }
...@@ -657,7 +657,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -657,7 +657,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print( printer->Print(
"int start = _package_size * channel_index;\n" "int start = _package_size * channel_index;\n"
"if (start >= total_size) {\n" "if (start >= total_size) {\n"
" return baidu::rpc::SubCall::Skip();\n" " return brpc::SubCall::Skip();\n"
"}\n" "}\n"
"int end = _package_size * (channel_index + 1);\n" "int end = _package_size * (channel_index + 1);\n"
"if (end > total_size) {\n" "if (end > total_size) {\n"
...@@ -670,7 +670,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -670,7 +670,7 @@ class PdsCodeGenerator : public CodeGenerator {
"if (sub_req == NULL) {\n" "if (sub_req == NULL) {\n"
" LOG(ERROR) << \"failed fetch sub_req from stub.\";\n" " LOG(ERROR) << \"failed fetch sub_req from stub.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n" " _stub_handler->update_average(1, \"pack_fail\");\n"
" return baidu::rpc::SubCall::Bad();\n" " return brpc::SubCall::Bad();\n"
"}\n", "}\n",
"name", "name",
class_name, class_name,
...@@ -685,7 +685,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -685,7 +685,7 @@ class PdsCodeGenerator : public CodeGenerator {
"req->$field_name$_size()\n" "req->$field_name$_size()\n"
" << \", field: $field_name$.\";\n" " << \", field: $field_name$.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n" " _stub_handler->update_average(1, \"pack_fail\");\n"
" return baidu::rpc::SubCall::Bad();\n" " return brpc::SubCall::Bad();\n"
"}\n", "}\n",
"field_name", "field_name",
field_name); field_name);
...@@ -718,7 +718,7 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -718,7 +718,7 @@ class PdsCodeGenerator : public CodeGenerator {
" if (!sub_req) {\n" " if (!sub_req) {\n"
" LOG(ERROR) << \"failed fetch sub_req from stub handler.\";\n" " LOG(ERROR) << \"failed fetch sub_req from stub handler.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n" " _stub_handler->update_average(1, \"pack_fail\");\n"
" return baidu::rpc::SubCall::Bad();\n" " return brpc::SubCall::Bad();\n"
" }\n" " }\n"
"}\n", "}\n",
"req_type", "req_type",
...@@ -761,9 +761,9 @@ class PdsCodeGenerator : public CodeGenerator { ...@@ -761,9 +761,9 @@ class PdsCodeGenerator : public CodeGenerator {
"if (sub_res == NULL) {\n" "if (sub_res == NULL) {\n"
" LOG(ERROR) << \"failed create sub_res from res.\";\n" " LOG(ERROR) << \"failed create sub_res from res.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n" " _stub_handler->update_average(1, \"pack_fail\");\n"
" return baidu::rpc::SubCall::Bad();\n" " return brpc::SubCall::Bad();\n"
"}\n" "}\n"
"return baidu::rpc::SubCall(method, sub_req, sub_res, 0);\n"); "return brpc::SubCall(method, sub_req, sub_res, 0);\n");
return true; return true;
} }
bool generate_paddle_serving_stub_package_merger( bool generate_paddle_serving_stub_package_merger(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册