From 6f98ec3b15c36dba03e425ca5196e9d83db24eed Mon Sep 17 00:00:00 2001 From: wangguibao Date: Thu, 28 Mar 2019 17:28:55 +0800 Subject: [PATCH] Fix BCLOUD.client --- BCLOUD.client | 1 + pdcodegen/src/pdcodegen.cpp | 70 ++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/BCLOUD.client b/BCLOUD.client index f084478f..60b00747 100644 --- a/BCLOUD.client +++ b/BCLOUD.client @@ -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/glog@v0.3.x@git_branch') CONFIGS('baidu/third-party/opencv@master@git_branch') +CONFIGS('baidu/third-party/protobuf@2b7430d96aeff2bb624c8d52182ff5e4b9f7f18a@git_branch') #sub directory Directory('pdcodegen') diff --git a/pdcodegen/src/pdcodegen.cpp b/pdcodegen/src/pdcodegen.cpp index 582423d3..4f0f1c95 100644 --- a/pdcodegen/src/pdcodegen.cpp +++ b/pdcodegen/src/pdcodegen.cpp @@ -116,7 +116,7 @@ class PdsCodeGenerator : public CodeGenerator { printer.Print("#include \"predictor/framework/service_manager.h\"\n"); } if (generate_stub) { - printer.Print("#include \n"); + printer.Print("#include \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_impl.h\"\n"); @@ -274,9 +274,9 @@ class PdsCodeGenerator : public CodeGenerator { google::protobuf::dots_to_colons(m->output_type()->full_name())); if (m->name() == "inference") { printer->Print( - " baidu::rpc::ClosureGuard done_guard(done);\n" - " baidu::rpc::Controller* cntl = \n" - " static_cast(cntl_base);\n" + " brpc::ClosureGuard done_guard(done);\n" + " brpc::Controller* cntl = \n" + " static_cast(cntl_base);\n" " ::baidu::paddle_serving::predictor::InferService* svr = \n" " " "::baidu::paddle_serving::predictor::InferServiceManager::instance(" @@ -311,9 +311,9 @@ class PdsCodeGenerator : public CodeGenerator { } if (m->name() == "debug") { printer->Print( - " baidu::rpc::ClosureGuard done_guard(done);\n" - " baidu::rpc::Controller* cntl = \n" - " static_cast(cntl_base);\n" + " brpc::ClosureGuard done_guard(done);\n" + " brpc::Controller* cntl = \n" + " static_cast(cntl_base);\n" " ::baidu::paddle_serving::predictor::InferService* svr = \n" " " "::baidu::paddle_serving::predictor::InferServiceManager::instance(" @@ -329,7 +329,7 @@ class PdsCodeGenerator : public CodeGenerator { "\"\]\";\n" " LOG(INFO) << \" service_name=\[\" << \"$name$\" << \"\]\";\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" " if (err_code != 0) {\n" " LOG(WARNING)\n" @@ -371,7 +371,7 @@ class PdsCodeGenerator : public CodeGenerator { const std::string& service_name, const std::string& class_name) const { printer->Print( - "class $name$_StubCallMapper : public baidu::rpc::CallMapper {\n" + "class $name$_StubCallMapper : public brpc::CallMapper {\n" "private:\n" " uint32_t _package_size;\n" " baidu::paddle_serving::sdk_cpp::Stub* _stub_handler;\n" @@ -389,7 +389,7 @@ class PdsCodeGenerator : public CodeGenerator { class_name); printer->Print( - "baidu::rpc::SubCall default_map(\n" + "brpc::SubCall default_map(\n" " int channel_index,\n" " const google::protobuf::MethodDescriptor* method,\n" " const google::protobuf::Message* request,\n" @@ -409,7 +409,7 @@ class PdsCodeGenerator : public CodeGenerator { printer->Print("}\n"); printer->Print( - "baidu::rpc::SubCall sub_package_map(\n" + "brpc::SubCall sub_package_map(\n" " int channel_index,\n" " const google::protobuf::MethodDescriptor* method,\n" " const google::protobuf::Message* request,\n" @@ -458,7 +458,7 @@ class PdsCodeGenerator : public CodeGenerator { printer->Print("}\n"); printer->Print( - "baidu::rpc::SubCall Map(\n" + "brpc::SubCall Map(\n" " int channel_index,\n" " const google::protobuf::MethodDescriptor* method,\n" " const google::protobuf::Message* request,\n" @@ -473,8 +473,8 @@ class PdsCodeGenerator : public CodeGenerator { "return default_map(channel_index, method, request, response);\n"); } else { printer->Print( - "base::Timer tt(base::Timer::STARTED);\n" - "baidu::rpc::SubCall ret;\n" + "butil::Timer tt(butil::Timer::STARTED);\n" + "brpc::SubCall ret;\n" "if (_package_size == 0) {\n" " ret = default_map(channel_index, method, request, response);\n" "} else {\n" @@ -482,7 +482,7 @@ class PdsCodeGenerator : public CodeGenerator { "response);\n" "}\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" "}\n" "return ret;\n"); @@ -496,7 +496,7 @@ class PdsCodeGenerator : public CodeGenerator { //////////////////////////////////////////////////////////////// printer->Print( - "class $name$_StubResponseMerger : public baidu::rpc::ResponseMerger {\n" + "class $name$_StubResponseMerger : public brpc::ResponseMerger {\n" "private:\n" " uint32_t _package_size;\n" " baidu::paddle_serving::sdk_cpp::Stub* _stub_handler;\n" @@ -514,7 +514,7 @@ class PdsCodeGenerator : public CodeGenerator { class_name); printer->Print( - "baidu::rpc::ResponseMerger::Result default_merge(\n" + "brpc::ResponseMerger::Result default_merge(\n" " google::protobuf::Message* response,\n" " const google::protobuf::Message* sub_response) {\n" " baidu::paddle_serving::sdk_cpp::TracePackScope " @@ -530,7 +530,7 @@ class PdsCodeGenerator : public CodeGenerator { printer->Print("}\n"); printer->Print( - "baidu::rpc::ResponseMerger::Result sub_package_merge(\n" + "brpc::ResponseMerger::Result sub_package_merge(\n" " google::protobuf::Message* response,\n" " const google::protobuf::Message* sub_response) {\n" " baidu::paddle_serving::sdk_cpp::TracePackScope " @@ -546,22 +546,22 @@ class PdsCodeGenerator : public CodeGenerator { printer->Print("}\n"); printer->Print( - "baidu::rpc::ResponseMerger::Result Merge(\n" + "brpc::ResponseMerger::Result Merge(\n" " google::protobuf::Message* response,\n" " const google::protobuf::Message* sub_response) {\n", "name", class_name); printer->Indent(); printer->Print( - "base::Timer tt(base::Timer::STARTED);\n" - "baidu::rpc::ResponseMerger::Result ret;" + "butil::Timer tt(butil::Timer::STARTED);\n" + "brpc::ResponseMerger::Result ret;" "if (_package_size <= 0) {\n" " ret = default_merge(response, sub_response);\n" "} else {\n" " ret = sub_package_merge(response, sub_response);\n" "}\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" "}\n" "return ret;\n"); @@ -580,7 +580,7 @@ class PdsCodeGenerator : public CodeGenerator { const std::string& class_name) const { printer->Print( "if (channel_index > 0) { \n" - " return baidu::rpc::SubCall::Skip();\n" + " return brpc::SubCall::Skip();\n" "}\n"); printer->Print( "google::protobuf::Message* cur_res = " @@ -591,14 +591,14 @@ class PdsCodeGenerator : public CodeGenerator { " if (cur_res == NULL) {\n" " LOG(ERROR) << \"Failed new response item!\";\n" " _stub_handler->update_average(1, \"pack_fail\");\n" - " return baidu::rpc::SubCall::Bad();\n" + " return brpc::SubCall::Bad();\n" " }\n" - " return baidu::rpc::SubCall(method, request, cur_res, " - "baidu::rpc::DELETE_RESPONSE);\n" + " return brpc::SubCall(method, request, cur_res, " + "brpc::DELETE_RESPONSE);\n" "}\n"); "LOG(INFO) \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; } bool generate_paddle_serving_stub_default_merger( @@ -610,11 +610,11 @@ class PdsCodeGenerator : public CodeGenerator { printer->Print( "try {\n" " response->MergeFrom(*sub_response);\n" - " return baidu::rpc::ResponseMerger::MERGED;\n" + " return brpc::ResponseMerger::MERGED;\n" "} catch (const std::exception& e) {\n" " LOG(ERROR) << \"Merge failed.\";\n" " _stub_handler->update_average(1, \"pack_fail\");\n" - " return baidu::rpc::ResponseMerger::FAIL;\n" + " return brpc::ResponseMerger::FAIL;\n" "}\n"); return true; } @@ -657,7 +657,7 @@ class PdsCodeGenerator : public CodeGenerator { printer->Print( "int start = _package_size * channel_index;\n" "if (start >= total_size) {\n" - " return baidu::rpc::SubCall::Skip();\n" + " return brpc::SubCall::Skip();\n" "}\n" "int end = _package_size * (channel_index + 1);\n" "if (end > total_size) {\n" @@ -670,7 +670,7 @@ class PdsCodeGenerator : public CodeGenerator { "if (sub_req == NULL) {\n" " LOG(ERROR) << \"failed fetch sub_req from stub.\";\n" " _stub_handler->update_average(1, \"pack_fail\");\n" - " return baidu::rpc::SubCall::Bad();\n" + " return brpc::SubCall::Bad();\n" "}\n", "name", class_name, @@ -685,7 +685,7 @@ class PdsCodeGenerator : public CodeGenerator { "req->$field_name$_size()\n" " << \", field: $field_name$.\";\n" " _stub_handler->update_average(1, \"pack_fail\");\n" - " return baidu::rpc::SubCall::Bad();\n" + " return brpc::SubCall::Bad();\n" "}\n", "field_name", field_name); @@ -718,7 +718,7 @@ class PdsCodeGenerator : public CodeGenerator { " if (!sub_req) {\n" " LOG(ERROR) << \"failed fetch sub_req from stub handler.\";\n" " _stub_handler->update_average(1, \"pack_fail\");\n" - " return baidu::rpc::SubCall::Bad();\n" + " return brpc::SubCall::Bad();\n" " }\n" "}\n", "req_type", @@ -761,9 +761,9 @@ class PdsCodeGenerator : public CodeGenerator { "if (sub_res == NULL) {\n" " LOG(ERROR) << \"failed create sub_res from res.\";\n" " _stub_handler->update_average(1, \"pack_fail\");\n" - " return baidu::rpc::SubCall::Bad();\n" + " return brpc::SubCall::Bad();\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; } bool generate_paddle_serving_stub_package_merger( -- GitLab