From e9fe8b1ef147988d266f12d46cb941f7c76d7ace Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 19 Nov 2018 01:26:57 -0800 Subject: [PATCH 001/270] add discovery client --- src/brpc/policy/discovery_naming_service.cpp | 365 ++++++++++++++++--- src/brpc/policy/discovery_naming_service.h | 56 ++- src/brpc/socket.cpp | 2 +- test/brpc_naming_service_unittest.cpp | 107 +++++- test/echo.proto | 3 + 5 files changed, 476 insertions(+), 57 deletions(-) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index 0fc2a73d..38252f9c 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -17,6 +17,8 @@ #include #include "butil/third_party/rapidjson/document.h" #include "butil/string_printf.h" +#include "butil/fast_rand.h" +#include "bthread/bthread.h" #include "brpc/channel.h" #include "brpc/controller.h" #include "brpc/policy/discovery_naming_service.h" @@ -33,14 +35,22 @@ DEFINE_string(discovery_api_addr, "", "The address of discovery api"); DEFINE_int32(discovery_timeout_ms, 3000, "Timeout for discovery requests"); DEFINE_string(discovery_env, "prod", "Environment of services"); DEFINE_string(discovery_status, "1", "Status of services. 1 for ready, 2 for not ready, 3 for all"); +DEFINE_int32(discovery_renew_interval_s, 30, "The interval between two consecutive renews"); +DEFINE_int32(discovery_reregister_threshold, 3, "The renew error threshold beyond" + " which Register would be called again"); -int DiscoveryNamingService::ParseNodesResult( - const butil::IOBuf& buf, std::string* server_addr) { - BUTIL_RAPIDJSON_NAMESPACE::Document nodes; +static Channel s_discovery_channel; +static pthread_once_t s_init_channel_once = PTHREAD_ONCE_INIT; +int ParseNodesResult(const butil::IOBuf& buf, std::string* server_addr) { + BUTIL_RAPIDJSON_NAMESPACE::Document d; const std::string response = buf.to_string(); - nodes.Parse(response.c_str()); - auto itr = nodes.FindMember("data"); - if (itr == nodes.MemberEnd()) { + d.Parse(response.c_str()); + if (!d.IsObject()) { + LOG(ERROR) << "Fail to parse " << buf << " as json object"; + return -1; + } + auto itr = d.FindMember("data"); + if (itr == d.MemberEnd()) { LOG(ERROR) << "No data field in discovery nodes response"; return -1; } @@ -68,13 +78,46 @@ int DiscoveryNamingService::ParseNodesResult( return 0; } -int DiscoveryNamingService::ParseFetchsResult( - const butil::IOBuf& buf, - const char* service_name, - std::vector* servers) { +static void InitChannel() { + Channel api_channel; + ChannelOptions channel_options; + channel_options.protocol = PROTOCOL_HTTP; + channel_options.timeout_ms = FLAGS_discovery_timeout_ms; + channel_options.connect_timeout_ms = FLAGS_discovery_timeout_ms / 3; + if (api_channel.Init(FLAGS_discovery_api_addr.c_str(), "", &channel_options) != 0) { + LOG(FATAL) << "Fail to init channel to " << FLAGS_discovery_api_addr; + return; + } + Controller cntl; + cntl.http_request().uri() = FLAGS_discovery_api_addr; + api_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + if (cntl.Failed()) { + LOG(FATAL) << "Fail to access " << cntl.http_request().uri() + << ": " << cntl.ErrorText(); + return; + } + std::string discovery_addr; + if (ParseNodesResult(cntl.response_attachment(), &discovery_addr) != 0) { + LOG(FATAL) << "Fail to parse nodes result from discovery api server"; + return; + } + if (s_discovery_channel.Init(discovery_addr.c_str(), "", &channel_options) != 0) { + LOG(FATAL) << "Fail to init channel to " << discovery_addr; + return; + } +} + + +int ParseFetchsResult(const butil::IOBuf& buf, + const char* service_name, + std::vector* servers) { BUTIL_RAPIDJSON_NAMESPACE::Document d; const std::string response = buf.to_string(); d.Parse(response.c_str()); + if (!d.IsObject()) { + LOG(ERROR) << "Fail to parse " << buf << " as json object"; + return -1; + } auto itr_data = d.FindMember("data"); if (itr_data == d.MemberEnd()) { LOG(ERROR) << "No data field in discovery fetchs response"; @@ -114,6 +157,11 @@ int DiscoveryNamingService::ParseFetchsResult( butil::StringPiece addr(addrs[j].GetString(), addrs[j].GetStringLength()); butil::StringPiece::size_type pos = addr.find("://"); if (pos != butil::StringPiece::npos) { + if (pos != 4 /* sizeof("grpc") */ || + strncmp("grpc", addr.data(), 4) != 0) { + // Skip server that has prefix but not start with "grpc" + continue; + } addr.remove_prefix(pos + 3); } ServerNode node; @@ -132,42 +180,13 @@ int DiscoveryNamingService::ParseFetchsResult( int DiscoveryNamingService::GetServers(const char* service_name, std::vector* servers) { - if (!_is_initialized) { - Channel api_channel; - ChannelOptions channel_options; - channel_options.protocol = PROTOCOL_HTTP; - channel_options.timeout_ms = FLAGS_discovery_timeout_ms; - channel_options.connect_timeout_ms = FLAGS_discovery_timeout_ms / 3; - if (api_channel.Init(FLAGS_discovery_api_addr.c_str(), "", &channel_options) != 0) { - LOG(ERROR) << "Fail to init channel to " << FLAGS_discovery_api_addr; - return -1; - } - Controller cntl; - cntl.http_request().uri() = FLAGS_discovery_api_addr; - api_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); - if (cntl.Failed()) { - LOG(ERROR) << "Fail to access " << cntl.http_request().uri() - << ": " << cntl.ErrorText(); - return -1; - } - std::string discovery_addr; - if (ParseNodesResult(cntl.response_attachment(), &discovery_addr) != 0) { - return -1; - } - - if (_channel.Init(discovery_addr.c_str(), "", &channel_options) != 0) { - LOG(ERROR) << "Fail to init channel to " << discovery_addr; - return -1; - } - _is_initialized = true; - } - + pthread_once(&s_init_channel_once, InitChannel); servers->clear(); Controller cntl; cntl.http_request().uri() = butil::string_printf( "/discovery/fetchs?appid=%s&env=%s&status=%s", service_name, FLAGS_discovery_env.c_str(), FLAGS_discovery_status.c_str()); - _channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); if (cntl.Failed()) { LOG(ERROR) << "Fail to make /discovery/fetchs request: " << cntl.ErrorText(); return -1; @@ -189,5 +208,269 @@ void DiscoveryNamingService::Destroy() { delete this; } +bool DiscoveryRegisterParam::IsValid() const { + if (appid.empty() || hostname.empty() || addrs.empty() || + env.empty() || zone.empty() || version.empty()) { + return false; + } + return true; +} + +DiscoveryClient::DiscoveryClient() + : _th(INVALID_BTHREAD) + , _state(INIT) {} + +DiscoveryClient::~DiscoveryClient() { + Cancel(); +} + + +int ParseCommonResult(const butil::IOBuf& buf, std::string* error_text) { + const std::string s = buf.to_string(); + BUTIL_RAPIDJSON_NAMESPACE::Document d; + d.Parse(s.c_str()); + if (!d.IsObject()) { + LOG(ERROR) << "Fail to parse " << buf << " as json object"; + return -1; + } + auto itr_code = d.FindMember("code"); + if (itr_code == d.MemberEnd() || !itr_code->value.IsInt()) { + LOG(ERROR) << "Invalid `code' field in " << buf; + return -1; + } + int code = itr_code->value.GetInt(); + auto itr_message = d.FindMember("message"); + if (itr_message != d.MemberEnd() && itr_message->value.IsString() && error_text) { + error_text->assign(itr_message->value.GetString(), + itr_message->value.GetStringLength()); + } + return code; +} + +void* DiscoveryClient::PeriodicRenew(void* arg) { + DiscoveryClient* d = static_cast(arg); + int consecutive_renew_error = 0; + int64_t init_sleep_s = FLAGS_discovery_renew_interval_s / 2 + + butil::fast_rand_less_than(FLAGS_discovery_renew_interval_s / 2); + if (bthread_usleep(init_sleep_s * 1000000) != 0) { + if (errno == ESTOP) { + return NULL; + } + } + + while (!bthread_stopped(bthread_self())) { + if (consecutive_renew_error == FLAGS_discovery_reregister_threshold) { + LOG(WARNING) << "Reregister since discovery renew error threshold reached"; + std::unique_lock mu(d->_mutex); + switch (d->_state) { + case INIT: + CHECK(false) << "Impossible"; + return NULL; + case REGISTERING: + case REGISTERED: + break; + case CANCELED: + return NULL; + default: + CHECK(false) << "Impossible"; + return NULL; + } + // Do register until succeed or Cancel is called + while (!bthread_stopped(bthread_self())) { + if (d->do_register() == 0) { + break; + } + bthread_usleep(FLAGS_discovery_renew_interval_s * 1000000); + } + consecutive_renew_error = 0; + } + + Controller cntl; + cntl.http_request().set_method(HTTP_METHOD_POST); + cntl.http_request().uri() = "/discovery/renew"; + cntl.http_request().set_content_type("application/x-www-form-urlencoded"); + butil::IOBufBuilder os; + os << "appid=" << d->_appid + << "&hostname=" << d->_hostname + << "&env=" << d->_env + << "®ion=" << d->_region + << "&zone=" << d->_zone; + os.move_to(cntl.request_attachment()); + s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + if (cntl.Failed()) { + LOG(ERROR) << "Fail to post /discovery/renew: " << cntl.ErrorText(); + consecutive_renew_error++; + continue; + } + std::string error_text; + int rc = ParseCommonResult(cntl.response_attachment(), &error_text); + if (rc != 0) { + LOG(ERROR) << "Fail to renew " << d->_hostname << " to " << d->_appid + << ": " << error_text; + consecutive_renew_error++; + continue; + } + consecutive_renew_error = 0; + if (bthread_usleep(FLAGS_discovery_renew_interval_s * 1000000) != 0) { + if (errno == ESTOP) { + break; + } + } + } + return NULL; +} + +int DiscoveryClient::Register(const DiscoveryRegisterParam& req) { + if (!req.IsValid()) { + return -1; + } + { + std::unique_lock mu(_mutex); + switch (_state) { + case INIT: + _state = REGISTERING; + break; + case REGISTERING: + case REGISTERED: + LOG(WARNING) << "Discovery Appid=" << req.appid + <<" is registering or registered"; + return 0; + case CANCELED: + LOG(ERROR) << "Discovery Appid=" << req.appid << " is canceled"; + return -1; + default: + CHECK(false) << "Impossible"; + return -1; + } + } + pthread_once(&s_init_channel_once, InitChannel); + _appid = req.appid; + _hostname = req.hostname; + _addrs = req.addrs; + _env = req.env; + _region = req.region; + _zone = req.zone; + _status = req.status; + _version = req.version; + _metadata = req.metadata; + + if (do_register() != 0) { + return -1; + } + if (bthread_start_background(&_th, NULL, PeriodicRenew, this) != 0) { + LOG(ERROR) << "Fail to start background PeriodicRenew"; + return -1; + } + bool is_canceled = false; + { + std::unique_lock mu(_mutex); + switch (_state) { + case INIT: + CHECK(false) << "Impossible"; + return -1; + case REGISTERING: + _state = REGISTERED; + break; + case REGISTERED: + CHECK(false) << "Impossible"; + return -1; + case CANCELED: + is_canceled = true; + break; + default: + CHECK(false) << "Impossible"; + return -1; + } + } + if (is_canceled) { + bthread_stop(_th); + bthread_join(_th, NULL); + return do_cancel(); + } + return 0; +} + +int DiscoveryClient::do_register() { + Controller cntl; + cntl.http_request().set_method(HTTP_METHOD_POST); + cntl.http_request().uri() = "/discovery/register"; + cntl.http_request().set_content_type("application/x-www-form-urlencoded"); + butil::IOBufBuilder os; + os << "appid=" << _appid + << "&hostname=" << _hostname + << "&addrs=" << _addrs + << "&env=" << _env + << "&zone=" << _zone + << "®ion=" << _region + << "&status=" << _status + << "&version=" << _version + << "&metadata=" << _metadata; + os.move_to(cntl.request_attachment()); + s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + if (cntl.Failed()) { + LOG(ERROR) << "Fail to register " << _appid << ": " << cntl.ErrorText(); + return -1; + } + std::string error_text; + int rc = ParseCommonResult(cntl.response_attachment(), &error_text); + if (rc != 0) { + LOG(ERROR) << "Fail to register " << _hostname << " to " << _appid + << ": " << error_text; + return -1; + } + return 0; +} + +int DiscoveryClient::Cancel() { + { + std::unique_lock mu(_mutex); + switch (_state) { + case INIT: + case REGISTERING: + _state = CANCELED; + return 0; + case REGISTERED: + _state = CANCELED; + break; + case CANCELED: + return 0; + default: + CHECK(false) << "Impossible"; + return -1; + } + } + bthread_stop(_th); + bthread_join(_th, NULL); + return do_cancel(); +} + +int DiscoveryClient::do_cancel() { + pthread_once(&s_init_channel_once, InitChannel); + Controller cntl; + cntl.http_request().set_method(HTTP_METHOD_POST); + cntl.http_request().uri() = "/discovery/cancel"; + butil::IOBufBuilder os; + os << "appid=" << _appid + << "&hostname=" << _hostname + << "&env=" << _env + << "®ion=" << _region + << "&zone=" << _zone; + os.move_to(cntl.request_attachment()); + s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + if (cntl.Failed()) { + LOG(ERROR) << "Fail to post /discovery/cancel: " << cntl.ErrorText(); + return -1; + } + std::string error_text; + int rc = ParseCommonResult(cntl.response_attachment(), &error_text); + if (rc != 0) { + LOG(ERROR) << "Fail to cancel " << _hostname << " in " << _appid + << ": " << error_text; + return -1; + } + return 0; +} + + } // namespace policy } // namespace brpc diff --git a/src/brpc/policy/discovery_naming_service.h b/src/brpc/policy/discovery_naming_service.h index 32001b1f..775e0ec0 100644 --- a/src/brpc/policy/discovery_naming_service.h +++ b/src/brpc/policy/discovery_naming_service.h @@ -19,6 +19,7 @@ #include "brpc/periodic_naming_service.h" #include "brpc/channel.h" +#include "butil/synchronization/lock.h" namespace brpc { namespace policy { @@ -33,18 +34,61 @@ private: NamingService* New() const override; void Destroy() override; +}; + +struct DiscoveryRegisterParam { + std::string appid; + std::string hostname; + std::string env; + std::string zone; + std::string region; + std::string addrs; // splitted by ',' + int status; + std::string version; + std::string metadata; + + bool IsValid() const; +}; + +// ONE DiscoveryClient corresponds to ONE service instance. +// If your program has multiple instances to register, you need multiple +// DiscoveryClient. +class DiscoveryClient { +public: + DiscoveryClient(); + ~DiscoveryClient(); + + int Register(const DiscoveryRegisterParam& req); + int Cancel(); private: - int ParseNodesResult(const butil::IOBuf& buf, std::string* server_addr); - int ParseFetchsResult(const butil::IOBuf& buf, const char* service_name, - std::vector* servers); + static void* PeriodicRenew(void* arg); + int do_cancel(); + int do_register(); - Channel _channel; - bool _is_initialized = false; +private: + enum State { + INIT, + REGISTERING, + REGISTERED, + CANCELED + }; + bthread_t _th; + State _state; + butil::Mutex _mutex; + std::string _appid; + std::string _hostname; + std::string _addrs; + std::string _env; + std::string _region; + std::string _zone; + int _status; + std::string _version; + std::string _metadata; }; + } // namespace policy } // namespace brpc - #endif // BRPC_POLICY_DISCOVERY_NAMING_SERVICE_H diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 37db8eef..68c56a18 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -863,7 +863,7 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) { // by Channel to revive never-connected socket when server side // comes online. if (_health_check_interval_s > 0) { - GetOrNewSharedPart( )->circuit_breaker.MarkAsBroken(); + GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); PeriodicTaskManager::StartTaskAt( new HealthCheckTask(id()), butil::milliseconds_from_now(GetOrNewSharedPart()-> diff --git a/test/brpc_naming_service_unittest.cpp b/test/brpc_naming_service_unittest.cpp index f9ca4734..64499b36 100644 --- a/test/brpc_naming_service_unittest.cpp +++ b/test/brpc_naming_service_unittest.cpp @@ -30,6 +30,13 @@ DECLARE_string(consul_file_naming_service_dir); DECLARE_string(consul_service_discovery_url); DECLARE_string(discovery_api_addr); DECLARE_string(discovery_env); +DECLARE_int32(discovery_renew_interval_s); + +// Defined in discovery_naming_service.cpp +int ParseFetchsResult(const butil::IOBuf& buf, + const char* service_name, + std::vector* servers); +int ParseNodesResult(const butil::IOBuf& buf, std::string* server_addr); } // policy } // brpc @@ -445,7 +452,7 @@ static const std::string s_fetchs_result = R"({ }, "addrs":[ "http://127.0.0.1:8999", - "gorpc://127.0.1.1:9000" + "grpc://127.0.1.1:9000" ], "status":1, "reg_timestamp":1539001034551496412, @@ -472,7 +479,7 @@ static const std::string s_fetchs_result = R"({ }, "addrs":[ "http://127.0.0.1:8999", - "gorpc://127.0.1.1:9000" + "grpc://127.0.1.1:9000" ], "status":1, "reg_timestamp":1539001034551496412, @@ -510,23 +517,26 @@ static std::string s_nodes_result = R"({ ] })"; + TEST(NamingServiceTest, discovery_parse_function) { std::vector servers; brpc::policy::DiscoveryNamingService dcns; butil::IOBuf buf; buf.append(s_fetchs_result); - ASSERT_EQ(0, dcns.ParseFetchsResult(buf, "admin.test", &servers)); - ASSERT_EQ((size_t)2, servers.size()); + ASSERT_EQ(0, brpc::policy::ParseFetchsResult(buf, "admin.test", &servers)); + ASSERT_EQ((size_t)1, servers.size()); buf.clear(); buf.append(s_nodes_result); std::string server; - ASSERT_EQ(0, dcns.ParseNodesResult(buf, &server)); + ASSERT_EQ(0, brpc::policy::ParseNodesResult(buf, &server)); ASSERT_EQ("127.0.0.1:8635", server); } class DiscoveryNamingServiceImpl : public test::DiscoveryNamingService { public: - DiscoveryNamingServiceImpl () {} + DiscoveryNamingServiceImpl() + : _renew_count(0) + , _cancel_count(0) {} virtual ~DiscoveryNamingServiceImpl() {} void Nodes(google::protobuf::RpcController* cntl_base, @@ -546,15 +556,67 @@ public: brpc::Controller* cntl = static_cast(cntl_base); cntl->response_attachment().append(s_fetchs_result); } + + void Register(google::protobuf::RpcController* cntl_base, + const test::HttpRequest*, + test::HttpResponse*, + google::protobuf::Closure* done) { + brpc::ClosureGuard done_guard(done); + brpc::Controller* cntl = static_cast(cntl_base); + cntl->response_attachment().append(R"({ + "code": 0, + "message": "0" + })"); + return; + } + + void Renew(google::protobuf::RpcController* cntl_base, + const test::HttpRequest*, + test::HttpResponse*, + google::protobuf::Closure* done) { + brpc::ClosureGuard done_guard(done); + brpc::Controller* cntl = static_cast(cntl_base); + cntl->response_attachment().append(R"({ + "code": 0, + "message": "0" + })"); + _renew_count++; + return; + } + + void Cancel(google::protobuf::RpcController* cntl_base, + const test::HttpRequest*, + test::HttpResponse*, + google::protobuf::Closure* done) { + brpc::ClosureGuard done_guard(done); + brpc::Controller* cntl = static_cast(cntl_base); + cntl->response_attachment().append(R"({ + "code": 0, + "message": "0" + })"); + _cancel_count++; + return; + } + + int RenewCount() const { return _renew_count; } + int CancelCount() const { return _cancel_count; } + +private: + int _renew_count; + int _cancel_count; }; TEST(NamingServiceTest, discovery_sanity) { brpc::policy::FLAGS_discovery_api_addr = "http://127.0.0.1:8635/discovery/nodes"; + brpc::policy::FLAGS_discovery_renew_interval_s = 1; brpc::Server server; DiscoveryNamingServiceImpl svc; std::string rest_mapping = "/discovery/nodes => Nodes, " - "/discovery/fetchs => Fetchs"; + "/discovery/fetchs => Fetchs, " + "/discovery/register => Register, " + "/discovery/renew => Renew, " + "/discovery/cancel => Cancel"; ASSERT_EQ(0, server.AddService(&svc, brpc::SERVER_DOESNT_OWN_SERVICE, rest_mapping.c_str())); ASSERT_EQ(0, server.Start("localhost:8635", NULL)); @@ -562,8 +624,35 @@ TEST(NamingServiceTest, discovery_sanity) { brpc::policy::DiscoveryNamingService dcns; std::vector servers; ASSERT_EQ(0, dcns.GetServers("admin.test", &servers)); - ASSERT_EQ((size_t)2, servers.size()); + ASSERT_EQ((size_t)1, servers.size()); + + brpc::policy::DiscoveryClient dc; + brpc::policy::DiscoveryRegisterParam dparam; + dparam.appid = "main.test"; + dparam.hostname = "hostname"; + dparam.addrs = "grpc://10.0.0.1:8000"; + dparam.env = "dev"; + dparam.zone = "sh001"; + dparam.status = 1; + dparam.version = "v1"; + ASSERT_EQ(0, dc.Register(dparam)); + bthread_usleep(1000000); + ASSERT_EQ(0, dc.Cancel()); + ASSERT_GT(svc.RenewCount(), 0); + ASSERT_EQ(svc.CancelCount(), 1); + + brpc::policy::DiscoveryClient dc2; + ASSERT_EQ(0, dc2.Cancel()); + ASSERT_EQ(-1, dc2.Register(dparam)); + + { + brpc::policy::DiscoveryClient dc3; + ASSERT_EQ(0, dc3.Register(dparam)); + ASSERT_EQ(0, dc3.Cancel()); + } + // dtor of DiscoveryClient also calls Cancel(), we need to ensure that + // Cancel() is called only once. + ASSERT_EQ(svc.CancelCount(), 2); } - } //namespace diff --git a/test/echo.proto b/test/echo.proto index eb82a700..2def9197 100644 --- a/test/echo.proto +++ b/test/echo.proto @@ -56,6 +56,9 @@ service UserNamingService { service DiscoveryNamingService { rpc Nodes(HttpRequest) returns (HttpResponse); rpc Fetchs(HttpRequest) returns (HttpResponse); + rpc Register(HttpRequest) returns (HttpResponse); + rpc Renew(HttpRequest) returns (HttpResponse); + rpc Cancel(HttpRequest) returns (HttpResponse); }; enum State0 { From a73bbdf9df887d25f4aa50217b69110799c6e8b9 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 19 Nov 2018 01:38:08 -0800 Subject: [PATCH 002/270] refine code --- src/brpc/policy/discovery_naming_service.cpp | 38 ++++++++++---------- src/brpc/policy/discovery_naming_service.h | 5 ++- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index 38252f9c..f576fc58 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -261,19 +261,21 @@ void* DiscoveryClient::PeriodicRenew(void* arg) { while (!bthread_stopped(bthread_self())) { if (consecutive_renew_error == FLAGS_discovery_reregister_threshold) { LOG(WARNING) << "Reregister since discovery renew error threshold reached"; - std::unique_lock mu(d->_mutex); - switch (d->_state) { - case INIT: - CHECK(false) << "Impossible"; - return NULL; - case REGISTERING: - case REGISTERED: - break; - case CANCELED: - return NULL; - default: - CHECK(false) << "Impossible"; - return NULL; + { + std::unique_lock mu(d->_mutex); + switch (d->_state) { + case INIT: + CHECK(false) << "Impossible"; + return NULL; + case REGISTERING: + case REGISTERED: + break; + case CANCELED: + return NULL; + default: + CHECK(false) << "Impossible"; + return NULL; + } } // Do register until succeed or Cancel is called while (!bthread_stopped(bthread_self())) { @@ -303,8 +305,7 @@ void* DiscoveryClient::PeriodicRenew(void* arg) { continue; } std::string error_text; - int rc = ParseCommonResult(cntl.response_attachment(), &error_text); - if (rc != 0) { + if (ParseCommonResult(cntl.response_attachment(), &error_text) != 0) { LOG(ERROR) << "Fail to renew " << d->_hostname << " to " << d->_appid << ": " << error_text; consecutive_renew_error++; @@ -412,8 +413,7 @@ int DiscoveryClient::do_register() { return -1; } std::string error_text; - int rc = ParseCommonResult(cntl.response_attachment(), &error_text); - if (rc != 0) { + if (ParseCommonResult(cntl.response_attachment(), &error_text) != 0) { LOG(ERROR) << "Fail to register " << _hostname << " to " << _appid << ": " << error_text; return -1; @@ -439,6 +439,7 @@ int DiscoveryClient::Cancel() { return -1; } } + CHECK_NE(_th, INVALID_BTHREAD); bthread_stop(_th); bthread_join(_th, NULL); return do_cancel(); @@ -462,8 +463,7 @@ int DiscoveryClient::do_cancel() { return -1; } std::string error_text; - int rc = ParseCommonResult(cntl.response_attachment(), &error_text); - if (rc != 0) { + if (ParseCommonResult(cntl.response_attachment(), &error_text) != 0) { LOG(ERROR) << "Fail to cancel " << _hostname << " in " << _appid << ": " << error_text; return -1; diff --git a/src/brpc/policy/discovery_naming_service.h b/src/brpc/policy/discovery_naming_service.h index 775e0ec0..2c5f1d44 100644 --- a/src/brpc/policy/discovery_naming_service.h +++ b/src/brpc/policy/discovery_naming_service.h @@ -51,8 +51,8 @@ struct DiscoveryRegisterParam { }; // ONE DiscoveryClient corresponds to ONE service instance. -// If your program has multiple instances to register, you need multiple -// DiscoveryClient. +// If your program has multiple service instances to register, +// you need multiple DiscoveryClient. class DiscoveryClient { public: DiscoveryClient(); @@ -87,7 +87,6 @@ private: std::string _metadata; }; - } // namespace policy } // namespace brpc From f01330d505435d4a749ba4176cf1bd86210d9465 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 19 Nov 2018 01:48:45 -0800 Subject: [PATCH 003/270] split part of Renew() into do_renew --- src/brpc/policy/discovery_naming_service.cpp | 52 +++++++++++--------- src/brpc/policy/discovery_naming_service.h | 5 +- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index f576fc58..aacb9a9c 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -247,6 +247,32 @@ int ParseCommonResult(const butil::IOBuf& buf, std::string* error_text) { return code; } +int DiscoveryClient::do_renew() const { + Controller cntl; + cntl.http_request().set_method(HTTP_METHOD_POST); + cntl.http_request().uri() = "/discovery/renew"; + cntl.http_request().set_content_type("application/x-www-form-urlencoded"); + butil::IOBufBuilder os; + os << "appid=" << _appid + << "&hostname=" << _hostname + << "&env=" << _env + << "®ion=" << _region + << "&zone=" << _zone; + os.move_to(cntl.request_attachment()); + s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + if (cntl.Failed()) { + LOG(ERROR) << "Fail to post /discovery/renew: " << cntl.ErrorText(); + return -1; + } + std::string error_text; + if (ParseCommonResult(cntl.response_attachment(), &error_text) != 0) { + LOG(ERROR) << "Fail to renew " << _hostname << " to " << _appid + << ": " << error_text; + return -1; + } + return 0; +} + void* DiscoveryClient::PeriodicRenew(void* arg) { DiscoveryClient* d = static_cast(arg); int consecutive_renew_error = 0; @@ -287,27 +313,7 @@ void* DiscoveryClient::PeriodicRenew(void* arg) { consecutive_renew_error = 0; } - Controller cntl; - cntl.http_request().set_method(HTTP_METHOD_POST); - cntl.http_request().uri() = "/discovery/renew"; - cntl.http_request().set_content_type("application/x-www-form-urlencoded"); - butil::IOBufBuilder os; - os << "appid=" << d->_appid - << "&hostname=" << d->_hostname - << "&env=" << d->_env - << "®ion=" << d->_region - << "&zone=" << d->_zone; - os.move_to(cntl.request_attachment()); - s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); - if (cntl.Failed()) { - LOG(ERROR) << "Fail to post /discovery/renew: " << cntl.ErrorText(); - consecutive_renew_error++; - continue; - } - std::string error_text; - if (ParseCommonResult(cntl.response_attachment(), &error_text) != 0) { - LOG(ERROR) << "Fail to renew " << d->_hostname << " to " << d->_appid - << ": " << error_text; + if (d->do_renew() != 0) { consecutive_renew_error++; continue; } @@ -391,7 +397,7 @@ int DiscoveryClient::Register(const DiscoveryRegisterParam& req) { return 0; } -int DiscoveryClient::do_register() { +int DiscoveryClient::do_register() const { Controller cntl; cntl.http_request().set_method(HTTP_METHOD_POST); cntl.http_request().uri() = "/discovery/register"; @@ -445,7 +451,7 @@ int DiscoveryClient::Cancel() { return do_cancel(); } -int DiscoveryClient::do_cancel() { +int DiscoveryClient::do_cancel() const { pthread_once(&s_init_channel_once, InitChannel); Controller cntl; cntl.http_request().set_method(HTTP_METHOD_POST); diff --git a/src/brpc/policy/discovery_naming_service.h b/src/brpc/policy/discovery_naming_service.h index 2c5f1d44..4a3e6e53 100644 --- a/src/brpc/policy/discovery_naming_service.h +++ b/src/brpc/policy/discovery_naming_service.h @@ -63,8 +63,9 @@ public: private: static void* PeriodicRenew(void* arg); - int do_cancel(); - int do_register(); + int do_cancel() const; + int do_register() const; + int do_renew() const; private: enum State { From 01bad2eaf77f696ad29ecc8a9084a6a08f74892f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 19 Nov 2018 01:55:02 -0800 Subject: [PATCH 004/270] remove unnecessary line --- src/brpc/policy/discovery_naming_service.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index aacb9a9c..4598ab05 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -224,7 +224,6 @@ DiscoveryClient::~DiscoveryClient() { Cancel(); } - int ParseCommonResult(const butil::IOBuf& buf, std::string* error_text) { const std::string s = buf.to_string(); BUTIL_RAPIDJSON_NAMESPACE::Document d; From 378d5ad2fe79a8d04a89e676c98d7867f80c8b37 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 19 Nov 2018 01:57:53 -0800 Subject: [PATCH 005/270] refine comment --- test/brpc_naming_service_unittest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/brpc_naming_service_unittest.cpp b/test/brpc_naming_service_unittest.cpp index 64499b36..c425f2e0 100644 --- a/test/brpc_naming_service_unittest.cpp +++ b/test/brpc_naming_service_unittest.cpp @@ -650,8 +650,8 @@ TEST(NamingServiceTest, discovery_sanity) { ASSERT_EQ(0, dc3.Register(dparam)); ASSERT_EQ(0, dc3.Cancel()); } - // dtor of DiscoveryClient also calls Cancel(), we need to ensure that - // Cancel() is called only once. + // Dtor of DiscoveryClient also calls Cancel(), we need to ensure that + // Cancel() is called only once. One is from dc1, the other is from dc3. ASSERT_EQ(svc.CancelCount(), 2); } From 3b174fe113b7c0273dcfde4bdd3d89ba885dca85 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 3 Dec 2018 01:41:00 -0800 Subject: [PATCH 006/270] move discovery getserver logic int client --- src/brpc/policy/discovery_naming_service.cpp | 93 ++++++++++++-------- src/brpc/policy/discovery_naming_service.h | 43 +++++---- 2 files changed, 83 insertions(+), 53 deletions(-) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index 4598ab05..5dbf70bb 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -41,6 +41,28 @@ DEFINE_int32(discovery_reregister_threshold, 3, "The renew error threshold beyon static Channel s_discovery_channel; static pthread_once_t s_init_channel_once = PTHREAD_ONCE_INIT; + +int DiscoveryNamingService::GetServers(const char* service_name, + std::vector* servers) { + DiscoveryFetchsParam params{ + service_name, FLAGS_discovery_env, FLAGS_discovery_status}; + return _client.Fetchs(params, servers); +} + +void DiscoveryNamingService::Describe(std::ostream& os, + const DescribeOptions&) const { + os << "discovery"; + return; +} + +NamingService* DiscoveryNamingService::New() const { + return new DiscoveryNamingService; +} + +void DiscoveryNamingService::Destroy() { + delete this; +} + int ParseNodesResult(const butil::IOBuf& buf, std::string* server_addr) { BUTIL_RAPIDJSON_NAMESPACE::Document d; const std::string response = buf.to_string(); @@ -178,36 +200,6 @@ int ParseFetchsResult(const butil::IOBuf& buf, return 0; } -int DiscoveryNamingService::GetServers(const char* service_name, - std::vector* servers) { - pthread_once(&s_init_channel_once, InitChannel); - servers->clear(); - Controller cntl; - cntl.http_request().uri() = butil::string_printf( - "/discovery/fetchs?appid=%s&env=%s&status=%s", service_name, - FLAGS_discovery_env.c_str(), FLAGS_discovery_status.c_str()); - s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); - if (cntl.Failed()) { - LOG(ERROR) << "Fail to make /discovery/fetchs request: " << cntl.ErrorText(); - return -1; - } - return ParseFetchsResult(cntl.response_attachment(), service_name, servers); -} - -void DiscoveryNamingService::Describe(std::ostream& os, - const DescribeOptions&) const { - os << "discovery"; - return; -} - -NamingService* DiscoveryNamingService::New() const { - return new DiscoveryNamingService; -} - -void DiscoveryNamingService::Destroy() { - delete this; -} - bool DiscoveryRegisterParam::IsValid() const { if (appid.empty() || hostname.empty() || addrs.empty() || env.empty() || zone.empty() || version.empty()) { @@ -216,6 +208,13 @@ bool DiscoveryRegisterParam::IsValid() const { return true; } +bool DiscoveryFetchsParam::IsValid() const { + if (appid.empty() || env.empty() || status.empty()) { + return false; + } + return true; +} + DiscoveryClient::DiscoveryClient() : _th(INVALID_BTHREAD) , _state(INIT) {} @@ -246,7 +245,7 @@ int ParseCommonResult(const butil::IOBuf& buf, std::string* error_text) { return code; } -int DiscoveryClient::do_renew() const { +int DiscoveryClient::DoRenew() const { Controller cntl; cntl.http_request().set_method(HTTP_METHOD_POST); cntl.http_request().uri() = "/discovery/renew"; @@ -304,7 +303,7 @@ void* DiscoveryClient::PeriodicRenew(void* arg) { } // Do register until succeed or Cancel is called while (!bthread_stopped(bthread_self())) { - if (d->do_register() == 0) { + if (d->DoRegister() == 0) { break; } bthread_usleep(FLAGS_discovery_renew_interval_s * 1000000); @@ -312,7 +311,7 @@ void* DiscoveryClient::PeriodicRenew(void* arg) { consecutive_renew_error = 0; } - if (d->do_renew() != 0) { + if (d->DoRenew() != 0) { consecutive_renew_error++; continue; } @@ -360,7 +359,7 @@ int DiscoveryClient::Register(const DiscoveryRegisterParam& req) { _version = req.version; _metadata = req.metadata; - if (do_register() != 0) { + if (DoRegister() != 0) { return -1; } if (bthread_start_background(&_th, NULL, PeriodicRenew, this) != 0) { @@ -391,12 +390,12 @@ int DiscoveryClient::Register(const DiscoveryRegisterParam& req) { if (is_canceled) { bthread_stop(_th); bthread_join(_th, NULL); - return do_cancel(); + return DoCancel(); } return 0; } -int DiscoveryClient::do_register() const { +int DiscoveryClient::DoRegister() const { Controller cntl; cntl.http_request().set_method(HTTP_METHOD_POST); cntl.http_request().uri() = "/discovery/register"; @@ -447,10 +446,10 @@ int DiscoveryClient::Cancel() { CHECK_NE(_th, INVALID_BTHREAD); bthread_stop(_th); bthread_join(_th, NULL); - return do_cancel(); + return DoCancel(); } -int DiscoveryClient::do_cancel() const { +int DiscoveryClient::DoCancel() const { pthread_once(&s_init_channel_once, InitChannel); Controller cntl; cntl.http_request().set_method(HTTP_METHOD_POST); @@ -476,6 +475,24 @@ int DiscoveryClient::do_cancel() const { return 0; } +int DiscoveryClient::Fetchs(const DiscoveryFetchsParam& req, + std::vector* servers) { + if (!req.IsValid()) { + return false; + } + pthread_once(&s_init_channel_once, InitChannel); + servers->clear(); + Controller cntl; + cntl.http_request().uri() = butil::string_printf( + "/discovery/fetchs?appid=%s&env=%s&status=%s", req.appid.c_str(), + req.env.c_str(), req.status.c_str()); + s_discovery_channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + if (cntl.Failed()) { + LOG(ERROR) << "Fail to get /discovery/fetchs: " << cntl.ErrorText(); + return -1; + } + return ParseFetchsResult(cntl.response_attachment(), req.appid.c_str(), servers); +} } // namespace policy } // namespace brpc diff --git a/src/brpc/policy/discovery_naming_service.h b/src/brpc/policy/discovery_naming_service.h index 4a3e6e53..24b9b4e8 100644 --- a/src/brpc/policy/discovery_naming_service.h +++ b/src/brpc/policy/discovery_naming_service.h @@ -24,18 +24,6 @@ namespace brpc { namespace policy { -class DiscoveryNamingService : public PeriodicNamingService { -private: - int GetServers(const char* service_name, - std::vector* servers) override; - - void Describe(std::ostream& os, const DescribeOptions&) const override; - - NamingService* New() const override; - - void Destroy() override; -}; - struct DiscoveryRegisterParam { std::string appid; std::string hostname; @@ -50,6 +38,14 @@ struct DiscoveryRegisterParam { bool IsValid() const; }; +struct DiscoveryFetchsParam { + std::string appid; + std::string env; + std::string status; + + bool IsValid() const; +}; + // ONE DiscoveryClient corresponds to ONE service instance. // If your program has multiple service instances to register, // you need multiple DiscoveryClient. @@ -60,12 +56,13 @@ public: int Register(const DiscoveryRegisterParam& req); int Cancel(); + int Fetchs(const DiscoveryFetchsParam& req, std::vector* servers); private: static void* PeriodicRenew(void* arg); - int do_cancel() const; - int do_register() const; - int do_renew() const; + int DoCancel() const; + int DoRegister() const; + int DoRenew() const; private: enum State { @@ -88,6 +85,22 @@ private: std::string _metadata; }; +class DiscoveryNamingService : public PeriodicNamingService { +private: + int GetServers(const char* service_name, + std::vector* servers) override; + + void Describe(std::ostream& os, const DescribeOptions&) const override; + + NamingService* New() const override; + + void Destroy() override; + +private: + DiscoveryClient _client; +}; + + } // namespace policy } // namespace brpc From 7129b3c582429b01f65c8446f1c521e56e4f7f32 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 3 Dec 2018 04:43:13 -0800 Subject: [PATCH 007/270] Fix ut in slow machine --- test/bthread_butex_unittest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bthread_butex_unittest.cpp b/test/bthread_butex_unittest.cpp index dc381edb..fa49edf6 100644 --- a/test/bthread_butex_unittest.cpp +++ b/test/bthread_butex_unittest.cpp @@ -208,7 +208,7 @@ TEST(ButexTest, wait_without_stop) { ASSERT_EQ(0, bthread_join(th, NULL)); tm.stop(); - ASSERT_LT(labs(tm.m_elapsed() - WAIT_MSEC), 40); + ASSERT_LT(labs(tm.m_elapsed() - WAIT_MSEC), 250); } bthread::butex_destroy(butex); } From 770cc50da962eca21a68ee411adb327d59cf2974 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 5 Dec 2018 00:31:20 -0800 Subject: [PATCH 008/270] hide cancel() from user --- src/brpc/policy/discovery_naming_service.cpp | 119 +++---------------- src/brpc/policy/discovery_naming_service.h | 13 +- test/brpc_naming_service_unittest.cpp | 30 ++--- 3 files changed, 31 insertions(+), 131 deletions(-) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index 5dbf70bb..f75896e5 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -129,7 +129,6 @@ static void InitChannel() { } } - int ParseFetchsResult(const butil::IOBuf& buf, const char* service_name, std::vector* servers) { @@ -201,26 +200,24 @@ int ParseFetchsResult(const butil::IOBuf& buf, } bool DiscoveryRegisterParam::IsValid() const { - if (appid.empty() || hostname.empty() || addrs.empty() || - env.empty() || zone.empty() || version.empty()) { - return false; - } - return true; + return !appid.empty() && !hostname.empty() && !addrs.empty() && + !env.empty() && !zone.empty() && !version.empty(); } bool DiscoveryFetchsParam::IsValid() const { - if (appid.empty() || env.empty() || status.empty()) { - return false; - } - return true; + return !appid.empty() && !env.empty() && !status.empty(); } DiscoveryClient::DiscoveryClient() : _th(INVALID_BTHREAD) - , _state(INIT) {} + , _registered(false) {} DiscoveryClient::~DiscoveryClient() { - Cancel(); + if (_registered.load(butil::memory_order_acquire)) { + bthread_stop(_th); + bthread_join(_th, NULL); + DoCancel(); + } } int ParseCommonResult(const butil::IOBuf& buf, std::string* error_text) { @@ -284,23 +281,7 @@ void* DiscoveryClient::PeriodicRenew(void* arg) { while (!bthread_stopped(bthread_self())) { if (consecutive_renew_error == FLAGS_discovery_reregister_threshold) { - LOG(WARNING) << "Reregister since discovery renew error threshold reached"; - { - std::unique_lock mu(d->_mutex); - switch (d->_state) { - case INIT: - CHECK(false) << "Impossible"; - return NULL; - case REGISTERING: - case REGISTERED: - break; - case CANCELED: - return NULL; - default: - CHECK(false) << "Impossible"; - return NULL; - } - } + LOG(WARNING) << "Re-register since discovery renew error threshold reached"; // Do register until succeed or Cancel is called while (!bthread_stopped(bthread_self())) { if (d->DoRegister() == 0) { @@ -310,17 +291,12 @@ void* DiscoveryClient::PeriodicRenew(void* arg) { } consecutive_renew_error = 0; } - if (d->DoRenew() != 0) { consecutive_renew_error++; continue; } consecutive_renew_error = 0; - if (bthread_usleep(FLAGS_discovery_renew_interval_s * 1000000) != 0) { - if (errno == ESTOP) { - break; - } - } + bthread_usleep(FLAGS_discovery_renew_interval_s * 1000000); } return NULL; } @@ -329,24 +305,9 @@ int DiscoveryClient::Register(const DiscoveryRegisterParam& req) { if (!req.IsValid()) { return -1; } - { - std::unique_lock mu(_mutex); - switch (_state) { - case INIT: - _state = REGISTERING; - break; - case REGISTERING: - case REGISTERED: - LOG(WARNING) << "Discovery Appid=" << req.appid - <<" is registering or registered"; - return 0; - case CANCELED: - LOG(ERROR) << "Discovery Appid=" << req.appid << " is canceled"; - return -1; - default: - CHECK(false) << "Impossible"; - return -1; - } + if (_registered.load(butil::memory_order_relaxed) || + _registered.exchange(true, butil::memory_order_release)) { + return 0; } pthread_once(&s_init_channel_once, InitChannel); _appid = req.appid; @@ -366,32 +327,6 @@ int DiscoveryClient::Register(const DiscoveryRegisterParam& req) { LOG(ERROR) << "Fail to start background PeriodicRenew"; return -1; } - bool is_canceled = false; - { - std::unique_lock mu(_mutex); - switch (_state) { - case INIT: - CHECK(false) << "Impossible"; - return -1; - case REGISTERING: - _state = REGISTERED; - break; - case REGISTERED: - CHECK(false) << "Impossible"; - return -1; - case CANCELED: - is_canceled = true; - break; - default: - CHECK(false) << "Impossible"; - return -1; - } - } - if (is_canceled) { - bthread_stop(_th); - bthread_join(_th, NULL); - return DoCancel(); - } return 0; } @@ -425,30 +360,6 @@ int DiscoveryClient::DoRegister() const { return 0; } -int DiscoveryClient::Cancel() { - { - std::unique_lock mu(_mutex); - switch (_state) { - case INIT: - case REGISTERING: - _state = CANCELED; - return 0; - case REGISTERED: - _state = CANCELED; - break; - case CANCELED: - return 0; - default: - CHECK(false) << "Impossible"; - return -1; - } - } - CHECK_NE(_th, INVALID_BTHREAD); - bthread_stop(_th); - bthread_join(_th, NULL); - return DoCancel(); -} - int DiscoveryClient::DoCancel() const { pthread_once(&s_init_channel_once, InitChannel); Controller cntl; @@ -476,7 +387,7 @@ int DiscoveryClient::DoCancel() const { } int DiscoveryClient::Fetchs(const DiscoveryFetchsParam& req, - std::vector* servers) { + std::vector* servers) const { if (!req.IsValid()) { return false; } diff --git a/src/brpc/policy/discovery_naming_service.h b/src/brpc/policy/discovery_naming_service.h index 24b9b4e8..f529262f 100644 --- a/src/brpc/policy/discovery_naming_service.h +++ b/src/brpc/policy/discovery_naming_service.h @@ -49,14 +49,14 @@ struct DiscoveryFetchsParam { // ONE DiscoveryClient corresponds to ONE service instance. // If your program has multiple service instances to register, // you need multiple DiscoveryClient. +// Note: Unregister is automatically called in dtor. class DiscoveryClient { public: DiscoveryClient(); ~DiscoveryClient(); int Register(const DiscoveryRegisterParam& req); - int Cancel(); - int Fetchs(const DiscoveryFetchsParam& req, std::vector* servers); + int Fetchs(const DiscoveryFetchsParam& req, std::vector* servers) const; private: static void* PeriodicRenew(void* arg); @@ -65,15 +65,8 @@ private: int DoRenew() const; private: - enum State { - INIT, - REGISTERING, - REGISTERED, - CANCELED - }; bthread_t _th; - State _state; - butil::Mutex _mutex; + butil::atomic _registered; std::string _appid; std::string _hostname; std::string _addrs; diff --git a/test/brpc_naming_service_unittest.cpp b/test/brpc_naming_service_unittest.cpp index c425f2e0..fc2b9a29 100644 --- a/test/brpc_naming_service_unittest.cpp +++ b/test/brpc_naming_service_unittest.cpp @@ -626,7 +626,6 @@ TEST(NamingServiceTest, discovery_sanity) { ASSERT_EQ(0, dcns.GetServers("admin.test", &servers)); ASSERT_EQ((size_t)1, servers.size()); - brpc::policy::DiscoveryClient dc; brpc::policy::DiscoveryRegisterParam dparam; dparam.appid = "main.test"; dparam.hostname = "hostname"; @@ -635,24 +634,21 @@ TEST(NamingServiceTest, discovery_sanity) { dparam.zone = "sh001"; dparam.status = 1; dparam.version = "v1"; - ASSERT_EQ(0, dc.Register(dparam)); - bthread_usleep(1000000); - ASSERT_EQ(0, dc.Cancel()); - ASSERT_GT(svc.RenewCount(), 0); - ASSERT_EQ(svc.CancelCount(), 1); - - brpc::policy::DiscoveryClient dc2; - ASSERT_EQ(0, dc2.Cancel()); - ASSERT_EQ(-1, dc2.Register(dparam)); - { - brpc::policy::DiscoveryClient dc3; - ASSERT_EQ(0, dc3.Register(dparam)); - ASSERT_EQ(0, dc3.Cancel()); + brpc::policy::DiscoveryClient dc; } - // Dtor of DiscoveryClient also calls Cancel(), we need to ensure that - // Cancel() is called only once. One is from dc1, the other is from dc3. - ASSERT_EQ(svc.CancelCount(), 2); + // Cancel is called iff Register is called + ASSERT_EQ(svc.CancelCount(), 0); + { + brpc::policy::DiscoveryClient dc; + // Two Register should start one Renew task , and make + // svc.RenewCount() be one. + ASSERT_EQ(0, dc.Register(dparam)); + ASSERT_EQ(0, dc.Register(dparam)); + bthread_usleep(1000000); + } + ASSERT_EQ(svc.RenewCount(), 1); + ASSERT_EQ(svc.CancelCount(), 1); } } //namespace From 50eed9b008e7eff012e788a8a328901f68373579 Mon Sep 17 00:00:00 2001 From: cdjgit Date: Tue, 11 Dec 2018 18:34:35 +0800 Subject: [PATCH 009/270] lb configurable && consistency lb refactor --- src/brpc/global.cpp | 7 +- src/brpc/load_balancer.cpp | 27 +++- src/brpc/load_balancer.h | 7 + .../consistent_hashing_load_balancer.cpp | 151 +++++++++++++----- .../policy/consistent_hashing_load_balancer.h | 34 ++-- src/brpc/policy/hasher.cpp | 8 +- src/brpc/policy/hasher.h | 1 + src/brpc/socket.h | 6 +- 8 files changed, 177 insertions(+), 64 deletions(-) diff --git a/src/brpc/global.cpp b/src/brpc/global.cpp index 69574331..d694eed4 100755 --- a/src/brpc/global.cpp +++ b/src/brpc/global.cpp @@ -108,8 +108,9 @@ const char* const DUMMY_SERVER_PORT_FILE = "dummy_server.port"; struct GlobalExtensions { GlobalExtensions() - : ch_mh_lb(MurmurHash32) - , ch_md5_lb(MD5Hash32) + : ch_mh_lb("murmurhash3") + , ch_md5_lb("md5") + , ch_ketama_lb("ketama") , constant_cl(0) { } @@ -129,6 +130,7 @@ struct GlobalExtensions { LocalityAwareLoadBalancer la_lb; ConsistentHashingLoadBalancer ch_mh_lb; ConsistentHashingLoadBalancer ch_md5_lb; + ConsistentHashingLoadBalancer ch_ketama_lb; DynPartLoadBalancer dynpart_lb; AutoConcurrencyLimiter auto_cl; @@ -350,6 +352,7 @@ static void GlobalInitializeOrDieImpl() { LoadBalancerExtension()->RegisterOrDie("la", &g_ext->la_lb); LoadBalancerExtension()->RegisterOrDie("c_murmurhash", &g_ext->ch_mh_lb); LoadBalancerExtension()->RegisterOrDie("c_md5", &g_ext->ch_md5_lb); + LoadBalancerExtension()->RegisterOrDie("c_ketama", &g_ext->ch_ketama_lb); LoadBalancerExtension()->RegisterOrDie("_dynpart", &g_ext->dynpart_lb); // Compress Handlers diff --git a/src/brpc/load_balancer.cpp b/src/brpc/load_balancer.cpp index 14b21dde..62cad3e7 100644 --- a/src/brpc/load_balancer.cpp +++ b/src/brpc/load_balancer.cpp @@ -62,8 +62,11 @@ SharedLoadBalancer::~SharedLoadBalancer() { } } -int SharedLoadBalancer::Init(const char* lb_name) { - const LoadBalancer* lb = LoadBalancerExtension()->Find(lb_name); +int SharedLoadBalancer::Init(const char* lb_protocol) { + std::string lb_name; + butil::StringPairs lb_parms; + ParseParameters(lb_protocol, &lb_name, &lb_parms); + const LoadBalancer* lb = LoadBalancerExtension()->Find(lb_name.c_str()); if (lb == NULL) { LOG(FATAL) << "Fail to find LoadBalancer by `" << lb_name << "'"; return -1; @@ -74,6 +77,10 @@ int SharedLoadBalancer::Init(const char* lb_name) { return -1; } _lb = lb_copy; + if (!_lb->SetParameters(lb_parms)) { + LOG(FATAL) << "Fail to set parameters of lb `" << lb_protocol << "'"; + return -1; + } if (FLAGS_show_lb_in_vars && !_exposed) { ExposeLB(); } @@ -89,4 +96,20 @@ void SharedLoadBalancer::Describe(std::ostream& os, } } +void SharedLoadBalancer::ParseParameters(const butil::StringPiece lb_protocol, + std::string* lb_name, + butil::StringPairs* parms) { + lb_name->clear(); + parms->clear(); + size_t pos = lb_protocol.find(':'); + if (pos == std::string::npos) { + lb_name->append(lb_protocol.data(), lb_protocol.size()); + } else { + lb_name->append(lb_protocol.data(), pos); + butil::StringPiece parms_piece = lb_protocol.substr(pos + sizeof(':')); + std::string parms_str(parms_piece.data(), parms_piece.size()); + butil::SplitStringIntoKeyValuePairs(parms_str, '=', ' ', parms); + } +} + } // namespace brpc diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 538c2d38..dd587953 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -24,6 +24,8 @@ #include "brpc/shared_object.h" // SharedObject #include "brpc/server_id.h" // ServerId #include "brpc/extension.h" // Extension +#include "butil/strings/string_piece.h" +#include "butil/strings/string_split.h" namespace brpc { @@ -102,6 +104,8 @@ public: // Caller is responsible for Destroy() the instance after usage. virtual LoadBalancer* New() const = 0; + virtual bool SetParameters(const butil::StringPairs& parms) { return true; } + protected: virtual ~LoadBalancer() { } }; @@ -164,6 +168,9 @@ public: } private: + static void ParseParameters(const butil::StringPiece lb_protocl, + std::string* lb_name, + butil::StringPairs* parms); static void DescribeLB(std::ostream& os, void* arg); void ExposeLB(); diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 942f8a49..f972954e 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -18,8 +18,10 @@ #include #include "butil/containers/flat_map.h" #include "butil/errno.h" +#include "butil/strings/string_number_conversions.h" #include "brpc/socket.h" #include "brpc/policy/consistent_hashing_load_balancer.h" +#include "brpc/policy/hasher.h" namespace brpc { @@ -29,16 +31,92 @@ namespace policy { DEFINE_int32(chash_num_replicas, 100, "default number of replicas per server in chash"); -ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(HashFunc hash) - : _hash(hash) - , _num_replicas(FLAGS_chash_num_replicas) { +namespace { + +using HashFun = uint32_t(*)(const void*, size_t); + +bool BuildReplicasDefault(const ServerId server, + const size_t num_replicas, + HashFun hash, + std::vector* replicas) { + SocketUniquePtr ptr; + if (Socket::AddressFailedAsWell(server.id, &ptr) == -1) { + return false; + } + replicas->clear(); + for (size_t i = 0; i < num_replicas; ++i) { + char host[32]; + int len = snprintf(host, sizeof(host), "%s-%lu", + endpoint2str(ptr->remote_side()).c_str(), i); + ConsistentHashingLoadBalancer::Node node; + node.hash = hash(host, len); + node.server_sock = server; + node.server_addr = ptr->remote_side(); + replicas->push_back(node); + } + return true; } -ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer( - HashFunc hash, - size_t num_replicas) - : _hash(hash) - , _num_replicas(num_replicas) { +bool BuildReplicasKetam(const ServerId server, + const size_t num_replicas, + std::vector* replicas) { + SocketUniquePtr ptr; + if (Socket::AddressFailedAsWell(server.id, &ptr) == -1) { + return false; + } + replicas->clear(); + const size_t points_per_hash = 4; + CHECK(num_replicas % points_per_hash == 0) + << "Ketam hash replicas number(" << num_replicas << ") should be n*4"; + for (size_t i = 0; i < num_replicas / points_per_hash; ++i) { + char host[32]; + int len = snprintf(host, sizeof(host), "%s-%lu", + endpoint2str(ptr->remote_side()).c_str(), i); + unsigned char digest[16]; + MD5HashSignature(host, len, digest); + for (size_t j = 0; j < points_per_hash; ++j) { + ConsistentHashingLoadBalancer::Node node; + node.server_sock = server; + node.server_addr = ptr->remote_side(); + node.hash = ((uint32_t) (digest[3 + j * 4] & 0xFF) << 24) + | ((uint32_t) (digest[2 + j * 4] & 0xFF) << 16) + | ((uint32_t) (digest[1 + j * 4] & 0xFF) << 8) + | (digest[0 + j * 4] & 0xFF); + replicas->push_back(node); + } + } + return true; +} + +} // namespace + +ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(const char* name) + : _num_replicas(FLAGS_chash_num_replicas), _name(name) { + Init(_name); +} + +void ConsistentHashingLoadBalancer::Init(const std::string& name) { + if (name.compare("murmurhash3") == 0) { + _build_replicas = std::bind(BuildReplicasDefault, + std::placeholders::_1, + std::placeholders::_2, + MurmurHash32, + std::placeholders::_3); + return; + } + if (name.compare("md5") == 0) { + _build_replicas = std::bind(BuildReplicasDefault, + std::placeholders::_1, + std::placeholders::_2, + MD5Hash32, + std::placeholders::_3); + return; + } + if (name.compare("ketama") == 0) { + _build_replicas = BuildReplicasKetam; + return; + } + CHECK(false) << "Failed to init consistency hash load balancer of \'" << name << '\''; } size_t ConsistentHashingLoadBalancer::AddBatch( @@ -112,20 +190,9 @@ size_t ConsistentHashingLoadBalancer::Remove( bool ConsistentHashingLoadBalancer::AddServer(const ServerId& server) { std::vector add_nodes; add_nodes.reserve(_num_replicas); - SocketUniquePtr ptr; - if (Socket::AddressFailedAsWell(server.id, &ptr) == -1) { + if (!_build_replicas(server, _num_replicas, &add_nodes)) { return false; } - for (size_t i = 0; i < _num_replicas; ++i) { - char host[32]; - int len = snprintf(host, sizeof(host), "%s-%lu", - endpoint2str(ptr->remote_side()).c_str(), i); - Node node; - node.hash = _hash(host, len); - node.server_sock = server; - node.server_addr = ptr->remote_side(); - add_nodes.push_back(node); - } std::sort(add_nodes.begin(), add_nodes.end()); bool executed = false; const size_t ret = _db_hash_ring.ModifyWithForeground( @@ -138,23 +205,12 @@ size_t ConsistentHashingLoadBalancer::AddServersInBatch( const std::vector &servers) { std::vector add_nodes; add_nodes.reserve(servers.size() * _num_replicas); + std::vector replicas; + replicas.reserve(_num_replicas); for (size_t i = 0; i < servers.size(); ++i) { - SocketUniquePtr ptr; - if (Socket::AddressFailedAsWell(servers[i].id, &ptr) == -1) { - continue; - } - for (size_t rep = 0; rep < _num_replicas; ++rep) { - char host[32]; - // To be compatible with libmemcached, we formulate the key of - // a virtual node as `|address|-|replica_index|', see - // http://fe.baidu.com/-1bszwnf at line 297. - int len = snprintf(host, sizeof(host), "%s-%lu", - endpoint2str(ptr->remote_side()).c_str(), rep); - Node node; - node.hash = _hash(host, len); - node.server_sock = servers[i]; - node.server_addr = ptr->remote_side(); - add_nodes.push_back(node); + replicas.clear(); + if (_build_replicas(servers[i], _num_replicas, &replicas)) { + add_nodes.insert(add_nodes.end(), replicas.begin(), replicas.end()); } } std::sort(add_nodes.begin(), add_nodes.end()); @@ -188,7 +244,7 @@ size_t ConsistentHashingLoadBalancer::RemoveServersInBatch( } LoadBalancer *ConsistentHashingLoadBalancer::New() const { - return new (std::nothrow) ConsistentHashingLoadBalancer(_hash); + return new (std::nothrow) ConsistentHashingLoadBalancer(_name.c_str()); } void ConsistentHashingLoadBalancer::Destroy() { @@ -232,8 +288,6 @@ int ConsistentHashingLoadBalancer::SelectServer( return EHOSTDOWN; } -extern const char *GetHashName(uint32_t (*hasher)(const void* key, size_t len)); - void ConsistentHashingLoadBalancer::Describe( std::ostream &os, const DescribeOptions& options) { if (!options.verbose) { @@ -241,7 +295,7 @@ void ConsistentHashingLoadBalancer::Describe( return; } os << "ConsistentHashingLoadBalancer {\n" - << " hash function: " << GetHashName(_hash) << '\n' + << " hash function: " << _name << '\n' << " replica per host: " << _num_replicas << '\n'; std::map load_map; GetLoads(&load_map); @@ -289,5 +343,22 @@ void ConsistentHashingLoadBalancer::GetLoads( } } +bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPairs& parms) { + for (const std::pair& parm : parms) { + if (parm.first.compare("replicas") == 0) { + size_t replicas = 0; + if (butil::StringToSizeT(parm.second, &replicas)) { + _num_replicas = replicas; + } else { + return false; + } + } else { + return false; + } + } + + return true; +} + } // namespace policy } // namespace brpc diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index 9881edbb..fcb1617e 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -18,6 +18,7 @@ #define BRPC_CONSISTENT_HASHING_LOAD_BALANCER_H #include // uint32_t +#include #include // std::vector #include "butil/endpoint.h" // butil::EndPoint #include "butil/containers/doubly_buffered_data.h" @@ -29,20 +30,6 @@ namespace policy { class ConsistentHashingLoadBalancer : public LoadBalancer { public: - typedef uint32_t (*HashFunc)(const void* key, size_t len); - explicit ConsistentHashingLoadBalancer(HashFunc hash); - ConsistentHashingLoadBalancer(HashFunc hash, size_t num_replicas); - bool AddServer(const ServerId& server); - bool RemoveServer(const ServerId& server); - size_t AddServersInBatch(const std::vector &servers); - size_t RemoveServersInBatch(const std::vector &servers); - LoadBalancer *New() const; - void Destroy(); - int SelectServer(const SelectIn &in, SelectOut *out); - void Describe(std::ostream &os, const DescribeOptions& options); - -private: - void GetLoads(std::map *load_map); struct Node { uint32_t hash; ServerId server_sock; @@ -56,14 +43,31 @@ private: return hash < code; } }; + using BuildReplicasFunc = + std::function* replicas)>; + explicit ConsistentHashingLoadBalancer(const char* name); + bool AddServer(const ServerId& server); + bool RemoveServer(const ServerId& server); + size_t AddServersInBatch(const std::vector &servers); + size_t RemoveServersInBatch(const std::vector &servers); + LoadBalancer *New() const; + void Destroy(); + int SelectServer(const SelectIn &in, SelectOut *out); + void Describe(std::ostream &os, const DescribeOptions& options); + virtual bool SetParameters(const butil::StringPairs& parms); + +private: + void Init(const std::string& name); + void GetLoads(std::map *load_map); static size_t AddBatch(std::vector &bg, const std::vector &fg, const std::vector &servers, bool *executed); static size_t RemoveBatch(std::vector &bg, const std::vector &fg, const std::vector &servers, bool *executed); static size_t Remove(std::vector &bg, const std::vector &fg, const ServerId& server, bool *executed); - HashFunc _hash; + BuildReplicasFunc _build_replicas; size_t _num_replicas; + std::string _name; butil::DoublyBufferedData > _db_hash_ring; }; diff --git a/src/brpc/policy/hasher.cpp b/src/brpc/policy/hasher.cpp index 55537a9b..c50d134d 100644 --- a/src/brpc/policy/hasher.cpp +++ b/src/brpc/policy/hasher.cpp @@ -23,12 +23,16 @@ namespace brpc { namespace policy { -uint32_t MD5Hash32(const void* key, size_t len) { +uint32_t MD5HashSignature(const void* key, size_t len, unsigned char* results) { MD5_CTX my_md5; MD5_Init(&my_md5); MD5_Update(&my_md5, (const unsigned char *)key, len); - unsigned char results[16]; MD5_Final(results, &my_md5); +} + +uint32_t MD5Hash32(const void* key, size_t len) { + unsigned char results[16]; + MD5HashSignature(key, len, results); return ((uint32_t) (results[3] & 0xFF) << 24) | ((uint32_t) (results[2] & 0xFF) << 16) | ((uint32_t) (results[1] & 0xFF) << 8) diff --git a/src/brpc/policy/hasher.h b/src/brpc/policy/hasher.h index adbc1e46..4db87050 100644 --- a/src/brpc/policy/hasher.h +++ b/src/brpc/policy/hasher.h @@ -25,6 +25,7 @@ namespace brpc { namespace policy { +uint32_t MD5HashSignature(const void* key, size_t len, unsigned char* results); uint32_t MD5Hash32(const void* key, size_t len); uint32_t MD5Hash32V(const butil::StringPiece* keys, size_t num_keys); diff --git a/src/brpc/socket.h b/src/brpc/socket.h index 98483fd4..71b453a9 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -303,6 +303,9 @@ public: // Always succeed even if this socket is failed. void ReAddress(SocketUniquePtr* ptr); + // Returns 0 on success, 1 on failed socket, -1 on recycled. + static int AddressFailedAsWell(SocketId id, SocketUniquePtr* ptr); + // Mark this Socket or the Socket associated with `id' as failed. // Any later Address() of the identifier shall return NULL unless the // Socket was revivied by HealthCheckThread. The Socket is NOT recycled @@ -550,9 +553,6 @@ friend void DereferenceSocket(Socket*); int ResetFileDescriptor(int fd); - // Returns 0 on success, 1 on failed socket, -1 on recycled. - static int AddressFailedAsWell(SocketId id, SocketUniquePtr* ptr); - // Wait until nref hits `expected_nref' and reset some internal resources. int WaitAndReset(int32_t expected_nref); From cc795ae596a2167bee7696e170507f4437abac8f Mon Sep 17 00:00:00 2001 From: caidaojin Date: Wed, 12 Dec 2018 00:13:45 +0800 Subject: [PATCH 010/270] bug fix && unitest fix --- src/brpc/global.cpp | 2 +- src/brpc/policy/consistent_hashing_load_balancer.cpp | 4 +--- src/brpc/policy/consistent_hashing_load_balancer.h | 1 + src/brpc/policy/hasher.cpp | 12 ++++++++++-- src/brpc/policy/hasher.h | 4 +++- test/brpc_load_balancer_unittest.cpp | 12 ++++++------ 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/brpc/global.cpp b/src/brpc/global.cpp index d694eed4..339f8633 100755 --- a/src/brpc/global.cpp +++ b/src/brpc/global.cpp @@ -108,7 +108,7 @@ const char* const DUMMY_SERVER_PORT_FILE = "dummy_server.port"; struct GlobalExtensions { GlobalExtensions() - : ch_mh_lb("murmurhash3") + : ch_mh_lb("murmurhash32") , ch_md5_lb("md5") , ch_ketama_lb("ketama") , constant_cl(0) { diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index f972954e..d2da7d4c 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -33,11 +33,9 @@ DEFINE_int32(chash_num_replicas, 100, namespace { -using HashFun = uint32_t(*)(const void*, size_t); - bool BuildReplicasDefault(const ServerId server, const size_t num_replicas, - HashFun hash, + ConsistentHashingLoadBalancer::HashFunc hash, std::vector* replicas) { SocketUniquePtr ptr; if (Socket::AddressFailedAsWell(server.id, &ptr) == -1) { diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index fcb1617e..c29da7ea 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -43,6 +43,7 @@ public: return hash < code; } }; + using HashFun = uint32_t(*)(const void*, size_t); using BuildReplicasFunc = std::function* replicas)>; explicit ConsistentHashingLoadBalancer(const char* name); diff --git a/src/brpc/policy/hasher.cpp b/src/brpc/policy/hasher.cpp index c50d134d..c3747c56 100644 --- a/src/brpc/policy/hasher.cpp +++ b/src/brpc/policy/hasher.cpp @@ -23,7 +23,7 @@ namespace brpc { namespace policy { -uint32_t MD5HashSignature(const void* key, size_t len, unsigned char* results) { +void MD5HashSignature(const void* key, size_t len, unsigned char* results) { MD5_CTX my_md5; MD5_Init(&my_md5); MD5_Update(&my_md5, (const unsigned char *)key, len); @@ -39,6 +39,10 @@ uint32_t MD5Hash32(const void* key, size_t len) { | (results[0] & 0xFF); } +uint32_t KetamaHash(const void* key, size_t len) { + return MD5Hash32(key, len); +} + uint32_t MD5Hash32V(const butil::StringPiece* keys, size_t num_keys) { MD5_CTX ctx; MD5_Init(&ctx); @@ -153,7 +157,7 @@ uint32_t CRCHash32(const void* key, size_t len) { const char *GetHashName(uint32_t (*hasher)(const void* key, size_t len)) { if (hasher == MurmurHash32) { - return "murmurhash3"; + return "murmurhash32"; } if (hasher == MD5Hash32) { return "md5"; @@ -161,6 +165,10 @@ const char *GetHashName(uint32_t (*hasher)(const void* key, size_t len)) { if (hasher == CRCHash32) { return "crc32"; } + if (hasher == KetamaHash) { + return "ketama"; + } + return "user_defined"; } diff --git a/src/brpc/policy/hasher.h b/src/brpc/policy/hasher.h index 4db87050..de9d39be 100644 --- a/src/brpc/policy/hasher.h +++ b/src/brpc/policy/hasher.h @@ -25,13 +25,15 @@ namespace brpc { namespace policy { -uint32_t MD5HashSignature(const void* key, size_t len, unsigned char* results); +void MD5HashSignature(const void* key, size_t len, unsigned char* results); uint32_t MD5Hash32(const void* key, size_t len); uint32_t MD5Hash32V(const butil::StringPiece* keys, size_t num_keys); uint32_t MurmurHash32(const void* key, size_t len); uint32_t MurmurHash32V(const butil::StringPiece* keys, size_t num_keys); +uint32_t KetamaHash(const void* key, size_t len); + } // namespace policy } // namespace brpc diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 0222dd4e..130d782e 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -25,6 +25,7 @@ namespace brpc { namespace policy { extern uint32_t CRCHash32(const char *key, size_t len); +extern const char* GetHashName(uint32_t (*hasher)(const void* key, size_t len)); }} namespace { @@ -250,8 +251,7 @@ TEST_F(LoadBalancerTest, update_while_selection) { } else if (round == 3) { lb = new brpc::policy::WeightedRoundRobinLoadBalancer; } else { - lb = new brpc::policy::ConsistentHashingLoadBalancer( - ::brpc::policy::MurmurHash32); + lb = new brpc::policy::ConsistentHashingLoadBalancer("murmurhash32"); sa.hash = ::brpc::policy::MurmurHash32; } sa.lb = lb; @@ -364,8 +364,7 @@ TEST_F(LoadBalancerTest, fairness) { } else if (3 == round || 4 == round) { lb = new brpc::policy::WeightedRoundRobinLoadBalancer; } else { - lb = new brpc::policy::ConsistentHashingLoadBalancer( - brpc::policy::MurmurHash32); + lb = new brpc::policy::ConsistentHashingLoadBalancer("murmurhash32"); sa.hash = brpc::policy::MurmurHash32; } sa.lb = lb; @@ -488,7 +487,8 @@ TEST_F(LoadBalancerTest, fairness) { TEST_F(LoadBalancerTest, consistent_hashing) { ::brpc::policy::ConsistentHashingLoadBalancer::HashFunc hashs[] = { ::brpc::policy::MurmurHash32, - ::brpc::policy::MD5Hash32 + ::brpc::policy::MD5Hash32, + ::brpc::policy::KetamaHash // ::brpc::policy::CRCHash32 crc is a bad hash function in test }; const char* servers[] = { @@ -499,7 +499,7 @@ TEST_F(LoadBalancerTest, consistent_hashing) { "10.42.122.201:8833", }; for (size_t round = 0; round < ARRAY_SIZE(hashs); ++round) { - brpc::policy::ConsistentHashingLoadBalancer chlb(hashs[round]); + brpc::policy::ConsistentHashingLoadBalancer chlb(brpc::policy::GetHashName(hashs[round])); std::vector ids; std::vector addrs; for (int j = 0;j < 5; ++j) From 96435e0305659638ead9881edb2c2984cc2c17d9 Mon Sep 17 00:00:00 2001 From: guofutan Date: Wed, 12 Dec 2018 11:31:22 +0800 Subject: [PATCH 011/270] Feature: Add always_print_primitive_fields flags into Controller and json2pb::Pb2JsonOptions. set ture if dumps all fields to json in protobuf3. --- src/brpc/controller.h | 9 +++++++++ src/brpc/policy/http_rpc_protocol.cpp | 3 +++ src/json2pb/pb_to_json.cpp | 8 ++++++-- src/json2pb/pb_to_json.h | 6 ++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/brpc/controller.h b/src/brpc/controller.h index 2c39b2b4..ce12a5f3 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -132,6 +132,7 @@ friend void policy::ProcessThriftRequest(InputMessageBase*); static const uint32_t FLAGS_REQUEST_WITH_AUTH = (1 << 15); static const uint32_t FLAGS_PB_JSONIFY_EMPTY_ARRAY = (1 << 16); static const uint32_t FLAGS_ENABLED_CIRCUIT_BREAKER = (1 << 17); + static const uint32_t FLAGS_ALWAYS_PRINT_PRIMITIVE_FIELDS = (1 << 18); public: Controller(); @@ -296,6 +297,14 @@ public: // of json in HTTP response. void set_pb_jsonify_empty_array(bool f) { set_flag(FLAGS_PB_JSONIFY_EMPTY_ARRAY, f); } bool has_pb_jsonify_empty_array() const { return has_flag(FLAGS_PB_JSONIFY_EMPTY_ARRAY); } + + // Whether to always print primitive fields. By default proto3 primitive + // fields with default values will be omitted in JSON output. For example, an + // int32 field set to 0 will be omitted. Set this flag to true will override + // the default behavior and print primitive fields regardless of their values. + void set_always_print_primitive_fields(bool f) { set_flag(FLAGS_ALWAYS_PRINT_PRIMITIVE_FIELDS, f); } + bool has_always_print_primitive_fields() const { return has_flag(FLAGS_ALWAYS_PRINT_PRIMITIVE_FIELDS); } + // Tell RPC that done of the RPC can be run in the same thread where // the RPC is issued, otherwise done is always run in a different thread. diff --git a/src/brpc/policy/http_rpc_protocol.cpp b/src/brpc/policy/http_rpc_protocol.cpp index 01d3a6f5..e0177aa7 100644 --- a/src/brpc/policy/http_rpc_protocol.cpp +++ b/src/brpc/policy/http_rpc_protocol.cpp @@ -509,6 +509,8 @@ void SerializeHttpRequest(butil::IOBuf* /*not used*/, json2pb::Pb2JsonOptions opt; opt.bytes_to_base64 = cntl->has_pb_bytes_to_base64(); opt.jsonify_empty_array = cntl->has_pb_jsonify_empty_array(); + opt.always_print_primitive_fields = cntl->has_always_print_primitive_fields(); + opt.enum_option = (FLAGS_pb_enum_as_number ? json2pb::OUTPUT_ENUM_BY_NUMBER : json2pb::OUTPUT_ENUM_BY_NAME); @@ -749,6 +751,7 @@ HttpResponseSender::~HttpResponseSender() { json2pb::Pb2JsonOptions opt; opt.bytes_to_base64 = cntl->has_pb_bytes_to_base64(); opt.jsonify_empty_array = cntl->has_pb_jsonify_empty_array(); + opt.always_print_primitive_fields = cntl->has_always_print_primitive_fields(); opt.enum_option = (FLAGS_pb_enum_as_number ? json2pb::OUTPUT_ENUM_BY_NUMBER : json2pb::OUTPUT_ENUM_BY_NAME); diff --git a/src/json2pb/pb_to_json.cpp b/src/json2pb/pb_to_json.cpp index 4c9298b7..c862d464 100644 --- a/src/json2pb/pb_to_json.cpp +++ b/src/json2pb/pb_to_json.cpp @@ -24,7 +24,8 @@ Pb2JsonOptions::Pb2JsonOptions() #else , bytes_to_base64(true) #endif - , jsonify_empty_array(false) { + , jsonify_empty_array(false) + , always_print_primitive_fields(false) { } class PbToJsonConverter { @@ -88,7 +89,10 @@ bool PbToJsonConverter::Convert(const google::protobuf::Message& message, Handle _error = "Missing required field: " + field->full_name(); return false; } - continue; + + if(!_option.always_print_primitive_fields) + continue; + } else if (field->is_repeated() && reflection->FieldSize(message, field) == 0 && !_option.jsonify_empty_array) { diff --git a/src/json2pb/pb_to_json.h b/src/json2pb/pb_to_json.h index 22e762ca..4f35664f 100644 --- a/src/json2pb/pb_to_json.h +++ b/src/json2pb/pb_to_json.h @@ -43,6 +43,12 @@ struct Pb2JsonOptions { // to a empty array of json when this option is turned on. // Default: false bool jsonify_empty_array; + + // Whether to always print primitive fields. By default proto3 primitive + // fields with default values will be omitted in JSON output. For example, an + // int32 field set to 0 will be omitted. Set this flag to true will override + // the default behavior and print primitive fields regardless of their values. + bool always_print_primitive_fields; }; // Convert protobuf `messge' to `json' according to `options'. From 2232e8af9b70cf692946fce09281009ea3a87363 Mon Sep 17 00:00:00 2001 From: cdjgit Date: Wed, 12 Dec 2018 17:09:19 +0800 Subject: [PATCH 012/270] bugs fix --- src/brpc/global.cpp | 2 +- src/brpc/load_balancer.cpp | 25 +++++++++++++------ src/brpc/load_balancer.h | 5 ++-- .../consistent_hashing_load_balancer.cpp | 18 ++++++------- .../policy/consistent_hashing_load_balancer.h | 2 +- src/brpc/policy/hasher.cpp | 2 +- test/brpc_load_balancer_unittest.cpp | 4 +-- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/brpc/global.cpp b/src/brpc/global.cpp index 339f8633..d694eed4 100755 --- a/src/brpc/global.cpp +++ b/src/brpc/global.cpp @@ -108,7 +108,7 @@ const char* const DUMMY_SERVER_PORT_FILE = "dummy_server.port"; struct GlobalExtensions { GlobalExtensions() - : ch_mh_lb("murmurhash32") + : ch_mh_lb("murmurhash3") , ch_md5_lb("md5") , ch_ketama_lb("ketama") , constant_cl(0) { diff --git a/src/brpc/load_balancer.cpp b/src/brpc/load_balancer.cpp index 62cad3e7..195ce36f 100644 --- a/src/brpc/load_balancer.cpp +++ b/src/brpc/load_balancer.cpp @@ -65,7 +65,10 @@ SharedLoadBalancer::~SharedLoadBalancer() { int SharedLoadBalancer::Init(const char* lb_protocol) { std::string lb_name; butil::StringPairs lb_parms; - ParseParameters(lb_protocol, &lb_name, &lb_parms); + if (!ParseParameters(lb_protocol, &lb_name, &lb_parms)) { + LOG(FATAL) << "Fail to parse this load balancer protocol '" << lb_protocol << '\''; + return -1; + } const LoadBalancer* lb = LoadBalancerExtension()->Find(lb_name.c_str()); if (lb == NULL) { LOG(FATAL) << "Fail to find LoadBalancer by `" << lb_name << "'"; @@ -96,20 +99,28 @@ void SharedLoadBalancer::Describe(std::ostream& os, } } -void SharedLoadBalancer::ParseParameters(const butil::StringPiece lb_protocol, +bool SharedLoadBalancer::ParseParameters(const butil::StringPiece& lb_protocol, std::string* lb_name, - butil::StringPairs* parms) { + butil::StringPairs* lb_params) { lb_name->clear(); - parms->clear(); + lb_params->clear(); + if (lb_protocol.empty()) { + return false; + } size_t pos = lb_protocol.find(':'); if (pos == std::string::npos) { lb_name->append(lb_protocol.data(), lb_protocol.size()); } else { lb_name->append(lb_protocol.data(), pos); - butil::StringPiece parms_piece = lb_protocol.substr(pos + sizeof(':')); - std::string parms_str(parms_piece.data(), parms_piece.size()); - butil::SplitStringIntoKeyValuePairs(parms_str, '=', ' ', parms); + butil::StringPiece params_piece = lb_protocol.substr(pos + sizeof(':')); + std::string params_str(params_piece.data(), params_piece.size()); + if (!butil::SplitStringIntoKeyValuePairs(params_str, '=', ' ', lb_params)) { + lb_params->clear(); + return false; + } } + + return true; } } // namespace brpc diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index dd587953..33e75b5a 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -104,6 +104,7 @@ public: // Caller is responsible for Destroy() the instance after usage. virtual LoadBalancer* New() const = 0; + // Set other virtual bool SetParameters(const butil::StringPairs& parms) { return true; } protected: @@ -168,9 +169,9 @@ public: } private: - static void ParseParameters(const butil::StringPiece lb_protocl, + static bool ParseParameters(const butil::StringPiece& lb_protocol, std::string* lb_name, - butil::StringPairs* parms); + butil::StringPairs* lb_params); static void DescribeLB(std::ostream& os, void* arg); void ExposeLB(); diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index d2da7d4c..b3369d33 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -94,7 +94,7 @@ ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(const char* name) } void ConsistentHashingLoadBalancer::Init(const std::string& name) { - if (name.compare("murmurhash3") == 0) { + if (name == "murmurhash3") { _build_replicas = std::bind(BuildReplicasDefault, std::placeholders::_1, std::placeholders::_2, @@ -102,7 +102,7 @@ void ConsistentHashingLoadBalancer::Init(const std::string& name) { std::placeholders::_3); return; } - if (name.compare("md5") == 0) { + if (name == "md5") { _build_replicas = std::bind(BuildReplicasDefault, std::placeholders::_1, std::placeholders::_2, @@ -110,7 +110,7 @@ void ConsistentHashingLoadBalancer::Init(const std::string& name) { std::placeholders::_3); return; } - if (name.compare("ketama") == 0) { + if (name == "ketama") { _build_replicas = BuildReplicasKetam; return; } @@ -341,18 +341,18 @@ void ConsistentHashingLoadBalancer::GetLoads( } } -bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPairs& parms) { - for (const std::pair& parm : parms) { - if (parm.first.compare("replicas") == 0) { +bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPairs& params) { + for (const std::pair& param : params) { + if (param.first == "replicas") { size_t replicas = 0; - if (butil::StringToSizeT(parm.second, &replicas)) { + if (butil::StringToSizeT(param.second, &replicas)) { _num_replicas = replicas; } else { return false; } - } else { - return false; + continue; } + LOG(ERROR) << "Failed to set this unknown parameters " << param.first << '=' << param.second; } return true; diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index c29da7ea..a6499733 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -43,7 +43,7 @@ public: return hash < code; } }; - using HashFun = uint32_t(*)(const void*, size_t); + using HashFunc = uint32_t(*)(const void*, size_t); using BuildReplicasFunc = std::function* replicas)>; explicit ConsistentHashingLoadBalancer(const char* name); diff --git a/src/brpc/policy/hasher.cpp b/src/brpc/policy/hasher.cpp index c3747c56..8a9bee99 100644 --- a/src/brpc/policy/hasher.cpp +++ b/src/brpc/policy/hasher.cpp @@ -157,7 +157,7 @@ uint32_t CRCHash32(const void* key, size_t len) { const char *GetHashName(uint32_t (*hasher)(const void* key, size_t len)) { if (hasher == MurmurHash32) { - return "murmurhash32"; + return "murmurhash3"; } if (hasher == MD5Hash32) { return "md5"; diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 130d782e..481fa1d4 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -251,7 +251,7 @@ TEST_F(LoadBalancerTest, update_while_selection) { } else if (round == 3) { lb = new brpc::policy::WeightedRoundRobinLoadBalancer; } else { - lb = new brpc::policy::ConsistentHashingLoadBalancer("murmurhash32"); + lb = new brpc::policy::ConsistentHashingLoadBalancer("murmurhash3"); sa.hash = ::brpc::policy::MurmurHash32; } sa.lb = lb; @@ -364,7 +364,7 @@ TEST_F(LoadBalancerTest, fairness) { } else if (3 == round || 4 == round) { lb = new brpc::policy::WeightedRoundRobinLoadBalancer; } else { - lb = new brpc::policy::ConsistentHashingLoadBalancer("murmurhash32"); + lb = new brpc::policy::ConsistentHashingLoadBalancer("murmurhash3"); sa.hash = brpc::policy::MurmurHash32; } sa.lb = lb; From 2dcfa32de1e65a9634ebf2c4f721e6838cb9467d Mon Sep 17 00:00:00 2001 From: cdjgit Date: Wed, 12 Dec 2018 17:15:28 +0800 Subject: [PATCH 013/270] fix typo --- src/brpc/load_balancer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/brpc/load_balancer.cpp b/src/brpc/load_balancer.cpp index 195ce36f..b48ca530 100644 --- a/src/brpc/load_balancer.cpp +++ b/src/brpc/load_balancer.cpp @@ -64,8 +64,8 @@ SharedLoadBalancer::~SharedLoadBalancer() { int SharedLoadBalancer::Init(const char* lb_protocol) { std::string lb_name; - butil::StringPairs lb_parms; - if (!ParseParameters(lb_protocol, &lb_name, &lb_parms)) { + butil::StringPairs lb_params; + if (!ParseParameters(lb_protocol, &lb_name, &lb_params)) { LOG(FATAL) << "Fail to parse this load balancer protocol '" << lb_protocol << '\''; return -1; } @@ -80,7 +80,7 @@ int SharedLoadBalancer::Init(const char* lb_protocol) { return -1; } _lb = lb_copy; - if (!_lb->SetParameters(lb_parms)) { + if (!_lb->SetParameters(lb_params)) { LOG(FATAL) << "Fail to set parameters of lb `" << lb_protocol << "'"; return -1; } From b1ed71cea7464bc2f551fe0cefca7acccaf6845a Mon Sep 17 00:00:00 2001 From: cdjgit Date: Wed, 12 Dec 2018 17:18:51 +0800 Subject: [PATCH 014/270] fix typo --- src/brpc/load_balancer.h | 2 +- src/brpc/policy/consistent_hashing_load_balancer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 33e75b5a..467c2a1b 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -105,7 +105,7 @@ public: virtual LoadBalancer* New() const = 0; // Set other - virtual bool SetParameters(const butil::StringPairs& parms) { return true; } + virtual bool SetParameters(const butil::StringPairs& params) { return true; } protected: virtual ~LoadBalancer() { } diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index a6499733..ede5165b 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -55,7 +55,7 @@ public: void Destroy(); int SelectServer(const SelectIn &in, SelectOut *out); void Describe(std::ostream &os, const DescribeOptions& options); - virtual bool SetParameters(const butil::StringPairs& parms); + virtual bool SetParameters(const butil::StringPairs& params); private: void Init(const std::string& name); From 7318bee38568f0da0fa8c2e394faf2afefc446e3 Mon Sep 17 00:00:00 2001 From: gejun Date: Fri, 14 Dec 2018 14:35:14 +0800 Subject: [PATCH 015/270] move all functions in stl_utils.h into namespace butil --- src/butil/stl_util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/butil/stl_util.h b/src/butil/stl_util.h index 4a98bbd6..19b638f4 100644 --- a/src/butil/stl_util.h +++ b/src/butil/stl_util.h @@ -15,6 +15,8 @@ #include "butil/logging.h" +namespace butil { + // Clears internal memory of an STL object. // STL clear()/reserve(0) does not always free internal memory allocated // This function uses swap/destructor to ensure the internal memory is freed. @@ -196,8 +198,6 @@ bool ContainsKey(const Collection& collection, const Key& key) { return collection.find(key) != collection.end(); } -namespace butil { - // Returns true if the container is sorted. template bool STLIsSorted(const Container& cont) { From 0f85acf83b4e71e38b00c5d17a0775ce50fa31e6 Mon Sep 17 00:00:00 2001 From: gejun Date: Fri, 14 Dec 2018 14:35:32 +0800 Subject: [PATCH 016/270] Move ScopedVector into namespace butil --- src/butil/memory/scoped_vector.h | 4 ++++ test/scoped_vector_unittest.cc | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/butil/memory/scoped_vector.h b/src/butil/memory/scoped_vector.h index 290887e0..f1a3474a 100644 --- a/src/butil/memory/scoped_vector.h +++ b/src/butil/memory/scoped_vector.h @@ -12,6 +12,8 @@ #include "butil/move.h" #include "butil/stl_util.h" +namespace butil { + // ScopedVector wraps a vector deleting the elements from its // destructor. template @@ -134,4 +136,6 @@ class ScopedVector { std::vector v_; }; +} // namespace butil + #endif // BUTIL_MEMORY_SCOPED_VECTOR_H_ diff --git a/test/scoped_vector_unittest.cc b/test/scoped_vector_unittest.cc index e5e78f54..80f325d2 100644 --- a/test/scoped_vector_unittest.cc +++ b/test/scoped_vector_unittest.cc @@ -113,7 +113,7 @@ TEST(ScopedVectorTest, LifeCycleWatcher) { TEST(ScopedVectorTest, PopBack) { LifeCycleWatcher watcher; EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); - ScopedVector scoped_vector; + butil::ScopedVector scoped_vector; scoped_vector.push_back(watcher.NewLifeCycleObject()); EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); @@ -125,7 +125,7 @@ TEST(ScopedVectorTest, PopBack) { TEST(ScopedVectorTest, Clear) { LifeCycleWatcher watcher; EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); - ScopedVector scoped_vector; + butil::ScopedVector scoped_vector; scoped_vector.push_back(watcher.NewLifeCycleObject()); EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); @@ -137,7 +137,7 @@ TEST(ScopedVectorTest, Clear) { TEST(ScopedVectorTest, WeakClear) { LifeCycleWatcher watcher; EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); - ScopedVector scoped_vector; + butil::ScopedVector scoped_vector; scoped_vector.push_back(watcher.NewLifeCycleObject()); EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); @@ -151,7 +151,7 @@ TEST(ScopedVectorTest, ResizeShrink) { EXPECT_EQ(LC_INITIAL, first_watcher.life_cycle_state()); LifeCycleWatcher second_watcher; EXPECT_EQ(LC_INITIAL, second_watcher.life_cycle_state()); - ScopedVector scoped_vector; + butil::ScopedVector scoped_vector; scoped_vector.push_back(first_watcher.NewLifeCycleObject()); EXPECT_EQ(LC_CONSTRUCTED, first_watcher.life_cycle_state()); @@ -176,7 +176,7 @@ TEST(ScopedVectorTest, ResizeShrink) { TEST(ScopedVectorTest, ResizeGrow) { LifeCycleWatcher watcher; EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); - ScopedVector scoped_vector; + butil::ScopedVector scoped_vector; scoped_vector.push_back(watcher.NewLifeCycleObject()); EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); @@ -195,7 +195,7 @@ TEST(ScopedVectorTest, Scope) { LifeCycleWatcher watcher; EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); { - ScopedVector scoped_vector; + butil::ScopedVector scoped_vector; scoped_vector.push_back(watcher.NewLifeCycleObject()); EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); @@ -207,12 +207,12 @@ TEST(ScopedVectorTest, MoveConstruct) { LifeCycleWatcher watcher; EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); { - ScopedVector scoped_vector; + butil::ScopedVector scoped_vector; scoped_vector.push_back(watcher.NewLifeCycleObject()); EXPECT_FALSE(scoped_vector.empty()); EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); - ScopedVector scoped_vector_copy(scoped_vector.Pass()); + butil::ScopedVector scoped_vector_copy(scoped_vector.Pass()); EXPECT_TRUE(scoped_vector.empty()); EXPECT_FALSE(scoped_vector_copy.empty()); EXPECT_TRUE(watcher.IsWatching(scoped_vector_copy.back())); @@ -226,9 +226,9 @@ TEST(ScopedVectorTest, MoveAssign) { LifeCycleWatcher watcher; EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); { - ScopedVector scoped_vector; + butil::ScopedVector scoped_vector; scoped_vector.push_back(watcher.NewLifeCycleObject()); - ScopedVector scoped_vector_assign; + butil::ScopedVector scoped_vector_assign; EXPECT_FALSE(scoped_vector.empty()); EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); @@ -261,18 +261,18 @@ class DeleteCounter { }; template -ScopedVector PassThru(ScopedVector scoper) { +butil::ScopedVector PassThru(butil::ScopedVector scoper) { return scoper.Pass(); } TEST(ScopedVectorTest, Passed) { int deletes = 0; - ScopedVector deleter_vector; + butil::ScopedVector deleter_vector; deleter_vector.push_back(new DeleteCounter(&deletes)); EXPECT_EQ(0, deletes); EXPECT_EQ(0, deletes); - ScopedVector result = deleter_vector.Pass(); + butil::ScopedVector result = deleter_vector.Pass(); EXPECT_EQ(0, deletes); result.clear(); EXPECT_EQ(1, deletes); @@ -290,7 +290,7 @@ TEST(ScopedVectorTest, InsertRange) { } // Start scope for ScopedVector. { - ScopedVector scoped_vector; + butil::ScopedVector scoped_vector; scoped_vector.insert(scoped_vector.end(), vec.begin() + 1, vec.begin() + 3); for(LifeCycleWatcher* it = watchers; it != watchers + arraysize(watchers); ++it) From be11fcdaf78a914e9414367c91570cc2d15058f3 Mon Sep 17 00:00:00 2001 From: cdjgit Date: Fri, 14 Dec 2018 18:41:38 +0800 Subject: [PATCH 017/270] add code comments && move brpc::policy::HashFunc to hasher.cpp --- src/brpc/load_balancer.h | 3 ++- src/brpc/policy/consistent_hashing_load_balancer.cpp | 2 +- src/brpc/policy/consistent_hashing_load_balancer.h | 1 - src/brpc/policy/hasher.cpp | 2 +- src/brpc/policy/hasher.h | 2 ++ test/brpc_load_balancer_unittest.cpp | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 467c2a1b..2f1026f1 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -104,7 +104,8 @@ public: // Caller is responsible for Destroy() the instance after usage. virtual LoadBalancer* New() const = 0; - // Set other + // Config user passed parameters to lb after constrction which + // make lb function more flexible. virtual bool SetParameters(const butil::StringPairs& params) { return true; } protected: diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index b3369d33..92cc6303 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -35,7 +35,7 @@ namespace { bool BuildReplicasDefault(const ServerId server, const size_t num_replicas, - ConsistentHashingLoadBalancer::HashFunc hash, + HashFunc hash, std::vector* replicas) { SocketUniquePtr ptr; if (Socket::AddressFailedAsWell(server.id, &ptr) == -1) { diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index ede5165b..0b03905e 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -43,7 +43,6 @@ public: return hash < code; } }; - using HashFunc = uint32_t(*)(const void*, size_t); using BuildReplicasFunc = std::function* replicas)>; explicit ConsistentHashingLoadBalancer(const char* name); diff --git a/src/brpc/policy/hasher.cpp b/src/brpc/policy/hasher.cpp index 8a9bee99..4898a349 100644 --- a/src/brpc/policy/hasher.cpp +++ b/src/brpc/policy/hasher.cpp @@ -155,7 +155,7 @@ uint32_t CRCHash32(const void* key, size_t len) { return ((~crc) >> 16) & 0x7fff; } -const char *GetHashName(uint32_t (*hasher)(const void* key, size_t len)) { +const char *GetHashName(HashFunc hasher) { if (hasher == MurmurHash32) { return "murmurhash3"; } diff --git a/src/brpc/policy/hasher.h b/src/brpc/policy/hasher.h index de9d39be..09f9c056 100644 --- a/src/brpc/policy/hasher.h +++ b/src/brpc/policy/hasher.h @@ -25,6 +25,8 @@ namespace brpc { namespace policy { +using HashFunc = uint32_t(*)(const void*, size_t); + void MD5HashSignature(const void* key, size_t len, unsigned char* results); uint32_t MD5Hash32(const void* key, size_t len); uint32_t MD5Hash32V(const butil::StringPiece* keys, size_t num_keys); diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 481fa1d4..f08a8c21 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -485,7 +485,7 @@ TEST_F(LoadBalancerTest, fairness) { } TEST_F(LoadBalancerTest, consistent_hashing) { - ::brpc::policy::ConsistentHashingLoadBalancer::HashFunc hashs[] = { + ::brpc::policy::HashFunc hashs[] = { ::brpc::policy::MurmurHash32, ::brpc::policy::MD5Hash32, ::brpc::policy::KetamaHash From 279b1d520e57f93ad751c4c427bb00861dcc0f17 Mon Sep 17 00:00:00 2001 From: PenINK Date: Sun, 16 Dec 2018 01:01:04 +0800 Subject: [PATCH 018/270] Update .bazelrc --- tools/bazel.rc => .bazelrc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/bazel.rc => .bazelrc (100%) diff --git a/tools/bazel.rc b/.bazelrc similarity index 100% rename from tools/bazel.rc rename to .bazelrc From 03ff7dab7996fa552b16d72e8400ad6abec74547 Mon Sep 17 00:00:00 2001 From: guofutan Date: Tue, 18 Dec 2018 18:42:29 +0800 Subject: [PATCH 019/270] fix code style in pb_to_json.cpp --- src/json2pb/pb_to_json.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/json2pb/pb_to_json.cpp b/src/json2pb/pb_to_json.cpp index c862d464..d19f3d0f 100644 --- a/src/json2pb/pb_to_json.cpp +++ b/src/json2pb/pb_to_json.cpp @@ -89,10 +89,10 @@ bool PbToJsonConverter::Convert(const google::protobuf::Message& message, Handle _error = "Missing required field: " + field->full_name(); return false; } - - if(!_option.always_print_primitive_fields) + // Whether dumps default fields + if (!_option.always_print_primitive_fields) { continue; - + } } else if (field->is_repeated() && reflection->FieldSize(message, field) == 0 && !_option.jsonify_empty_array) { From 98aeda6bd64b5b6648a8c0db41c374f7e8fd57df Mon Sep 17 00:00:00 2001 From: caidaojin Date: Wed, 19 Dec 2018 23:03:03 +0800 Subject: [PATCH 020/270] pass parameters string to lb SetParamters() --- src/brpc/load_balancer.cpp | 14 ++++++-------- src/brpc/load_balancer.h | 12 ++++++++++-- .../policy/consistent_hashing_load_balancer.cpp | 8 ++++++-- src/brpc/policy/consistent_hashing_load_balancer.h | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/brpc/load_balancer.cpp b/src/brpc/load_balancer.cpp index b48ca530..499f4ea1 100644 --- a/src/brpc/load_balancer.cpp +++ b/src/brpc/load_balancer.cpp @@ -64,7 +64,7 @@ SharedLoadBalancer::~SharedLoadBalancer() { int SharedLoadBalancer::Init(const char* lb_protocol) { std::string lb_name; - butil::StringPairs lb_params; + butil::StringPiece lb_params; if (!ParseParameters(lb_protocol, &lb_name, &lb_params)) { LOG(FATAL) << "Fail to parse this load balancer protocol '" << lb_protocol << '\''; return -1; @@ -101,22 +101,20 @@ void SharedLoadBalancer::Describe(std::ostream& os, bool SharedLoadBalancer::ParseParameters(const butil::StringPiece& lb_protocol, std::string* lb_name, - butil::StringPairs* lb_params) { + butil::StringPiece* lb_params) { lb_name->clear(); lb_params->clear(); if (lb_protocol.empty()) { return false; } - size_t pos = lb_protocol.find(':'); + const char separator = ':'; + size_t pos = lb_protocol.find(separator); if (pos == std::string::npos) { lb_name->append(lb_protocol.data(), lb_protocol.size()); } else { lb_name->append(lb_protocol.data(), pos); - butil::StringPiece params_piece = lb_protocol.substr(pos + sizeof(':')); - std::string params_str(params_piece.data(), params_piece.size()); - if (!butil::SplitStringIntoKeyValuePairs(params_str, '=', ' ', lb_params)) { - lb_params->clear(); - return false; + if (pos < lb_protocol.size() - sizeof(separator)) { + *lb_params = lb_protocol.substr(pos + sizeof(separator)); } } diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 2f1026f1..2f3be4cb 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -106,10 +106,18 @@ public: // Config user passed parameters to lb after constrction which // make lb function more flexible. - virtual bool SetParameters(const butil::StringPairs& params) { return true; } + virtual bool SetParameters(const butil::StringPiece& params) { return true; } protected: virtual ~LoadBalancer() { } + bool SplitParameters(const butil::StringPiece& params, butil::StringPairs* param_vec) { + std::string params_str(params.data(), params.size()); + if (!butil::SplitStringIntoKeyValuePairs(params_str, '=', ' ', param_vec)) { + param_vec->clear(); + return false; + } + return true; + } }; DECLARE_bool(show_lb_in_vars); @@ -172,7 +180,7 @@ public: private: static bool ParseParameters(const butil::StringPiece& lb_protocol, std::string* lb_name, - butil::StringPairs* lb_params); + butil::StringPiece* lb_params); static void DescribeLB(std::ostream& os, void* arg); void ExposeLB(); diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 92cc6303..58d9d39b 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -341,8 +341,12 @@ void ConsistentHashingLoadBalancer::GetLoads( } } -bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPairs& params) { - for (const std::pair& param : params) { +bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& params) { + butil::StringPairs param_vec; + if (!SplitParameters(params, ¶m_vec)) { + return false; + } + for (const std::pair& param : param_vec) { if (param.first == "replicas") { size_t replicas = 0; if (butil::StringToSizeT(param.second, &replicas)) { diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index 0b03905e..ebd2ce04 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -54,7 +54,7 @@ public: void Destroy(); int SelectServer(const SelectIn &in, SelectOut *out); void Describe(std::ostream &os, const DescribeOptions& options); - virtual bool SetParameters(const butil::StringPairs& params); + virtual bool SetParameters(const butil::StringPiece& params); private: void Init(const std::string& name); From 39c4d729d28b56c1fa1f28609d5461d413c3ddb1 Mon Sep 17 00:00:00 2001 From: caidaojin Date: Wed, 19 Dec 2018 23:06:07 +0800 Subject: [PATCH 021/270] little change --- src/brpc/load_balancer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 2f3be4cb..69b2e92b 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -110,7 +110,8 @@ public: protected: virtual ~LoadBalancer() { } - bool SplitParameters(const butil::StringPiece& params, butil::StringPairs* param_vec) { + static bool SplitParameters(const butil::StringPiece& params, + butil::StringPairs* param_vec) { std::string params_str(params.data(), params.size()); if (!butil::SplitStringIntoKeyValuePairs(params_str, '=', ' ', param_vec)) { param_vec->clear(); From c9c901b8664018aa89c4caa4918fc3348fef0c28 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sun, 13 Jan 2019 22:08:23 -0800 Subject: [PATCH 022/270] fix glog name problem in cmake --- CMakeLists.txt | 2 +- config.h.in | 2 +- src/brpc/builtin/vlog_service.cpp | 2 +- src/brpc/builtin/vlog_service.h | 6 +++--- src/brpc/server.cpp | 2 +- src/butil/logging.cc | 4 ++-- src/butil/logging.h | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4170c465..0732c66c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}") +set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DWITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}") set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\\\"${BRPC_REVISION}\\\" -D__STRICT_ANSI__") set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEBUG_SYMBOL} ${THRIFT_CPP_FLAG}") set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer") diff --git a/config.h.in b/config.h.in index 4810a7b1..42a6d7cc 100644 --- a/config.h.in +++ b/config.h.in @@ -1,6 +1,6 @@ #ifndef BUTIL_CONFIG_H #define BUTIL_CONFIG_H -#cmakedefine BRPC_WITH_GLOG @WITH_GLOG_VAL@ +#cmakedefine WITH_GLOG @WITH_GLOG_VAL@ #endif // BUTIL_CONFIG_H diff --git a/src/brpc/builtin/vlog_service.cpp b/src/brpc/builtin/vlog_service.cpp index 4959eef7..b6e1d7c0 100644 --- a/src/brpc/builtin/vlog_service.cpp +++ b/src/brpc/builtin/vlog_service.cpp @@ -14,7 +14,7 @@ // Authors: Ge,Jun (gejun@baidu.com) -#if !BRPC_WITH_GLOG +#if !WITH_GLOG #include "brpc/log.h" #include "brpc/controller.h" // Controller diff --git a/src/brpc/builtin/vlog_service.h b/src/brpc/builtin/vlog_service.h index c32fec0d..84f67a89 100644 --- a/src/brpc/builtin/vlog_service.h +++ b/src/brpc/builtin/vlog_service.h @@ -17,11 +17,11 @@ #ifndef BRPC_VLOG_SERVICE_H #define BRPC_VLOG_SERVICE_H -#if !BRPC_WITH_GLOG +#if !WITH_GLOG + #include #include "brpc/builtin_service.pb.h" - namespace brpc { class VLogService : public vlog { @@ -35,6 +35,6 @@ public: } // namespace brpc -#endif // BRPC_WITH_GLOG +#endif // WITH_GLOG #endif //BRPC_VLOG_SERVICE_H diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 051d18ac..4a1897a2 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -497,7 +497,7 @@ int Server::AddBuiltinServices() { return -1; } -#if !BRPC_WITH_GLOG +#if !WITH_GLOG if (AddBuiltinService(new (std::nothrow) VLogService)) { LOG(ERROR) << "Fail to add VLogService"; return -1; diff --git a/src/butil/logging.cc b/src/butil/logging.cc index b9e2b23d..537f4858 100644 --- a/src/butil/logging.cc +++ b/src/butil/logging.cc @@ -17,7 +17,7 @@ #include "butil/logging.h" -#if !BRPC_WITH_GLOG +#if !WITH_GLOG #if defined(OS_WIN) #include @@ -1440,4 +1440,4 @@ std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { return out << butil::WideToUTF8(std::wstring(wstr)); } -#endif // BRPC_WITH_GLOG +#endif // WITH_GLOG diff --git a/src/butil/logging.h b/src/butil/logging.h index 998ee95f..8ab78280 100644 --- a/src/butil/logging.h +++ b/src/butil/logging.h @@ -20,7 +20,7 @@ #ifndef BUTIL_LOGGING_H_ #define BUTIL_LOGGING_H_ -#include "butil/config.h" // BRPC_WITH_GLOG +#include "butil/config.h" // WITH_GLOG #include #include @@ -30,7 +30,7 @@ #include "butil/atomicops.h" // Used by LOG_EVERY_N, LOG_FIRST_N etc #include "butil/time.h" // gettimeofday_us() -#if BRPC_WITH_GLOG +#if WITH_GLOG # include # include // define macros that not implemented in glog @@ -1096,7 +1096,7 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { // 4 -- [default] LOG(ERROR) at runtime // 5 -- LOG(ERROR) at runtime, only once per call-site -#endif // BRPC_WITH_GLOG +#endif // WITH_GLOG #ifndef NOTIMPLEMENTED_POLICY #if defined(OS_ANDROID) && defined(OFFICIAL_BUILD) From 817a3530b37301d9c091670fd2af99813dc79092 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sun, 13 Jan 2019 22:40:26 -0800 Subject: [PATCH 023/270] revise WITH_GLOG TO BRPC_WITH_GLOG in CMakeLists.txt --- CMakeLists.txt | 10 +++++----- config.h.in | 2 +- src/brpc/builtin/vlog_service.cpp | 2 +- src/brpc/builtin/vlog_service.h | 4 ++-- src/brpc/server.cpp | 2 +- src/butil/logging.cc | 4 ++-- src/butil/logging.h | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0732c66c..c2803fa3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,14 +22,14 @@ else() message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.") endif() -option(WITH_GLOG "With glog" OFF) +option(BRPC_WITH_GLOG "With glog" OFF) option(DEBUG "Print debug logs" OFF) option(WITH_DEBUG_SYMBOLS "With debug symbols" ON) option(WITH_THRIFT "With thrift framed protocol supported" OFF) option(BUILD_UNIT_TESTS "Whether to build unit tests" OFF) set(WITH_GLOG_VAL "0") -if(WITH_GLOG) +if(BRPC_WITH_GLOG) set(WITH_GLOG_VAL "1") endif() @@ -80,7 +80,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DWITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}") +set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}") set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\\\"${BRPC_REVISION}\\\" -D__STRICT_ANSI__") set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEBUG_SYMBOL} ${THRIFT_CPP_FLAG}") set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer") @@ -121,7 +121,7 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) message(FATAL_ERROR "Fail to find leveldb") endif() -if(WITH_GLOG) +if(BRPC_WITH_GLOG) find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h) find_library(GLOG_LIB NAMES glog) if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB)) @@ -165,7 +165,7 @@ set(DYNAMIC_LIB ) set(BRPC_PRIVATE_LIBS "-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz") -if(WITH_GLOG) +if(BRPC_WITH_GLOG) set(DYNAMIC_LIB ${DYNAMIC_LIB} ${GLOG_LIB}) set(BRPC_PRIVATE_LIBS "${BRPC_PRIVATE_LIBS} -lglog") endif() diff --git a/config.h.in b/config.h.in index 42a6d7cc..4810a7b1 100644 --- a/config.h.in +++ b/config.h.in @@ -1,6 +1,6 @@ #ifndef BUTIL_CONFIG_H #define BUTIL_CONFIG_H -#cmakedefine WITH_GLOG @WITH_GLOG_VAL@ +#cmakedefine BRPC_WITH_GLOG @WITH_GLOG_VAL@ #endif // BUTIL_CONFIG_H diff --git a/src/brpc/builtin/vlog_service.cpp b/src/brpc/builtin/vlog_service.cpp index b6e1d7c0..0708cf44 100644 --- a/src/brpc/builtin/vlog_service.cpp +++ b/src/brpc/builtin/vlog_service.cpp @@ -14,7 +14,7 @@ // Authors: Ge,Jun (gejun@baidu.com) -#if !WITH_GLOG +#if !BRPC_WITH_GLOG #include "brpc/log.h" #include "brpc/controller.h" // Controller diff --git a/src/brpc/builtin/vlog_service.h b/src/brpc/builtin/vlog_service.h index 84f67a89..ece83f08 100644 --- a/src/brpc/builtin/vlog_service.h +++ b/src/brpc/builtin/vlog_service.h @@ -17,7 +17,7 @@ #ifndef BRPC_VLOG_SERVICE_H #define BRPC_VLOG_SERVICE_H -#if !WITH_GLOG +#if !BRPC_WITH_GLOG #include #include "brpc/builtin_service.pb.h" @@ -35,6 +35,6 @@ public: } // namespace brpc -#endif // WITH_GLOG +#endif // BRPC_WITH_GLOG #endif //BRPC_VLOG_SERVICE_H diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 4a1897a2..051d18ac 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -497,7 +497,7 @@ int Server::AddBuiltinServices() { return -1; } -#if !WITH_GLOG +#if !BRPC_WITH_GLOG if (AddBuiltinService(new (std::nothrow) VLogService)) { LOG(ERROR) << "Fail to add VLogService"; return -1; diff --git a/src/butil/logging.cc b/src/butil/logging.cc index 537f4858..b9e2b23d 100644 --- a/src/butil/logging.cc +++ b/src/butil/logging.cc @@ -17,7 +17,7 @@ #include "butil/logging.h" -#if !WITH_GLOG +#if !BRPC_WITH_GLOG #if defined(OS_WIN) #include @@ -1440,4 +1440,4 @@ std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { return out << butil::WideToUTF8(std::wstring(wstr)); } -#endif // WITH_GLOG +#endif // BRPC_WITH_GLOG diff --git a/src/butil/logging.h b/src/butil/logging.h index 8ab78280..998ee95f 100644 --- a/src/butil/logging.h +++ b/src/butil/logging.h @@ -20,7 +20,7 @@ #ifndef BUTIL_LOGGING_H_ #define BUTIL_LOGGING_H_ -#include "butil/config.h" // WITH_GLOG +#include "butil/config.h" // BRPC_WITH_GLOG #include #include @@ -30,7 +30,7 @@ #include "butil/atomicops.h" // Used by LOG_EVERY_N, LOG_FIRST_N etc #include "butil/time.h" // gettimeofday_us() -#if WITH_GLOG +#if BRPC_WITH_GLOG # include # include // define macros that not implemented in glog @@ -1096,7 +1096,7 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { // 4 -- [default] LOG(ERROR) at runtime // 5 -- LOG(ERROR) at runtime, only once per call-site -#endif // WITH_GLOG +#endif // BRPC_WITH_GLOG #ifndef NOTIMPLEMENTED_POLICY #if defined(OS_ANDROID) && defined(OFFICIAL_BUILD) From 6295344ddd4c44ce0027c9dc62e2cf62cc01f0eb Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sun, 13 Jan 2019 22:55:33 -0800 Subject: [PATCH 024/270] make config.h.in consistent with config_brpc.sh --- config.h.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.h.in b/config.h.in index 4810a7b1..58708ee5 100644 --- a/config.h.in +++ b/config.h.in @@ -1,6 +1,9 @@ #ifndef BUTIL_CONFIG_H #define BUTIL_CONFIG_H +#ifdef BRPC_WITH_GLOG +#undef BRPC_WITH_GLOG +#endif #cmakedefine BRPC_WITH_GLOG @WITH_GLOG_VAL@ #endif // BUTIL_CONFIG_H From 730656fe36a65a85b7f02252bf274c3a3a13fbcd Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sun, 13 Jan 2019 23:59:37 -0800 Subject: [PATCH 025/270] update cmake docs after fixing pull/620 --- docs/cn/getting_started.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index adfba489..2808eb93 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -84,7 +84,7 @@ To change compiler to clang, overwrite environment variable CC and CXX to clang To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller. -To use brpc with glog, add `-DWITH_GLOG=ON`. +To use brpc with glog, add `-DBRPC_WITH_GLOG=ON`. To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`. @@ -175,7 +175,7 @@ To change compiler to clang, overwrite environment variable CC and CXX to clang To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller. -To use brpc with glog, add `-DWITH_GLOG=ON`. +To use brpc with glog, add `-DBRPC_WITH_GLOG=ON`. To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`. @@ -249,7 +249,7 @@ To change compiler to clang, overwrite environment variable CC and CXX to clang To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller. -To use brpc with glog, add `-DWITH_GLOG=ON`. +To use brpc with glog, add `-DBRPC_WITH_GLOG=ON`. To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`. @@ -316,7 +316,7 @@ mkdir bld && cd bld && cmake .. && make To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller. -To use brpc with glog, add `-DWITH_GLOG=ON`. +To use brpc with glog, add `-DBRPC_WITH_GLOG=ON`. To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`. @@ -392,7 +392,7 @@ When you remove tcmalloc, not only remove the linkage with tcmalloc but also the ## glog: 3.3+ -brpc implements a default [logging utility](../../src/butil/logging.h) which conflicts with glog. To replace this with glog, add *--with-glog* to config_brpc.sh or add `-DWITH_GLOG=ON` to cmake. +brpc implements a default [logging utility](../../src/butil/logging.h) which conflicts with glog. To replace this with glog, add *--with-glog* to config_brpc.sh or add `-DBRPC_WITH_GLOG=ON` to cmake. ## valgrind: 3.8+ From 42de92b4e24a248ff0ee7f7e1526186af4a06251 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 14 Jan 2019 01:09:47 -0800 Subject: [PATCH 026/270] revert flag name of glog to WITH_GLOG in cmake --- CMakeLists.txt | 9 +++++---- docs/cn/getting_started.md | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2803fa3..44b9a2f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,15 +22,16 @@ else() message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.") endif() -option(BRPC_WITH_GLOG "With glog" OFF) +option(WITH_GLOG "With glog" OFF) option(DEBUG "Print debug logs" OFF) option(WITH_DEBUG_SYMBOLS "With debug symbols" ON) option(WITH_THRIFT "With thrift framed protocol supported" OFF) option(BUILD_UNIT_TESTS "Whether to build unit tests" OFF) set(WITH_GLOG_VAL "0") -if(BRPC_WITH_GLOG) +if(WITH_GLOG) set(WITH_GLOG_VAL "1") + set(BRPC_WITH_GLOG 1) endif() if(WITH_DEBUG_SYMBOLS) @@ -121,7 +122,7 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB)) message(FATAL_ERROR "Fail to find leveldb") endif() -if(BRPC_WITH_GLOG) +if(WITH_GLOG) find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h) find_library(GLOG_LIB NAMES glog) if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB)) @@ -165,7 +166,7 @@ set(DYNAMIC_LIB ) set(BRPC_PRIVATE_LIBS "-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz") -if(BRPC_WITH_GLOG) +if(WITH_GLOG) set(DYNAMIC_LIB ${DYNAMIC_LIB} ${GLOG_LIB}) set(BRPC_PRIVATE_LIBS "${BRPC_PRIVATE_LIBS} -lglog") endif() diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index 2808eb93..adfba489 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -84,7 +84,7 @@ To change compiler to clang, overwrite environment variable CC and CXX to clang To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller. -To use brpc with glog, add `-DBRPC_WITH_GLOG=ON`. +To use brpc with glog, add `-DWITH_GLOG=ON`. To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`. @@ -175,7 +175,7 @@ To change compiler to clang, overwrite environment variable CC and CXX to clang To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller. -To use brpc with glog, add `-DBRPC_WITH_GLOG=ON`. +To use brpc with glog, add `-DWITH_GLOG=ON`. To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`. @@ -249,7 +249,7 @@ To change compiler to clang, overwrite environment variable CC and CXX to clang To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller. -To use brpc with glog, add `-DBRPC_WITH_GLOG=ON`. +To use brpc with glog, add `-DWITH_GLOG=ON`. To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`. @@ -316,7 +316,7 @@ mkdir bld && cd bld && cmake .. && make To not link debugging symbols, use `cmake -DWITH_DEBUG_SYMBOLS=OFF ..` and compiled binaries will be much smaller. -To use brpc with glog, add `-DBRPC_WITH_GLOG=ON`. +To use brpc with glog, add `-DWITH_GLOG=ON`. To enable [thrift support](../en/thrift.md), install thrift first and add `-DWITH_THRIFT=ON`. @@ -392,7 +392,7 @@ When you remove tcmalloc, not only remove the linkage with tcmalloc but also the ## glog: 3.3+ -brpc implements a default [logging utility](../../src/butil/logging.h) which conflicts with glog. To replace this with glog, add *--with-glog* to config_brpc.sh or add `-DBRPC_WITH_GLOG=ON` to cmake. +brpc implements a default [logging utility](../../src/butil/logging.h) which conflicts with glog. To replace this with glog, add *--with-glog* to config_brpc.sh or add `-DWITH_GLOG=ON` to cmake. ## valgrind: 3.8+ From 9b5c24f68a8ad174b5449d0bb87604d5dc6117a3 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 14 Jan 2019 02:34:19 -0800 Subject: [PATCH 027/270] reduce sleep time in ns test to adapt to slow machine --- test/brpc_naming_service_unittest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/brpc_naming_service_unittest.cpp b/test/brpc_naming_service_unittest.cpp index fc2b9a29..478aec45 100644 --- a/test/brpc_naming_service_unittest.cpp +++ b/test/brpc_naming_service_unittest.cpp @@ -645,7 +645,7 @@ TEST(NamingServiceTest, discovery_sanity) { // svc.RenewCount() be one. ASSERT_EQ(0, dc.Register(dparam)); ASSERT_EQ(0, dc.Register(dparam)); - bthread_usleep(1000000); + bthread_usleep(100000); } ASSERT_EQ(svc.RenewCount(), 1); ASSERT_EQ(svc.CancelCount(), 1); From 301aac13f0cc9a41c4e96bb65c960fa3ca9f4ec0 Mon Sep 17 00:00:00 2001 From: dyike Date: Thu, 17 Jan 2019 17:52:01 +0800 Subject: [PATCH 028/270] fix discovery docancel request return error response --- src/brpc/policy/discovery_naming_service.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index f75896e5..7519f83a 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -365,6 +365,7 @@ int DiscoveryClient::DoCancel() const { Controller cntl; cntl.http_request().set_method(HTTP_METHOD_POST); cntl.http_request().uri() = "/discovery/cancel"; + cntl.http_request().set_content_type("application/x-www-form-urlencoded"); butil::IOBufBuilder os; os << "appid=" << _appid << "&hostname=" << _hostname From 0b0422c8ad6f19ee6a0d1094f4f4ba8bc27f17e8 Mon Sep 17 00:00:00 2001 From: Yiming Jing Date: Wed, 23 Jan 2019 14:45:37 -0800 Subject: [PATCH 029/270] build: add --with-mesalink to config_brpc.sh This commit adds an option "--with-mesalink" to config_brpc.sh, which enables MesaLink as a TLS backend instead of OpenSSL. --- config_brpc.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/config_brpc.sh b/config_brpc.sh index 72ae3134..3c980c44 100755 --- a/config_brpc.sh +++ b/config_brpc.sh @@ -21,9 +21,10 @@ else LDD=ldd fi -TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,nodebugsymbols -n 'config_brpc' -- "$@"` +TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-mesalink,nodebugsymbols -n 'config_brpc' -- "$@"` WITH_GLOG=0 WITH_THRIFT=0 +WITH_MESALINK=0 DEBUGSYMBOLS=-g if [ $? != 0 ] ; then >&2 $ECHO "Terminating..."; exit 1 ; fi @@ -46,6 +47,7 @@ while true; do --cxx ) CXX=$2; shift 2 ;; --with-glog ) WITH_GLOG=1; shift 1 ;; --with-thrift) WITH_THRIFT=1; shift 1 ;; + --with-mesalink) WITH_MESALINK=1; shift 1 ;; --nodebugsymbols ) DEBUGSYMBOLS=; shift 1 ;; -- ) shift; break ;; * ) break ;; @@ -137,8 +139,18 @@ find_dir_of_header_or_die() { #PTHREAD_HDR=$(find_dir_of_header_or_die pthread.h) OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h) +if [ $WITH_MESALINK != 0 ]; then + MESALINK_HDR=$(find_dir_of_header_or_die mesalink/openssl/ssl.h) + OPENSSL_HDR="$OPENSSL_HDR\n$MESALINK_HDR" +fi + STATIC_LINKINGS= DYNAMIC_LINKINGS="-lpthread -lssl -lcrypto -ldl -lz" + +if [ $WITH_MESALINK != 0 ]; then + DYNAMIC_LINKINGS="$DYNAMIC_LINKINGS -lmesalink" +fi + if [ "$SYSTEM" = "Linux" ]; then DYNAMIC_LINKINGS="$DYNAMIC_LINKINGS -lrt" fi @@ -304,6 +316,10 @@ if [ $WITH_THRIFT != 0 ]; then fi fi +if [ $WITH_MESALINK != 0 ]; then + CPPFLAGS="${CPPFLAGS} -DUSE_MESALINK" +fi + append_to_output "CPPFLAGS=${CPPFLAGS}" append_to_output "ifeq (\$(NEED_LIBPROTOC), 1)" From 7de7406c8064edda31846d632b7290c60f22d1eb Mon Sep 17 00:00:00 2001 From: Yiming Jing Date: Wed, 23 Jan 2019 14:48:22 -0800 Subject: [PATCH 030/270] tls: implement the MesaLink TLS backend This commit adds a new TLS backend in mesalink_ssl_helper.cpp. openssl/*.h are replaced with mesalink/openssl/*.h in some files. --- src/brpc/controller.h | 5 + src/brpc/details/mesalink_ssl_helper.cpp | 402 +++++++++++++++++++++++ src/brpc/details/ssl_helper.cpp | 5 + src/brpc/details/ssl_helper.h | 6 + src/brpc/global.cpp | 5 + src/brpc/socket.cpp | 7 +- src/butil/iobuf.cpp | 13 + src/butil/iobuf.h | 4 + 8 files changed, 446 insertions(+), 1 deletion(-) create mode 100644 src/brpc/details/mesalink_ssl_helper.cpp diff --git a/src/brpc/controller.h b/src/brpc/controller.h index ce12a5f3..2627b877 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -48,7 +48,12 @@ #endif extern "C" { +#ifndef USE_MESALINK struct x509_st; +#else +#include +#define x509_st X509 +#endif } namespace brpc { diff --git a/src/brpc/details/mesalink_ssl_helper.cpp b/src/brpc/details/mesalink_ssl_helper.cpp new file mode 100644 index 00000000..3c12fce6 --- /dev/null +++ b/src/brpc/details/mesalink_ssl_helper.cpp @@ -0,0 +1,402 @@ +// Copyright (c) 2019 Baidu, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Authors: Yiming Jing (jingyijming@baidu.com) + +#ifdef USE_MESALINK + +#include // recv +#include +#include +#include +#include +#include +#include +#include "butil/unique_ptr.h" +#include "butil/logging.h" +#include "butil/string_splitter.h" +#include "brpc/socket.h" +#include "brpc/ssl_options.h" +#include "brpc/details/ssl_helper.h" + +namespace brpc { + +static const char* const PEM_START = "-----BEGIN"; + +static bool IsPemString(const std::string& input) { + for (const char* s = input.c_str(); *s != '\0'; ++s) { + if (*s != '\n') { + return strncmp(s, PEM_START, strlen(PEM_START)) == 0; + } + } + return false; +} + +const char* SSLStateToString(SSLState s) { + switch (s) { + case SSL_UNKNOWN: + return "SSL_UNKNOWN"; + case SSL_OFF: + return "SSL_OFF"; + case SSL_CONNECTING: + return "SSL_CONNECTING"; + case SSL_CONNECTED: + return "SSL_CONNECTED"; + } + return "Bad SSLState"; +} + +static int ParseSSLProtocols(const std::string& str_protocol) { + int protocol_flag = 0; + butil::StringSplitter sp(str_protocol.data(), + str_protocol.data() + str_protocol.size(), ','); + for (; sp; ++sp) { + butil::StringPiece protocol(sp.field(), sp.length()); + protocol.trim_spaces(); + if (strncasecmp(protocol.data(), "SSLv3", protocol.size()) == 0) { + protocol_flag |= SSLv3; + } else if (strncasecmp(protocol.data(), "TLSv1", protocol.size()) == 0) { + protocol_flag |= TLSv1; + } else if (strncasecmp(protocol.data(), "TLSv1.1", protocol.size()) == 0) { + protocol_flag |= TLSv1_1; + } else if (strncasecmp(protocol.data(), "TLSv1.2", protocol.size()) == 0) { + protocol_flag |= TLSv1_2; + } else { + LOG(ERROR) << "Unknown SSL protocol=" << protocol; + return -1; + } + } + return protocol_flag; +} + +std::ostream& operator<<(std::ostream& os, const SSLError& ssl) { + char buf[128]; // Should be enough + ERR_error_string_n(ssl.error, buf, sizeof(buf)); + return os << buf; +} + +std::ostream& operator<<(std::ostream& os, const CertInfo& cert) { + os << "certificate["; + if (IsPemString(cert.certificate)) { + size_t pos = cert.certificate.find('\n'); + if (pos == std::string::npos) { + pos = 0; + } else { + pos++; + } + os << cert.certificate.substr(pos, 16) << "..."; + } else { + os << cert.certificate; + } + + os << "] private-key["; + if (IsPemString(cert.private_key)) { + size_t pos = cert.private_key.find('\n'); + if (pos == std::string::npos) { + pos = 0; + } else { + pos++; + } + os << cert.private_key.substr(pos, 16) << "..."; + } else { + os << cert.private_key; + } + os << "]"; + return os; +} + +void ExtractHostnames(X509* x, std::vector* hostnames) { + STACK_OF(X509_NAME)* names = (STACK_OF(X509_NAME)*) + X509_get_alt_subject_names(x); + if (names) { + for (int i = 0; i < sk_X509_NAME_num(names); i++) { + char buf[255] = {0}; + X509_NAME* name = sk_X509_NAME_value(names, i); + if (X509_NAME_oneline(name, buf, 255)) { + std::string hostname(buf); + hostnames->push_back(hostname); + } + } + sk_X509_NAME_free(names); + } +} + +struct FreeSSL { + inline void operator()(SSL* ssl) const { + if (ssl != NULL) { + SSL_free(ssl); + } + } +}; + +struct FreeBIO { + inline void operator()(BIO* io) const { + if (io != NULL) { + BIO_free(io); + } + } +}; + +struct FreeX509 { + inline void operator()(X509* x) const { + if (x != NULL) { + X509_free(x); + } + } +}; + +struct FreeEVPKEY { + inline void operator()(EVP_PKEY* k) const { + if (k != NULL) { + EVP_PKEY_free(k); + } + } +}; + +static int LoadCertificate(SSL_CTX* ctx, + const std::string& certificate, + const std::string& private_key, + std::vector* hostnames) { + // Load the private key + if (IsPemString(private_key)) { + std::unique_ptr kbio( + BIO_new_mem_buf((void*)private_key.c_str(), -1)); + std::unique_ptr key( + PEM_read_bio_PrivateKey(kbio.get(), NULL, 0, NULL)); + if (SSL_CTX_use_PrivateKey(ctx, key.get()) != 1) { + LOG(ERROR) << "Fail to load " << private_key << ": " + << SSLError(ERR_get_error()); + return -1; + } + } else { + if (SSL_CTX_use_PrivateKey_file( + ctx, private_key.c_str(), SSL_FILETYPE_PEM) != 1) { + LOG(ERROR) << "Fail to load " << private_key << ": " + << SSLError(ERR_get_error()); + return -1; + } + } + + // Open & Read certificate + std::unique_ptr cbio; + if (IsPemString(certificate)) { + cbio.reset(BIO_new_mem_buf((void*)certificate.c_str(), -1)); + } else { + cbio.reset(BIO_new(BIO_s_file())); + if (BIO_read_filename(cbio.get(), certificate.c_str()) <= 0) { + LOG(ERROR) << "Fail to read " << certificate << ": " + << SSLError(ERR_get_error()); + return -1; + } + } + std::unique_ptr x( + PEM_read_bio_X509(cbio.get(), NULL, 0, NULL)); + if (!x) { + LOG(ERROR) << "Fail to parse " << certificate << ": " + << SSLError(ERR_get_error()); + return -1; + } + + // Load the main certficate + if (SSL_CTX_use_certificate(ctx, x.get()) != 1) { + LOG(ERROR) << "Fail to load " << certificate << ": " + << SSLError(ERR_get_error()); + return -1; + } + + // Load the certificate chain + //SSL_CTX_clear_chain_certs(ctx); + X509* ca = NULL; + while ((ca = PEM_read_bio_X509(cbio.get(), NULL, 0, NULL))) { + if (SSL_CTX_add_extra_chain_cert(ctx, ca) != 1) { + LOG(ERROR) << "Fail to load chain certificate in " + << certificate << ": " << SSLError(ERR_get_error()); + X509_free(ca); + return -1; + } + } + ERR_clear_error(); + + // Validate certificate and private key + if (SSL_CTX_check_private_key(ctx) != 1) { + LOG(ERROR) << "Fail to verify " << private_key << ": " + << SSLError(ERR_get_error()); + return -1; + } + + return 0; +} + +static int SetSSLOptions(SSL_CTX* ctx, const std::string& ciphers, + int protocols, const VerifyOptions& verify) { + if (verify.verify_depth > 0) { + SSL_CTX_set_verify(ctx, (SSL_VERIFY_PEER + | SSL_VERIFY_FAIL_IF_NO_PEER_CERT), NULL); + std::string cafile = verify.ca_file_path; + if (!cafile.empty()) { + if (SSL_CTX_load_verify_locations(ctx, cafile.c_str(), NULL) == 0) { + LOG(ERROR) << "Fail to load CA file " << cafile + << ": " << SSLError(ERR_get_error()); + return -1; + } + } + } else { + SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); + } + + return 0; +} + +SSL_CTX* CreateClientSSLContext(const ChannelSSLOptions& options) { + std::unique_ptr ssl_ctx( + SSL_CTX_new(TLSv1_2_client_method())); + if (!ssl_ctx) { + LOG(ERROR) << "Fail to new SSL_CTX: " << SSLError(ERR_get_error()); + return NULL; + } + + if (!options.client_cert.certificate.empty() + && LoadCertificate(ssl_ctx.get(), + options.client_cert.certificate, + options.client_cert.private_key, NULL) != 0) { + return NULL; + } + + int protocols = ParseSSLProtocols(options.protocols); + if (protocols < 0 + || SetSSLOptions(ssl_ctx.get(), options.ciphers, + protocols, options.verify) != 0) { + return NULL; + } + + SSL_CTX_set_session_cache_mode(ssl_ctx.get(), SSL_SESS_CACHE_CLIENT); + return ssl_ctx.release(); +} + +SSL_CTX* CreateServerSSLContext(const std::string& certificate, + const std::string& private_key, + const ServerSSLOptions& options, + std::vector* hostnames) { + std::unique_ptr ssl_ctx( + SSL_CTX_new(TLSv1_2_server_method())); + if (!ssl_ctx) { + LOG(ERROR) << "Fail to new SSL_CTX: " << SSLError(ERR_get_error()); + return NULL; + } + + if (LoadCertificate(ssl_ctx.get(), certificate, + private_key, hostnames) != 0) { + return NULL; + } + + int protocols = TLSv1 | TLSv1_1 | TLSv1_2; + if (!options.disable_ssl3) { + protocols |= SSLv3; + } + if (SetSSLOptions(ssl_ctx.get(), options.ciphers, + protocols, options.verify) != 0) { + return NULL; + } + + /* SSL_CTX_set_timeout(ssl_ctx.get(), options.session_lifetime_s); */ + SSL_CTX_sess_set_cache_size(ssl_ctx.get(), options.session_cache_size); + + return ssl_ctx.release(); +} + +SSL* CreateSSLSession(SSL_CTX* ctx, SocketId id, int fd, bool server_mode) { + if (ctx == NULL) { + LOG(WARNING) << "Lack SSL_ctx to create an SSL session"; + return NULL; + } + SSL* ssl = SSL_new(ctx); + if (ssl == NULL) { + LOG(ERROR) << "Fail to SSL_new: " << SSLError(ERR_get_error()); + return NULL; + } + if (SSL_set_fd(ssl, fd) != 1) { + LOG(ERROR) << "Fail to SSL_set_fd: " << SSLError(ERR_get_error()); + SSL_free(ssl); + return NULL; + } + + if (server_mode) { + SSL_set_accept_state(ssl); + } else { + SSL_set_connect_state(ssl); + } + + return ssl; +} + +void AddBIOBuffer(SSL* ssl, int fd, int bufsize) { + // MesaLink uses buffered IO internally +} + +SSLState DetectSSLState(int fd, int* error_code) { + // Peek the first few bytes inside socket to detect whether + // it's an SSL connection. If it is, create an SSL session + // which will be used to read/write after + + // Header format of SSLv2 + // +-----------+------+----- + // | 2B header | 0x01 | etc. + // +-----------+------+----- + // The first bit of header is always 1, with the following + // 15 bits are the length of data + + // Header format of SSLv3 or TLSv1.0, 1.1, 1.2 + // +------+------------+-----------+------+----- + // | 0x16 | 2B version | 2B length | 0x01 | etc. + // +------+------------+-----------+------+----- + char header[6]; + const ssize_t nr = recv(fd, header, sizeof(header), MSG_PEEK); + if (nr < (ssize_t)sizeof(header)) { + if (nr < 0) { + if (errno == ENOTSOCK) { + return SSL_OFF; + } + *error_code = errno; // Including EAGAIN and EINTR + } else if (nr == 0) { // EOF + *error_code = 0; + } else { // Not enough data, need retry + *error_code = EAGAIN; + } + return SSL_UNKNOWN; + } + + if ((header[0] == 0x16 && header[5] == 0x01) // SSLv3 or TLSv1.0, 1.1, 1.2 + || ((header[0] & 0x80) == 0x80 && header[2] == 0x01)) { // SSLv2 + return SSL_CONNECTING; + } else { + return SSL_OFF; + } +} + +int SSLThreadInit() { + return 0; +} + +int SSLDHInit() { + return 0; +} + +void Print(std::ostream& os, SSL* ssl, const char* sep) { + os << "cipher=" << SSL_get_cipher_name(ssl) << sep + << "protocol=" << SSL_get_version(ssl) << sep; +} + +} // namespace brpc + +#endif // USE_MESALINK diff --git a/src/brpc/details/ssl_helper.cpp b/src/brpc/details/ssl_helper.cpp index 6415b0f6..5032258d 100644 --- a/src/brpc/details/ssl_helper.cpp +++ b/src/brpc/details/ssl_helper.cpp @@ -14,6 +14,9 @@ // Authors: Rujie Jiang (jiangrujie@baidu.com) + +#ifndef USE_MESALINK + #include // recv #include #include @@ -829,3 +832,5 @@ void Print(std::ostream& os, X509* cert, const char* sep) { } } // namespace brpc + +#endif // USE_MESALINK diff --git a/src/brpc/details/ssl_helper.h b/src/brpc/details/ssl_helper.h index e91b103d..793be7d2 100644 --- a/src/brpc/details/ssl_helper.h +++ b/src/brpc/details/ssl_helper.h @@ -18,9 +18,15 @@ #define BRPC_SSL_HELPER_H #include +#ifndef USE_MESALINK #include // For some versions of openssl, SSL_* are defined inside this header #include +#else +#include +#include +#include +#endif #include "brpc/socket_id.h" // SocketId #include "brpc/ssl_options.h" // ServerSSLOptions diff --git a/src/brpc/global.cpp b/src/brpc/global.cpp index 69574331..06bcd447 100755 --- a/src/brpc/global.cpp +++ b/src/brpc/global.cpp @@ -14,8 +14,13 @@ // Authors: Ge,Jun (gejun@baidu.com) +#ifndef USE_MESALINK #include #include +#else +#include +#endif + #include #include // O_RDONLY #include diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 68c56a18..616f66f1 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -19,6 +19,11 @@ #include "butil/compat.h" // OS_MACOSX #include #include +#ifdef USE_MESALINK +#include +#include +#include +#endif #include // getsockopt #include #include "bthread/unstable.h" // bthread_timer_del @@ -1834,7 +1839,7 @@ int Socket::SSLHandshake(int fd, bool server_mode) { LOG(ERROR) << "Fail to CreateSSLSession"; return -1; } -#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME +#if defined(SSL_CTRL_SET_TLSEXT_HOSTNAME) || defined(USE_MESALINK) if (!_ssl_ctx->sni_name.empty()) { SSL_set_tlsext_host_name(_ssl_session, _ssl_ctx->sni_name.c_str()); } diff --git a/src/butil/iobuf.cpp b/src/butil/iobuf.cpp index bb91c4ed..e82ba971 100644 --- a/src/butil/iobuf.cpp +++ b/src/butil/iobuf.cpp @@ -17,6 +17,10 @@ // Date: Thu Nov 22 13:57:56 CST 2012 #include // SSL_* +#ifdef USE_MESALINK +#include +#include +#endif #include // syscall #include // O_RDONLY #include // errno @@ -1033,6 +1037,7 @@ ssize_t IOBuf::cut_multiple_into_SSL_channel(SSL* ssl, IOBuf* const* pieces, } } +#ifndef USE_MESALINK // Flush remaining data inside the BIO buffer layer BIO* wbio = SSL_get_wbio(ssl); if (BIO_wpending(wbio) > 0) { @@ -1043,6 +1048,14 @@ ssize_t IOBuf::cut_multiple_into_SSL_channel(SSL* ssl, IOBuf* const* pieces, return rc; } } +#else + int rc = SSL_flush(ssl); + if (rc <= 0) { + *ssl_error = SSL_ERROR_SYSCALL; + return rc; + } +#endif + return nw; } diff --git a/src/butil/iobuf.h b/src/butil/iobuf.h index 93bff760..13474367 100644 --- a/src/butil/iobuf.h +++ b/src/butil/iobuf.h @@ -39,7 +39,11 @@ struct const_iovec { const void* iov_base; size_t iov_len; }; +#ifndef USE_MESALINK struct ssl_st; +#else +#define ssl_st MESALINK_SSL +#endif } namespace butil { From 1348c84270d314fa14e53a7858cbe9edc4ce73cb Mon Sep 17 00:00:00 2001 From: Yiming Jing Date: Wed, 23 Jan 2019 14:51:09 -0800 Subject: [PATCH 031/270] test: set SNI for the SSL unit tests MesaLink requires an SNI set in client session. This commit sets the SNI in the test cases. Note OpenSSL is not affected by this change. --- test/brpc_ssl_unittest.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/brpc_ssl_unittest.cpp b/test/brpc_ssl_unittest.cpp index fc9f25fb..65e3230b 100644 --- a/test/brpc_ssl_unittest.cpp +++ b/test/brpc_ssl_unittest.cpp @@ -109,6 +109,7 @@ TEST_F(SSLTest, sanity) { brpc::Channel channel; brpc::ChannelOptions coptions; coptions.mutable_ssl_options(); + coptions.mutable_ssl_options()->sni_name = "localhost"; ASSERT_EQ(0, channel.Init("localhost", port, &coptions)); brpc::Controller cntl; @@ -125,6 +126,7 @@ TEST_F(SSLTest, sanity) { brpc::Channel channel; brpc::ChannelOptions coptions; coptions.mutable_ssl_options(); + coptions.mutable_ssl_options()->sni_name = "localhost"; ASSERT_EQ(0, channel.Init("127.0.0.1", port, &coptions)); for (int i = 0; i < NUM; ++i) { google::protobuf::Closure* thrd_func = @@ -141,6 +143,7 @@ TEST_F(SSLTest, sanity) { brpc::ChannelOptions coptions; coptions.protocol = "http"; coptions.mutable_ssl_options(); + coptions.mutable_ssl_options()->sni_name = "localhost"; ASSERT_EQ(0, channel.Init("127.0.0.1", port, &coptions)); for (int i = 0; i < NUM; ++i) { google::protobuf::Closure* thrd_func = @@ -322,6 +325,7 @@ TEST_F(SSLTest, ssl_perf) { brpc::CreateServerSSLContext("cert1.crt", "cert1.key", brpc::SSLOptions(), NULL); SSL* cli_ssl = brpc::CreateSSLSession(cli_ctx, 0, clifd, false); + SSL_set_tlsext_host_name(cli_ssl, "localhost"); SSL* serv_ssl = brpc::CreateSSLSession(serv_ctx, 0, servfd, true); pthread_t cpid; pthread_t spid; From 1bdd8fa434e3a916f3ddae942d59ea8fc4776b26 Mon Sep 17 00:00:00 2001 From: Yiming Jing Date: Wed, 23 Jan 2019 15:30:14 -0800 Subject: [PATCH 032/270] travis: build and test the MesaLink TLS backend --- .travis.yml | 3 +++ build_in_travis_ci.sh | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 170c08b6..da947539 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ env: - PURPOSE=compile - PURPOSE=unittest - PURPOSE=compile-with-bazel +- PURPOSE=compile USE_MESALINK=yes +- PURPOSE=unittest USE_MESALINK=yes before_script: - ulimit -c unlimited -S # enable core dumps @@ -23,6 +25,7 @@ install: - sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgoogle-perftools-dev libboost-dev libssl-dev libevent-dev libboost-test-dev - sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo env "PATH=$PATH" cmake . && sudo make && sudo mv libgtest* /usr/lib/ && cd - - sudo apt-get install -y gdb # install gdb +- if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0-pre.tar.gz && tar -xf v0.8.0-pre.tar.gz && cd mesalink-0.8.0-pre && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi script: - if [[ "$PURPOSE" == "compile-with-bazel" ]]; then bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //... ; fi diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index b59f7f91..6e353090 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -21,8 +21,13 @@ runcmd(){ echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC" +EXTRA_BUILD_OPTS="" +if [ "$USE_MESALINK" = "yes" ]; then + EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" +fi + # The default env in travis-ci is Ubuntu. -if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC; then +if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS; then echo "Fail to configure brpc" exit 1 fi From d21e5cae96785cfbb8787d138aba76884860a2a5 Mon Sep 17 00:00:00 2001 From: Yiming Jing Date: Wed, 23 Jan 2019 14:53:48 -0800 Subject: [PATCH 033/270] test: rebuild test certs with 2048-bit RSA keys The previous test certificates use 1024-bit RSA keys and SHA-1 for signatures. They are somewhat deprecated. This commit updates the certificates with RSA-2048 and SHA-256. --- test/cert1.crt | 35 +++++++++++++++++++++++------------ test/cert1.key | 43 ++++++++++++++++++++++++++++--------------- test/cert2.crt | 35 +++++++++++++++++++++++------------ test/cert2.key | 43 ++++++++++++++++++++++++++++--------------- 4 files changed, 102 insertions(+), 54 deletions(-) diff --git a/test/cert1.crt b/test/cert1.crt index d0f6628a..1b0a939f 100644 --- a/test/cert1.crt +++ b/test/cert1.crt @@ -1,14 +1,25 @@ -----BEGIN CERTIFICATE----- -MIICOTCCAaICCQD6TiOx55+OsDANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJD -TjERMA8GA1UECAwIU2hhbmdoYWkxETAPBgNVBAcMCFNoYW5naGFpMQ4wDAYDVQQK -DAVCYWlkdTEMMAoGA1UECwwDQ0JVMQ4wDAYDVQQDDAVjZXJ0MTAeFw0xNjExMjgw -OTEzMzRaFw0yNjExMjYwOTEzMzRaMGExCzAJBgNVBAYTAkNOMREwDwYDVQQIDAhT -aGFuZ2hhaTERMA8GA1UEBwwIU2hhbmdoYWkxDjAMBgNVBAoMBUJhaWR1MQwwCgYD -VQQLDANDQlUxDjAMBgNVBAMMBWNlcnQxMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB -iQKBgQC8r8469OdZ+MeZiWBsV/7XlusjjnwKP2asmEepzkZXmxX1YEuXRuKkH7zJ -VTg1DCwgTnpCvd0Y1kJ9WOonB5433gnDR32fJ2lswmpFmh+yaZmcTn5MZmE1b4AM -QJ/BEXJcIiKWYMgqh6nw/N+eWymQzmZSC9R/JWgmee/kRRoaiQIDAQABMA0GCSqG -SIb3DQEBBQUAA4GBAGs1o7SkRa9YcDjcbZziNPLOdoZueACxtCLPn4/DZWOiFPku -PitB9UaGkiivKYKwmC1nnE2VyYcCIIGqIQ6GtagNPE6DAcd8TFviIHs6jnGhC7Y/ -ZEePLNpEx9HFkJiQzmH+mMfGftZFBwu9cF4Qa7DzCjMSb+s5qrT/WUXobEch +MIIENjCCAx6gAwIBAgIJAPpOI7Hnn46wMA0GCSqGSIb3DQEBCwUAMGExCzAJBgNV +BAYTAkNOMREwDwYDVQQIDAhTaGFuZ2hhaTERMA8GA1UEBwwIU2hhbmdoYWkxDjAM +BgNVBAoMBUJhaWR1MQwwCgYDVQQLDANDQlUxDjAMBgNVBAMMBWNlcnQxMB4XDTE5 +MDEyMzIyMTU0MVoXDTI5MDEyMDIyMTU0MVowYTELMAkGA1UEBhMCQ04xETAPBgNV +BAgMCFNoYW5naGFpMREwDwYDVQQHDAhTaGFuZ2hhaTEOMAwGA1UECgwFQmFpZHUx +DDAKBgNVBAsMA0NCVTEOMAwGA1UEAwwFY2VydDEwggEiMA0GCSqGSIb3DQEBAQUA +A4IBDwAwggEKAoIBAQC0ypYQmHvVlMaxe5phlUpvKNZrwQSrg/CGN6jrDkV8u7d4 +5pI6zcbA1g2fq1Q5EuwexeuWRPt/zSL6PYcOQjZcHIrQwXrilfjw6gOPhFUg54jN +Xzj8XqdZkZp/0qNksPROoeJMnNH+RMjWZox9WLdLAaC7t2R90OMzpBN675XMWGrj +XJo3ZgWkrv0AtiE7AGGed/gL+iybDwKhN9qftywt6TRqYUOsk2/j6PtWEKg9EfRk +rkdh0jQkpXeh+tk1nUtlnohFqhxz4XPN5+wHtmZinliSMWEXh6XaXyk6ojXdjPMy +vpWCxmHz9R9sNP7T/gHkN02pEXbZScGnoPmr635bAgMBAAGjgfAwge0wDAYDVR0T +AQH/BAIwADALBgNVHQ8EBAMCBsAwHQYDVR0OBBYEFAktYxDf0c02h0XkYdeGBtLd +pkuDMIGTBgNVHSMEgYswgYiAFAktYxDf0c02h0XkYdeGBtLdpkuDoWWkYzBhMQsw +CQYDVQQGEwJDTjERMA8GA1UECAwIU2hhbmdoYWkxETAPBgNVBAcMCFNoYW5naGFp +MQ4wDAYDVQQKDAVCYWlkdTEMMAoGA1UECwwDQ0JVMQ4wDAYDVQQDDAVjZXJ0MYIJ +APpOI7Hnn46wMBsGA1UdEQQUMBKCBWNlcnQxgglsb2NhbGhvc3QwDQYJKoZIhvcN +AQELBQADggEBAAN0NWqqAGpqmxBd5VcnCX26pt6WeY5i0XjTVpmrf18qz4JN4Zwo +yHELON9qCNradCNFOUD0kGNGokOSPw4HakQx6mRPwzAxkctI12nj/ArBhTYC+QEQ +WsYCu9rIr3TzT5mz2LpTC1RA+HVkvC7uB1ROc+rl88n1Tuyy2mwj5PbteE3Lpnif +dYgPrU3PM6AVs+1wV1tMUc+DH5UYEaVR7VbN54yiMe4mjwCmsrrC/Y22WgxTBqwG +Z7+YjHT6p2MvRlJ2a0kwb15X492iC1KeBsb/NomWO40WTFTxL0zxk8XEnjwcRPs0 +rT3UGBMRPbGDV6fnbf5r3cuOcv7qlHf+7xM= -----END CERTIFICATE----- diff --git a/test/cert1.key b/test/cert1.key index 4abc4951..0c5f6323 100644 --- a/test/cert1.key +++ b/test/cert1.key @@ -1,15 +1,28 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXAIBAAKBgQC8r8469OdZ+MeZiWBsV/7XlusjjnwKP2asmEepzkZXmxX1YEuX -RuKkH7zJVTg1DCwgTnpCvd0Y1kJ9WOonB5433gnDR32fJ2lswmpFmh+yaZmcTn5M -ZmE1b4AMQJ/BEXJcIiKWYMgqh6nw/N+eWymQzmZSC9R/JWgmee/kRRoaiQIDAQAB -AoGAEaGr975iz/l7TVGU/QrL+YFUv6HU3XBHO+GO8MMht5X6W0+AQMaS7xs4HOgl -tG9KwEoVCp+LRYLf+66PUs5Xbl/qSYnrGz4r+H/Fv1xf1PjUFwlHyLW8dkh4kibq -jQ2W9zrEjkZi+MhkYBAMvczAjmunI+ZehIDyQJ3SJnN5qrECQQDkYYyPGGmrqMWY -B6dZdB78JN03ip9PLljV9MqoAR2NUlFhLLlwSkLN8lrAwQ2XxvfhbDdaRnx8z6x/ -E0sG3lfbAkEA04FcKr2db2lspwfb3WFx9S/cdiTrkGCtPXVovrbit0p6tm9hv8gD -rSC+WQNmZXs2QzFNdm2eWrowEdI4XCjGawJAQ/MOKgkeb5eAatJkJUZabbTeKMdS -zPFCNy5lGYVzcHe8hMgUyGcf5zyjadRGohDt8aEL+w0bvtrfPNPVr855nwJBAM2g -D14SOJRPV23QSyYgja0FGf3WiRo1k1eT5QC9Rw9RnpntEYhlSYWwtr5NeuigcDHF -Jf1EN1cXepJo4Zhfn/8CQDgRvF9tesalPfRMQTP+OitLQw60ngMaOCXgr9cevWU0 -iPiToCki18hVQtM5pWt/83K0B2NLYbluoOXNKBkEQvA= ------END RSA PRIVATE KEY----- +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC0ypYQmHvVlMax +e5phlUpvKNZrwQSrg/CGN6jrDkV8u7d45pI6zcbA1g2fq1Q5EuwexeuWRPt/zSL6 +PYcOQjZcHIrQwXrilfjw6gOPhFUg54jNXzj8XqdZkZp/0qNksPROoeJMnNH+RMjW +Zox9WLdLAaC7t2R90OMzpBN675XMWGrjXJo3ZgWkrv0AtiE7AGGed/gL+iybDwKh +N9qftywt6TRqYUOsk2/j6PtWEKg9EfRkrkdh0jQkpXeh+tk1nUtlnohFqhxz4XPN +5+wHtmZinliSMWEXh6XaXyk6ojXdjPMyvpWCxmHz9R9sNP7T/gHkN02pEXbZScGn +oPmr635bAgMBAAECggEAC5d5q7K7LeSOIM8WBO+3iA0MQnhrvjuFbnWfJQMTPX4j +s2LFOXP8LF0NHpGzor0t2oNCKa5emcEjXvwW7rkcFyfVVrExGdoXzgqTE96ePq/Z +u6FBXB0NidamG0/8Hfaik3AZvGPJqw3p+qU0mMzZY7vE/IQzs0Vza9o3TYiTCDj/ +WBMEaNLRMymK8Ejyoj7Dm90Tr0TN9PRNBl24KAVOuxYhqajFJV8SkVITXD8ujOt8 +JnpeLnteYsi2Du9cOmu90hc0kRvwQGn4j++T25FvESITz490/7ZEfMG59jTzF0be ++TJjhqMJ6AcUp5/DtKWhcBYvxhVrOowO3dV0DFLU0QKBgQDtoR+Hut8ZPWZynTSQ +m7k8lvmLFa+l0nIMSEEciInQSKgZLWeDRrIR9F7GyFhmBRf2u2V4uK0P/g8bhj73 +D91KdYXImPqGapCkvTBed0UzSVE236i4rnBO3/e+2Oux806a9sqXvSqENj/OjSVE +de5wrV1y0IH4s9ukwsqZhPnBxwKBgQDCxJeyW+tS4LglY2Qk1kR5ELZhfMe11Mg4 +Gqeh1oJcuXV0cVfj2MS8li/gGBrIuzQL62plk7o6j6ybPxraXNObNMF3ZnisEbWj +cykgcQyD+HRuPT1xwH/+dHs7mLtuk/p19e4ZPy1wn41PAC2fDHbEKdYWDAdujUl5 +BEEe2xoezQKBgQDGyQq/WKxZSOvy5V+buSl0bjfDChkt9qZBcBBH9lCTVLSKm1kE +kJdWPb8rO133ujsZxBpWqubbggTRWbRCqZrNNxL7hD3PREZMCZf07oGNLcAqz18t +X3/D+8gcdwp0ir0vFVTVKwHuKBOojpqmcqFM0TpjWdngW1VatzkUxBDK8QKBgQCm +jY0Xlekvr0Fpn4vkwGI/kR4VUapKgNJSv+B30cMa3fFmCQLaseTTTC9Wl+ZXn1aL +lt4eTOzk5TX6cEVbVCQURlHm8/bfVimYw4L43hOQyydtmerwWmhZxWwYc6xcjCiT +NSJN7qvB8n7ZftKEfxkU+J29rr2wORwKY6v4Ye79RQKBgBMxrOmLnCfXgt/Mzm3Q +LGwXjmsC7O4wgmQBhkpimXOOVwRW4KFpkODfAk6vb/rMeKkhg1h18oFlxHduN/kw +5BNDnDDdZgOV8dUTjFAJEJsuOi3B8rLsC2TEmIwZN1wmqDPcHCwPP4+ttqDsalzL +wV+3rZ8xTyFAVZmTokIPMlqE +-----END PRIVATE KEY----- diff --git a/test/cert2.crt b/test/cert2.crt index cc9763ec..ec4ad359 100644 --- a/test/cert2.crt +++ b/test/cert2.crt @@ -1,14 +1,25 @@ -----BEGIN CERTIFICATE----- -MIICOTCCAaICCQDwZoNAUJYKizANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJD -TjERMA8GA1UECAwIU2hhbmdoYWkxETAPBgNVBAcMCFNoYW5naGFpMQ4wDAYDVQQK -DAVCYWlkdTEMMAoGA1UECwwDQ0JVMQ4wDAYDVQQDDAVjZXJ0MjAeFw0xNjExMjgw -OTE2MDRaFw0yNjExMjYwOTE2MDRaMGExCzAJBgNVBAYTAkNOMREwDwYDVQQIDAhT -aGFuZ2hhaTERMA8GA1UEBwwIU2hhbmdoYWkxDjAMBgNVBAoMBUJhaWR1MQwwCgYD -VQQLDANDQlUxDjAMBgNVBAMMBWNlcnQyMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB -iQKBgQDB37VXm4I4apWHysL77GX6ohqLaGxhZ6fnl7qGVqpCe4c5+jMLDKRagNmV -dDFObjDFnchZ5qM0lbW21jp5v1gxz9C/j6X7Hsl/HO6hS09B1I/Q3UhTjKKsnZSY -WRcUF/t9YVWtzEDKtKgTcLBQrotxzh9qP/GliHbTLsojvmsVgQIDAQABMA0GCSqG -SIb3DQEBBQUAA4GBAA1Y17J13GE7gvfGPz5fKkD1eQUFtiR0JGltaU64neuzYG4C -R+tlnngtzpJf1bcNqITcSwCiEqrkccIbYTCXfHpV1G2w/7Ce13dTOZwsViI2tJWt -8dWCAHcRvQXRqWm9G8TWwx8hDJJT8U2O71FNkIvqEBSkY0mLgfHXj5cnh0WQ +MIIENjCCAx6gAwIBAgIJAPBmg0BQlgqLMA0GCSqGSIb3DQEBCwUAMGExCzAJBgNV +BAYTAkNOMREwDwYDVQQIDAhTaGFuZ2hhaTERMA8GA1UEBwwIU2hhbmdoYWkxDjAM +BgNVBAoMBUJhaWR1MQwwCgYDVQQLDANDQlUxDjAMBgNVBAMMBWNlcnQyMB4XDTE5 +MDEyMzIyMTU0MVoXDTI5MDEyMDIyMTU0MVowYTELMAkGA1UEBhMCQ04xETAPBgNV +BAgMCFNoYW5naGFpMREwDwYDVQQHDAhTaGFuZ2hhaTEOMAwGA1UECgwFQmFpZHUx +DDAKBgNVBAsMA0NCVTEOMAwGA1UEAwwFY2VydDIwggEiMA0GCSqGSIb3DQEBAQUA +A4IBDwAwggEKAoIBAQCcbPV5j9eex7cnAsUMMreZ9H76yUgp1Y54gR3TqSELYjtu +XwudIKVQGawPcoFIysvapDBXSj6LgEWVXSqs8bVSUW7lmraSKGJ+wIXmZFHvweaY +7rXpSma357i0do5VLvIZS9ZRN40SAS6EaSqgpvD3ISeT4xHaiQ/XtKLc/dCSmNSd +tXsH/CHvcGxEH78i+n2lNjHnabZ+aLTnEQ59R2wDPqymHb2j9gz3QMlM50m7vK83 +v42lhObPQ/JZBs/0taWv6GbFIMYVLwUiCmIb7ecJk1/k3gBo6VYQ5tnnyhcUdTvv +sWv94KuUU8OmPzJLSo6nKXSE63cIgTOGDR1YmqhNAgMBAAGjgfAwge0wDAYDVR0T +AQH/BAIwADALBgNVHQ8EBAMCBsAwHQYDVR0OBBYEFOuA5h9dbBrkxeUiH7cSNxV5 +ygP0MIGTBgNVHSMEgYswgYiAFOuA5h9dbBrkxeUiH7cSNxV5ygP0oWWkYzBhMQsw +CQYDVQQGEwJDTjERMA8GA1UECAwIU2hhbmdoYWkxETAPBgNVBAcMCFNoYW5naGFp +MQ4wDAYDVQQKDAVCYWlkdTEMMAoGA1UECwwDQ0JVMQ4wDAYDVQQDDAVjZXJ0MoIJ +APBmg0BQlgqLMBsGA1UdEQQUMBKCBWNlcnQygglsb2NhbGhvc3QwDQYJKoZIhvcN +AQELBQADggEBAGlEgAyI0R/phfGbdbMdF2WtcbflZrs1wsX4y2zUcmKJt7CkAED/ +tj33gHh0qg3eWADUQ3AZ5iCalY86NcKsDoIT2mJn7oO6ejovGOnjQbF53HhY7MIy +1xqGu3MYWc8XuuqnvSqS//sokEVqIm9bAnZaY32cjsrHqZcYCPZbMqSOwqSnz3Ia +fDMw21GOVtgWIXrRFVykTZ9nzey16EB21ry9gci89+1sy5bz0fhXUG1XFguXj8zH +clAzL1mzjYQ1SWMzMmCX7GiiwjkNkiTr6grGQCDBTaIg5E1firkJm3GFJRXmZKSZ +FYR32SX4H3vj6cHf2iu7ilN5t9EQ60KPQ+k= -----END CERTIFICATE----- diff --git a/test/cert2.key b/test/cert2.key index c7e71a14..ef4c6254 100644 --- a/test/cert2.key +++ b/test/cert2.key @@ -1,15 +1,28 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXgIBAAKBgQDB37VXm4I4apWHysL77GX6ohqLaGxhZ6fnl7qGVqpCe4c5+jML -DKRagNmVdDFObjDFnchZ5qM0lbW21jp5v1gxz9C/j6X7Hsl/HO6hS09B1I/Q3UhT -jKKsnZSYWRcUF/t9YVWtzEDKtKgTcLBQrotxzh9qP/GliHbTLsojvmsVgQIDAQAB -AoGBAKodxB+lYrRiQecvcbxgiHNN/oDJFiC6NciviIoMTcWcYuHquxM8+pI3cbUE -iadKZR1h/8Vy7U5c92ABxrnBvn4epy1hKm9N1oidb+wSGLcaV+9YGzuNIQeqXmM5 -26IUjzQsObULM2cp/AianzrlkBL2j7kH/A3a4shdrtj4P1OBAkEA8UiCwAEMPIGY -nDMr6JeNBHkkBQcoY5kuuW902qTCI5M8g6canNsjYEA0Im8YvHsz+9K2YhdIj8F7 -KZtM5mkWCQJBAM2y7eYJhZmKaCwhLGLrO+QLoJ7DOzPg/JAUKWDEhEs1uSUPqTwg -ghAOynyP6wHxXLIaD9BC88zWoM26IVxLIbkCQQCcHMFUP5lOML+wGL/JHv1Drqmq -gyYTwxHjMwUVTlK6N9KIj/79DCBIb2IMAXusv74zqfMNZmkxcgshMXVBAy8ZAkBM -1NuVQ9M6IX99lDp/DDxHlqw9ANE5NH1B17YI5f5AFWX9WNculTnfg5bQZfUyuZOV -FrT3ZjqoNTbFARP65DlJAkEAtlBLITLqHdq2C4jzHLjXm9vRe2Fsz759ywDy1RCk -2f54B9uUFjzaHl5Z8WVpO6loVBcOu685ROCwfMVW1HRWzA== ------END RSA PRIVATE KEY----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCcbPV5j9eex7cn +AsUMMreZ9H76yUgp1Y54gR3TqSELYjtuXwudIKVQGawPcoFIysvapDBXSj6LgEWV +XSqs8bVSUW7lmraSKGJ+wIXmZFHvweaY7rXpSma357i0do5VLvIZS9ZRN40SAS6E +aSqgpvD3ISeT4xHaiQ/XtKLc/dCSmNSdtXsH/CHvcGxEH78i+n2lNjHnabZ+aLTn +EQ59R2wDPqymHb2j9gz3QMlM50m7vK83v42lhObPQ/JZBs/0taWv6GbFIMYVLwUi +CmIb7ecJk1/k3gBo6VYQ5tnnyhcUdTvvsWv94KuUU8OmPzJLSo6nKXSE63cIgTOG +DR1YmqhNAgMBAAECggEAHPp+e1evfUXIY1y6/miC5O2LfJA/Yyih7ScWTHjfm0lG +c0r+TsyWc4FeA7qVwtN28nlKT1F8xsErouEQn9tjWO2nGrgPrIH4xTyLUcQx/bWx +L5HBd4eGAfnWmPABrDw3M4J+IKum4bgAUx1cfUiQCWhF+bquOwr7OV3IciI/Onj1 +fXBOn98EamJD5SoQwV0WOqWE2grj3bXQd04sHYfYjCb0C3uDqKa3YGyCIB5axK8s +SBMnQ0tEKlgF7GY4i9OXXq//wLIEMM23rby5k5oJxPlFvN1MCnQOShHSrK2cprtl +1KhZxkL/xXJr8NhMumfDgTEKmpQyPpssWRiYKA1GwQKBgQDIzrLPI1NlYxgRUjGN +PsILc6c3jj73wW7NEPUyLAGkmA4GRhkXusC+pNlO1baEUPm7wWVEo7qndG8rsWjC +nDjCxiVY/5rGYBchwXZUKEh9nowMmDcfwhXb+zJf45aj+jA72pOrMTYGHQ/X/xzj +aVFyABhcUStcM3ts0CvmQnWZkQKBgQDHa3LYbBQI9DLGXfPjwqfUJEen7xypbdlI +UkoXqJa5kMZqpspoIHHMxOa9Rcbhu/E2qCXLypkQ9CPyWzNBPHu499F3kHob5xFt +A6qxnHG+ilGYSd4qej/HIPvAU4TVP6yfwyyBALCB5/wYSRDxT6Zfv3OGvaIaj+qT +qBdLW3Gk/QKBgEGrFt6WdtdZKK3Ba2L9ewezsqOAaScsosd9HDJkIcVp1GxI0Dvq +Xs35qvcU/LMYqBK2lB92S7wnX5OyWMgLvqQzmFMag8sL8YSgd8ndwpcSGkqkHKLO +HcfqxfaFvuWxE8T/HfuGBFzLdDr2usPD1VaqoUzPXpawX1SeXzzVzw+BAoGAQktz +K4WKh4t/EbkMKkx89KZ299oi4iR1lnhcz06phNkfTTdTlJgsnNFcj9GRk1uijfQK +VJxulFdFV/1/pZFQ5CXmieQK5BnGDkKozVDf82MSSxlLdT2c1Dsf1kktoKMBZT9C +HUS4aQdRJFWt/zrmaXBBHKsQJ9puNlYsIE4vEpUCgYEAvN1sBXbt/8R8ELvOrhQv +HO136LtI/KRPpxXRRdBFj//ijwfMchUfChGVk4P0fYXyUA8tF19DJ3GbqtmObYV4 +TFYli0z1xDN3Pwo+55Kxwx42Ir7GHmevvNa+RitQYePZVsdLGxY+azh11/5bOZ14 +ZkVDf9Glu7bDIwn1wz4HpFw= +-----END PRIVATE KEY----- From e9bfdeb2507ae109ecec75c60b91a57694b03f8a Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 25 Jan 2019 00:19:56 +0800 Subject: [PATCH 034/270] improve the readability of code --- src/butil/object_pool_inl.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/butil/object_pool_inl.h b/src/butil/object_pool_inl.h index 2e95b82c..c8b323d5 100644 --- a/src/butil/object_pool_inl.h +++ b/src/butil/object_pool_inl.h @@ -222,7 +222,7 @@ public: inline T* get_object() { LocalPool* lp = get_or_new_local_pool(); - if (__builtin_expect(lp != NULL, 1)) { + if (BAIDU_LIKELY(lp != NULL)) { return lp->get(); } return NULL; @@ -231,7 +231,7 @@ public: template inline T* get_object(const A1& arg1) { LocalPool* lp = get_or_new_local_pool(); - if (__builtin_expect(lp != NULL, 1)) { + if (BAIDU_LIKELY(lp != NULL)) { return lp->get(arg1); } return NULL; @@ -240,7 +240,7 @@ public: template inline T* get_object(const A1& arg1, const A2& arg2) { LocalPool* lp = get_or_new_local_pool(); - if (__builtin_expect(lp != NULL, 1)) { + if (BAIDU_LIKELY(lp != NULL)) { return lp->get(arg1, arg2); } return NULL; @@ -248,7 +248,7 @@ public: inline int return_object(T* ptr) { LocalPool* lp = get_or_new_local_pool(); - if (__builtin_expect(lp != NULL, 1)) { + if (BAIDU_LIKELY(lp != NULL)) { return lp->return_object(ptr); } return -1; @@ -378,7 +378,7 @@ private: inline LocalPool* get_or_new_local_pool() { LocalPool* lp = _local_pool; - if (__builtin_expect(lp != NULL, 1)) { + if (BAIDU_LIKELY(lp != NULL)) { return lp; } lp = new(std::nothrow) LocalPool(this); From ae0df7fe0c8dd0e838b4e70d9cf7dacce4d77a88 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 24 Jan 2019 23:32:38 -0800 Subject: [PATCH 035/270] fix h2 big response not sending bug --- src/brpc/policy/http2_rpc_protocol.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index b43b5994..1eb74854 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -1672,8 +1672,15 @@ H2UnsentResponse::AppendAndDestroySelf(butil::IOBuf* out, Socket* socket) { // NOTE: Currently the stream context is definitely removed and updating // window size is useless, however it's not true when progressive request // is supported. + // TODO(zhujiashun): Instead of just returning error to client, a better + // solution to handle not enough window size is to wait until WINDOW_UPDATE + // is received, and then retry those failed response again. if (!MinusWindowSize(&ctx->_remote_window_left, _data.size())) { - return butil::Status(ELIMIT, "Remote window size is not enough"); + char rstbuf[FRAME_HEAD_SIZE + 4]; + SerializeFrameHead(rstbuf, 4, H2_FRAME_RST_STREAM, 0, _stream_id); + SaveUint32(rstbuf + FRAME_HEAD_SIZE, H2_FLOW_CONTROL_ERROR); + out->append(rstbuf, sizeof(rstbuf)); + return butil::Status::OK(); } HPacker& hpacker = ctx->hpacker(); From c4908ae7698188bf2c0781b93b96ede9fb528a42 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 25 Jan 2019 00:16:43 -0800 Subject: [PATCH 036/270] fix a leak when sending h2 req --- src/brpc/policy/http2_rpc_protocol.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index 1eb74854..93ed17db 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -1522,18 +1522,9 @@ H2UnsentRequest::AppendAndDestroySelf(butil::IOBuf* out, Socket* socket) { << " h2req=" << (StreamUserData*)this; return butil::Status(EH2RUNOUTSTREAMS, "Fail to allocate stream_id"); } - H2StreamContext* sctx = _sctx.release(); - sctx->Init(ctx, id); - const int rc = ctx->TryToInsertStream(id, sctx); - if (rc < 0) { - delete sctx; - return butil::Status(EINTERNAL, "Fail to insert existing stream_id"); - } else if (rc > 0) { - delete sctx; - return butil::Status(ELOGOFF, "the connection just issued GOAWAY"); - } - _stream_id = sctx->stream_id(); + std::unique_ptr sctx(std::move(_sctx)); + sctx->Init(ctx, id); // flow control if (!_cntl->request_attachment().empty()) { const int64_t data_size = _cntl->request_attachment().size(); @@ -1542,6 +1533,16 @@ H2UnsentRequest::AppendAndDestroySelf(butil::IOBuf* out, Socket* socket) { } } + const int rc = ctx->TryToInsertStream(id, sctx.get()); + if (rc < 0) { + return butil::Status(EINTERNAL, "Fail to insert existing stream_id"); + } else if (rc > 0) { + return butil::Status(ELOGOFF, "the connection just issued GOAWAY"); + } + _stream_id = sctx->stream_id(); + // After calling TryToInsertStream, ownership of sctx is transferred to ctx + sctx.release(); + HPacker& hpacker = ctx->hpacker(); butil::IOBufAppender appender; HPackOptions options; From e1d1d9af685fd0d0f0661eac892d8ed9a78155e2 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 25 Jan 2019 00:23:13 -0800 Subject: [PATCH 037/270] optimize impl --- src/brpc/policy/http2_rpc_protocol.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index 93ed17db..d0e1e25e 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -1523,25 +1523,24 @@ H2UnsentRequest::AppendAndDestroySelf(butil::IOBuf* out, Socket* socket) { return butil::Status(EH2RUNOUTSTREAMS, "Fail to allocate stream_id"); } - std::unique_ptr sctx(std::move(_sctx)); - sctx->Init(ctx, id); + _sctx->Init(ctx, id); // flow control if (!_cntl->request_attachment().empty()) { const int64_t data_size = _cntl->request_attachment().size(); - if (!sctx->ConsumeWindowSize(data_size)) { + if (!_sctx->ConsumeWindowSize(data_size)) { return butil::Status(ELIMIT, "remote_window_left is not enough, data_size=%" PRId64, data_size); } } - const int rc = ctx->TryToInsertStream(id, sctx.get()); + const int rc = ctx->TryToInsertStream(id, _sctx.get()); if (rc < 0) { return butil::Status(EINTERNAL, "Fail to insert existing stream_id"); } else if (rc > 0) { return butil::Status(ELOGOFF, "the connection just issued GOAWAY"); } - _stream_id = sctx->stream_id(); - // After calling TryToInsertStream, ownership of sctx is transferred to ctx - sctx.release(); + _stream_id = _sctx->stream_id(); + // After calling TryToInsertStream, the ownership of _sctx is transferred to ctx + _sctx.release(); HPacker& hpacker = ctx->hpacker(); butil::IOBufAppender appender; From 655cc536e09f7788c76b22ffcaed18a12d135f50 Mon Sep 17 00:00:00 2001 From: ericliu Date: Sat, 26 Jan 2019 12:14:01 +0800 Subject: [PATCH 038/270] fix a typo --- src/bthread/task_control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bthread/task_control.h b/src/bthread/task_control.h index 46dbd53f..83c0c995 100644 --- a/src/bthread/task_control.h +++ b/src/bthread/task_control.h @@ -68,7 +68,7 @@ public: int64_t get_cumulated_signal_count(); // [Not thread safe] Add more worker threads. - // Return the number of workers actually added, which may be less then |num| + // Return the number of workers actually added, which may be less than |num| int add_workers(int num); // Choose one TaskGroup (randomly right now). From ad0196a9b6f1549cde62a721bcb535ded90b11ce Mon Sep 17 00:00:00 2001 From: Yiming Jing Date: Sun, 27 Jan 2019 13:38:03 -0800 Subject: [PATCH 039/270] travis: use MesaLink the 0.8.0 release --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index da947539..87a183b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ install: - sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgoogle-perftools-dev libboost-dev libssl-dev libevent-dev libboost-test-dev - sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo env "PATH=$PATH" cmake . && sudo make && sudo mv libgtest* /usr/lib/ && cd - - sudo apt-get install -y gdb # install gdb -- if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0-pre.tar.gz && tar -xf v0.8.0-pre.tar.gz && cd mesalink-0.8.0-pre && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi +- if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0.tar.gz && tar -xf v0.8.0.tar.gz && cd mesalink-0.8.0 && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi script: - if [[ "$PURPOSE" == "compile-with-bazel" ]]; then bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //... ; fi From d0589fbb13536abfddbf5296e24d22c44249f942 Mon Sep 17 00:00:00 2001 From: Yiming Jing Date: Mon, 28 Jan 2019 12:47:53 -0800 Subject: [PATCH 040/270] test: set SNI only when SSL_CTRL_SET_TLSEXT_HOSTNAME or USE_MESALINK is defined --- test/brpc_ssl_unittest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/brpc_ssl_unittest.cpp b/test/brpc_ssl_unittest.cpp index 65e3230b..1be6e416 100644 --- a/test/brpc_ssl_unittest.cpp +++ b/test/brpc_ssl_unittest.cpp @@ -325,7 +325,9 @@ TEST_F(SSLTest, ssl_perf) { brpc::CreateServerSSLContext("cert1.crt", "cert1.key", brpc::SSLOptions(), NULL); SSL* cli_ssl = brpc::CreateSSLSession(cli_ctx, 0, clifd, false); +#if defined(SSL_CTRL_SET_TLSEXT_HOSTNAME) || defined(USE_MESALINK) SSL_set_tlsext_host_name(cli_ssl, "localhost"); +#endif SSL* serv_ssl = brpc::CreateSSLSession(serv_ctx, 0, servfd, true); pthread_t cpid; pthread_t spid; From 8b74f72aaae71ced856afb5dcbb7f38f100e3cdf Mon Sep 17 00:00:00 2001 From: Ge Jun Date: Tue, 29 Jan 2019 12:12:21 +0800 Subject: [PATCH 041/270] fix typo --- docs/cn/threading_overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cn/threading_overview.md b/docs/cn/threading_overview.md index 6dd7b21d..8d494dde 100644 --- a/docs/cn/threading_overview.md +++ b/docs/cn/threading_overview.md @@ -28,7 +28,7 @@ ## M:N线程库 -即把M个用户线程映射入N个系统线程。M:N线程库可以决定一段代码何时开始在哪运行,并何时结束,相比多线程reactor在调度上具备更多的灵活度。但实现全功能的M:N线程库是困难的,它一直是个活跃的研究话题。我们这里说的M:N线程库特别针对编写网络服务,在这一前提下一些需求可以简化,比如没有时间片抢占,没有(完备的)优先级等。M:N线程库可以在用户态也可以在内核中实现,用户态的实现以新语言为主,比如GHC threads和goroutine,这些语言可以围绕线程库设计全新的关键字并拦截所有相关的API。而在现有语言中的实现往往得修改内核,比如[Windows UMS](https://msdn.microsoft.com/en-us/library/windows/desktop/dd627187(v=vs.85).aspx)和google SwicthTo(虽然是1:1,但基于它可以实现M:N的效果)。相比N:1线程库,M:N线程库在使用上更类似于系统线程,需要用锁或消息传递保证代码的线程安全。 +即把M个用户线程映射入N个系统线程。M:N线程库可以决定一段代码何时开始在哪运行,并何时结束,相比多线程reactor在调度上具备更多的灵活度。但实现全功能的M:N线程库是困难的,它一直是个活跃的研究话题。我们这里说的M:N线程库特别针对编写网络服务,在这一前提下一些需求可以简化,比如没有时间片抢占,没有(完备的)优先级等。M:N线程库可以在用户态也可以在内核中实现,用户态的实现以新语言为主,比如GHC threads和goroutine,这些语言可以围绕线程库设计全新的关键字并拦截所有相关的API。而在现有语言中的实现往往得修改内核,比如[Windows UMS](https://msdn.microsoft.com/en-us/library/windows/desktop/dd627187(v=vs.85).aspx)和google SwitchTo(虽然是1:1,但基于它可以实现M:N的效果)。相比N:1线程库,M:N线程库在使用上更类似于系统线程,需要用锁或消息传递保证代码的线程安全。 # 问题 From 476818df8a8c4cf35a4b6ee56cd233dc55837cce Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 29 Jan 2019 19:36:44 +0800 Subject: [PATCH 042/270] bugfix to prevent accessing to reclaimed task --- src/bthread/timer_thread.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bthread/timer_thread.cpp b/src/bthread/timer_thread.cpp index ec779186..51add8c7 100644 --- a/src/bthread/timer_thread.cpp +++ b/src/bthread/timer_thread.cpp @@ -348,12 +348,17 @@ void TimerThread::run() { // Pull tasks from buckets. for (size_t i = 0; i < _options.num_buckets; ++i) { Bucket& bucket = _buckets[i]; - for (Task* p = bucket.consume_tasks(); p != NULL; - p = p->next, ++nscheduled) { + Task* next_task = nullptr; + for (Task* p = bucket.consume_tasks(); p != nullptr; ++nscheduled) { + // p->next should be kept first + // in case of the deletion of Task p which is unscheduled + next_task = p->next; + if (!p->try_delete()) { // remove the task if it's unscheduled tasks.push_back(p); std::push_heap(tasks.begin(), tasks.end(), task_greater); } + p = next_task; } } From 61b7959bc39b5858e1a12818a8b3f5939fe43c91 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 29 Jan 2019 20:38:02 +0800 Subject: [PATCH 043/270] bugfix to prevent accessing the reclaimed task --- src/bthread/timer_thread.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bthread/timer_thread.cpp b/src/bthread/timer_thread.cpp index 51add8c7..1a5ff35f 100644 --- a/src/bthread/timer_thread.cpp +++ b/src/bthread/timer_thread.cpp @@ -348,11 +348,10 @@ void TimerThread::run() { // Pull tasks from buckets. for (size_t i = 0; i < _options.num_buckets; ++i) { Bucket& bucket = _buckets[i]; - Task* next_task = nullptr; for (Task* p = bucket.consume_tasks(); p != nullptr; ++nscheduled) { // p->next should be kept first // in case of the deletion of Task p which is unscheduled - next_task = p->next; + Task* next_task = p->next; if (!p->try_delete()) { // remove the task if it's unscheduled tasks.push_back(p); From d27251dc21c9de16db3d3274a05bda2720eecae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=A3=8A?= Date: Wed, 13 Feb 2019 20:23:15 +0800 Subject: [PATCH 044/270] Fix acquire tls block --- src/butil/iobuf.cpp | 12 ++++++++---- test/iobuf_unittest.cpp | 30 +++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/butil/iobuf.cpp b/src/butil/iobuf.cpp index e82ba971..2219ff8b 100644 --- a/src/butil/iobuf.cpp +++ b/src/butil/iobuf.cpp @@ -282,10 +282,14 @@ IOBuf::Block* get_portal_next(IOBuf::Block const* b) { return b->portal_next; } -uint32_t block_cap(IOBuf::Block const *b) { +uint32_t block_cap(IOBuf::Block const* b) { return b->cap; } +uint32_t block_size(IOBuf::Block const* b) { + return b->size; +} + inline IOBuf::Block* create_block(const size_t block_size) { if (block_size > 0xFFFFFFFFULL) { LOG(FATAL) << "block_size=" << block_size << " is too large"; @@ -417,7 +421,7 @@ inline void release_tls_block(IOBuf::Block *b) { // Return chained blocks to TLS. // NOTE: b MUST be non-NULL and all blocks linked SHOULD not be full. -inline void release_tls_block_chain(IOBuf::Block* b) { +void release_tls_block_chain(IOBuf::Block* b) { TLSData& tls_data = g_tls_data; size_t n = 0; if (tls_data.num_blocks >= MAX_BLOCKS_PER_THREAD) { @@ -451,13 +455,13 @@ inline void release_tls_block_chain(IOBuf::Block* b) { } // Get and remove one (non-full) block from TLS. If TLS is empty, create one. -inline IOBuf::Block* acquire_tls_block() { +IOBuf::Block* acquire_tls_block() { TLSData& tls_data = g_tls_data; IOBuf::Block* b = tls_data.block_head; if (!b) { return create_block(); } - if (b->full()) { + while (b->full()) { IOBuf::Block* const saved_next = b->portal_next; b->dec_ref(); tls_data.block_head = saved_next; diff --git a/test/iobuf_unittest.cpp b/test/iobuf_unittest.cpp index a57cad69..61d9dfb0 100644 --- a/test/iobuf_unittest.cpp +++ b/test/iobuf_unittest.cpp @@ -33,7 +33,11 @@ extern uint32_t block_cap(butil::IOBuf::Block const* b); extern IOBuf::Block* get_tls_block_head(); extern int get_tls_block_count(); extern void remove_tls_block_chain(); -IOBuf::Block* get_portal_next(IOBuf::Block const* b); +extern IOBuf::Block* acquire_tls_block(); +extern void release_tls_block_chain(IOBuf::Block* b); +extern uint32_t block_cap(IOBuf::Block const* b); +extern uint32_t block_size(IOBuf::Block const* b); +extern IOBuf::Block* get_portal_next(IOBuf::Block const* b); } } @@ -1639,4 +1643,28 @@ TEST_F(IOBufTest, append_user_data_and_share) { ASSERT_EQ(data, my_free_params); } +TEST_F(IOBufTest, acquire_tls_block) { + butil::iobuf::remove_tls_block_chain(); + butil::IOBuf::Block* b = butil::iobuf::acquire_tls_block(); + const size_t block_cap = butil::iobuf::block_cap(b); + butil::IOBuf buf; + for (size_t i = 0; i < block_cap; i++) { + buf.append("x"); + } + ASSERT_EQ(1, butil::iobuf::get_tls_block_count()); + butil::IOBuf::Block* head = butil::iobuf::get_tls_block_head(); + ASSERT_EQ(butil::iobuf::block_cap(head), butil::iobuf::block_size(head)); + butil::iobuf::release_tls_block_chain(b); + ASSERT_EQ(2, butil::iobuf::get_tls_block_count()); + for (size_t i = 0; i < block_cap; i++) { + buf.append("x"); + } + ASSERT_EQ(2, butil::iobuf::get_tls_block_count()); + head = butil::iobuf::get_tls_block_head(); + ASSERT_EQ(butil::iobuf::block_cap(head), butil::iobuf::block_size(head)); + b = butil::iobuf::acquire_tls_block(); + ASSERT_EQ(0, butil::iobuf::get_tls_block_count()); + ASSERT_NE(butil::iobuf::block_cap(b), butil::iobuf::block_size(b)); +} + } // namespace From 55e39400f01f2af5bb86998aacdcfcba0c06bcc1 Mon Sep 17 00:00:00 2001 From: Cholerae Hu Date: Thu, 14 Feb 2019 11:19:19 +0800 Subject: [PATCH 045/270] fix googletest compile commands on macos --- docs/cn/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index adfba489..8b1bca07 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -276,7 +276,7 @@ brew install gperftools If you need to run tests, install and compile googletest (which is not compiled yet): ```shell -git clone https://github.com/google/googletest && cd googletest/googletest && mkdir bld && cd bld && cmake .. && make && sudo mv libgtest* /usr/lib/ && cd - +git clone https://github.com/google/googletest && cd googletest/googletest && mkdir bld && cd bld && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make && sudo mv libgtest* /usr/lib/ && cd - ``` ### Compile brpc with config_brpc.sh From 16e57f2b40b5467820b7ef7a435d1b54affb8f13 Mon Sep 17 00:00:00 2001 From: Zhangyi Chen Date: Thu, 14 Feb 2019 11:27:16 +0800 Subject: [PATCH 046/270] Some tiny fixes: - Fix the bug that when command line is too large - Add weak symbol annotation to RunOnValgrind to avoid conflicts with absel --- src/butil/process_util.cc | 3 +-- .../third_party/dynamic_annotations/dynamic_annotations.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/butil/process_util.cc b/src/butil/process_util.cc index c89fa7a9..a2dbfa19 100644 --- a/src/butil/process_util.cc +++ b/src/butil/process_util.cc @@ -59,8 +59,7 @@ ssize_t ReadCommandLine(char* buf, size_t len, bool with_args) { if (with_args) { if ((size_t)nr == len) { - LOG(ERROR) << "buf is not big enough"; - return -1; + return len; } for (ssize_t i = 0; i < nr; ++i) { if (buf[i] == '\0') { diff --git a/src/butil/third_party/dynamic_annotations/dynamic_annotations.c b/src/butil/third_party/dynamic_annotations/dynamic_annotations.c index 50a6e7a2..5589c793 100644 --- a/src/butil/third_party/dynamic_annotations/dynamic_annotations.c +++ b/src/butil/third_party/dynamic_annotations/dynamic_annotations.c @@ -255,7 +255,7 @@ static int GetRunningOnValgrind(void) { } /* See the comments in dynamic_annotations.h */ -int RunningOnValgrind(void) { +int DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK RunningOnValgrind(void) { static volatile int running_on_valgrind = -1; /* C doesn't have thread-safe initialization of statics, and we don't want to depend on pthread_once here, so hack it. */ From d10dce1cd09dbf06bba57776dcefc88d76d94b1b Mon Sep 17 00:00:00 2001 From: Zhangyi Chen Date: Thu, 14 Feb 2019 14:42:38 +0800 Subject: [PATCH 047/270] Fix the issue that weak annotation didn't work --- src/butil/third_party/dynamic_annotations/dynamic_annotations.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/butil/third_party/dynamic_annotations/dynamic_annotations.c b/src/butil/third_party/dynamic_annotations/dynamic_annotations.c index 5589c793..199bbcab 100644 --- a/src/butil/third_party/dynamic_annotations/dynamic_annotations.c +++ b/src/butil/third_party/dynamic_annotations/dynamic_annotations.c @@ -255,7 +255,7 @@ static int GetRunningOnValgrind(void) { } /* See the comments in dynamic_annotations.h */ -int DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK RunningOnValgrind(void) { +int __attribute__((weak)) RunningOnValgrind(void) { static volatile int running_on_valgrind = -1; /* C doesn't have thread-safe initialization of statics, and we don't want to depend on pthread_once here, so hack it. */ From 43b1af7228512f73c20be25e85411baebb940b15 Mon Sep 17 00:00:00 2001 From: Cholerae Hu Date: Thu, 14 Feb 2019 14:05:13 +0800 Subject: [PATCH 048/270] mutex: throw system_error when constuctor failed and lock failed Signed-off-by: Cholerae Hu --- src/bthread/mutex.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/bthread/mutex.h b/src/bthread/mutex.h index a1941aa1..a1c8ec00 100644 --- a/src/bthread/mutex.h +++ b/src/bthread/mutex.h @@ -42,10 +42,20 @@ namespace bthread { class Mutex { public: typedef bthread_mutex_t* native_handler_type; - Mutex() { CHECK_EQ(0, bthread_mutex_init(&_mutex, NULL)); } + Mutex() { + int ec = bthread_mutex_init(&_mutex, NULL); + if (ec != 0) { + throw std::system_error(std::error_code(ec, std::system_category()), "Mutex constructor failed"); + } + } ~Mutex() { CHECK_EQ(0, bthread_mutex_destroy(&_mutex)); } native_handler_type native_handler() { return &_mutex; } - void lock() { bthread_mutex_lock(&_mutex); } + void lock() { + int ec = bthread_mutex_lock(&_mutex); + if (ec != 0) { + throw std::system_error(std::error_code(ec, std::system_category()), "Mutex lock failed"); + } + } void unlock() { bthread_mutex_unlock(&_mutex); } bool try_lock() { return !bthread_mutex_trylock(&_mutex); } // TODO(chenzhangyi01): Complement interfaces for C++11 From ea654154ba2386bf4bd48ddc926723cdfa2f25ab Mon Sep 17 00:00:00 2001 From: Zhiting Zhu Date: Thu, 14 Feb 2019 21:43:51 -0600 Subject: [PATCH 049/270] use cpack to generate deb package --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44b9a2f8..7f221dc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,10 @@ endif() set(BRPC_VERSION 0.9.0) +SET(CPACK_GENERATOR "DEB") +SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "brpc authors") +INCLUDE(CPack) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # require at least gcc 4.8 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) From f4e791b403a76f5b08f5aa0389a21955eedd0b71 Mon Sep 17 00:00:00 2001 From: Mengmeng Yang Date: Sat, 16 Feb 2019 16:08:40 +0800 Subject: [PATCH 050/270] fix rtt display in connection page --- src/brpc/builtin/connections_service.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/brpc/builtin/connections_service.cpp b/src/brpc/builtin/connections_service.cpp index 48548aeb..a81c81f1 100644 --- a/src/brpc/builtin/connections_service.cpp +++ b/src/brpc/builtin/connections_service.cpp @@ -255,12 +255,16 @@ void ConnectionsService::PrintConnections( socklen_t len = sizeof(ti); if (0 == getsockopt(rttfd, SOL_TCP, TCP_INFO, &ti, &len)) { got_rtt = true; + srtt = ti.tcpi_rtt; + rtt_var = ti.tcpi_rttvar; } #elif defined(OS_MACOSX) struct tcp_connection_info ti; socklen_t len = sizeof(ti); if (0 == getsockopt(rttfd, IPPROTO_TCP, TCP_CONNECTION_INFO, &ti, &len)) { got_rtt = true; + srtt = ti.tcpi_srtt; + rtt_var = ti.tcpi_rttvar; } #endif char rtt_display[32]; From 483294e3cc9799301828879d9907340634561db9 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 18 Feb 2019 17:14:55 +0800 Subject: [PATCH 051/270] fix the comment --- src/butil/resource_pool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/butil/resource_pool.h b/src/butil/resource_pool.h index 0d2cb3ae..5b51c150 100644 --- a/src/butil/resource_pool.h +++ b/src/butil/resource_pool.h @@ -75,7 +75,7 @@ template struct ResourcePoolFreeChunkMaxItem { // ResourcePool calls this function on newly constructed objects. If this // function returns false, the object is destructed immediately and -// get_object() shall return NULL. This is useful when the constructor +// get_resource() shall return NULL. This is useful when the constructor // failed internally(namely ENOMEM). template struct ResourcePoolValidator { static bool validate(const T*) { return true; } From 86c95f3e5c2125382459869a57523d15d42e7853 Mon Sep 17 00:00:00 2001 From: LorinLee Date: Mon, 18 Feb 2019 23:46:58 +0800 Subject: [PATCH 052/270] Fix redis parse --- src/brpc/policy/redis_protocol.cpp | 5 ++- src/brpc/redis.cpp | 16 ++++---- src/brpc/redis.h | 7 +++- src/brpc/redis_reply.cpp | 65 +++++++++++++++++------------- src/brpc/redis_reply.h | 19 +++++---- 5 files changed, 65 insertions(+), 47 deletions(-) diff --git a/src/brpc/policy/redis_protocol.cpp b/src/brpc/policy/redis_protocol.cpp index eae52add..0df56fee 100644 --- a/src/brpc/policy/redis_protocol.cpp +++ b/src/brpc/policy/redis_protocol.cpp @@ -79,9 +79,10 @@ ParseResult ParseRedisMessage(butil::IOBuf* source, Socket* socket, const int consume_count = (pi.with_auth ? 1 : pi.count); - if (!msg->response.ConsumePartialIOBuf(*source, consume_count)) { + ParseError err = msg->response.ConsumePartialIOBuf(*source, consume_count); + if (err != PARSE_OK) { socket->GivebackPipelinedInfo(pi); - return MakeParseError(PARSE_ERROR_NOT_ENOUGH_DATA); + return MakeParseError(err); } if (pi.with_auth) { diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp index 0fe0701e..c4ff4c5a 100644 --- a/src/brpc/redis.cpp +++ b/src/brpc/redis.cpp @@ -515,11 +515,12 @@ void RedisResponse::Swap(RedisResponse* other) { // =================================================================== -bool RedisResponse::ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count) { +ParseError RedisResponse::ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count) { size_t oldsize = buf.size(); if (reply_size() == 0) { - if (!_first_reply.ConsumePartialIOBuf(buf, &_arena)) { - return false; + ParseError err = _first_reply.ConsumePartialIOBuf(buf, &_arena); + if (err != PARSE_OK) { + return err; } const size_t newsize = buf.size(); _cached_size_ += oldsize - newsize; @@ -532,15 +533,16 @@ bool RedisResponse::ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count) { sizeof(RedisReply) * (reply_count - 1)); if (_other_replies == NULL) { LOG(ERROR) << "Fail to allocate RedisReply[" << reply_count -1 << "]"; - return false; + return PARSE_ERROR_ABSOLUTELY_WRONG; } for (int i = 0; i < reply_count - 1; ++i) { new (&_other_replies[i]) RedisReply; } } for (int i = reply_size(); i < reply_count; ++i) { - if (!_other_replies[i - 1].ConsumePartialIOBuf(buf, &_arena)) { - return false; + ParseError err = _other_replies[i - 1].ConsumePartialIOBuf(buf, &_arena); + if (err != PARSE_OK) { + return err; } const size_t newsize = buf.size(); _cached_size_ += oldsize - newsize; @@ -548,7 +550,7 @@ bool RedisResponse::ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count) { ++_nreply; } } - return true; + return PARSE_OK; } std::ostream& operator<<(std::ostream& os, const RedisResponse& response) { diff --git a/src/brpc/redis.h b/src/brpc/redis.h index f9e5a9de..d70af0a8 100644 --- a/src/brpc/redis.h +++ b/src/brpc/redis.h @@ -30,6 +30,7 @@ #include "butil/strings/string_piece.h" #include "butil/arena.h" #include "redis_reply.h" +#include "parse_result.h" namespace brpc { @@ -177,8 +178,10 @@ public: } // Parse and consume intact replies from the buf. - // Returns true on success, false otherwise. - bool ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count); + // Returns PARSE_OK on success. + // Returns PARSE_ERROR_NOT_ENOUGH_DATA if data in `buf' is not enough to parse. + // Returns PARSE_ERROR_ABSOLUTELY_WRONG if the parsing failed. + ParseError ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count); // implements Message ---------------------------------------------- diff --git a/src/brpc/redis_reply.cpp b/src/brpc/redis_reply.cpp index 7adf990e..504e3033 100644 --- a/src/brpc/redis_reply.cpp +++ b/src/brpc/redis_reply.cpp @@ -34,26 +34,27 @@ const char* RedisReplyTypeToString(RedisReplyType type) { } } -bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { +ParseError RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { if (_type == REDIS_REPLY_ARRAY && _data.array.last_index >= 0) { // The parsing was suspended while parsing sub replies, // continue the parsing. RedisReply* subs = (RedisReply*)_data.array.replies; for (uint32_t i = _data.array.last_index; i < _length; ++i) { - if (!subs[i].ConsumePartialIOBuf(buf, arena)) { - return false; + ParseError err = subs[i].ConsumePartialIOBuf(buf, arena); + if (err != PARSE_OK) { + return err; } ++_data.array.last_index; } // We've got an intact reply. reset the index. _data.array.last_index = -1; - return true; + return PARSE_OK; } - // Notice that all branches returning false must not change `buf'. + // Notice that all branches returning PARSE_ERROR_NOT_ENOUGH_DATA must not change `buf'. const char* pfc = (const char*)buf.fetch1(); if (pfc == NULL) { - return false; + return PARSE_ERROR_NOT_ENOUGH_DATA; } const char fc = *pfc; // first character switch (fc) { @@ -61,7 +62,13 @@ bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { case '+': { // Simple String "+\r\n" butil::IOBuf str; if (buf.cut_until(&str, "\r\n") != 0) { - return false; + const size_t len = buf.size(); + if (len > std::numeric_limits::max()) { + LOG(ERROR) << "simple string is too long! max length=2^32-1," + " actually=" << len; + return PARSE_ERROR_ABSOLUTELY_WRONG; + } + return PARSE_ERROR_NOT_ENOUGH_DATA; } const size_t len = str.size() - 1; if (len < sizeof(_data.short_str)) { @@ -69,18 +76,18 @@ bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { _type = (fc == '-' ? REDIS_REPLY_ERROR : REDIS_REPLY_STATUS); _length = len; str.copy_to_cstr(_data.short_str, (size_t)-1L, 1/*skip fc*/); - return true; + return PARSE_OK; } char* d = (char*)arena->allocate((len/8 + 1)*8); if (d == NULL) { LOG(FATAL) << "Fail to allocate string[" << len << "]"; - return false; + return PARSE_ERROR_ABSOLUTELY_WRONG; } CHECK_EQ(len, str.copy_to_cstr(d, (size_t)-1L, 1/*skip fc*/)); _type = (fc == '-' ? REDIS_REPLY_ERROR : REDIS_REPLY_STATUS); _length = len; _data.long_str = d; - return true; + return PARSE_OK; } case '$': // Bulk String "$\r\n\r\n" case '*': // Array "*\r\n..." @@ -90,20 +97,20 @@ bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { intbuf[ncopied] = '\0'; const size_t crlf_pos = butil::StringPiece(intbuf, ncopied).find("\r\n"); if (crlf_pos == butil::StringPiece::npos) { // not enough data - return false; + return PARSE_ERROR_NOT_ENOUGH_DATA; } char* endptr = NULL; int64_t value = strtoll(intbuf + 1/*skip fc*/, &endptr, 10); if (endptr != intbuf + crlf_pos) { LOG(ERROR) << '`' << intbuf + 1 << "' is not a valid 64-bit decimal"; - return false; + return PARSE_ERROR_ABSOLUTELY_WRONG; } if (fc == ':') { buf.pop_front(crlf_pos + 2/*CRLF*/); _type = REDIS_REPLY_INTEGER; _length = 0; _data.integer = value; - return true; + return PARSE_OK; } else if (fc == '$') { const int64_t len = value; // `value' is length of the string if (len < 0) { // redis nil @@ -111,17 +118,17 @@ bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { _type = REDIS_REPLY_NIL; _length = 0; _data.integer = 0; - return true; + return PARSE_OK; } if (len > (int64_t)std::numeric_limits::max()) { LOG(ERROR) << "bulk string is too long! max length=2^32-1," " actually=" << len; - return false; + return PARSE_ERROR_ABSOLUTELY_WRONG; } // We provide c_str(), thus even if bulk string is started with // length, we have to end it with \0. if (buf.size() < crlf_pos + 2 + (size_t)len + 2/*CRLF*/) { - return false; + return PARSE_ERROR_NOT_ENOUGH_DATA; } if ((size_t)len < sizeof(_data.short_str)) { // SSO short strings, including empty string. @@ -134,7 +141,7 @@ bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { char* d = (char*)arena->allocate((len/8 + 1)*8); if (d == NULL) { LOG(FATAL) << "Fail to allocate string[" << len << "]"; - return false; + return PARSE_ERROR_ABSOLUTELY_WRONG; } buf.pop_front(crlf_pos + 2/*CRLF*/); buf.cutn(d, len); @@ -147,8 +154,9 @@ bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { buf.cutn(crlf, sizeof(crlf)); if (crlf[0] != '\r' || crlf[1] != '\n') { LOG(ERROR) << "Bulk string is not ended with CRLF"; + return PARSE_ERROR_ABSOLUTELY_WRONG; } - return true; + return PARSE_OK; } else { const int64_t count = value; // `value' is count of sub replies if (count < 0) { // redis nil @@ -156,7 +164,7 @@ bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { _type = REDIS_REPLY_NIL; _length = 0; _data.integer = 0; - return true; + return PARSE_OK; } if (count == 0) { // empty array buf.pop_front(crlf_pos + 2/*CRLF*/); @@ -164,18 +172,18 @@ bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { _length = 0; _data.array.last_index = -1; _data.array.replies = NULL; - return true; + return PARSE_OK; } if (count > (int64_t)std::numeric_limits::max()) { LOG(ERROR) << "Too many sub replies! max count=2^32-1," " actually=" << count; - return false; + return PARSE_ERROR_ABSOLUTELY_WRONG; } // FIXME(gejun): Call allocate_aligned instead. RedisReply* subs = (RedisReply*)arena->allocate(sizeof(RedisReply) * count); if (subs == NULL) { LOG(FATAL) << "Fail to allocate RedisReply[" << count << "]"; - return false; + return PARSE_ERROR_ABSOLUTELY_WRONG; } for (int64_t i = 0; i < count; ++i) { new (&subs[i]) RedisReply; @@ -185,24 +193,25 @@ bool RedisReply::ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena) { _length = count; _data.array.replies = subs; - // Resursively parse sub replies. If any of them fails, it will + // Recursively parse sub replies. If any of them fails, it will // be continued in next calls by tracking _data.array.last_index. _data.array.last_index = 0; for (int64_t i = 0; i < count; ++i) { - if (!subs[i].ConsumePartialIOBuf(buf, arena)) { - return false; + ParseError err = subs[i].ConsumePartialIOBuf(buf, arena); + if (err != PARSE_OK) { + return err; } ++_data.array.last_index; } _data.array.last_index = -1; - return true; + return PARSE_OK; } } default: LOG(ERROR) << "Invalid first character=" << (int)fc; - return false; + return PARSE_ERROR_ABSOLUTELY_WRONG; } - return false; + return PARSE_ERROR_ABSOLUTELY_WRONG; } class RedisStringPrinter { diff --git a/src/brpc/redis_reply.h b/src/brpc/redis_reply.h index c06d9782..308b2258 100644 --- a/src/brpc/redis_reply.h +++ b/src/brpc/redis_reply.h @@ -21,6 +21,7 @@ #include "butil/strings/string_piece.h" // butil::StringPiece #include "butil/arena.h" // butil::Arena #include "butil/logging.h" // CHECK +#include "parse_result.h" // ParseError namespace brpc { @@ -79,14 +80,16 @@ public: // Parse from `buf' which may be incomplete and allocate needed memory // on `arena'. - // Returns true when an intact reply is parsed and cut off from `buf', - // false otherwise and `buf' is guaranteed to be UNCHANGED so that you - // can call this function on a RedisReply object with the same buf again - // and again until the function returns true. This property makes sure - // the parsing of RedisReply in the worst case is O(N) where N is size - // of the on-wire reply. As a contrast, if the parsing needs `buf' to be - // intact, the complexity in worst case may be O(N^2). - bool ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena); + // Returns PARSE_OK when an intact reply is parsed and cut off from `buf'. + // Returns PARSE_ERROR_NOT_ENOUGH_DATA if data in `buf' is not enough to parse, + // and `buf' is guaranteed to be UNCHANGED so that you can call this + // function on a RedisReply object with the same buf again and again until + // the function returns PARSE_OK. This property makes sure the parsing of + // RedisReply in the worst case is O(N) where N is size of the on-wire + // reply. As a contrast, if the parsing needs `buf' to be intact, + // the complexity in worst case may be O(N^2). + // Returns PARSE_ERROR_ABSOLUTELY_WRONG if the parsing failed. + ParseError ConsumePartialIOBuf(butil::IOBuf& buf, butil::Arena* arena); // Swap internal fields with another reply. void Swap(RedisReply& other); From b8a31b9677755962eb6e956338aa442ecddbfc1f Mon Sep 17 00:00:00 2001 From: helei Date: Tue, 19 Feb 2019 15:19:46 +0800 Subject: [PATCH 053/270] delete unnecessary check. --- src/brpc/socket.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 616f66f1..e360da83 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -746,9 +746,6 @@ int Socket::WaitAndReset(int32_t expected_nref) { _pipeline_q->clear(); } } - CHECK(NULL == _write_head.load(butil::memory_order_relaxed)); - CHECK_EQ(0, _unwritten_bytes.load(butil::memory_order_relaxed)); - CHECK(!_overcrowded); return 0; } From 74b5a1f69d64502cdd30d0ad9fcd10b78dfc10a1 Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 19 Feb 2019 15:23:31 +0800 Subject: [PATCH 054/270] find bin from --libs first --- config_brpc.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config_brpc.sh b/config_brpc.sh index 3c980c44..a1934d79 100755 --- a/config_brpc.sh +++ b/config_brpc.sh @@ -98,20 +98,21 @@ find_dir_of_lib_or_die() { } find_bin() { - TARGET_BIN=$(which "$1" 2>/dev/null) + TARGET_BIN=$(find ${LIBS_IN} -type f -name "$1" 2>/dev/null | head -n1) if [ ! -z "$TARGET_BIN" ]; then $ECHO $TARGET_BIN else - find ${LIBS_IN} -name "$1" 2>/dev/null | head -n1 + which "$1" 2>/dev/null fi } find_bin_or_die() { TARGET_BIN=$(find_bin "$1") - if [ -z "$TARGET_BIN" ]; then - >&2 $ECHO "Fail to find $1 from --libs" + if [ ! -z "$TARGET_BIN" ]; then + $ECHO $TARGET_BIN + else + >&2 $ECHO "Fail to find $1" exit 1 fi - $ECHO $TARGET_BIN } find_dir_of_header() { From dbfdc52c73cd2383916151fc6f856383109f2898 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 4 Mar 2019 19:59:28 -0800 Subject: [PATCH 055/270] Fix CMakeLists.txt of example/auto_concurrency_limiter --- example/auto_concurrency_limiter/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/auto_concurrency_limiter/CMakeLists.txt b/example/auto_concurrency_limiter/CMakeLists.txt index 03a8e854..218f059f 100644 --- a/example/auto_concurrency_limiter/CMakeLists.txt +++ b/example/auto_concurrency_limiter/CMakeLists.txt @@ -12,7 +12,7 @@ set(CMAKE_PREFIX_PATH ${OUTPUT_PATH}) include(FindThreads) include(FindProtobuf) -protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto) +protobuf_generate_cpp(PROTO_SRC PROTO_HEADER cl_test.proto) # include PROTO_HEADER include_directories(${CMAKE_CURRENT_BINARY_DIR}) From c564742180e0208e8bb4ea18fdc16db218ce585e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 5 Mar 2019 22:12:03 +0800 Subject: [PATCH 056/270] fix travis-ci link after transfering to apache --- CONTRIBUTING.md | 4 ++-- README.md | 2 +- README_cn.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30d3ffe4..b3f9bae5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ Before the PR: After the PR: -* Make sure the [travis-ci](https://travis-ci.org/brpc/brpc/pull_requests) passed. +* Make sure the [travis-ci](https://travis-ci.org/apache/incubator-brpc/pull_requests) passed. # Chinese version @@ -26,4 +26,4 @@ After the PR: 提交PR后请确认: -* [travis-ci](https://travis-ci.org/brpc/brpc/pull_requests)成功通过。 +* [travis-ci](https://travis-ci.org/apache/incubator-brpc/pull_requests)成功通过。 diff --git a/README.md b/README.md index 71d95d2e..21009d1a 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [中文版](README_cn.md) -[![Build Status](https://travis-ci.org/brpc/brpc.svg?branch=master)](https://travis-ci.org/brpc/brpc) +[![Build Status](https://travis-ci.org/apache/incubator-brpc.svg?branch=master)](https://travis-ci.org/apache/incubator-brpc) # ![brpc](docs/images/logo.png) diff --git a/README_cn.md b/README_cn.md index b12acdc5..819b25f1 100755 --- a/README_cn.md +++ b/README_cn.md @@ -1,6 +1,6 @@ [English version](README.md) -[![Build Status](https://travis-ci.org/brpc/brpc.svg?branch=master)](https://travis-ci.org/brpc/brpc) +[![Build Status](https://travis-ci.org/apache/incubator-brpc.svg?branch=master)](https://travis-ci.org/apache/incubator-brpc) # ![brpc](docs/images/logo.png) From 5f5a5ab5b92c224ac99befc8fa17da94018dfe13 Mon Sep 17 00:00:00 2001 From: helei Date: Sun, 10 Mar 2019 23:04:16 +0800 Subject: [PATCH 057/270] add doc for circuit breaker --- docs/cn/circuit_breaker.md | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 docs/cn/circuit_breaker.md diff --git a/docs/cn/circuit_breaker.md b/docs/cn/circuit_breaker.md new file mode 100644 index 00000000..faee8efa --- /dev/null +++ b/docs/cn/circuit_breaker.md @@ -0,0 +1,62 @@ +# 熔断功能 +当我们发起一个rpc之后,brpc首先会从名字服务(naming service)拿到一个可用节点列表,之后根据负载均衡策略挑选出一个节点作为实际访问的节点。当某个节点出现故障时,brpc能够自动将它从可用节点列表中剔除,并周期性的对故障节点进行健康检查。 + +# 保守的熔断策略 +brpc 默认会提供保守的熔断策略,在保守的熔断策略下,brpc只有在发现节点无法建立连接时才会将该节点熔断。当某一次rpc返回以下错误时,brpc会认为目标节点无法建立连接,并进行熔断:ECONNREFUSED 、ENETUNREACH、EHOSTUNREACH、EINVAL。 + +这里需要指出的是,假如brpc发现某个节点出现连续三次连接超时(而不是rpc超时),那么也会把第三次超时当做ENETUNREACH来处理。所以假如rpc的超时时间设置的比连接超时更短,那么当节点无法建立连接时,rpc超时会比连接超时更早触发,最终导致永远触发不了熔断。所以在自定义超时时间时,需要保证rpc的超时时间大于连接超时时间。即ChannelOptions.timeout_ms > ChannelOptions.connect_timeout_ms。 + +保守的熔断策略是一直开启的,并不需要做任何配置,也无法关闭。 + +# 更激进的熔断策略 +仅仅依赖上述保守的熔断策略有时候并不能完全满足需求,举个极端的例子: 假如某个下游节点逻辑线程全部卡死,但是io线程能够正常工作,那么所有的请求都会超时,但是tcp连接却能够正常建立。对于这类情况,brpc提供了更加激进的熔断策略:当某个节点的出错率高于预期值时,也会主动将该节点进行摘除。 + +## 开启方法 +激进的熔断策略默认是关闭的,用户可以根据需要在ChannelOptions中手动开启: +``` +brpc::ChannelOptions option; +option.enable_circuit_breaker = true; +``` + +## 工作原理 +激动的熔断由CircuitBreaker实现,在开启了熔断之后,CircuitBreaker会记录每一个请求的处理结果,并维护一个累计出错时长,记为acc_error_cost,当acc_error_cost > max_error_cost时,熔断该节点。 + + +**error_cost的计算过程如下:** +1. 如果请求处理成功,则令 acc_error_cost = alpha * acc_error_cost (alpha 为常数,由window_size决定) +2. 如果请求处理失败,则令 acc_error_cost = acc_error_cost + 该次请求的latency + + +**max_error_cost的计算如下:** +1. 计算出当前latency的EMA值,记为 ema_latency,当请求处理成功时, ema_latency = ema_latency * alpha + (1 - alpha) * latency,否则不更新ema_latency +2. max_error_cost = window_size * max_error_rate * ema_latency (window_size和max_error_rate均为常量,通过gflag配置) +考虑到超时等错误的latency往往会远远大于平均latency,当请求处理失败时,会对其latency进行修正之后再进行error_cost的计算,修正之后的latency不超过ema_latency的两倍。(最大的倍率可以通过gflag配置) + +**根据实际需要配置熔断参数:** + +为了允许某个节点在短时间内抖动,同时又能够剔除长期错误率较高的节点,CircuitBreaker同时维护了长短两个窗口,长窗口阈值较低,短窗口阈值较高。长窗口的主要作用是剔除那些长期错误率较高的服务。我们可以根据实际的qps及对于错误的容忍程度来调整circuit_breaker_long_window_size及circuit_breaker_long_window_error_percent。 + +短窗口则允许我们更加精细的控制熔断的灵敏度,在一些对抖动很敏感的场景,可以通过调整circuit_breaker_short_window_size和circuit_breaker_long_window_short_percent来缩短短窗口的长度、降低短窗口对于错误的容忍程度,使得出现抖动时能够更快的进行熔断。 + +此外,circuit_breaker_epsilon_value可以调整窗口对于**连续抖动的容忍程度**,circuit_breaker_epsilon_value的值越低,acc_error_cost下降的速度越快,当circuit_breaker_epsilon_value的值达到0.001时,若一整个窗口的请求都没有出错,那么正好可以把acc_error_cost降低到0。 + +由于计算ema需要积累一定量的数据,在熔断的初始阶段(即目前已经收集到的请求 < 窗口大小),会直接使用错误数量来判定是否该熔断,即: acc_error_count > window_size * max_error_rate 为真,则熔断节点。 + +## 熔断的范围 +brpc在决定熔断某个节点时,会熔断掉整个连接,即: +1. 假如我们使用pooled模式,那么会熔断掉所有的连接。 +2. brpc的tcp连接是会被所有的channel所共享的,当某个连接被熔断之后,所有的channel都不能再使用这个故障的连接。 +3. 假如想要避免2中所述的情况,可以通过设置ChannelOptions.connection_group,不同ConnectionGroup的channel并不会共享连接。 + +## 熔断数据的收集 +只有通过开启了enable_circuit_breaker的channel发送的请求,才会将请求的处理结果提交到CircuitBreaker。所以假如我们决定对下游某个服务开启单节点熔断,最好是在所有的连接到该服务的channel里都开启enable_circuit_breaker。 + +## 熔断的恢复 +目前brpc使用通用的健康检查来判定某个节点是否已经恢复,即只要能够建立tcp连接则认为该节点已经恢复。为了能够正确隔离那ä›能够建立tcp连接的故障节点,每次熔断之后会先对节点进行一段时间的隔离。当节点在短时间内被连续熔断,则隔离时间翻倍。最大的隔离时间和判断两次熔断是否为连续熔断的时间间隔都使用circuit_breaker_max_isolation_duration_ms控制,默认为30秒 + +## 数据体现 +节点的熔断次数、最近一次恢复之后的累积错误数都可以在监控页面的connections里找到,即便我们没有在ChannelOptions里开启了enable_circuit_breaker,都会对这些数据进行统计。nBreak表示进程启动之后该节点的总熔断次数,RecentErr则表示节点最近一次从熔断中回复之后,出错的次数。 + +假如没有开启enable_circuit_breaker,那么熔断次数就是brpc自带的保守熔断策略发生的熔断,这通常是tcp连接失败/连续三次连接超时导致的。 + + From ade6bb254421c528ca0c68ddae8e9953019a104a Mon Sep 17 00:00:00 2001 From: helei Date: Tue, 12 Mar 2019 22:28:05 +0800 Subject: [PATCH 058/270] ajust document for circuit breaker --- docs/cn/circuit_breaker.md | 55 ++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/docs/cn/circuit_breaker.md b/docs/cn/circuit_breaker.md index faee8efa..63aaed1b 100644 --- a/docs/cn/circuit_breaker.md +++ b/docs/cn/circuit_breaker.md @@ -1,62 +1,65 @@ # 熔断功能 -当我们发起一个rpc之后,brpc首先会从名字服务(naming service)拿到一个可用节点列表,之后根据负载均衡策略挑选出一个节点作为实际访问的节点。当某个节点出现故障时,brpc能够自动将它从可用节点列表中剔除,并周期性的对故障节点进行健康检查。 +当我们发起一个rpc之后,brpc首先会从命名服务(naming service)拿到一个可用节点列表,之后根据负载均衡策略挑选出一个节点作为实际访问的节点。当某个节点出现故障时,brpc能够自动将它从可用节点列表中剔除,并周期性的对故障节点进行健康检查。 -# 保守的熔断策略 -brpc 默认会提供保守的熔断策略,在保守的熔断策略下,brpc只有在发现节点无法建立连接时才会将该节点熔断。当某一次rpc返回以下错误时,brpc会认为目标节点无法建立连接,并进行熔断:ECONNREFUSED 、ENETUNREACH、EHOSTUNREACH、EINVAL。 +# 默认的熔断策略 +brpc 默认会提供一个简单的熔断策略,在的默认的熔断策略下,brpc若检测到某个节点无法建立连接,则会将该节点熔断。当某一次rpc返回以下错误时,brpc会认为目标节点无法建立连接:ECONNREFUSED 、ENETUNREACH、EHOSTUNREACH、EINVAL。 这里需要指出的是,假如brpc发现某个节点出现连续三次连接超时(而不是rpc超时),那么也会把第三次超时当做ENETUNREACH来处理。所以假如rpc的超时时间设置的比连接超时更短,那么当节点无法建立连接时,rpc超时会比连接超时更早触发,最终导致永远触发不了熔断。所以在自定义超时时间时,需要保证rpc的超时时间大于连接超时时间。即ChannelOptions.timeout_ms > ChannelOptions.connect_timeout_ms。 -保守的熔断策略是一直开启的,并不需要做任何配置,也无法关闭。 +默认的熔断策略是一直开启的,并不需要做任何配置,也无法关闭。 -# 更激进的熔断策略 -仅仅依赖上述保守的熔断策略有时候并不能完全满足需求,举个极端的例子: 假如某个下游节点逻辑线程全部卡死,但是io线程能够正常工作,那么所有的请求都会超时,但是tcp连接却能够正常建立。对于这类情况,brpc提供了更加激进的熔断策略:当某个节点的出错率高于预期值时,也会主动将该节点进行摘除。 +# 可选的熔断策略 +仅仅依赖上述默认的熔断策略有时候并不能完全满足需求,举个极端的例子: 假如某个下游节点逻辑线程全部卡死,但是io线程能够正常工作,那么所有的请求都会超时,但是tcp连接却能够正常建立。对于这类情况,brpc在默认的熔断策略的基础上,提供了更加激进的熔断策略。开启之后brpc会根据出错率来判断节点是否处于故障状态。 ## 开启方法 -激进的熔断策略默认是关闭的,用户可以根据需要在ChannelOptions中手动开启: +可选的熔断策略默认是关闭的,用户可以根据实际需要在ChannelOptions中开启: ``` brpc::ChannelOptions option; option.enable_circuit_breaker = true; ``` ## 工作原理 -激动的熔断由CircuitBreaker实现,在开启了熔断之后,CircuitBreaker会记录每一个请求的处理结果,并维护一个累计出错时长,记为acc_error_cost,当acc_error_cost > max_error_cost时,熔断该节点。 +可选的熔断由CircuitBreaker实现,在开启了熔断之后,CircuitBreaker会记录每一个请求的处理结果,并维护一个累计出错时长,记为acc_error_cost,当acc_error_cost > max_error_cost时,熔断该节点。 + +**每次请求返回成功之后,更新max_error_cost:** +1. 首先需要更新latency的EMA值,记为ema_latency: ema_latency = ema_latency * alpha + (1 - alpha) * latency。 +2. 之后根据ema_latency更新max_error_cost: max_error_cost = window_size * max_error_rate * ema_latency。 -**error_cost的计算过程如下:** -1. 如果请求处理成功,则令 acc_error_cost = alpha * acc_error_cost (alpha 为常数,由window_size决定) -2. 如果请求处理失败,则令 acc_error_cost = acc_error_cost + 该次请求的latency +上面的window_size和max_error_rate均为gflag所指定的常量, alpha则是一个略小于1的常量,其值由window_size和下面提到的circuit_breaker_epsilon_value决定。latency则指该次请求所的耗时。 + +**每次请求返回之后,都会更新acc_error_cost:** +1. 如果请求处理成功,则令 acc_error_cost = alpha * acc_error_cost +2. 如果请求处理失败,则令 acc_error_cost = acc_error_cost + min(latency, ema_latency * 2) -**max_error_cost的计算如下:** -1. 计算出当前latency的EMA值,记为 ema_latency,当请求处理成功时, ema_latency = ema_latency * alpha + (1 - alpha) * latency,否则不更新ema_latency -2. max_error_cost = window_size * max_error_rate * ema_latency (window_size和max_error_rate均为常量,通过gflag配置) -考虑到超时等错误的latency往往会远远大于平均latency,当请求处理失败时,会对其latency进行修正之后再进行error_cost的计算,修正之后的latency不超过ema_latency的两倍。(最大的倍率可以通过gflag配置) +上面的alpha与计算max_error_cost所用到的alpha为同一个值。考虑到出现超时等错误时,latency往往会远远大于ema_latency。所以在计算acc_error_cost时对失败请求的latency进行了修正,使其值不超过ema_latency的两倍。这个倍率同样可以通过gflag配置。 + **根据实际需要配置熔断参数:** -为了允许某个节点在短时间内抖动,同时又能够剔除长期错误率较高的节点,CircuitBreaker同时维护了长短两个窗口,长窗口阈值较低,短窗口阈值较高。长窗口的主要作用是剔除那些长期错误率较高的服务。我们可以根据实际的qps及对于错误的容忍程度来调整circuit_breaker_long_window_size及circuit_breaker_long_window_error_percent。 +为了允许某个节点在短时间内抖动,同时又能够剔除长期错误率较高的节点,CircuitBreaker同时维护了长短两个窗口,长窗口阈值较低,短窗口阈值较高。长窗口的主要作用是剔除那些长期错误率较高的服务。我们可以根据实际的qps及对于错误的容忍程度来调整circuit_breaker_long_window_size及circuit_breaker_long_window_error_percent。 -短窗口则允许我们更加精细的控制熔断的灵敏度,在一些对抖动很敏感的场景,可以通过调整circuit_breaker_short_window_size和circuit_breaker_long_window_short_percent来缩短短窗口的长度、降低短窗口对于错误的容忍程度,使得出现抖动时能够更快的进行熔断。 +短窗口则允许我们更加精细的控制熔断的灵敏度,在一些对抖动很敏感的场景,可以通过调整circuit_breaker_short_window_size和circuit_breaker_long_window_short_percent来缩短短窗口的长度、降低短窗口对于错误的容忍程度,使得出现抖动时能够快速对故障节点进行熔断。 -此外,circuit_breaker_epsilon_value可以调整窗口对于**连续抖动的容忍程度**,circuit_breaker_epsilon_value的值越低,acc_error_cost下降的速度越快,当circuit_breaker_epsilon_value的值达到0.001时,若一整个窗口的请求都没有出错,那么正好可以把acc_error_cost降低到0。 +此外,circuit_breaker_epsilon_value可以调整窗口对于**连续抖动的容忍程度**,circuit_breaker_epsilon_value的值越低,计算公式中的alpha越小,acc_error_cost下降的速度就越快,当circuit_breaker_epsilon_value的值达到0.001时,若一整个窗口的请求都没有出错,那么正好可以把acc_error_cost降低到0。 -由于计算ema需要积累一定量的数据,在熔断的初始阶段(即目前已经收集到的请求 < 窗口大小),会直接使用错误数量来判定是否该熔断,即: acc_error_count > window_size * max_error_rate 为真,则熔断节点。 +由于计算EMA需要积累一定量的数据,在熔断的初始阶段(即目前已经收集到的请求 < 窗口大小),会直接使用错误数量来判定是否该熔断,即:若 acc_error_count > window_size * max_error_rate 为真,则进行熔断。 ## 熔断的范围 brpc在决定熔断某个节点时,会熔断掉整个连接,即: 1. 假如我们使用pooled模式,那么会熔断掉所有的连接。 -2. brpc的tcp连接是会被所有的channel所共享的,当某个连接被熔断之后,所有的channel都不能再使用这个故障的连接。 -3. 假如想要避免2中所述的情况,可以通过设置ChannelOptions.connection_group,不同ConnectionGroup的channel并不会共享连接。 +2. brpc的tcp连接是会被channel所共享的,当某个连接被熔断之后,所有的channel都不能再使用这个故障的连接。 +3. 假如想要避免2中所述的情况,可以通过设置ChannelOptions.connection_group将channel放进不同的ConnectionGroup,不同ConnectionGroup的channel并不会共享连接。 ## 熔断数据的收集 -只有通过开启了enable_circuit_breaker的channel发送的请求,才会将请求的处理结果提交到CircuitBreaker。所以假如我们决定对下游某个服务开启单节点熔断,最好是在所有的连接到该服务的channel里都开启enable_circuit_breaker。 +只有通过开启了enable_circuit_breaker的channel发送的请求,才会将请求的处理结果提交到CircuitBreaker。所以假如我们决定对下游某个服务开启可选的熔断策略,最好是在所有的连接到该服务的channel里都开启enable_circuit_breaker。 ## 熔断的恢复 -目前brpc使用通用的健康检查来判定某个节点是否已经恢复,即只要能够建立tcp连接则认为该节点已经恢复。为了能够正确隔离那ä›能够建立tcp连接的故障节点,每次熔断之后会先对节点进行一段时间的隔离。当节点在短时间内被连续熔断,则隔离时间翻倍。最大的隔离时间和判断两次熔断是否为连续熔断的时间间隔都使用circuit_breaker_max_isolation_duration_ms控制,默认为30秒 +目前brpc使用通用的健康检查来判定某个节点是否已经恢复,即只要能够建立tcp连接则认为该节点已经恢复。为了能够正确的摘除那些能够建立tcp连接的故障节点,每次熔断之后会先对故障节点进行一段时间的隔离,隔离期间故障节点即不会被lb选中,也不会进行健康检查。若节点在短时间内被连续熔断,则隔离时间翻倍。初始的隔离时间为100ms,最大的隔离时间和判断两次熔断是否为连续熔断的时间间隔都使用circuit_breaker_max_isolation_duration_ms控制,默认为30秒。 ## 数据体现 -节点的熔断次数、最近一次恢复之后的累积错误数都可以在监控页面的connections里找到,即便我们没有在ChannelOptions里开启了enable_circuit_breaker,都会对这些数据进行统计。nBreak表示进程启动之后该节点的总熔断次数,RecentErr则表示节点最近一次从熔断中回复之后,出错的次数。 - -假如没有开启enable_circuit_breaker,那么熔断次数就是brpc自带的保守熔断策略发生的熔断,这通常是tcp连接失败/连续三次连接超时导致的。 +节点的熔断次数、最近一次从熔断中恢复之后的累积错误数都可以在监控页面的/connections里找到,即便我们没有开启可选的熔断策略,brpc也会对这些数据进行统计。nBreak表示进程启动之后该节点的总熔断次数,RecentErr则表示该节点最近一次从熔断中恢复之后,累计的出错请求数。 +由于brpc默认熔断策略是一直开启的,即便我们没有开启可选的熔断策略,nBreak还是可能会大于0,这时nBreak通常是因为tcp连接建立失败而产生的。 From 8c1d522809a329de35996de82eebaf68eae27a32 Mon Sep 17 00:00:00 2001 From: Mengmeng Yang Date: Sat, 23 Feb 2019 11:49:41 +0800 Subject: [PATCH 059/270] support custom executor in execution_queue --- src/bthread/execution_queue.cpp | 25 ++++++++++++++++--------- src/bthread/execution_queue.h | 13 +++++++++++++ src/bthread/execution_queue_inl.h | 2 +- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/bthread/execution_queue.cpp b/src/bthread/execution_queue.cpp index 46850565..a87362c3 100644 --- a/src/bthread/execution_queue.cpp +++ b/src/bthread/execution_queue.cpp @@ -101,15 +101,22 @@ void ExecutionQueueBase::start_execute(TaskNode* node) { } } - bthread_t tid; - // We start the execution thread in background instead of foreground as - // we can't determine whether the code after execute() is urgent (like - // unlock a pthread_mutex_t) in which case implicit context switch may - // cause undefined behavior (e.g. deadlock) - if (bthread_start_background(&tid, &_options.bthread_attr, - _execute_tasks, node) != 0) { - PLOG(FATAL) << "Fail to start bthread"; - _execute_tasks(node); + if (nullptr == _options.executor) { + bthread_t tid; + // We start the execution thread in background instead of foreground as + // we can't determine whether the code after execute() is urgent (like + // unlock a pthread_mutex_t) in which case implicit context switch may + // cause undefined behavior (e.g. deadlock) + if (bthread_start_background(&tid, &_options.bthread_attr, + _execute_tasks, node) != 0) { + PLOG(FATAL) << "Fail to start bthread"; + _execute_tasks(node); + } + } else { + if (_options.executor->submit(_execute_tasks, node) != 0) { + PLOG(FATAL) << "Fail to submit task"; + _execute_tasks(node); + } } } diff --git a/src/bthread/execution_queue.h b/src/bthread/execution_queue.h index c4636450..a9515f20 100644 --- a/src/bthread/execution_queue.h +++ b/src/bthread/execution_queue.h @@ -128,11 +128,24 @@ const static TaskOptions TASK_OPTIONS_NORMAL = TaskOptions(false, false); const static TaskOptions TASK_OPTIONS_URGENT = TaskOptions(true, false); const static TaskOptions TASK_OPTIONS_INPLACE = TaskOptions(false, true); +class Executor { +public: + virtual ~Executor() {} + + // Return 0 on success. + virtual int submit(void * (*fn)(void*), void* args) = 0; +}; + struct ExecutionQueueOptions { ExecutionQueueOptions(); // Attribute of the bthread which execute runs on // default: BTHREAD_ATTR_NORMAL bthread_attr_t bthread_attr; + + // Executor that tasks run on. bthread will be used when executor = NULL. + // Note that TaskOptions.in_place_if_possible = false will not work, if implementation of + // Executor is in-place(synchronous). + Executor * executor; }; // Start a ExecutionQueue. If |options| is NULL, the queue will be created with diff --git a/src/bthread/execution_queue_inl.h b/src/bthread/execution_queue_inl.h index 75d9935c..429ad25e 100644 --- a/src/bthread/execution_queue_inl.h +++ b/src/bthread/execution_queue_inl.h @@ -317,7 +317,7 @@ public: }; inline ExecutionQueueOptions::ExecutionQueueOptions() - : bthread_attr(BTHREAD_ATTR_NORMAL) + : bthread_attr(BTHREAD_ATTR_NORMAL), executor(NULL) {} template From 51259c0b5d68bdea12895865b24683c8dda18554 Mon Sep 17 00:00:00 2001 From: gejun Date: Fri, 22 Mar 2019 19:45:06 +0800 Subject: [PATCH 060/270] Move reuse_addr from server.cpp to endpoint.cpp and make the code more robust --- src/brpc/server.cpp | 7 ++----- src/butil/endpoint.cpp | 25 ++++++++++++++++++------- src/butil/endpoint.h | 7 ++++--- test/brpc_channel_unittest.cpp | 2 +- test/brpc_input_messenger_unittest.cpp | 2 +- test/brpc_server_unittest.cpp | 2 +- test/brpc_socket_unittest.cpp | 4 ++-- test/brpc_ssl_unittest.cpp | 2 +- 8 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 051d18ac..383b6438 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -104,9 +104,6 @@ const char* status_str(Server::Status s) { butil::static_atomic g_running_server_count = BUTIL_STATIC_ATOMIC_INIT(0); -DEFINE_bool(reuse_addr, true, "Bind to ports in TIME_WAIT state"); -BRPC_VALIDATE_GFLAG(reuse_addr, PassValidate); - // Following services may have security issues and are disabled by default. DEFINE_bool(enable_dir_service, false, "Enable /dir"); DEFINE_bool(enable_threads_service, false, "Enable /threads"); @@ -939,7 +936,7 @@ int Server::StartInternal(const butil::ip_t& ip, _listen_addr.ip = ip; for (int port = port_range.min_port; port <= port_range.max_port; ++port) { _listen_addr.port = port; - butil::fd_guard sockfd(tcp_listen(_listen_addr, FLAGS_reuse_addr)); + butil::fd_guard sockfd(tcp_listen(_listen_addr)); if (sockfd < 0) { if (port != port_range.max_port) { // not the last port, try next continue; @@ -999,7 +996,7 @@ int Server::StartInternal(const butil::ip_t& ip, } butil::EndPoint internal_point = _listen_addr; internal_point.port = _options.internal_port; - butil::fd_guard sockfd(tcp_listen(internal_point, FLAGS_reuse_addr)); + butil::fd_guard sockfd(tcp_listen(internal_point)); if (sockfd < 0) { LOG(ERROR) << "Fail to listen " << internal_point << " (internal)"; return -1; diff --git a/src/butil/endpoint.cpp b/src/butil/endpoint.cpp index dcb683b5..a0ecb35f 100644 --- a/src/butil/endpoint.cpp +++ b/src/butil/endpoint.cpp @@ -29,12 +29,12 @@ #include "butil/logging.h" #include "butil/memory/singleton_on_pthread_once.h" #include "butil/strings/string_piece.h" +#include // SO_REUSEADDR SO_REUSEPORT -#ifndef SO_REUSEPORT -#define SO_REUSEPORT 15 -#endif -//This option is supported since Linux 3.9. -DEFINE_bool(reuse_port, false, "turn on support for SO_REUSEPORT socket option."); +//supported since Linux 3.9. +DEFINE_bool(reuse_port, false, "Enable SO_REUSEPORT for all listened sockets"); + +DEFINE_bool(reuse_addr, true, "Enable SO_REUSEADDR for all listened sockets"); __BEGIN_DECLS int BAIDU_WEAK bthread_connect( @@ -308,25 +308,36 @@ int tcp_connect(EndPoint point, int* self_port) { return sockfd.release(); } -int tcp_listen(EndPoint point, bool reuse_addr) { +int tcp_listen(EndPoint point) { fd_guard sockfd(socket(AF_INET, SOCK_STREAM, 0)); if (sockfd < 0) { return -1; } - if (reuse_addr) { + + if (FLAGS_reuse_addr) { +#if defined(SO_REUSEADDR) const int on = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) { return -1; } +#else + LOG(ERROR) << "Missing def of SO_REUSEADDR while -reuse_addr is on"; + return -1; +#endif } if (FLAGS_reuse_port) { +#if defined(SO_REUSEPORT) const int on = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) != 0) { LOG(WARNING) << "Fail to setsockopt SO_REUSEPORT of sockfd=" << sockfd; } +#else + LOG(ERROR) << "Missing def of SO_REUSEPORT while -reuse_port is on"; + return -1; +#endif } struct sockaddr_in serv_addr; diff --git a/src/butil/endpoint.h b/src/butil/endpoint.h index c6446d7a..bec4dc5f 100644 --- a/src/butil/endpoint.h +++ b/src/butil/endpoint.h @@ -119,10 +119,11 @@ int endpoint2hostname(const EndPoint& point, std::string* host); // Returns the socket descriptor, -1 otherwise and errno is set. int tcp_connect(EndPoint server, int* self_port); -// Create and listen to a TCP socket bound with `ip_and_port'. If `reuse_addr' -// is true, ports in TIME_WAIT will be bound as well. +// Create and listen to a TCP socket bound with `ip_and_port'. +// To enable SO_REUSEADDR for the whole program, enable gflag -reuse_addr +// To enable SO_REUSEPORT for the whole program, enable gflag -reuse_port // Returns the socket descriptor, -1 otherwise and errno is set. -int tcp_listen(EndPoint ip_and_port, bool reuse_addr); +int tcp_listen(EndPoint ip_and_port); // Get the local end of a socket connection int get_local_side(int fd, EndPoint *out); diff --git a/test/brpc_channel_unittest.cpp b/test/brpc_channel_unittest.cpp index 2707f4ea..049a4975 100644 --- a/test/brpc_channel_unittest.cpp +++ b/test/brpc_channel_unittest.cpp @@ -240,7 +240,7 @@ protected: int StartAccept(butil::EndPoint ep) { int listening_fd = -1; - while ((listening_fd = tcp_listen(ep, true)) < 0) { + while ((listening_fd = tcp_listen(ep)) < 0) { if (errno == EADDRINUSE) { bthread_usleep(1000); } else { diff --git a/test/brpc_input_messenger_unittest.cpp b/test/brpc_input_messenger_unittest.cpp index a7619cb2..5fe4680e 100644 --- a/test/brpc_input_messenger_unittest.cpp +++ b/test/brpc_input_messenger_unittest.cpp @@ -148,7 +148,7 @@ TEST_F(MessengerTest, dispatch_tasks) { snprintf(buf, sizeof(buf), "input_messenger.socket%lu", i); int listening_fd = butil::unix_socket_listen(buf); #else - int listening_fd = tcp_listen(butil::EndPoint(butil::IP_ANY, 7878), false); + int listening_fd = tcp_listen(butil::EndPoint(butil::IP_ANY, 7878)); #endif ASSERT_TRUE(listening_fd > 0); butil::make_non_blocking(listening_fd); diff --git a/test/brpc_server_unittest.cpp b/test/brpc_server_unittest.cpp index ecd16d45..575c88ec 100644 --- a/test/brpc_server_unittest.cpp +++ b/test/brpc_server_unittest.cpp @@ -1178,7 +1178,7 @@ TEST_F(ServerTest, range_start) { butil::EndPoint point; for (int i = START_PORT; i < END_PORT; ++i) { point.port = i; - listen_fds[i - START_PORT].reset(butil::tcp_listen(point, true)); + listen_fds[i - START_PORT].reset(butil::tcp_listen(point)); } brpc::Server server; diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index e392ea1b..b7249b84 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -303,7 +303,7 @@ TEST_F(SocketTest, single_threaded_connect_and_write) { }; butil::EndPoint point(butil::IP_ANY, 7878); - int listening_fd = tcp_listen(point, false); + int listening_fd = tcp_listen(point); ASSERT_TRUE(listening_fd > 0); butil::make_non_blocking(listening_fd); ASSERT_EQ(0, messenger->AddHandler(pairs[0])); @@ -606,7 +606,7 @@ TEST_F(SocketTest, health_check) { EchoProcessHuluRequest, NULL, NULL, "dummy_hulu" } }; - int listening_fd = tcp_listen(point, false); + int listening_fd = tcp_listen(point); ASSERT_TRUE(listening_fd > 0); butil::make_non_blocking(listening_fd); ASSERT_EQ(0, messenger->AddHandler(pairs[0])); diff --git a/test/brpc_ssl_unittest.cpp b/test/brpc_ssl_unittest.cpp index 1be6e416..aaa5c4b6 100644 --- a/test/brpc_ssl_unittest.cpp +++ b/test/brpc_ssl_unittest.cpp @@ -312,7 +312,7 @@ void* ssl_perf_server(void* arg) { TEST_F(SSLTest, ssl_perf) { const butil::EndPoint ep(butil::IP_ANY, 5961); - butil::fd_guard listenfd(butil::tcp_listen(ep, false)); + butil::fd_guard listenfd(butil::tcp_listen(ep)); ASSERT_GT(listenfd, 0); int clifd = tcp_connect(ep, NULL); ASSERT_GT(clifd, 0); From 2dc9cbad5310961ba4e0a0b444fcd3a1006779e6 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 20 Mar 2019 12:26:54 +0800 Subject: [PATCH 061/270] health_check_using_rpc: add single server --- .gitignore | 1 + src/brpc/channel.cpp | 9 +++ src/brpc/channel.h | 1 + src/brpc/controller.cpp | 23 ++++++-- src/brpc/controller.h | 5 ++ src/brpc/socket.cpp | 36 ++++++++++++ src/brpc/socket.h | 8 +++ src/brpc/socket_inl.h | 4 ++ test/CMakeLists.txt | 3 +- test/brpc_socket_unittest.cpp | 108 ++++++++++++++++++++++++++++++++++ test/health_check.proto | 11 ++++ 11 files changed, 202 insertions(+), 7 deletions(-) create mode 100644 test/health_check.proto diff --git a/.gitignore b/.gitignore index 37cede50..ac58035b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ *.rej /output /test/output +build/ # Ignore hidden files .* diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index 27fdb841..2c212d81 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -281,6 +281,15 @@ int Channel::Init(butil::EndPoint server_addr_and_port, return InitSingle(server_addr_and_port, "", options); } +int Channel::Init(SocketId id, const ChannelOptions* options) { + GlobalInitializeOrDie(); + if (InitChannelOptions(options) != 0) { + return -1; + } + _server_id = id; + return 0; +} + int Channel::InitSingle(const butil::EndPoint& server_addr_and_port, const char* raw_server_address, const ChannelOptions* options) { diff --git a/src/brpc/channel.h b/src/brpc/channel.h index be631cff..4e0154f5 100644 --- a/src/brpc/channel.h +++ b/src/brpc/channel.h @@ -155,6 +155,7 @@ public: int Init(butil::EndPoint server_addr_and_port, const ChannelOptions* options); int Init(const char* server_addr_and_port, const ChannelOptions* options); int Init(const char* server_addr, int port, const ChannelOptions* options); + int Init(SocketId id, const ChannelOptions* options); // Connect this channel to a group of servers whose addresses can be // accessed via `naming_service_url' according to its protocol. Use the diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index f0077d50..cfda123a 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -982,15 +982,26 @@ void Controller::IssueRPC(int64_t start_realtime_us) { _current_call.need_feedback = false; _current_call.enable_circuit_breaker = has_enabled_circuit_breaker(); SocketUniquePtr tmp_sock; + bool health_check_call = has_flag(FLAGS_HEALTH_CHECK_CALL); if (SingleServer()) { // Don't use _current_call.peer_id which is set to -1 after construction // of the backup call. - const int rc = Socket::Address(_single_server_id, &tmp_sock); - if (rc != 0 || tmp_sock->IsLogOff()) { - SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, - endpoint2str(_remote_side).c_str(), _single_server_id); - tmp_sock.reset(); // Release ref ASAP - return HandleSendFailed(); + if (!health_check_call) { + const int rc = Socket::Address(_single_server_id, &tmp_sock); + if (rc != 0 || tmp_sock->IsLogOff()) { + SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, + endpoint2str(_remote_side).c_str(), _single_server_id); + tmp_sock.reset(); // Release ref ASAP + return HandleSendFailed(); + } + } else { + const int rc = Socket::AddressFailedAsWell(_single_server_id, &tmp_sock); + if (rc < 0) { + SetFailed(EFAILEDSOCKET, "Socket to %s has been recycled, server_id=%" PRIu64, + endpoint2str(_remote_side).c_str(), _single_server_id); + tmp_sock.reset(); // Release ref ASAP + return HandleSendFailed(); + } } _current_call.peer_id = _single_server_id; } else { diff --git a/src/brpc/controller.h b/src/brpc/controller.h index 2627b877..c6f988e8 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -138,6 +138,7 @@ friend void policy::ProcessThriftRequest(InputMessageBase*); static const uint32_t FLAGS_PB_JSONIFY_EMPTY_ARRAY = (1 << 16); static const uint32_t FLAGS_ENABLED_CIRCUIT_BREAKER = (1 << 17); static const uint32_t FLAGS_ALWAYS_PRINT_PRIMITIVE_FIELDS = (1 << 18); + static const uint32_t FLAGS_HEALTH_CHECK_CALL = (1 << 19); public: Controller(); @@ -324,6 +325,10 @@ public: bool is_done_allowed_to_run_in_place() const { return has_flag(FLAGS_ALLOW_DONE_TO_RUN_IN_PLACE); } + // TODO(zhujiahsun): comment + void set_health_check_call(bool f) { set_flag(FLAGS_HEALTH_CHECK_CALL, f); } + bool has_health_check_call() const { return has_flag(FLAGS_HEALTH_CHECK_CALL); } + // ------------------------------------------------------------------------ // Server-side methods. // These calls shall be made from the server side only. Their results are diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index e360da83..24cd8468 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -48,6 +48,8 @@ #include "brpc/shared_object.h" #include "brpc/policy/rtmp_protocol.h" // FIXME #include "brpc/periodic_task.h" +#include "brpc/channel.h" +#include "brpc/controller.h" #if defined(OS_MACOSX) #include #endif @@ -92,6 +94,10 @@ DEFINE_int32(connect_timeout_as_unreachable, 3, "times *continuously*, the error is changed to ENETUNREACH which " "fails the main socket as well when this socket is pooled."); +DEFINE_bool(health_check_using_rpc, false, "todo"); +DEFINE_string(health_check_path, "/health", "todo"); +DEFINE_int32(health_check_timeout_ms, 300, "todo"); + static bool validate_connect_timeout_as_unreachable(const char*, int32_t v) { return v >= 2 && v < 1000/*large enough*/; } @@ -473,6 +479,7 @@ Socket::Socket(Forbidden) , _epollout_butex(NULL) , _write_head(NULL) , _stream_set(NULL) + //, _health_checking_using_rpc(false) { CreateVarsOnce(); pthread_mutex_init(&_id_wait_list_mutex, NULL); @@ -655,6 +662,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) { m->_error_code = 0; m->_error_text.clear(); m->_agent_socket_id.store(INVALID_SOCKET_ID, butil::memory_order_relaxed); + //m->_health_checking_using_rpc.store(false, butil::memory_order_relaxed); // NOTE: last two params are useless in bthread > r32787 const int rc = bthread_id_list_init(&m->_id_wait_list, 512, 512); if (rc) { @@ -775,6 +783,7 @@ void Socket::Revive() { } // Set this flag to true since we add additional ref again _recycle_flag.store(false, butil::memory_order_relaxed); + //_health_checking_using_rpc.store(false, butil::memory_order_relaxed); if (_user) { _user->AfterRevived(this); } else { @@ -865,6 +874,7 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) { // by Channel to revive never-connected socket when server side // comes online. if (_health_check_interval_s > 0) { + //!_health_checking_using_rpc.load(butil::memory_order_relaxed)) { GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); PeriodicTaskManager::StartTaskAt( new HealthCheckTask(id()), @@ -1024,6 +1034,32 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { if (ptr->CreatedByConnect()) { s_vars->channel_conn << -1; } + if (FLAGS_health_check_using_rpc) { + //ptr->_health_checking_using_rpc.store(true, butil::memory_order_relaxed); + brpc::ChannelOptions options; + options.protocol = "http"; + options.max_retry = 0; + options.timeout_ms = FLAGS_health_check_timeout_ms; + brpc::Channel channel; + if (channel.Init(_id, &options) != 0) { + ++ ptr->_hc_count; + *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); + return true; + } + + brpc::Controller cntl; + cntl.http_request().uri() = FLAGS_health_check_path; + cntl.set_health_check_call(true); + channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + if (cntl.Failed()) { + LOG(WARNING) << "Fail to health check using rpc, error=" + << cntl.ErrorText(); + ++ ptr->_hc_count; + *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); + return true; + } + LOG(INFO) << "Succeed to health check using rpc"; + } ptr->Revive(); ptr->_hc_count = 0; return false; diff --git a/src/brpc/socket.h b/src/brpc/socket.h index a6621e8e..76eb749d 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -348,6 +348,9 @@ public: // Once set, this flag can only be cleared inside `WaitAndReset' void SetLogOff(); bool IsLogOff() const; + + // TODO(zhujiashun) + bool IsHealthCheckingUsingRPC() const; // Start to process edge-triggered events from the fd. // This function does not block caller. @@ -790,6 +793,11 @@ private: butil::Mutex _stream_mutex; std::set *_stream_set; + + // If this flag is set, then the current socket is used to health check + // and should not health check again + butil::atomic _health_checking_using_rpc; + }; } // namespace brpc diff --git a/src/brpc/socket_inl.h b/src/brpc/socket_inl.h index f65ac3cf..021386dd 100644 --- a/src/brpc/socket_inl.h +++ b/src/brpc/socket_inl.h @@ -245,6 +245,10 @@ inline bool Socket::IsLogOff() const { return _logoff_flag.load(butil::memory_order_relaxed); } +inline bool Socket::IsHealthCheckingUsingRPC() const { + return _health_checking_using_rpc.load(butil::memory_order_relaxed); +} + static const uint32_t EOF_FLAG = (1 << 31); inline void Socket::PostponeEOF() { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1c678081..2c9023a1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,7 +14,8 @@ set(TEST_PROTO_FILES addressbook1.proto snappy_message.proto v1.proto v2.proto - grpc.proto) + grpc.proto + health_check.proto) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/test/hdrs) set(PROTOC_FLAGS ${PROTOC_FLAGS} -I${CMAKE_SOURCE_DIR}/src) compile_proto(PROTO_HDRS PROTO_SRCS ${CMAKE_BINARY_DIR}/test diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index b7249b84..0683ce05 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -18,7 +18,10 @@ #include "brpc/acceptor.h" #include "brpc/policy/hulu_pbrpc_protocol.h" #include "brpc/policy/most_common_message.h" +#include "brpc/policy/http_rpc_protocol.h" #include "brpc/nshead.h" +#include "brpc/server.h" +#include "health_check.pb.h" #if defined(OS_MACOSX) #include #endif @@ -522,6 +525,111 @@ TEST_F(SocketTest, not_health_check_when_nref_hits_0) { ASSERT_EQ(-1, brpc::Socket::Status(id)); } +class HealthCheckTestServiceImpl : public test::HealthCheckTestService { +public: + HealthCheckTestServiceImpl() + : _sleep_flag(true) {} + virtual ~HealthCheckTestServiceImpl() {} + + virtual void default_method(google::protobuf::RpcController* cntl_base, + const test::HealthCheckRequest* request, + test::HealthCheckResponse* response, + google::protobuf::Closure* done) { + brpc::ClosureGuard done_guard(done); + brpc::Controller* cntl = (brpc::Controller*)cntl_base; + LOG(INFO) << "In HealthCheckTestServiceImpl, flag=" << _sleep_flag; + if (_sleep_flag) { + bthread_usleep(310000 /* 310ms, a little bit longer than the default + timeout of health checking rpc */); + } else { + LOG(INFO) << "Return fast!"; + + } + cntl->response_attachment().append("OK"); + } + + bool _sleep_flag; +}; + +TEST_F(SocketTest, health_check_using_rpc) { + GFLAGS_NS::SetCommandLineOption("health_check_using_rpc", "true"); + GFLAGS_NS::SetCommandLineOption("health_check_path", "/HealthCheckTestService"); + brpc::SocketId id = 8888; + butil::EndPoint point(butil::IP_ANY, 7777); + const int kCheckInteval = 1; + brpc::SocketOptions options; + options.remote_side = point; + options.user = new CheckRecycle; + options.health_check_interval_s = kCheckInteval/*s*/; + ASSERT_EQ(0, brpc::Socket::Create(options, &id)); + brpc::SocketUniquePtr s; + ASSERT_EQ(0, brpc::Socket::Address(id, &s)); + + global_sock = s.get(); + ASSERT_TRUE(global_sock); + + const char* buf = "GET / HTTP/1.1\r\nHost: brpc.com\r\n\r\n"; + const bool use_my_message = (butil::fast_rand_less_than(2) == 0); + brpc::SocketMessagePtr msg; + int appended_msg = 0; + butil::IOBuf src; + if (use_my_message) { + LOG(INFO) << "Use MyMessage"; + msg.reset(new MyMessage(buf, strlen(buf), &appended_msg)); + } else { + src.append(buf, strlen(buf)); + ASSERT_EQ(strlen(buf), src.length()); + } +#ifdef CONNECT_IN_KEEPWRITE + bthread_id_t wait_id; + WaitData data; + ASSERT_EQ(0, bthread_id_create2(&wait_id, &data, OnWaitIdReset)); + brpc::Socket::WriteOptions wopt; + wopt.id_wait = wait_id; + if (use_my_message) { + ASSERT_EQ(0, s->Write(msg, &wopt)); + } else { + ASSERT_EQ(0, s->Write(&src, &wopt)); + } + ASSERT_EQ(0, bthread_id_join(wait_id)); + ASSERT_EQ(wait_id.value, data.id.value); + ASSERT_EQ(ECONNREFUSED, data.error_code); + ASSERT_TRUE(butil::StringPiece(data.error_text).starts_with( + "Fail to connect ")); + if (use_my_message) { + ASSERT_TRUE(appended_msg); + } +#else + if (use_my_message) { + ASSERT_EQ(-1, s->Write(msg)); + } else { + ASSERT_EQ(-1, s->Write(&src)); + } + ASSERT_EQ(ECONNREFUSED, errno); +#endif + ASSERT_TRUE(src.empty()); + ASSERT_EQ(-1, s->fd()); + ASSERT_TRUE(global_sock); + brpc::SocketUniquePtr invalid_ptr; + ASSERT_EQ(-1, brpc::Socket::Address(id, &invalid_ptr)); + + brpc::Server server; + HealthCheckTestServiceImpl hc_service; + ASSERT_EQ(0, server.AddService(&hc_service, brpc::SERVER_DOESNT_OWN_SERVICE)); + ASSERT_EQ(0, server.Start("127.0.0.1:7777", NULL)); + for (int i = 0; i < 3; ++i) { + // although ::connect would succeed, the stall in hc_service makes + // the health checking rpc fail. + ASSERT_EQ(1, brpc::Socket::Status(id)); + bthread_usleep(1000000 /*1s*/); + } + hc_service._sleep_flag = false; + bthread_usleep(2000000); + // recover + ASSERT_EQ(0, brpc::Socket::Status(id)); + GFLAGS_NS::SetCommandLineOption("health_check_using_rpc", "false"); +} + TEST_F(SocketTest, health_check) { // FIXME(gejun): Messenger has to be new otherwise quitting may crash. brpc::Acceptor* messenger = new brpc::Acceptor; diff --git a/test/health_check.proto b/test/health_check.proto new file mode 100644 index 00000000..a63b5469 --- /dev/null +++ b/test/health_check.proto @@ -0,0 +1,11 @@ +syntax="proto2"; +option cc_generic_services = true; + +package test; + +message HealthCheckRequest {}; +message HealthCheckResponse {}; + +service HealthCheckTestService { + rpc default_method(HealthCheckRequest) returns (HealthCheckResponse); +} From 084c1e7af77ca22952479614e4cdbb5c8a58c598 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 20 Mar 2019 17:48:56 +0800 Subject: [PATCH 062/270] health_check_using_rpc: health check after revive & add UT --- src/brpc/channel.cpp | 2 +- src/brpc/controller.cpp | 27 ++--- src/brpc/load_balancer.h | 1 + .../consistent_hashing_load_balancer.cpp | 3 +- src/brpc/policy/dynpart_load_balancer.cpp | 3 +- .../policy/locality_aware_load_balancer.cpp | 3 +- src/brpc/policy/randomized_load_balancer.cpp | 3 +- src/brpc/policy/round_robin_load_balancer.cpp | 3 +- .../weighted_round_robin_load_balancer.cpp | 3 +- src/brpc/selective_channel.cpp | 3 +- src/brpc/socket.cpp | 34 +++--- src/brpc/socket.h | 4 +- src/brpc/socket_inl.h | 4 + test/brpc_load_balancer_unittest.cpp | 105 ++++++++++++++++-- test/brpc_socket_unittest.cpp | 105 +++++++----------- 15 files changed, 186 insertions(+), 117 deletions(-) diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index 2c212d81..9920d457 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -571,7 +571,7 @@ int Channel::CheckHealth() { return -1; } else { SocketUniquePtr tmp_sock; - LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL }; + LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL, false}; LoadBalancer::SelectOut sel_out(&tmp_sock); return _lb->SelectServer(sel_in, &sel_out); } diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index cfda123a..d38fe500 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -986,28 +986,19 @@ void Controller::IssueRPC(int64_t start_realtime_us) { if (SingleServer()) { // Don't use _current_call.peer_id which is set to -1 after construction // of the backup call. - if (!health_check_call) { - const int rc = Socket::Address(_single_server_id, &tmp_sock); - if (rc != 0 || tmp_sock->IsLogOff()) { - SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, - endpoint2str(_remote_side).c_str(), _single_server_id); - tmp_sock.reset(); // Release ref ASAP - return HandleSendFailed(); - } - } else { - const int rc = Socket::AddressFailedAsWell(_single_server_id, &tmp_sock); - if (rc < 0) { - SetFailed(EFAILEDSOCKET, "Socket to %s has been recycled, server_id=%" PRIu64, - endpoint2str(_remote_side).c_str(), _single_server_id); - tmp_sock.reset(); // Release ref ASAP - return HandleSendFailed(); - } + const int rc = Socket::Address(_single_server_id, &tmp_sock); + if (rc != 0 || tmp_sock->IsLogOff() || + (!health_check_call && tmp_sock->IsHealthCheckingUsingRPC())) { + SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, + endpoint2str(_remote_side).c_str(), _single_server_id); + tmp_sock.reset(); // Release ref ASAP + return HandleSendFailed(); } _current_call.peer_id = _single_server_id; } else { LoadBalancer::SelectIn sel_in = - { start_realtime_us, true, - has_request_code(), _request_code, _accessed }; + { start_realtime_us, true, has_request_code(), + _request_code, _accessed, health_check_call}; LoadBalancer::SelectOut sel_out(&tmp_sock); const int rc = _lb->SelectServer(sel_in, &sel_out); if (rc != 0) { diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 538c2d38..21f31c8a 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -40,6 +40,7 @@ public: bool has_request_code; uint64_t request_code; const ExcludedServers* excluded; + bool health_check_call; }; struct SelectOut { diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 942f8a49..6ffda306 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -221,7 +221,8 @@ int ConsistentHashingLoadBalancer::SelectServer( if (((i + 1) == s->size() // always take last chance || !ExcludedServers::IsExcluded(in.excluded, choice->server_sock.id)) && Socket::Address(choice->server_sock.id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff()) { + && !(*out->ptr)->IsLogOff() + && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { return 0; } else { if (++choice == s->end()) { diff --git a/src/brpc/policy/dynpart_load_balancer.cpp b/src/brpc/policy/dynpart_load_balancer.cpp index 8da8c622..3786f078 100644 --- a/src/brpc/policy/dynpart_load_balancer.cpp +++ b/src/brpc/policy/dynpart_load_balancer.cpp @@ -122,7 +122,8 @@ int DynPartLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { for (size_t i = 0; i < n; ++i) { const SocketId id = s->server_list[i].id; if ((!exclusion || !ExcludedServers::IsExcluded(in.excluded, id)) - && Socket::Address(id, &ptrs[nptr].first) == 0) { + && Socket::Address(id, &ptrs[nptr].first) == 0 + && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { int w = schan::GetSubChannelWeight(ptrs[nptr].first->user()); total_weight += w; if (nptr < 8) { diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index dde0d2a9..9cd72f29 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -303,7 +303,8 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) continue; } } else if (Socket::Address(info.server_id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff()) { + && !(*out->ptr)->IsLogOff() + && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { if ((ntry + 1) == n // Instead of fail with EHOSTDOWN, we prefer // choosing the server again. || !ExcludedServers::IsExcluded(in.excluded, info.server_id)) { diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 3e8ac4e9..ab982775 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -118,7 +118,8 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (((i + 1) == n // always take last chance || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff()) { + && !(*out->ptr)->IsLogOff() + && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { // We found an available server return 0; } diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 5e3f1ab0..370d96a5 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -122,7 +122,8 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (((i + 1) == n // always take last chance || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff()) { + && !(*out->ptr)->IsLogOff() + && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { s.tls() = tls; return 0; } diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index 53a07b9c..a65e51d9 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -180,7 +180,8 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* SocketId server_id = GetServerInNextStride(s->server_list, filter, tls_temp); if (!ExcludedServers::IsExcluded(in.excluded, server_id) && Socket::Address(server_id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff()) { + && !(*out->ptr)->IsLogOff() + && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { // update tls. tls.remain_server = tls_temp.remain_server; tls.position = tls_temp.position; diff --git a/src/brpc/selective_channel.cpp b/src/brpc/selective_channel.cpp index 4a1c0f69..9dee7897 100644 --- a/src/brpc/selective_channel.cpp +++ b/src/brpc/selective_channel.cpp @@ -290,7 +290,8 @@ int Sender::IssueRPC(int64_t start_realtime_us) { true, _main_cntl->has_request_code(), _main_cntl->_request_code, - _main_cntl->_accessed }; + _main_cntl->_accessed, + false }; ChannelBalancer::SelectOut sel_out; const int rc = static_cast(_main_cntl->_lb.get()) ->SelectChannel(sel_in, &sel_out); diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 24cd8468..34622cc7 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -479,7 +479,7 @@ Socket::Socket(Forbidden) , _epollout_butex(NULL) , _write_head(NULL) , _stream_set(NULL) - //, _health_checking_using_rpc(false) + , _health_checking_using_rpc(false) { CreateVarsOnce(); pthread_mutex_init(&_id_wait_list_mutex, NULL); @@ -662,7 +662,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) { m->_error_code = 0; m->_error_text.clear(); m->_agent_socket_id.store(INVALID_SOCKET_ID, butil::memory_order_relaxed); - //m->_health_checking_using_rpc.store(false, butil::memory_order_relaxed); + m->_health_checking_using_rpc.store(false, butil::memory_order_relaxed); // NOTE: last two params are useless in bthread > r32787 const int rc = bthread_id_list_init(&m->_id_wait_list, 512, 512); if (rc) { @@ -754,6 +754,7 @@ int Socket::WaitAndReset(int32_t expected_nref) { _pipeline_q->clear(); } } + _health_checking_using_rpc.store(false, butil::memory_order_relaxed); return 0; } @@ -783,12 +784,14 @@ void Socket::Revive() { } // Set this flag to true since we add additional ref again _recycle_flag.store(false, butil::memory_order_relaxed); - //_health_checking_using_rpc.store(false, butil::memory_order_relaxed); if (_user) { _user->AfterRevived(this); } else { LOG(INFO) << "Revived " << *this; } + if (FLAGS_health_check_using_rpc) { + _health_checking_using_rpc.store(true, butil::memory_order_relaxed); + } return; } } @@ -874,7 +877,6 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) { // by Channel to revive never-connected socket when server side // comes online. if (_health_check_interval_s > 0) { - //!_health_checking_using_rpc.load(butil::memory_order_relaxed)) { GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); PeriodicTaskManager::StartTaskAt( new HealthCheckTask(id()), @@ -1034,34 +1036,31 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { if (ptr->CreatedByConnect()) { s_vars->channel_conn << -1; } - if (FLAGS_health_check_using_rpc) { - //ptr->_health_checking_using_rpc.store(true, butil::memory_order_relaxed); + ptr->Revive(); + ptr->_hc_count = 0; + if (ptr->IsHealthCheckingUsingRPC()) { brpc::ChannelOptions options; options.protocol = "http"; options.max_retry = 0; options.timeout_ms = FLAGS_health_check_timeout_ms; brpc::Channel channel; if (channel.Init(_id, &options) != 0) { - ++ ptr->_hc_count; - *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); - return true; + // SetFailed() again to trigger next round of health checking + ptr->SetFailed(); + return false; } - brpc::Controller cntl; cntl.http_request().uri() = FLAGS_health_check_path; cntl.set_health_check_call(true); channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); if (cntl.Failed()) { - LOG(WARNING) << "Fail to health check using rpc, error=" + RPC_VLOG << "Fail to health check using rpc, error=" << cntl.ErrorText(); - ++ ptr->_hc_count; - *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); - return true; + ptr->SetFailed(); + return false; } - LOG(INFO) << "Succeed to health check using rpc"; + ptr->ResetHealthCheckingUsingRPC(); } - ptr->Revive(); - ptr->_hc_count = 0; return false; } else if (hc == ESTOP) { LOG(INFO) << "Cancel checking " << *ptr; @@ -2241,6 +2240,7 @@ void Socket::DebugSocket(std::ostream& os, SocketId id) { << "\nauth_id=" << ptr->_auth_id.value << "\nauth_context=" << ptr->_auth_context << "\nlogoff_flag=" << ptr->_logoff_flag.load(butil::memory_order_relaxed) + // TODO(zhujiashun): add _health_checking_using_rpc << "\nrecycle_flag=" << ptr->_recycle_flag.load(butil::memory_order_relaxed) << "\nagent_socket_id="; const SocketId asid = ptr->_agent_socket_id.load(butil::memory_order_relaxed); diff --git a/src/brpc/socket.h b/src/brpc/socket.h index 76eb749d..e4f1d155 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -351,7 +351,8 @@ public: // TODO(zhujiashun) bool IsHealthCheckingUsingRPC() const; - + void ResetHealthCheckingUsingRPC(); + // Start to process edge-triggered events from the fd. // This function does not block caller. static int StartInputEvent(SocketId id, uint32_t events, @@ -797,7 +798,6 @@ private: // If this flag is set, then the current socket is used to health check // and should not health check again butil::atomic _health_checking_using_rpc; - }; } // namespace brpc diff --git a/src/brpc/socket_inl.h b/src/brpc/socket_inl.h index 021386dd..5a9dd7c3 100644 --- a/src/brpc/socket_inl.h +++ b/src/brpc/socket_inl.h @@ -249,6 +249,10 @@ inline bool Socket::IsHealthCheckingUsingRPC() const { return _health_checking_using_rpc.load(butil::memory_order_relaxed); } +inline void Socket::ResetHealthCheckingUsingRPC() { + _health_checking_using_rpc.store(false, butil::memory_order_relaxed); +} + static const uint32_t EOF_FLAG = (1 << 31); inline void Socket::PostponeEOF() { diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 6ba865ac..7fbc880c 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -205,7 +205,7 @@ void* select_server(void* arg) { brpc::LoadBalancer* c = sa->lb; brpc::SocketUniquePtr ptr; CountMap *selected_count = new CountMap; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; brpc::LoadBalancer::SelectOut out(&ptr); uint32_t rand_seed = rand(); if (sa->hash) { @@ -259,7 +259,7 @@ TEST_F(LoadBalancerTest, update_while_selection) { // Accessing empty lb should result in error. brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, NULL, false }; brpc::LoadBalancer::SelectOut out(&ptr); ASSERT_EQ(ENODATA, lb->SelectServer(in, &out)); @@ -555,7 +555,7 @@ TEST_F(LoadBalancerTest, consistent_hashing) { const size_t SELECT_TIMES = 1000000; std::map times; brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; ::brpc::LoadBalancer::SelectOut out(&ptr); for (size_t i = 0; i < SELECT_TIMES; ++i) { in.has_request_code = true; @@ -632,7 +632,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) { // consistent with weight configured. std::map select_result; brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; brpc::LoadBalancer::SelectOut out(&ptr); int total_weight = 12; std::vector select_servers; @@ -647,11 +647,11 @@ TEST_F(LoadBalancerTest, weighted_round_robin) { } std::cout << std::endl; // Check whether slected result is consistent with expected. - EXPECT_EQ(3, select_result.size()); + EXPECT_EQ((size_t)3, select_result.size()); for (const auto& result : select_result) { std::cout << result.first << " result=" << result.second << " configured=" << configed_weight[result.first] << std::endl; - EXPECT_EQ(result.second, configed_weight[result.first]); + EXPECT_EQ(result.second, (size_t)configed_weight[result.first]); } } @@ -690,10 +690,101 @@ TEST_F(LoadBalancerTest, weighted_round_robin_no_valid_server) { // The first socket is excluded. The second socket is logfoff. // The third socket is invalid. brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, exclude }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, exclude, false }; brpc::LoadBalancer::SelectOut out(&ptr); EXPECT_EQ(EHOSTDOWN, wrrlb.SelectServer(in, &out)); brpc::ExcludedServers::Destroy(exclude); } +TEST_F(LoadBalancerTest, health_checking_no_valid_server) { + // If socket is revived and FLAGS_health_check_using_rpc is set, + // this socket should not be selected. + const char* servers[] = { + "10.92.115.19:8832", + "10.42.122.201:8833", + }; + + std::vector lbs; + lbs.push_back(new brpc::policy::RoundRobinLoadBalancer); + lbs.push_back(new brpc::policy::RandomizedLoadBalancer); + lbs.push_back(new brpc::policy::WeightedRoundRobinLoadBalancer); + + for (int i = 0; i < (int)lbs.size(); ++i) { + brpc::LoadBalancer* lb = lbs[i]; + std::vector ids; + for (size_t i = 0; i < ARRAY_SIZE(servers); ++i) { + butil::EndPoint dummy; + ASSERT_EQ(0, str2endpoint(servers[i], &dummy)); + brpc::ServerId id(8888); + brpc::SocketOptions options; + options.remote_side = dummy; + ASSERT_EQ(0, brpc::Socket::Create(options, &id.id)); + id.tag = "50"; + ids.push_back(id); + lb->AddServer(id); + } + + // Without setting anything, the lb should work fine + for (int i = 0; i < 4; ++i) { + brpc::SocketUniquePtr ptr; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectOut out(&ptr); + ASSERT_EQ(0, lb->SelectServer(in, &out)); + } + + brpc::SocketUniquePtr ptr; + ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); + ptr->_health_checking_using_rpc.store(true, butil::memory_order_relaxed); + for (int i = 0; i < 4; ++i) { + brpc::SocketUniquePtr ptr; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectOut out(&ptr); + ASSERT_EQ(0, lb->SelectServer(in, &out)); + // After putting server[0] into health checking state, the only choice is servers[1] + ASSERT_EQ(ptr->remote_side().port, 8833); + } + + ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); + ptr->_health_checking_using_rpc.store(true, butil::memory_order_relaxed); + for (int i = 0; i < 4; ++i) { + brpc::SocketUniquePtr ptr; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectOut out(&ptr); + // There is no server available + ASSERT_EQ(EHOSTDOWN, lb->SelectServer(in, &out)); + } + + // set health_check_call to true, the lb should work fine + bool get_server1 = false; + bool get_server2 = false; + // The probability of 20 consecutive same server is 1 / (2^19) + for (int i = 0; i < 20; ++i) { + brpc::SocketUniquePtr ptr; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, true }; + brpc::LoadBalancer::SelectOut out(&ptr); + ASSERT_EQ(0, lb->SelectServer(in, &out)); + if (ptr->remote_side().port == 8832) { + get_server1 = true; + } else { + get_server2 = true; + } + } + ASSERT_TRUE(get_server1 && get_server2); + ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); + ptr->ResetHealthCheckingUsingRPC(); + ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); + ptr->ResetHealthCheckingUsingRPC(); + + // After reset health checking state, the lb should work fine + for (int i = 0; i < 4; ++i) { + brpc::SocketUniquePtr ptr; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectOut out(&ptr); + ASSERT_EQ(0, lb->SelectServer(in, &out)); + } + + delete lb; + } +} + } //namespace diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index 0683ce05..3692933b 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -7,6 +7,7 @@ #include #include // F_GETFD #include +#include #include "butil/gperftools_profiler.h" #include "butil/time.h" #include "butil/macros.h" @@ -21,6 +22,8 @@ #include "brpc/policy/http_rpc_protocol.h" #include "brpc/nshead.h" #include "brpc/server.h" +#include "brpc/channel.h" +#include "brpc/controller.h" #include "health_check.pb.h" #if defined(OS_MACOSX) #include @@ -32,6 +35,10 @@ namespace bthread { extern TaskControl* g_task_control; } +namespace brpc { +DECLARE_int32(health_check_interval); +} + void EchoProcessHuluRequest(brpc::InputMessageBase* msg_base); int main(int argc, char* argv[]) { @@ -537,13 +544,9 @@ public: google::protobuf::Closure* done) { brpc::ClosureGuard done_guard(done); brpc::Controller* cntl = (brpc::Controller*)cntl_base; - LOG(INFO) << "In HealthCheckTestServiceImpl, flag=" << _sleep_flag; if (_sleep_flag) { bthread_usleep(310000 /* 310ms, a little bit longer than the default timeout of health checking rpc */); - } else { - LOG(INFO) << "Return fast!"; - } cntl->response_attachment().append("OK"); } @@ -554,80 +557,52 @@ public: TEST_F(SocketTest, health_check_using_rpc) { GFLAGS_NS::SetCommandLineOption("health_check_using_rpc", "true"); GFLAGS_NS::SetCommandLineOption("health_check_path", "/HealthCheckTestService"); - brpc::SocketId id = 8888; - butil::EndPoint point(butil::IP_ANY, 7777); - const int kCheckInteval = 1; - brpc::SocketOptions options; - options.remote_side = point; - options.user = new CheckRecycle; - options.health_check_interval_s = kCheckInteval/*s*/; - ASSERT_EQ(0, brpc::Socket::Create(options, &id)); - brpc::SocketUniquePtr s; - ASSERT_EQ(0, brpc::Socket::Address(id, &s)); - - global_sock = s.get(); - ASSERT_TRUE(global_sock); + int old_health_check_interval = brpc::FLAGS_health_check_interval; - const char* buf = "GET / HTTP/1.1\r\nHost: brpc.com\r\n\r\n"; - const bool use_my_message = (butil::fast_rand_less_than(2) == 0); - brpc::SocketMessagePtr msg; - int appended_msg = 0; - butil::IOBuf src; - if (use_my_message) { - LOG(INFO) << "Use MyMessage"; - msg.reset(new MyMessage(buf, strlen(buf), &appended_msg)); - } else { - src.append(buf, strlen(buf)); - ASSERT_EQ(strlen(buf), src.length()); + brpc::ChannelOptions options; + options.protocol = "http"; + options.max_retry = 0; + brpc::Channel channel; + ASSERT_EQ(0, channel.Init("127.0.0.1:7777", &options)); + { + brpc::Controller cntl; + cntl.http_request().uri() = "/"; + channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + EXPECT_TRUE(cntl.Failed()); + ASSERT_EQ(ECONNREFUSED, cntl.ErrorCode()); } -#ifdef CONNECT_IN_KEEPWRITE - bthread_id_t wait_id; - WaitData data; - ASSERT_EQ(0, bthread_id_create2(&wait_id, &data, OnWaitIdReset)); - brpc::Socket::WriteOptions wopt; - wopt.id_wait = wait_id; - if (use_my_message) { - ASSERT_EQ(0, s->Write(msg, &wopt)); - } else { - ASSERT_EQ(0, s->Write(&src, &wopt)); - } - ASSERT_EQ(0, bthread_id_join(wait_id)); - ASSERT_EQ(wait_id.value, data.id.value); - ASSERT_EQ(ECONNREFUSED, data.error_code); - ASSERT_TRUE(butil::StringPiece(data.error_text).starts_with( - "Fail to connect ")); - if (use_my_message) { - ASSERT_TRUE(appended_msg); - } -#else - if (use_my_message) { - ASSERT_EQ(-1, s->Write(msg)); - } else { - ASSERT_EQ(-1, s->Write(&src)); - } - ASSERT_EQ(ECONNREFUSED, errno); -#endif - ASSERT_TRUE(src.empty()); - ASSERT_EQ(-1, s->fd()); - ASSERT_TRUE(global_sock); - brpc::SocketUniquePtr invalid_ptr; - ASSERT_EQ(-1, brpc::Socket::Address(id, &invalid_ptr)); - + brpc::Server server; HealthCheckTestServiceImpl hc_service; ASSERT_EQ(0, server.AddService(&hc_service, brpc::SERVER_DOESNT_OWN_SERVICE)); ASSERT_EQ(0, server.Start("127.0.0.1:7777", NULL)); + for (int i = 0; i < 3; ++i) { // although ::connect would succeed, the stall in hc_service makes // the health checking rpc fail. - ASSERT_EQ(1, brpc::Socket::Status(id)); + brpc::Controller cntl; + cntl.http_request().uri() = "/"; + channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + ASSERT_EQ(EHOSTDOWN, cntl.ErrorCode()); bthread_usleep(1000000 /*1s*/); } hc_service._sleep_flag = false; - bthread_usleep(2000000); - // recover - ASSERT_EQ(0, brpc::Socket::Status(id)); + // sleep so long because of the buggy impl of health check with no circuit breaker + // enabled but the sleep time is still exponentially backoff. + bthread_usleep(2500000); + // should recover now + { + brpc::Controller cntl; + cntl.http_request().uri() = "/"; + channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); + ASSERT_FALSE(cntl.Failed()); + ASSERT_GT(cntl.response_attachment().size(), (size_t)0); + } + GFLAGS_NS::SetCommandLineOption("health_check_using_rpc", "false"); + char hc_buf[8]; + snprintf(hc_buf, sizeof(hc_buf), "%d", old_health_check_interval); + GFLAGS_NS::SetCommandLineOption("health_check_interval", hc_buf); } TEST_F(SocketTest, health_check) { From 8b2edf4eb8d4ed44c69d40fdd4bc697ce9bb53e0 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 20 Mar 2019 18:14:19 +0800 Subject: [PATCH 063/270] health_check_using_rpc: refine comment --- src/brpc/controller.h | 4 +++- src/brpc/socket.cpp | 11 +++++++---- src/brpc/socket.h | 10 +++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/brpc/controller.h b/src/brpc/controller.h index c6f988e8..04335e3d 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -325,7 +325,9 @@ public: bool is_done_allowed_to_run_in_place() const { return has_flag(FLAGS_ALLOW_DONE_TO_RUN_IN_PLACE); } - // TODO(zhujiahsun): comment + // Tell RPC that this particular call is used to do health check. These two + // functions is used by the developers of brpc and should not be touched or + // called by users. void set_health_check_call(bool f) { set_flag(FLAGS_HEALTH_CHECK_CALL, f); } bool has_health_check_call() const { return has_flag(FLAGS_HEALTH_CHECK_CALL); } diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 34622cc7..a4d6bd2d 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -94,9 +94,12 @@ DEFINE_int32(connect_timeout_as_unreachable, 3, "times *continuously*, the error is changed to ENETUNREACH which " "fails the main socket as well when this socket is pooled."); -DEFINE_bool(health_check_using_rpc, false, "todo"); -DEFINE_string(health_check_path, "/health", "todo"); -DEFINE_int32(health_check_timeout_ms, 300, "todo"); +DEFINE_bool(health_check_using_rpc, false, "By default health check succeeds if server" + "can be connected. If this flag is set, health check is completed not only" + "when server can be connected but also an additional http call succeeds" + "indicated by FLAGS_health_check_path and FLAGS_health_check_timeout_ms"); +DEFINE_string(health_check_path, "/health", "Http path of health check call"); +DEFINE_int32(health_check_timeout_ms, 300, "Timeout of health check call"); static bool validate_connect_timeout_as_unreachable(const char*, int32_t v) { return v >= 2 && v < 1000/*large enough*/; @@ -1045,7 +1048,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { options.timeout_ms = FLAGS_health_check_timeout_ms; brpc::Channel channel; if (channel.Init(_id, &options) != 0) { - // SetFailed() again to trigger next round of health checking + // SetFailed to trigger next round of health checking ptr->SetFailed(); return false; } diff --git a/src/brpc/socket.h b/src/brpc/socket.h index e4f1d155..e8a82f4c 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -349,8 +349,12 @@ public: void SetLogOff(); bool IsLogOff() const; - // TODO(zhujiashun) + // Check Whether the state is in health check using rpc state or + // not, which means this socket would not be selected in further + // user request until rpc succeed and can only be used by health + // check rpc call. bool IsHealthCheckingUsingRPC() const; + // Reset health check state to the initial state(which is false) void ResetHealthCheckingUsingRPC(); // Start to process edge-triggered events from the fd. @@ -795,8 +799,8 @@ private: butil::Mutex _stream_mutex; std::set *_stream_set; - // If this flag is set, then the current socket is used to health check - // and should not health check again + // If this flag is set, socket is now in health check state using + // application-level rpc. butil::atomic _health_checking_using_rpc; }; From e38afc885d0a5924d78036613002f4d8530076ba Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 20 Mar 2019 18:24:16 +0800 Subject: [PATCH 064/270] health_check_using_rpc: add doc --- docs/cn/client.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index ec0254b0..a7542ead 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -242,7 +242,7 @@ locality-aware,优先选择延时低的下游,直到其延时高于其他机 | ------------------------- | ----- | ---------------------------------------- | ----------------------- | | health_check_interval (R) | 3 | seconds between consecutive health-checkings | src/brpc/socket_map.cpp | -一旦server被连接上,它会恢复为可用状态。如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 +在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过-health\_check\_using\_rpc=true来打开这个功能,-health\_check\_path设置访问的路径(默认访问brpc自带的/health接口),-health\_check\_timeout\_ms设置访问超时。当一个连接断开时,只有如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 # 发起访问 From a236b5d1fcc8a459f1d951544fc8d1188ab7830b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 20 Mar 2019 18:29:35 +0800 Subject: [PATCH 065/270] health_check_using_rpc: refine doc and comment --- docs/cn/client.md | 2 +- src/brpc/socket.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index a7542ead..222f3bce 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -242,7 +242,7 @@ locality-aware,优先选择延时低的下游,直到其延时高于其他机 | ------------------------- | ----- | ---------------------------------------- | ----------------------- | | health_check_interval (R) | 3 | seconds between consecutive health-checkings | src/brpc/socket_map.cpp | -在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过-health\_check\_using\_rpc=true来打开这个功能,-health\_check\_path设置访问的路径(默认访问brpc自带的/health接口),-health\_check\_timeout\_ms设置访问超时。当一个连接断开时,只有如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 +在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过-health\_check\_using\_rpc=true来打开这个功能,-health\_check\_path设置访问的路径(默认访问brpc自带的/health接口),-health\_check\_timeout\_ms设置超时(默认500ms)。当一个连接断开时,只有如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 # 发起访问 diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index a4d6bd2d..45fe8b39 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -99,7 +99,7 @@ DEFINE_bool(health_check_using_rpc, false, "By default health check succeeds if "when server can be connected but also an additional http call succeeds" "indicated by FLAGS_health_check_path and FLAGS_health_check_timeout_ms"); DEFINE_string(health_check_path, "/health", "Http path of health check call"); -DEFINE_int32(health_check_timeout_ms, 300, "Timeout of health check call"); +DEFINE_int32(health_check_timeout_ms, 500, "Timeout of health check call"); static bool validate_connect_timeout_as_unreachable(const char*, int32_t v) { return v >= 2 && v < 1000/*large enough*/; @@ -2243,8 +2243,9 @@ void Socket::DebugSocket(std::ostream& os, SocketId id) { << "\nauth_id=" << ptr->_auth_id.value << "\nauth_context=" << ptr->_auth_context << "\nlogoff_flag=" << ptr->_logoff_flag.load(butil::memory_order_relaxed) - // TODO(zhujiashun): add _health_checking_using_rpc << "\nrecycle_flag=" << ptr->_recycle_flag.load(butil::memory_order_relaxed) + << "\nhealth_checking_using_rpc=" + << ptr->_health_checking_using_rpc.load(butil::memory_order_relaxed) << "\nagent_socket_id="; const SocketId asid = ptr->_agent_socket_id.load(butil::memory_order_relaxed); if (asid != INVALID_SOCKET_ID) { From a2cc202cfa8ed6dc89f0e72c46b47311169b1a4a Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 20 Mar 2019 20:28:47 +0800 Subject: [PATCH 066/270] health_check_using_rpc: fix UT --- test/brpc_socket_unittest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index 3692933b..fbe22758 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -545,7 +545,7 @@ public: brpc::ClosureGuard done_guard(done); brpc::Controller* cntl = (brpc::Controller*)cntl_base; if (_sleep_flag) { - bthread_usleep(310000 /* 310ms, a little bit longer than the default + bthread_usleep(510000 /* 510ms, a little bit longer than the default timeout of health checking rpc */); } cntl->response_attachment().append("OK"); @@ -589,7 +589,7 @@ TEST_F(SocketTest, health_check_using_rpc) { hc_service._sleep_flag = false; // sleep so long because of the buggy impl of health check with no circuit breaker // enabled but the sleep time is still exponentially backoff. - bthread_usleep(2500000); + bthread_usleep(3000000); // should recover now { brpc::Controller cntl; From 69477c32e12deb2076c1e3b831a8afcb9ac8c593 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 20 Mar 2019 20:33:27 +0800 Subject: [PATCH 067/270] health_check_using_rpc: fix docs --- docs/cn/client.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index 222f3bce..b2c50120 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -242,7 +242,7 @@ locality-aware,优先选择延时低的下游,直到其延时高于其他机 | ------------------------- | ----- | ---------------------------------------- | ----------------------- | | health_check_interval (R) | 3 | seconds between consecutive health-checkings | src/brpc/socket_map.cpp | -在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过-health\_check\_using\_rpc=true来打开这个功能,-health\_check\_path设置访问的路径(默认访问brpc自带的/health接口),-health\_check\_timeout\_ms设置超时(默认500ms)。当一个连接断开时,只有如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 +在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过-health\_check\_using\_rpc=true来打开这个功能,-health\_check\_path设置访问的路径(默认访问brpc自带的/health接口),-health\_check\_timeout\_ms设置超时(默认500ms)。如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 # 发起访问 From 44c9698a244c7677c897207b5a30f8dee25b2e48 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 21 Mar 2019 11:40:16 +0800 Subject: [PATCH 068/270] health_check_using_rpc: change the position of Channel::Init --- src/brpc/channel.cpp | 3 ++- src/brpc/channel.h | 6 +++++- test/brpc_http_rpc_protocol_unittest.cpp | 10 +++++----- test/brpc_naming_service_filter_unittest.cpp | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index 9920d457..8a821f68 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -565,7 +565,8 @@ int Channel::Weight() { int Channel::CheckHealth() { if (_lb == NULL) { SocketUniquePtr ptr; - if (Socket::Address(_server_id, &ptr) == 0) { + if (Socket::Address(_server_id, &ptr) == 0 && !ptr->IsLogOff() && + !ptr->IsHealthCheckingUsingRPC()) { return 0; } return -1; diff --git a/src/brpc/channel.h b/src/brpc/channel.h index 4e0154f5..9836b100 100644 --- a/src/brpc/channel.h +++ b/src/brpc/channel.h @@ -146,6 +146,7 @@ private: class Channel : public ChannelBase { friend class Controller; friend class SelectiveChannel; +friend class HealthCheckTask; public: Channel(ProfilerLinker = ProfilerLinker()); ~Channel(); @@ -155,7 +156,6 @@ public: int Init(butil::EndPoint server_addr_and_port, const ChannelOptions* options); int Init(const char* server_addr_and_port, const ChannelOptions* options); int Init(const char* server_addr, int port, const ChannelOptions* options); - int Init(SocketId id, const ChannelOptions* options); // Connect this channel to a group of servers whose addresses can be // accessed via `naming_service_url' according to its protocol. Use the @@ -215,6 +215,10 @@ protected: const char* raw_server_address, const ChannelOptions* options); + // Init a channel from a known SocketId. Currently it is + // used only by health check using rpc. + int Init(SocketId id, const ChannelOptions* options); + butil::EndPoint _server_address; SocketId _server_id; Protocol::SerializeRequest _serialize_request; diff --git a/test/brpc_http_rpc_protocol_unittest.cpp b/test/brpc_http_rpc_protocol_unittest.cpp index 4a2740c4..255fd055 100644 --- a/test/brpc_http_rpc_protocol_unittest.cpp +++ b/test/brpc_http_rpc_protocol_unittest.cpp @@ -706,7 +706,7 @@ TEST_F(HttpTest, read_long_body_progressively) { last_read = current_read; } // Read something in past N seconds. - ASSERT_GT(last_read, 100000); + ASSERT_GT(last_read, (size_t)100000); } // the socket still holds a ref. ASSERT_FALSE(reader->destroyed()); @@ -794,7 +794,7 @@ TEST_F(HttpTest, read_progressively_after_cntl_destroys) { last_read = current_read; } // Read something in past N seconds. - ASSERT_GT(last_read, 100000); + ASSERT_GT(last_read, (size_t)100000); ASSERT_FALSE(reader->destroyed()); } // Wait for recycling of the main socket. @@ -843,7 +843,7 @@ TEST_F(HttpTest, read_progressively_after_long_delay) { last_read = current_read; } // Read something in past N seconds. - ASSERT_GT(last_read, 100000); + ASSERT_GT(last_read, (size_t)100000); } ASSERT_FALSE(reader->destroyed()); } @@ -883,7 +883,7 @@ TEST_F(HttpTest, skip_progressive_reading) { ASSERT_EQ(0, svc.last_errno()); LOG(INFO) << "Server still wrote " << new_written_bytes - old_written_bytes; // The server side still wrote things. - ASSERT_GT(new_written_bytes - old_written_bytes, 100000); + ASSERT_GT(new_written_bytes - old_written_bytes, (size_t)100000); } class AlwaysFailRead : public brpc::ProgressiveReader { @@ -954,7 +954,7 @@ TEST_F(HttpTest, broken_socket_stops_progressive_reading) { last_read = current_read; } // Read something in past N seconds. - ASSERT_GT(last_read, 100000); + ASSERT_GT(last_read, (size_t)100000); } // the socket still holds a ref. ASSERT_FALSE(reader->destroyed()); diff --git a/test/brpc_naming_service_filter_unittest.cpp b/test/brpc_naming_service_filter_unittest.cpp index b25470df..1d75cde4 100644 --- a/test/brpc_naming_service_filter_unittest.cpp +++ b/test/brpc_naming_service_filter_unittest.cpp @@ -53,7 +53,7 @@ TEST_F(NamingServiceFilterTest, sanity) { ASSERT_EQ(0, butil::hostname2endpoint("10.128.0.1:1234", &ep)); for (int i = 0; i < 10; ++i) { brpc::SocketUniquePtr tmp_sock; - brpc::LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL }; + brpc::LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL, false }; brpc::LoadBalancer::SelectOut sel_out(&tmp_sock); ASSERT_EQ(0, channel._lb->SelectServer(sel_in, &sel_out)); ASSERT_EQ(ep, tmp_sock->remote_side()); From cfbe1e5c33eb5851f998a87e1211f13ecf3022b8 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 22 Mar 2019 14:10:10 +0800 Subject: [PATCH 069/270] health_check_using_rpc: hc in the original task again if failed --- src/brpc/socket.cpp | 34 +++++++++++++++++++++++++++++----- test/brpc_socket_unittest.cpp | 7 +++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 45fe8b39..eeea1bb8 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -879,7 +879,11 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) { // Do health-checking even if we're not connected before, needed // by Channel to revive never-connected socket when server side // comes online. - if (_health_check_interval_s > 0) { + if (_health_check_interval_s > 0 && + // We don't want to start another health check task while + // the socket is in health checking using rpc state. + // Also see comment in HealthCheckTask::OnTriggeringTask + !_health_checking_using_rpc.load(butil::memory_order_relaxed)) { GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); PeriodicTaskManager::StartTaskAt( new HealthCheckTask(id()), @@ -1048,9 +1052,10 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { options.timeout_ms = FLAGS_health_check_timeout_ms; brpc::Channel channel; if (channel.Init(_id, &options) != 0) { - // SetFailed to trigger next round of health checking ptr->SetFailed(); - return false; + ++ ptr->_hc_count; + *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); + return true; } brpc::Controller cntl; cntl.http_request().uri() = FLAGS_health_check_path; @@ -1059,8 +1064,27 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { if (cntl.Failed()) { RPC_VLOG << "Fail to health check using rpc, error=" << cntl.ErrorText(); - ptr->SetFailed(); - return false; + // the hc rpc above may fail too, we should handle this case + // carefully. If this rpc fails, hc must be triggered again. + // One Solution is to trigger the second hc in Socket::SetFailed + // in rpc code path, but rpc fails doesn't mean socket fails, + // so we should call Socket::SetFailed[1] explicitly here. + // But there is a race here: + // If the second hc succeed, the socket is revived and comes back + // to normal, after that, [1] is called here, making socket failed + // again, which is not an expected case. + // + // Another solution is to forbid hc while socket is in health check + // using rpc state. So there would be no second hc memtioned above, + // and this task should return true to trigger next round hc. There + // is no race in this solution. + // + // We take the second solution here, which is a clear and simple + // solution. + ptr->SetFailed(); // [1] + ++ ptr->_hc_count; + *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); + return true; } ptr->ResetHealthCheckingUsingRPC(); } diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index fbe22758..dcb40959 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -555,9 +555,10 @@ public: }; TEST_F(SocketTest, health_check_using_rpc) { + int old_health_check_interval = brpc::FLAGS_health_check_interval; GFLAGS_NS::SetCommandLineOption("health_check_using_rpc", "true"); GFLAGS_NS::SetCommandLineOption("health_check_path", "/HealthCheckTestService"); - int old_health_check_interval = brpc::FLAGS_health_check_interval; + GFLAGS_NS::SetCommandLineOption("health_check_interval", "1"); brpc::ChannelOptions options; options.protocol = "http"; @@ -587,9 +588,7 @@ TEST_F(SocketTest, health_check_using_rpc) { bthread_usleep(1000000 /*1s*/); } hc_service._sleep_flag = false; - // sleep so long because of the buggy impl of health check with no circuit breaker - // enabled but the sleep time is still exponentially backoff. - bthread_usleep(3000000); + bthread_usleep(2000000 /* a little bit longer than hc rpc timeout + hc interval */); // should recover now { brpc::Controller cntl; From 387d034bda5fd59ba3e71ec6d2a84667458893ff Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 22 Mar 2019 16:09:40 +0800 Subject: [PATCH 070/270] health_check_using_rpc: use HealthCheckChannel instead of Channel to hc --- src/brpc/channel.cpp | 9 --------- src/brpc/channel.h | 4 ---- src/brpc/socket.cpp | 20 +++++++++++++++++++- test/brpc_socket_unittest.cpp | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index 8a821f68..f8494fd4 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -281,15 +281,6 @@ int Channel::Init(butil::EndPoint server_addr_and_port, return InitSingle(server_addr_and_port, "", options); } -int Channel::Init(SocketId id, const ChannelOptions* options) { - GlobalInitializeOrDie(); - if (InitChannelOptions(options) != 0) { - return -1; - } - _server_id = id; - return 0; -} - int Channel::InitSingle(const butil::EndPoint& server_addr_and_port, const char* raw_server_address, const ChannelOptions* options) { diff --git a/src/brpc/channel.h b/src/brpc/channel.h index 9836b100..e5cb5e93 100644 --- a/src/brpc/channel.h +++ b/src/brpc/channel.h @@ -215,10 +215,6 @@ protected: const char* raw_server_address, const ChannelOptions* options); - // Init a channel from a known SocketId. Currently it is - // used only by health check using rpc. - int Init(SocketId id, const ChannelOptions* options); - butil::EndPoint _server_address; SocketId _server_id; Protocol::SerializeRequest _serialize_request; diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index eeea1bb8..d83f9709 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -50,6 +50,7 @@ #include "brpc/periodic_task.h" #include "brpc/channel.h" #include "brpc/controller.h" +#include "brpc/global.h" #if defined(OS_MACOSX) #include #endif @@ -998,6 +999,23 @@ void HealthCheckTask::OnDestroyingTask() { delete this; } +class HealthCheckChannel : public brpc::Channel { +public: + HealthCheckChannel() {} + ~HealthCheckChannel() {} + + int Init(SocketId id, const ChannelOptions* options); +}; + +int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) { + brpc::GlobalInitializeOrDie(); + if (InitChannelOptions(options) != 0) { + return -1; + } + _server_id = id; + return 0; +} + bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { SocketUniquePtr ptr; const int rc = Socket::AddressFailedAsWell(_id, &ptr); @@ -1050,7 +1068,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { options.protocol = "http"; options.max_retry = 0; options.timeout_ms = FLAGS_health_check_timeout_ms; - brpc::Channel channel; + HealthCheckChannel channel; if (channel.Init(_id, &options) != 0) { ptr->SetFailed(); ++ ptr->_hc_count; diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index dcb40959..5ac0da6e 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -578,7 +578,7 @@ TEST_F(SocketTest, health_check_using_rpc) { ASSERT_EQ(0, server.AddService(&hc_service, brpc::SERVER_DOESNT_OWN_SERVICE)); ASSERT_EQ(0, server.Start("127.0.0.1:7777", NULL)); - for (int i = 0; i < 3; ++i) { + for (int i = 0; i < 4; ++i) { // although ::connect would succeed, the stall in hc_service makes // the health checking rpc fail. brpc::Controller cntl; From 400d8c613b2fa71aa9fe7b3bd3ae487159bbceab Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 22 Mar 2019 16:37:04 +0800 Subject: [PATCH 071/270] health_check_using_rpc: remove unnecessary friend class --- src/brpc/channel.h | 1 - src/brpc/socket.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/brpc/channel.h b/src/brpc/channel.h index e5cb5e93..be631cff 100644 --- a/src/brpc/channel.h +++ b/src/brpc/channel.h @@ -146,7 +146,6 @@ private: class Channel : public ChannelBase { friend class Controller; friend class SelectiveChannel; -friend class HealthCheckTask; public: Channel(ProfilerLinker = ProfilerLinker()); ~Channel(); diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index d83f9709..4c341384 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -1084,7 +1084,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { << cntl.ErrorText(); // the hc rpc above may fail too, we should handle this case // carefully. If this rpc fails, hc must be triggered again. - // One Solution is to trigger the second hc in Socket::SetFailed + // One solution is to trigger the second hc in Socket::SetFailed // in rpc code path, but rpc fails doesn't mean socket fails, // so we should call Socket::SetFailed[1] explicitly here. // But there is a race here: From d5bc479ea06b73b85f3ab89ff392078778b30e1a Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 23 Mar 2019 11:19:38 +0800 Subject: [PATCH 072/270] health_check_using_rpc: make hc rpc async --- src/brpc/socket.cpp | 114 ++++++++++++++++++++-------------- src/brpc/socket.h | 2 + test/brpc_socket_unittest.cpp | 16 ++++- 3 files changed, 84 insertions(+), 48 deletions(-) diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 4c341384..cfc39614 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -880,11 +880,7 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) { // Do health-checking even if we're not connected before, needed // by Channel to revive never-connected socket when server side // comes online. - if (_health_check_interval_s > 0 && - // We don't want to start another health check task while - // the socket is in health checking using rpc state. - // Also see comment in HealthCheckTask::OnTriggeringTask - !_health_checking_using_rpc.load(butil::memory_order_relaxed)) { + if (_health_check_interval_s > 0) { GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); PeriodicTaskManager::StartTaskAt( new HealthCheckTask(id()), @@ -1016,6 +1012,72 @@ int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) { return 0; } +class OnHealthCheckRPCDone : public google::protobuf::Closure { +public: + void Run() { + std::unique_ptr self_guard(this); + SocketUniquePtr ptr; + const int rc = Socket::AddressFailedAsWell(id, &ptr); + if (rc < 0) { + RPC_VLOG << "SocketId=" << id + << " was abandoned during health checking"; + return; + } + if (!cntl.Failed()) { + ptr->ResetHealthCheckingUsingRPC(); + return; + } + + // Socket::SetFailed() will trigger next round of hc, just + // return here. + if (cntl.Failed() && ptr->Failed()) { + return; + } + // the left case is cntl.Failed() && !ptr->Failed(), + // in which we should retry hc rpc. + RPC_VLOG << "Fail to health check using rpc, error=" + << cntl.ErrorText(); + bthread_usleep(interval_s * 1000000); + cntl.Reset(); + cntl.http_request().uri() = FLAGS_health_check_path; + cntl.set_health_check_call(true); + channel.CallMethod(NULL, &cntl, NULL, NULL, self_guard.release()); + } + + HealthCheckChannel channel; + brpc::Controller cntl; + SocketId id; + int64_t interval_s; +}; + +class HealthCheckManager { +public: + static void StartCheck(SocketId id, int64_t check_interval_s) { + SocketUniquePtr ptr; + const int rc = Socket::AddressFailedAsWell(id, &ptr); + if (rc < 0) { + RPC_VLOG << "SocketId=" << id + << " was abandoned during health checking"; + return; + } + OnHealthCheckRPCDone* done = new OnHealthCheckRPCDone; + done->id = id; + done->interval_s = check_interval_s; + brpc::ChannelOptions options; + options.protocol = "http"; + options.max_retry = 0; + options.timeout_ms = FLAGS_health_check_timeout_ms; + if (done->channel.Init(id, &options) != 0) { + LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; + ptr->ResetHealthCheckingUsingRPC(); + return; + } + done->cntl.http_request().uri() = FLAGS_health_check_path; + done->cntl.set_health_check_call(true); + done->channel.CallMethod(NULL, &done->cntl, NULL, NULL, done); + } +}; + bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { SocketUniquePtr ptr; const int rc = Socket::AddressFailedAsWell(_id, &ptr); @@ -1064,47 +1126,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { ptr->Revive(); ptr->_hc_count = 0; if (ptr->IsHealthCheckingUsingRPC()) { - brpc::ChannelOptions options; - options.protocol = "http"; - options.max_retry = 0; - options.timeout_ms = FLAGS_health_check_timeout_ms; - HealthCheckChannel channel; - if (channel.Init(_id, &options) != 0) { - ptr->SetFailed(); - ++ ptr->_hc_count; - *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); - return true; - } - brpc::Controller cntl; - cntl.http_request().uri() = FLAGS_health_check_path; - cntl.set_health_check_call(true); - channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); - if (cntl.Failed()) { - RPC_VLOG << "Fail to health check using rpc, error=" - << cntl.ErrorText(); - // the hc rpc above may fail too, we should handle this case - // carefully. If this rpc fails, hc must be triggered again. - // One solution is to trigger the second hc in Socket::SetFailed - // in rpc code path, but rpc fails doesn't mean socket fails, - // so we should call Socket::SetFailed[1] explicitly here. - // But there is a race here: - // If the second hc succeed, the socket is revived and comes back - // to normal, after that, [1] is called here, making socket failed - // again, which is not an expected case. - // - // Another solution is to forbid hc while socket is in health check - // using rpc state. So there would be no second hc memtioned above, - // and this task should return true to trigger next round hc. There - // is no race in this solution. - // - // We take the second solution here, which is a clear and simple - // solution. - ptr->SetFailed(); // [1] - ++ ptr->_hc_count; - *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); - return true; - } - ptr->ResetHealthCheckingUsingRPC(); + HealthCheckManager::StartCheck(_id, ptr->_health_check_interval_s); } return false; } else if (hc == ESTOP) { diff --git a/src/brpc/socket.h b/src/brpc/socket.h index e8a82f4c..bedbb999 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -186,6 +186,8 @@ friend class policy::ConsistentHashingLoadBalancer; friend class policy::RtmpContext; friend class schan::ChannelBalancer; friend class HealthCheckTask; +friend class OnHealthCheckRPCDone; +friend class HealthCheckManager; friend class policy::H2GlobalStreamCreator; class SharedPart; struct Forbidden {}; diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index 5ac0da6e..3056d353 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -560,11 +560,12 @@ TEST_F(SocketTest, health_check_using_rpc) { GFLAGS_NS::SetCommandLineOption("health_check_path", "/HealthCheckTestService"); GFLAGS_NS::SetCommandLineOption("health_check_interval", "1"); + butil::EndPoint point(butil::IP_ANY, 7777); brpc::ChannelOptions options; options.protocol = "http"; options.max_retry = 0; brpc::Channel channel; - ASSERT_EQ(0, channel.Init("127.0.0.1:7777", &options)); + ASSERT_EQ(0, channel.Init(point, &options)); { brpc::Controller cntl; cntl.http_request().uri() = "/"; @@ -572,11 +573,22 @@ TEST_F(SocketTest, health_check_using_rpc) { EXPECT_TRUE(cntl.Failed()); ASSERT_EQ(ECONNREFUSED, cntl.ErrorCode()); } + + // 2s to make sure remote is connected by HealthCheckTask and enter the + // sending-rpc state. Because the remote is not down, so hc rpc would keep + // sending. + int listening_fd = tcp_listen(point, false); + bthread_usleep(2000000); + + // 2s to make sure HealthCheckTask find socket is failed and correct impl + // should trigger next round of hc + close(listening_fd); + bthread_usleep(2000000); brpc::Server server; HealthCheckTestServiceImpl hc_service; ASSERT_EQ(0, server.AddService(&hc_service, brpc::SERVER_DOESNT_OWN_SERVICE)); - ASSERT_EQ(0, server.Start("127.0.0.1:7777", NULL)); + ASSERT_EQ(0, server.Start(point, NULL)); for (int i = 0; i < 4; ++i) { // although ::connect would succeed, the stall in hc_service makes From 75a80db855874cc70638503bd0cc46c97d84183e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 23 Mar 2019 12:14:58 +0800 Subject: [PATCH 073/270] health_check_using_rpc: misc change & update docs --- docs/cn/client.md | 2 +- src/brpc/channel.cpp | 5 ++- src/brpc/controller.cpp | 2 +- src/brpc/controller.h | 13 +++--- src/brpc/load_balancer.h | 1 - .../consistent_hashing_load_balancer.cpp | 2 +- src/brpc/policy/dynpart_load_balancer.cpp | 2 +- .../policy/locality_aware_load_balancer.cpp | 2 +- src/brpc/policy/randomized_load_balancer.cpp | 2 +- src/brpc/policy/round_robin_load_balancer.cpp | 2 +- .../weighted_round_robin_load_balancer.cpp | 2 +- src/brpc/selective_channel.cpp | 3 +- src/brpc/socket.cpp | 12 +++--- test/brpc_load_balancer_unittest.cpp | 42 +++++++------------ test/brpc_naming_service_filter_unittest.cpp | 2 +- test/brpc_socket_unittest.cpp | 3 +- 16 files changed, 42 insertions(+), 55 deletions(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index b2c50120..5d1dd435 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -242,7 +242,7 @@ locality-aware,优先选择延时低的下游,直到其延时高于其他机 | ------------------------- | ----- | ---------------------------------------- | ----------------------- | | health_check_interval (R) | 3 | seconds between consecutive health-checkings | src/brpc/socket_map.cpp | -在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过-health\_check\_using\_rpc=true来打开这个功能,-health\_check\_path设置访问的路径(默认访问brpc自带的/health接口),-health\_check\_timeout\_ms设置超时(默认500ms)。如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 +在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过设置-health\_check\_path来打开这个功能(如果下游也是brpc,推荐设置成/health,服务健康的话会返回200),-health\_check\_timeout\_ms设置超时(默认500ms)。如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 # 发起访问 diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index f8494fd4..7c576e55 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -556,14 +556,15 @@ int Channel::Weight() { int Channel::CheckHealth() { if (_lb == NULL) { SocketUniquePtr ptr; - if (Socket::Address(_server_id, &ptr) == 0 && !ptr->IsLogOff() && + if (Socket::Address(_server_id, &ptr) == 0 && + !ptr->IsLogOff() && !ptr->IsHealthCheckingUsingRPC()) { return 0; } return -1; } else { SocketUniquePtr tmp_sock; - LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL, false}; + LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL }; LoadBalancer::SelectOut sel_out(&tmp_sock); return _lb->SelectServer(sel_in, &sel_out); } diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index d38fe500..c21fd8a5 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -998,7 +998,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { } else { LoadBalancer::SelectIn sel_in = { start_realtime_us, true, has_request_code(), - _request_code, _accessed, health_check_call}; + _request_code, _accessed }; LoadBalancer::SelectOut sel_out(&tmp_sock); const int rc = _lb->SelectServer(sel_in, &sel_out); if (rc != 0) { diff --git a/src/brpc/controller.h b/src/brpc/controller.h index 04335e3d..d679eb33 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -118,6 +118,8 @@ friend int StreamCreate(StreamId*, Controller&, const StreamOptions*); friend int StreamAccept(StreamId*, Controller&, const StreamOptions*); friend void policy::ProcessMongoRequest(InputMessageBase*); friend void policy::ProcessThriftRequest(InputMessageBase*); +friend class OnHealthCheckRPCDone; +friend class HealthCheckManager; // << Flags >> static const uint32_t FLAGS_IGNORE_EOVERCROWDED = 1; static const uint32_t FLAGS_SECURITY_MODE = (1 << 1); @@ -325,12 +327,6 @@ public: bool is_done_allowed_to_run_in_place() const { return has_flag(FLAGS_ALLOW_DONE_TO_RUN_IN_PLACE); } - // Tell RPC that this particular call is used to do health check. These two - // functions is used by the developers of brpc and should not be touched or - // called by users. - void set_health_check_call(bool f) { set_flag(FLAGS_HEALTH_CHECK_CALL, f); } - bool has_health_check_call() const { return has_flag(FLAGS_HEALTH_CHECK_CALL); } - // ------------------------------------------------------------------------ // Server-side methods. // These calls shall be made from the server side only. Their results are @@ -590,6 +586,11 @@ private: CallId id = { _correlation_id.value + nretry + 1 }; return id; } + + // Tell RPC that this particular call is used to do health check. + void set_health_check_call(bool f) { set_flag(FLAGS_HEALTH_CHECK_CALL, f); } + bool has_health_check_call() const { return has_flag(FLAGS_HEALTH_CHECK_CALL); } + public: CallId current_id() const { CallId id = { _correlation_id.value + _current_call.nretry + 1 }; diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 21f31c8a..538c2d38 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -40,7 +40,6 @@ public: bool has_request_code; uint64_t request_code; const ExcludedServers* excluded; - bool health_check_call; }; struct SelectOut { diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 6ffda306..16207e88 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -222,7 +222,7 @@ int ConsistentHashingLoadBalancer::SelectServer( || !ExcludedServers::IsExcluded(in.excluded, choice->server_sock.id)) && Socket::Address(choice->server_sock.id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { + && !(*out->ptr)->IsHealthCheckingUsingRPC()) { return 0; } else { if (++choice == s->end()) { diff --git a/src/brpc/policy/dynpart_load_balancer.cpp b/src/brpc/policy/dynpart_load_balancer.cpp index 3786f078..d9a83054 100644 --- a/src/brpc/policy/dynpart_load_balancer.cpp +++ b/src/brpc/policy/dynpart_load_balancer.cpp @@ -123,7 +123,7 @@ int DynPartLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { const SocketId id = s->server_list[i].id; if ((!exclusion || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, &ptrs[nptr].first) == 0 - && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { + && !(*out->ptr)->IsHealthCheckingUsingRPC()) { int w = schan::GetSubChannelWeight(ptrs[nptr].first->user()); total_weight += w; if (nptr < 8) { diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index 9cd72f29..44e6d499 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -304,7 +304,7 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) } } else if (Socket::Address(info.server_id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { + && !(*out->ptr)->IsHealthCheckingUsingRPC()) { if ((ntry + 1) == n // Instead of fail with EHOSTDOWN, we prefer // choosing the server again. || !ExcludedServers::IsExcluded(in.excluded, info.server_id)) { diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index ab982775..974ebaa0 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -119,7 +119,7 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { + && !(*out->ptr)->IsHealthCheckingUsingRPC()) { // We found an available server return 0; } diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 370d96a5..233be0d2 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -123,7 +123,7 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { + && !(*out->ptr)->IsHealthCheckingUsingRPC()) { s.tls() = tls; return 0; } diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index a65e51d9..dbfd87cd 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -181,7 +181,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* if (!ExcludedServers::IsExcluded(in.excluded, server_id) && Socket::Address(server_id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && (in.health_check_call || !(*out->ptr)->IsHealthCheckingUsingRPC())) { + && !(*out->ptr)->IsHealthCheckingUsingRPC()) { // update tls. tls.remain_server = tls_temp.remain_server; tls.position = tls_temp.position; diff --git a/src/brpc/selective_channel.cpp b/src/brpc/selective_channel.cpp index 9dee7897..4a1c0f69 100644 --- a/src/brpc/selective_channel.cpp +++ b/src/brpc/selective_channel.cpp @@ -290,8 +290,7 @@ int Sender::IssueRPC(int64_t start_realtime_us) { true, _main_cntl->has_request_code(), _main_cntl->_request_code, - _main_cntl->_accessed, - false }; + _main_cntl->_accessed }; ChannelBalancer::SelectOut sel_out; const int rc = static_cast(_main_cntl->_lb.get()) ->SelectChannel(sel_in, &sel_out); diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index cfc39614..b6adc31c 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -95,11 +95,11 @@ DEFINE_int32(connect_timeout_as_unreachable, 3, "times *continuously*, the error is changed to ENETUNREACH which " "fails the main socket as well when this socket is pooled."); -DEFINE_bool(health_check_using_rpc, false, "By default health check succeeds if server" - "can be connected. If this flag is set, health check is completed not only" - "when server can be connected but also an additional http call succeeds" - "indicated by FLAGS_health_check_path and FLAGS_health_check_timeout_ms"); -DEFINE_string(health_check_path, "/health", "Http path of health check call"); +DEFINE_string(health_check_path, "", "Http path of health check call." + "By default health check succeeds if server can be connected. If this" + "flag is set, health check is completed not only when server can be" + "connected but also an additional http call succeeds indicated by this" + "flag and FLAGS_health_check_timeout_ms"); DEFINE_int32(health_check_timeout_ms, 500, "Timeout of health check call"); static bool validate_connect_timeout_as_unreachable(const char*, int32_t v) { @@ -793,7 +793,7 @@ void Socket::Revive() { } else { LOG(INFO) << "Revived " << *this; } - if (FLAGS_health_check_using_rpc) { + if (!FLAGS_health_check_path.empty()) { _health_checking_using_rpc.store(true, butil::memory_order_relaxed); } return; diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 7fbc880c..e1141ade 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -205,7 +205,7 @@ void* select_server(void* arg) { brpc::LoadBalancer* c = sa->lb; brpc::SocketUniquePtr ptr; CountMap *selected_count = new CountMap; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); uint32_t rand_seed = rand(); if (sa->hash) { @@ -259,7 +259,7 @@ TEST_F(LoadBalancerTest, update_while_selection) { // Accessing empty lb should result in error. brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, NULL, false }; + brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); ASSERT_EQ(ENODATA, lb->SelectServer(in, &out)); @@ -555,7 +555,7 @@ TEST_F(LoadBalancerTest, consistent_hashing) { const size_t SELECT_TIMES = 1000000; std::map times; brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; ::brpc::LoadBalancer::SelectOut out(&ptr); for (size_t i = 0; i < SELECT_TIMES; ++i) { in.has_request_code = true; @@ -632,7 +632,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) { // consistent with weight configured. std::map select_result; brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); int total_weight = 12; std::vector select_servers; @@ -690,15 +690,13 @@ TEST_F(LoadBalancerTest, weighted_round_robin_no_valid_server) { // The first socket is excluded. The second socket is logfoff. // The third socket is invalid. brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, exclude, false }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, exclude }; brpc::LoadBalancer::SelectOut out(&ptr); EXPECT_EQ(EHOSTDOWN, wrrlb.SelectServer(in, &out)); brpc::ExcludedServers::Destroy(exclude); } TEST_F(LoadBalancerTest, health_checking_no_valid_server) { - // If socket is revived and FLAGS_health_check_using_rpc is set, - // this socket should not be selected. const char* servers[] = { "10.92.115.19:8832", "10.42.122.201:8833", @@ -727,7 +725,7 @@ TEST_F(LoadBalancerTest, health_checking_no_valid_server) { // Without setting anything, the lb should work fine for (int i = 0; i < 4; ++i) { brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); ASSERT_EQ(0, lb->SelectServer(in, &out)); } @@ -737,7 +735,7 @@ TEST_F(LoadBalancerTest, health_checking_no_valid_server) { ptr->_health_checking_using_rpc.store(true, butil::memory_order_relaxed); for (int i = 0; i < 4; ++i) { brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); ASSERT_EQ(0, lb->SelectServer(in, &out)); // After putting server[0] into health checking state, the only choice is servers[1] @@ -748,19 +746,22 @@ TEST_F(LoadBalancerTest, health_checking_no_valid_server) { ptr->_health_checking_using_rpc.store(true, butil::memory_order_relaxed); for (int i = 0; i < 4; ++i) { brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); // There is no server available ASSERT_EQ(EHOSTDOWN, lb->SelectServer(in, &out)); } - // set health_check_call to true, the lb should work fine + ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); + ptr->ResetHealthCheckingUsingRPC(); + ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); + ptr->ResetHealthCheckingUsingRPC(); + // After reset health checking state, the lb should work fine bool get_server1 = false; - bool get_server2 = false; - // The probability of 20 consecutive same server is 1 / (2^19) + bool get_server2 = false; for (int i = 0; i < 20; ++i) { brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, true }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); ASSERT_EQ(0, lb->SelectServer(in, &out)); if (ptr->remote_side().port == 8832) { @@ -770,19 +771,6 @@ TEST_F(LoadBalancerTest, health_checking_no_valid_server) { } } ASSERT_TRUE(get_server1 && get_server2); - ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); - ptr->ResetHealthCheckingUsingRPC(); - ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); - ptr->ResetHealthCheckingUsingRPC(); - - // After reset health checking state, the lb should work fine - for (int i = 0; i < 4; ++i) { - brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, false }; - brpc::LoadBalancer::SelectOut out(&ptr); - ASSERT_EQ(0, lb->SelectServer(in, &out)); - } - delete lb; } } diff --git a/test/brpc_naming_service_filter_unittest.cpp b/test/brpc_naming_service_filter_unittest.cpp index 1d75cde4..b25470df 100644 --- a/test/brpc_naming_service_filter_unittest.cpp +++ b/test/brpc_naming_service_filter_unittest.cpp @@ -53,7 +53,7 @@ TEST_F(NamingServiceFilterTest, sanity) { ASSERT_EQ(0, butil::hostname2endpoint("10.128.0.1:1234", &ep)); for (int i = 0; i < 10; ++i) { brpc::SocketUniquePtr tmp_sock; - brpc::LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL, false }; + brpc::LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL }; brpc::LoadBalancer::SelectOut sel_out(&tmp_sock); ASSERT_EQ(0, channel._lb->SelectServer(sel_in, &sel_out)); ASSERT_EQ(ep, tmp_sock->remote_side()); diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index 3056d353..2d099b50 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -556,7 +556,6 @@ public: TEST_F(SocketTest, health_check_using_rpc) { int old_health_check_interval = brpc::FLAGS_health_check_interval; - GFLAGS_NS::SetCommandLineOption("health_check_using_rpc", "true"); GFLAGS_NS::SetCommandLineOption("health_check_path", "/HealthCheckTestService"); GFLAGS_NS::SetCommandLineOption("health_check_interval", "1"); @@ -610,7 +609,7 @@ TEST_F(SocketTest, health_check_using_rpc) { ASSERT_GT(cntl.response_attachment().size(), (size_t)0); } - GFLAGS_NS::SetCommandLineOption("health_check_using_rpc", "false"); + GFLAGS_NS::SetCommandLineOption("health_check_path", ""); char hc_buf[8]; snprintf(hc_buf, sizeof(hc_buf), "%d", old_health_check_interval); GFLAGS_NS::SetCommandLineOption("health_check_interval", hc_buf); From c4076408d9c47b8f8b35e4493aedbadfd52c9641 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 23 Mar 2019 12:28:20 +0800 Subject: [PATCH 074/270] health_check_using_rpc: refine docs --- docs/cn/client.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index 5d1dd435..6c2c741b 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -242,7 +242,7 @@ locality-aware,优先选择延时低的下游,直到其延时高于其他机 | ------------------------- | ----- | ---------------------------------------- | ----------------------- | | health_check_interval (R) | 3 | seconds between consecutive health-checkings | src/brpc/socket_map.cpp | -在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过设置-health\_check\_path来打开这个功能(如果下游也是brpc,推荐设置成/health,服务健康的话会返回200),-health\_check\_timeout\_ms设置超时(默认500ms)。如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 +在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过把-health\_check\_path设置成被检查的路径来打开这个功能(如果下游也是brpc,推荐设置成/health,服务健康的话会返回200),-health\_check\_timeout\_ms设置超时(默认500ms)。如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 # 发起访问 From 267c6257c7476be75cf234bc25dfc9227b9e957c Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 23 Mar 2019 13:54:44 +0800 Subject: [PATCH 075/270] health_check_using_rpc: fix UT after rebase master --- test/brpc_socket_unittest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index 2d099b50..a99ea1e1 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -576,7 +576,7 @@ TEST_F(SocketTest, health_check_using_rpc) { // 2s to make sure remote is connected by HealthCheckTask and enter the // sending-rpc state. Because the remote is not down, so hc rpc would keep // sending. - int listening_fd = tcp_listen(point, false); + int listening_fd = tcp_listen(point); bthread_usleep(2000000); // 2s to make sure HealthCheckTask find socket is failed and correct impl From 95b8f54f1cf76f6b2b41db2ca39d2ba666658e72 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 23 Mar 2019 14:03:32 +0800 Subject: [PATCH 076/270] health_check_using_rpc: remove unnecessary local vars --- src/brpc/controller.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index c21fd8a5..41b8dccf 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -982,13 +982,12 @@ void Controller::IssueRPC(int64_t start_realtime_us) { _current_call.need_feedback = false; _current_call.enable_circuit_breaker = has_enabled_circuit_breaker(); SocketUniquePtr tmp_sock; - bool health_check_call = has_flag(FLAGS_HEALTH_CHECK_CALL); if (SingleServer()) { // Don't use _current_call.peer_id which is set to -1 after construction // of the backup call. const int rc = Socket::Address(_single_server_id, &tmp_sock); if (rc != 0 || tmp_sock->IsLogOff() || - (!health_check_call && tmp_sock->IsHealthCheckingUsingRPC())) { + (!has_flag(FLAGS_HEALTH_CHECK_CALL) && tmp_sock->IsHealthCheckingUsingRPC())) { SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, endpoint2str(_remote_side).c_str(), _single_server_id); tmp_sock.reset(); // Release ref ASAP @@ -997,8 +996,8 @@ void Controller::IssueRPC(int64_t start_realtime_us) { _current_call.peer_id = _single_server_id; } else { LoadBalancer::SelectIn sel_in = - { start_realtime_us, true, has_request_code(), - _request_code, _accessed }; + { start_realtime_us, true, + has_request_code(), _request_code, _accessed }; LoadBalancer::SelectOut sel_out(&tmp_sock); const int rc = _lb->SelectServer(sel_in, &sel_out); if (rc != 0) { From 77566c8703d1fb40daee54070eed3160edcca328 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sun, 24 Mar 2019 15:13:04 +0800 Subject: [PATCH 077/270] health_check_using_rpc: fix leak & change the time of setting _health_check_using_rpc --- src/brpc/controller.cpp | 2 +- src/brpc/controller.h | 2 +- src/brpc/socket.cpp | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 41b8dccf..d600fea1 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -987,7 +987,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { // of the backup call. const int rc = Socket::Address(_single_server_id, &tmp_sock); if (rc != 0 || tmp_sock->IsLogOff() || - (!has_flag(FLAGS_HEALTH_CHECK_CALL) && tmp_sock->IsHealthCheckingUsingRPC())) { + (!is_health_check_call() && tmp_sock->IsHealthCheckingUsingRPC())) { SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, endpoint2str(_remote_side).c_str(), _single_server_id); tmp_sock.reset(); // Release ref ASAP diff --git a/src/brpc/controller.h b/src/brpc/controller.h index d679eb33..d014092e 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -589,7 +589,7 @@ private: // Tell RPC that this particular call is used to do health check. void set_health_check_call(bool f) { set_flag(FLAGS_HEALTH_CHECK_CALL, f); } - bool has_health_check_call() const { return has_flag(FLAGS_HEALTH_CHECK_CALL); } + bool is_health_check_call() const { return has_flag(FLAGS_HEALTH_CHECK_CALL); } public: CallId current_id() const { diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index b6adc31c..0c3f812f 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -758,7 +758,11 @@ int Socket::WaitAndReset(int32_t expected_nref) { _pipeline_q->clear(); } } - _health_checking_using_rpc.store(false, butil::memory_order_relaxed); + if (!FLAGS_health_check_path.empty()) { + _health_checking_using_rpc.store(true, butil::memory_order_relaxed); + } else { + _health_checking_using_rpc.store(false, butil::memory_order_relaxed); + } return 0; } @@ -793,9 +797,6 @@ void Socket::Revive() { } else { LOG(INFO) << "Revived " << *this; } - if (!FLAGS_health_check_path.empty()) { - _health_checking_using_rpc.store(true, butil::memory_order_relaxed); - } return; } } @@ -1070,6 +1071,7 @@ public: if (done->channel.Init(id, &options) != 0) { LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; ptr->ResetHealthCheckingUsingRPC(); + delete done; return; } done->cntl.http_request().uri() = FLAGS_health_check_path; From 9d5b136616e05ab1a8874cc219f219497e10411f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 25 Mar 2019 11:21:09 +0800 Subject: [PATCH 078/270] health_check_using_rpc: refine code --- src/brpc/socket.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 0c3f812f..78f674e2 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -758,11 +758,7 @@ int Socket::WaitAndReset(int32_t expected_nref) { _pipeline_q->clear(); } } - if (!FLAGS_health_check_path.empty()) { - _health_checking_using_rpc.store(true, butil::memory_order_relaxed); - } else { - _health_checking_using_rpc.store(false, butil::memory_order_relaxed); - } + _health_checking_using_rpc.store(!FLAGS_health_check_path.empty(), butil::memory_order_relaxed); return 0; } From 3ab2b2d61d66ed2b016cde422d3d7dec096f6bf2 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 25 Mar 2019 12:21:37 +0800 Subject: [PATCH 079/270] health_check_using_rpc: change _health_checking_using_rpc to _app_level_health_checking & use Address in OnHealthCheckRPCDone --- src/brpc/channel.cpp | 2 +- src/brpc/controller.cpp | 2 +- .../consistent_hashing_load_balancer.cpp | 2 +- src/brpc/policy/dynpart_load_balancer.cpp | 2 +- .../policy/locality_aware_load_balancer.cpp | 2 +- src/brpc/policy/randomized_load_balancer.cpp | 2 +- src/brpc/policy/round_robin_load_balancer.cpp | 2 +- .../weighted_round_robin_load_balancer.cpp | 2 +- src/brpc/socket.cpp | 32 +++++++------------ src/brpc/socket.h | 11 +++---- src/brpc/socket_inl.h | 8 ++--- test/brpc_load_balancer_unittest.cpp | 8 ++--- test/brpc_socket_unittest.cpp | 2 +- 13 files changed, 34 insertions(+), 43 deletions(-) diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index 7c576e55..8d720b8c 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -558,7 +558,7 @@ int Channel::CheckHealth() { SocketUniquePtr ptr; if (Socket::Address(_server_id, &ptr) == 0 && !ptr->IsLogOff() && - !ptr->IsHealthCheckingUsingRPC()) { + !ptr->IsAppLevelHealthChecking()) { return 0; } return -1; diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index d600fea1..53e7a247 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -987,7 +987,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { // of the backup call. const int rc = Socket::Address(_single_server_id, &tmp_sock); if (rc != 0 || tmp_sock->IsLogOff() || - (!is_health_check_call() && tmp_sock->IsHealthCheckingUsingRPC())) { + (!is_health_check_call() && tmp_sock->IsAppLevelHealthChecking())) { SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, endpoint2str(_remote_side).c_str(), _single_server_id); tmp_sock.reset(); // Release ref ASAP diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 16207e88..33fa891c 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -222,7 +222,7 @@ int ConsistentHashingLoadBalancer::SelectServer( || !ExcludedServers::IsExcluded(in.excluded, choice->server_sock.id)) && Socket::Address(choice->server_sock.id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsHealthCheckingUsingRPC()) { + && !(*out->ptr)->IsAppLevelHealthChecking()) { return 0; } else { if (++choice == s->end()) { diff --git a/src/brpc/policy/dynpart_load_balancer.cpp b/src/brpc/policy/dynpart_load_balancer.cpp index d9a83054..b619a3db 100644 --- a/src/brpc/policy/dynpart_load_balancer.cpp +++ b/src/brpc/policy/dynpart_load_balancer.cpp @@ -123,7 +123,7 @@ int DynPartLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { const SocketId id = s->server_list[i].id; if ((!exclusion || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, &ptrs[nptr].first) == 0 - && !(*out->ptr)->IsHealthCheckingUsingRPC()) { + && !(*out->ptr)->IsAppLevelHealthChecking()) { int w = schan::GetSubChannelWeight(ptrs[nptr].first->user()); total_weight += w; if (nptr < 8) { diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index 44e6d499..a50337cd 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -304,7 +304,7 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) } } else if (Socket::Address(info.server_id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsHealthCheckingUsingRPC()) { + && !(*out->ptr)->IsAppLevelHealthChecking()) { if ((ntry + 1) == n // Instead of fail with EHOSTDOWN, we prefer // choosing the server again. || !ExcludedServers::IsExcluded(in.excluded, info.server_id)) { diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 974ebaa0..7247b165 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -119,7 +119,7 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsHealthCheckingUsingRPC()) { + && !(*out->ptr)->IsAppLevelHealthChecking()) { // We found an available server return 0; } diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 233be0d2..d56c8f70 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -123,7 +123,7 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsHealthCheckingUsingRPC()) { + && !(*out->ptr)->IsAppLevelHealthChecking()) { s.tls() = tls; return 0; } diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index dbfd87cd..a1da8a8a 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -181,7 +181,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* if (!ExcludedServers::IsExcluded(in.excluded, server_id) && Socket::Address(server_id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsHealthCheckingUsingRPC()) { + && !(*out->ptr)->IsAppLevelHealthChecking()) { // update tls. tls.remain_server = tls_temp.remain_server; tls.position = tls_temp.position; diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 78f674e2..d4610440 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -483,7 +483,7 @@ Socket::Socket(Forbidden) , _epollout_butex(NULL) , _write_head(NULL) , _stream_set(NULL) - , _health_checking_using_rpc(false) + , _app_level_health_checking(false) { CreateVarsOnce(); pthread_mutex_init(&_id_wait_list_mutex, NULL); @@ -666,7 +666,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) { m->_error_code = 0; m->_error_text.clear(); m->_agent_socket_id.store(INVALID_SOCKET_ID, butil::memory_order_relaxed); - m->_health_checking_using_rpc.store(false, butil::memory_order_relaxed); + m->_app_level_health_checking.store(false, butil::memory_order_relaxed); // NOTE: last two params are useless in bthread > r32787 const int rc = bthread_id_list_init(&m->_id_wait_list, 512, 512); if (rc) { @@ -758,7 +758,7 @@ int Socket::WaitAndReset(int32_t expected_nref) { _pipeline_q->clear(); } } - _health_checking_using_rpc.store(!FLAGS_health_check_path.empty(), butil::memory_order_relaxed); + _app_level_health_checking.store(!FLAGS_health_check_path.empty(), butil::memory_order_relaxed); return 0; } @@ -1014,24 +1014,16 @@ public: void Run() { std::unique_ptr self_guard(this); SocketUniquePtr ptr; - const int rc = Socket::AddressFailedAsWell(id, &ptr); - if (rc < 0) { - RPC_VLOG << "SocketId=" << id - << " was abandoned during health checking"; + const int rc = Socket::Address(id, &ptr); + if (rc != 0) { + // If the socket is failed, Socket::SetFailed() will + // trigger next round of hc, just return here. return; } if (!cntl.Failed()) { - ptr->ResetHealthCheckingUsingRPC(); + ptr->ResetAppLevelHealthChecking(); return; } - - // Socket::SetFailed() will trigger next round of hc, just - // return here. - if (cntl.Failed() && ptr->Failed()) { - return; - } - // the left case is cntl.Failed() && !ptr->Failed(), - // in which we should retry hc rpc. RPC_VLOG << "Fail to health check using rpc, error=" << cntl.ErrorText(); bthread_usleep(interval_s * 1000000); @@ -1066,7 +1058,7 @@ public: options.timeout_ms = FLAGS_health_check_timeout_ms; if (done->channel.Init(id, &options) != 0) { LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; - ptr->ResetHealthCheckingUsingRPC(); + ptr->ResetAppLevelHealthChecking(); delete done; return; } @@ -1123,7 +1115,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { } ptr->Revive(); ptr->_hc_count = 0; - if (ptr->IsHealthCheckingUsingRPC()) { + if (ptr->IsAppLevelHealthChecking()) { HealthCheckManager::StartCheck(_id, ptr->_health_check_interval_s); } return false; @@ -2306,8 +2298,8 @@ void Socket::DebugSocket(std::ostream& os, SocketId id) { << "\nauth_context=" << ptr->_auth_context << "\nlogoff_flag=" << ptr->_logoff_flag.load(butil::memory_order_relaxed) << "\nrecycle_flag=" << ptr->_recycle_flag.load(butil::memory_order_relaxed) - << "\nhealth_checking_using_rpc=" - << ptr->_health_checking_using_rpc.load(butil::memory_order_relaxed) + << "\napp_level_health_checking=" + << ptr->_app_level_health_checking.load(butil::memory_order_relaxed) << "\nagent_socket_id="; const SocketId asid = ptr->_agent_socket_id.load(butil::memory_order_relaxed); if (asid != INVALID_SOCKET_ID) { diff --git a/src/brpc/socket.h b/src/brpc/socket.h index bedbb999..13e439bd 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -351,13 +351,12 @@ public: void SetLogOff(); bool IsLogOff() const; - // Check Whether the state is in health check using rpc state or + // Check Whether the state is in app level health checking state or // not, which means this socket would not be selected in further - // user request until rpc succeed and can only be used by health - // check rpc call. - bool IsHealthCheckingUsingRPC() const; + // user request until app level check succeed. + bool IsAppLevelHealthChecking() const; // Reset health check state to the initial state(which is false) - void ResetHealthCheckingUsingRPC(); + void ResetAppLevelHealthChecking(); // Start to process edge-triggered events from the fd. // This function does not block caller. @@ -803,7 +802,7 @@ private: // If this flag is set, socket is now in health check state using // application-level rpc. - butil::atomic _health_checking_using_rpc; + butil::atomic _app_level_health_checking; }; } // namespace brpc diff --git a/src/brpc/socket_inl.h b/src/brpc/socket_inl.h index 5a9dd7c3..58e4c14d 100644 --- a/src/brpc/socket_inl.h +++ b/src/brpc/socket_inl.h @@ -245,12 +245,12 @@ inline bool Socket::IsLogOff() const { return _logoff_flag.load(butil::memory_order_relaxed); } -inline bool Socket::IsHealthCheckingUsingRPC() const { - return _health_checking_using_rpc.load(butil::memory_order_relaxed); +inline bool Socket::IsAppLevelHealthChecking() const { + return _app_level_health_checking.load(butil::memory_order_relaxed); } -inline void Socket::ResetHealthCheckingUsingRPC() { - _health_checking_using_rpc.store(false, butil::memory_order_relaxed); +inline void Socket::ResetAppLevelHealthChecking() { + _app_level_health_checking.store(false, butil::memory_order_relaxed); } static const uint32_t EOF_FLAG = (1 << 31); diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index e1141ade..cc8640ef 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -732,7 +732,7 @@ TEST_F(LoadBalancerTest, health_checking_no_valid_server) { brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); - ptr->_health_checking_using_rpc.store(true, butil::memory_order_relaxed); + ptr->_app_level_health_checking.store(true, butil::memory_order_relaxed); for (int i = 0; i < 4; ++i) { brpc::SocketUniquePtr ptr; brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; @@ -743,7 +743,7 @@ TEST_F(LoadBalancerTest, health_checking_no_valid_server) { } ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); - ptr->_health_checking_using_rpc.store(true, butil::memory_order_relaxed); + ptr->_app_level_health_checking.store(true, butil::memory_order_relaxed); for (int i = 0; i < 4; ++i) { brpc::SocketUniquePtr ptr; brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; @@ -753,9 +753,9 @@ TEST_F(LoadBalancerTest, health_checking_no_valid_server) { } ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); - ptr->ResetHealthCheckingUsingRPC(); + ptr->ResetAppLevelHealthChecking(); ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); - ptr->ResetHealthCheckingUsingRPC(); + ptr->ResetAppLevelHealthChecking(); // After reset health checking state, the lb should work fine bool get_server1 = false; bool get_server2 = false; diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index a99ea1e1..278ef198 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -554,7 +554,7 @@ public: bool _sleep_flag; }; -TEST_F(SocketTest, health_check_using_rpc) { +TEST_F(SocketTest, app_level_health_checking) { int old_health_check_interval = brpc::FLAGS_health_check_interval; GFLAGS_NS::SetCommandLineOption("health_check_path", "/HealthCheckTestService"); GFLAGS_NS::SetCommandLineOption("health_check_interval", "1"); From ddcb074933c7c8ee1cfd0b46a997e2d1a45e2b77 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 25 Mar 2019 18:59:20 +0800 Subject: [PATCH 080/270] health_check_using_rpc: use _ninflight_app_level_health_check to solve race --- src/brpc/channel.cpp | 2 +- src/brpc/controller.cpp | 2 +- .../consistent_hashing_load_balancer.cpp | 2 +- src/brpc/policy/dynpart_load_balancer.cpp | 2 +- .../policy/locality_aware_load_balancer.cpp | 2 +- src/brpc/policy/randomized_load_balancer.cpp | 2 +- src/brpc/policy/round_robin_load_balancer.cpp | 2 +- .../weighted_round_robin_load_balancer.cpp | 2 +- src/brpc/socket.cpp | 31 +++++++++++-------- src/brpc/socket.h | 8 ++--- src/brpc/socket_inl.h | 8 ++--- test/brpc_load_balancer_unittest.cpp | 14 ++++----- test/brpc_socket_unittest.cpp | 6 ++-- 13 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index 8d720b8c..dfb072bc 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -558,7 +558,7 @@ int Channel::CheckHealth() { SocketUniquePtr ptr; if (Socket::Address(_server_id, &ptr) == 0 && !ptr->IsLogOff() && - !ptr->IsAppLevelHealthChecking()) { + !ptr->IsAppLevelHealthCheck()) { return 0; } return -1; diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 53e7a247..343617b8 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -987,7 +987,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { // of the backup call. const int rc = Socket::Address(_single_server_id, &tmp_sock); if (rc != 0 || tmp_sock->IsLogOff() || - (!is_health_check_call() && tmp_sock->IsAppLevelHealthChecking())) { + (!is_health_check_call() && tmp_sock->IsAppLevelHealthCheck())) { SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, endpoint2str(_remote_side).c_str(), _single_server_id); tmp_sock.reset(); // Release ref ASAP diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 33fa891c..fa8d3835 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -222,7 +222,7 @@ int ConsistentHashingLoadBalancer::SelectServer( || !ExcludedServers::IsExcluded(in.excluded, choice->server_sock.id)) && Socket::Address(choice->server_sock.id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthChecking()) { + && !(*out->ptr)->IsAppLevelHealthCheck()) { return 0; } else { if (++choice == s->end()) { diff --git a/src/brpc/policy/dynpart_load_balancer.cpp b/src/brpc/policy/dynpart_load_balancer.cpp index b619a3db..cd7a8f29 100644 --- a/src/brpc/policy/dynpart_load_balancer.cpp +++ b/src/brpc/policy/dynpart_load_balancer.cpp @@ -123,7 +123,7 @@ int DynPartLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { const SocketId id = s->server_list[i].id; if ((!exclusion || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, &ptrs[nptr].first) == 0 - && !(*out->ptr)->IsAppLevelHealthChecking()) { + && !(*out->ptr)->IsAppLevelHealthCheck()) { int w = schan::GetSubChannelWeight(ptrs[nptr].first->user()); total_weight += w; if (nptr < 8) { diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index a50337cd..cce9cef6 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -304,7 +304,7 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) } } else if (Socket::Address(info.server_id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthChecking()) { + && !(*out->ptr)->IsAppLevelHealthCheck()) { if ((ntry + 1) == n // Instead of fail with EHOSTDOWN, we prefer // choosing the server again. || !ExcludedServers::IsExcluded(in.excluded, info.server_id)) { diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 7247b165..50a0bebf 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -119,7 +119,7 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthChecking()) { + && !(*out->ptr)->IsAppLevelHealthCheck()) { // We found an available server return 0; } diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index d56c8f70..2c788150 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -123,7 +123,7 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthChecking()) { + && !(*out->ptr)->IsAppLevelHealthCheck()) { s.tls() = tls; return 0; } diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index a1da8a8a..6b0a37a0 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -181,7 +181,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* if (!ExcludedServers::IsExcluded(in.excluded, server_id) && Socket::Address(server_id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthChecking()) { + && !(*out->ptr)->IsAppLevelHealthCheck()) { // update tls. tls.remain_server = tls_temp.remain_server; tls.position = tls_temp.position; diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index d4610440..c8f3fd43 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -483,7 +483,7 @@ Socket::Socket(Forbidden) , _epollout_butex(NULL) , _write_head(NULL) , _stream_set(NULL) - , _app_level_health_checking(false) + , _ninflight_app_level_health_check(0) { CreateVarsOnce(); pthread_mutex_init(&_id_wait_list_mutex, NULL); @@ -666,7 +666,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) { m->_error_code = 0; m->_error_text.clear(); m->_agent_socket_id.store(INVALID_SOCKET_ID, butil::memory_order_relaxed); - m->_app_level_health_checking.store(false, butil::memory_order_relaxed); + m->_ninflight_app_level_health_check.store(0, butil::memory_order_relaxed); // NOTE: last two params are useless in bthread > r32787 const int rc = bthread_id_list_init(&m->_id_wait_list, 512, 512); if (rc) { @@ -758,7 +758,6 @@ int Socket::WaitAndReset(int32_t expected_nref) { _pipeline_q->clear(); } } - _app_level_health_checking.store(!FLAGS_health_check_path.empty(), butil::memory_order_relaxed); return 0; } @@ -1014,14 +1013,15 @@ public: void Run() { std::unique_ptr self_guard(this); SocketUniquePtr ptr; - const int rc = Socket::Address(id, &ptr); - if (rc != 0) { - // If the socket is failed, Socket::SetFailed() will - // trigger next round of hc, just return here. + const int rc = Socket::AddressFailedAsWell(id, &ptr); + if (rc < 0) { + RPC_VLOG << "SocketId=" << id + << " was abandoned during health checking"; return; } - if (!cntl.Failed()) { - ptr->ResetAppLevelHealthChecking(); + if (!cntl.Failed() || ptr->Failed()) { + ptr->_ninflight_app_level_health_check.fetch_sub( + 1, butil::memory_order_relaxed); return; } RPC_VLOG << "Fail to health check using rpc, error=" @@ -1058,7 +1058,8 @@ public: options.timeout_ms = FLAGS_health_check_timeout_ms; if (done->channel.Init(id, &options) != 0) { LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; - ptr->ResetAppLevelHealthChecking(); + ptr->_ninflight_app_level_health_check.fetch_sub( + 1, butil::memory_order_relaxed); delete done; return; } @@ -1113,9 +1114,13 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { if (ptr->CreatedByConnect()) { s_vars->channel_conn << -1; } + if (!FLAGS_health_check_path.empty()) { + ptr->_ninflight_app_level_health_check.fetch_add( + 1, butil::memory_order_relaxed); + } ptr->Revive(); ptr->_hc_count = 0; - if (ptr->IsAppLevelHealthChecking()) { + if (ptr->IsAppLevelHealthCheck()) { HealthCheckManager::StartCheck(_id, ptr->_health_check_interval_s); } return false; @@ -2298,8 +2303,8 @@ void Socket::DebugSocket(std::ostream& os, SocketId id) { << "\nauth_context=" << ptr->_auth_context << "\nlogoff_flag=" << ptr->_logoff_flag.load(butil::memory_order_relaxed) << "\nrecycle_flag=" << ptr->_recycle_flag.load(butil::memory_order_relaxed) - << "\napp_level_health_checking=" - << ptr->_app_level_health_checking.load(butil::memory_order_relaxed) + << "\nninflight_app_level_health_check=" + << ptr->_ninflight_app_level_health_check.load(butil::memory_order_relaxed) << "\nagent_socket_id="; const SocketId asid = ptr->_agent_socket_id.load(butil::memory_order_relaxed); if (asid != INVALID_SOCKET_ID) { diff --git a/src/brpc/socket.h b/src/brpc/socket.h index 13e439bd..ecb6c422 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -354,9 +354,7 @@ public: // Check Whether the state is in app level health checking state or // not, which means this socket would not be selected in further // user request until app level check succeed. - bool IsAppLevelHealthChecking() const; - // Reset health check state to the initial state(which is false) - void ResetAppLevelHealthChecking(); + bool IsAppLevelHealthCheck() const; // Start to process edge-triggered events from the fd. // This function does not block caller. @@ -800,9 +798,7 @@ private: butil::Mutex _stream_mutex; std::set *_stream_set; - // If this flag is set, socket is now in health check state using - // application-level rpc. - butil::atomic _app_level_health_checking; + butil::atomic _ninflight_app_level_health_check; }; } // namespace brpc diff --git a/src/brpc/socket_inl.h b/src/brpc/socket_inl.h index 58e4c14d..9a96a036 100644 --- a/src/brpc/socket_inl.h +++ b/src/brpc/socket_inl.h @@ -245,12 +245,8 @@ inline bool Socket::IsLogOff() const { return _logoff_flag.load(butil::memory_order_relaxed); } -inline bool Socket::IsAppLevelHealthChecking() const { - return _app_level_health_checking.load(butil::memory_order_relaxed); -} - -inline void Socket::ResetAppLevelHealthChecking() { - _app_level_health_checking.store(false, butil::memory_order_relaxed); +inline bool Socket::IsAppLevelHealthCheck() const { + return (_ninflight_app_level_health_check.load(butil::memory_order_relaxed) != 0); } static const uint32_t EOF_FLAG = (1 << 31); diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index cc8640ef..0d160ce2 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -696,7 +696,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin_no_valid_server) { brpc::ExcludedServers::Destroy(exclude); } -TEST_F(LoadBalancerTest, health_checking_no_valid_server) { +TEST_F(LoadBalancerTest, health_check_no_valid_server) { const char* servers[] = { "10.92.115.19:8832", "10.42.122.201:8833", @@ -732,18 +732,18 @@ TEST_F(LoadBalancerTest, health_checking_no_valid_server) { brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); - ptr->_app_level_health_checking.store(true, butil::memory_order_relaxed); + ptr->_ninflight_app_level_health_check.store(1, butil::memory_order_relaxed); for (int i = 0; i < 4; ++i) { brpc::SocketUniquePtr ptr; brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); ASSERT_EQ(0, lb->SelectServer(in, &out)); - // After putting server[0] into health checking state, the only choice is servers[1] + // After putting server[0] into health check state, the only choice is servers[1] ASSERT_EQ(ptr->remote_side().port, 8833); } ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); - ptr->_app_level_health_checking.store(true, butil::memory_order_relaxed); + ptr->_ninflight_app_level_health_check.store(1, butil::memory_order_relaxed); for (int i = 0; i < 4; ++i) { brpc::SocketUniquePtr ptr; brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; @@ -753,10 +753,10 @@ TEST_F(LoadBalancerTest, health_checking_no_valid_server) { } ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); - ptr->ResetAppLevelHealthChecking(); + ptr->_ninflight_app_level_health_check.store(0, butil::memory_order_relaxed); ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); - ptr->ResetAppLevelHealthChecking(); - // After reset health checking state, the lb should work fine + ptr->_ninflight_app_level_health_check.store(0, butil::memory_order_relaxed); + // After reset health check state, the lb should work fine bool get_server1 = false; bool get_server2 = false; for (int i = 0; i < 20; ++i) { diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index 278ef198..5fbd8314 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -546,7 +546,7 @@ public: brpc::Controller* cntl = (brpc::Controller*)cntl_base; if (_sleep_flag) { bthread_usleep(510000 /* 510ms, a little bit longer than the default - timeout of health checking rpc */); + timeout of health check rpc */); } cntl->response_attachment().append("OK"); } @@ -554,7 +554,7 @@ public: bool _sleep_flag; }; -TEST_F(SocketTest, app_level_health_checking) { +TEST_F(SocketTest, app_level_health_check) { int old_health_check_interval = brpc::FLAGS_health_check_interval; GFLAGS_NS::SetCommandLineOption("health_check_path", "/HealthCheckTestService"); GFLAGS_NS::SetCommandLineOption("health_check_interval", "1"); @@ -591,7 +591,7 @@ TEST_F(SocketTest, app_level_health_checking) { for (int i = 0; i < 4; ++i) { // although ::connect would succeed, the stall in hc_service makes - // the health checking rpc fail. + // the health check rpc fail. brpc::Controller cntl; cntl.http_request().uri() = "/"; channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); From 4acdf92345315cb087b5f2b6f8ec171d8c0568b0 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 25 Mar 2019 20:11:46 +0800 Subject: [PATCH 081/270] health_check_using_rpc: replace app_level_health_check with app_health_check --- src/brpc/channel.cpp | 2 +- src/brpc/controller.cpp | 2 +- .../policy/consistent_hashing_load_balancer.cpp | 2 +- src/brpc/policy/dynpart_load_balancer.cpp | 2 +- src/brpc/policy/locality_aware_load_balancer.cpp | 2 +- src/brpc/policy/randomized_load_balancer.cpp | 2 +- src/brpc/policy/round_robin_load_balancer.cpp | 2 +- .../weighted_round_robin_load_balancer.cpp | 2 +- src/brpc/socket.cpp | 16 ++++++++-------- src/brpc/socket.h | 4 ++-- src/brpc/socket_inl.h | 4 ++-- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index dfb072bc..b1aea739 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -558,7 +558,7 @@ int Channel::CheckHealth() { SocketUniquePtr ptr; if (Socket::Address(_server_id, &ptr) == 0 && !ptr->IsLogOff() && - !ptr->IsAppLevelHealthCheck()) { + !ptr->IsAppHealthCheck()) { return 0; } return -1; diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 343617b8..5b857d46 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -987,7 +987,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { // of the backup call. const int rc = Socket::Address(_single_server_id, &tmp_sock); if (rc != 0 || tmp_sock->IsLogOff() || - (!is_health_check_call() && tmp_sock->IsAppLevelHealthCheck())) { + (!is_health_check_call() && tmp_sock->IsAppHealthCheck())) { SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, endpoint2str(_remote_side).c_str(), _single_server_id); tmp_sock.reset(); // Release ref ASAP diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index fa8d3835..09f61eb3 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -222,7 +222,7 @@ int ConsistentHashingLoadBalancer::SelectServer( || !ExcludedServers::IsExcluded(in.excluded, choice->server_sock.id)) && Socket::Address(choice->server_sock.id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthCheck()) { + && !(*out->ptr)->IsAppHealthCheck()) { return 0; } else { if (++choice == s->end()) { diff --git a/src/brpc/policy/dynpart_load_balancer.cpp b/src/brpc/policy/dynpart_load_balancer.cpp index cd7a8f29..c4c39d7d 100644 --- a/src/brpc/policy/dynpart_load_balancer.cpp +++ b/src/brpc/policy/dynpart_load_balancer.cpp @@ -123,7 +123,7 @@ int DynPartLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { const SocketId id = s->server_list[i].id; if ((!exclusion || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, &ptrs[nptr].first) == 0 - && !(*out->ptr)->IsAppLevelHealthCheck()) { + && !(*out->ptr)->IsAppHealthCheck()) { int w = schan::GetSubChannelWeight(ptrs[nptr].first->user()); total_weight += w; if (nptr < 8) { diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index cce9cef6..341fbdb7 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -304,7 +304,7 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) } } else if (Socket::Address(info.server_id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthCheck()) { + && !(*out->ptr)->IsAppHealthCheck()) { if ((ntry + 1) == n // Instead of fail with EHOSTDOWN, we prefer // choosing the server again. || !ExcludedServers::IsExcluded(in.excluded, info.server_id)) { diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 50a0bebf..febb3a01 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -119,7 +119,7 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthCheck()) { + && !(*out->ptr)->IsAppHealthCheck()) { // We found an available server return 0; } diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 2c788150..d9b9b20c 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -123,7 +123,7 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthCheck()) { + && !(*out->ptr)->IsAppHealthCheck()) { s.tls() = tls; return 0; } diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index 6b0a37a0..7cc5dd46 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -181,7 +181,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* if (!ExcludedServers::IsExcluded(in.excluded, server_id) && Socket::Address(server_id, out->ptr) == 0 && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppLevelHealthCheck()) { + && !(*out->ptr)->IsAppHealthCheck()) { // update tls. tls.remain_server = tls_temp.remain_server; tls.position = tls_temp.position; diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index c8f3fd43..a793a2a5 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -483,7 +483,7 @@ Socket::Socket(Forbidden) , _epollout_butex(NULL) , _write_head(NULL) , _stream_set(NULL) - , _ninflight_app_level_health_check(0) + , _ninflight_app_health_check(0) { CreateVarsOnce(); pthread_mutex_init(&_id_wait_list_mutex, NULL); @@ -666,7 +666,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) { m->_error_code = 0; m->_error_text.clear(); m->_agent_socket_id.store(INVALID_SOCKET_ID, butil::memory_order_relaxed); - m->_ninflight_app_level_health_check.store(0, butil::memory_order_relaxed); + m->_ninflight_app_health_check.store(0, butil::memory_order_relaxed); // NOTE: last two params are useless in bthread > r32787 const int rc = bthread_id_list_init(&m->_id_wait_list, 512, 512); if (rc) { @@ -1020,7 +1020,7 @@ public: return; } if (!cntl.Failed() || ptr->Failed()) { - ptr->_ninflight_app_level_health_check.fetch_sub( + ptr->_ninflight_app_health_check.fetch_sub( 1, butil::memory_order_relaxed); return; } @@ -1058,7 +1058,7 @@ public: options.timeout_ms = FLAGS_health_check_timeout_ms; if (done->channel.Init(id, &options) != 0) { LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; - ptr->_ninflight_app_level_health_check.fetch_sub( + ptr->_ninflight_app_health_check.fetch_sub( 1, butil::memory_order_relaxed); delete done; return; @@ -1115,12 +1115,12 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { s_vars->channel_conn << -1; } if (!FLAGS_health_check_path.empty()) { - ptr->_ninflight_app_level_health_check.fetch_add( + ptr->_ninflight_app_health_check.fetch_add( 1, butil::memory_order_relaxed); } ptr->Revive(); ptr->_hc_count = 0; - if (ptr->IsAppLevelHealthCheck()) { + if (ptr->IsAppHealthCheck()) { HealthCheckManager::StartCheck(_id, ptr->_health_check_interval_s); } return false; @@ -2303,8 +2303,8 @@ void Socket::DebugSocket(std::ostream& os, SocketId id) { << "\nauth_context=" << ptr->_auth_context << "\nlogoff_flag=" << ptr->_logoff_flag.load(butil::memory_order_relaxed) << "\nrecycle_flag=" << ptr->_recycle_flag.load(butil::memory_order_relaxed) - << "\nninflight_app_level_health_check=" - << ptr->_ninflight_app_level_health_check.load(butil::memory_order_relaxed) + << "\nninflight_app_health_check=" + << ptr->_ninflight_app_health_check.load(butil::memory_order_relaxed) << "\nagent_socket_id="; const SocketId asid = ptr->_agent_socket_id.load(butil::memory_order_relaxed); if (asid != INVALID_SOCKET_ID) { diff --git a/src/brpc/socket.h b/src/brpc/socket.h index ecb6c422..d2d1f5aa 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -354,7 +354,7 @@ public: // Check Whether the state is in app level health checking state or // not, which means this socket would not be selected in further // user request until app level check succeed. - bool IsAppLevelHealthCheck() const; + bool IsAppHealthCheck() const; // Start to process edge-triggered events from the fd. // This function does not block caller. @@ -798,7 +798,7 @@ private: butil::Mutex _stream_mutex; std::set *_stream_set; - butil::atomic _ninflight_app_level_health_check; + butil::atomic _ninflight_app_health_check; }; } // namespace brpc diff --git a/src/brpc/socket_inl.h b/src/brpc/socket_inl.h index 9a96a036..dd5cdb56 100644 --- a/src/brpc/socket_inl.h +++ b/src/brpc/socket_inl.h @@ -245,8 +245,8 @@ inline bool Socket::IsLogOff() const { return _logoff_flag.load(butil::memory_order_relaxed); } -inline bool Socket::IsAppLevelHealthCheck() const { - return (_ninflight_app_level_health_check.load(butil::memory_order_relaxed) != 0); +inline bool Socket::IsAppHealthCheck() const { + return (_ninflight_app_health_check.load(butil::memory_order_relaxed) != 0); } static const uint32_t EOF_FLAG = (1 << 31); From cc3de349732a7012a121a62269c341a138c7bff5 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 25 Mar 2019 20:39:48 +0800 Subject: [PATCH 082/270] health_check_using_rpc: add necessary logs --- src/brpc/controller.h | 2 +- src/brpc/socket.cpp | 14 ++++++++------ src/brpc/socket.h | 2 +- test/brpc_load_balancer_unittest.cpp | 8 ++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/brpc/controller.h b/src/brpc/controller.h index d014092e..c936ef5d 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -118,7 +118,7 @@ friend int StreamCreate(StreamId*, Controller&, const StreamOptions*); friend int StreamAccept(StreamId*, Controller&, const StreamOptions*); friend void policy::ProcessMongoRequest(InputMessageBase*); friend void policy::ProcessThriftRequest(InputMessageBase*); -friend class OnHealthCheckRPCDone; +friend class OnAppHealthCheckDone; friend class HealthCheckManager; // << Flags >> static const uint32_t FLAGS_IGNORE_EOVERCROWDED = 1; diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index a793a2a5..9e6dcefd 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -1008,10 +1008,10 @@ int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) { return 0; } -class OnHealthCheckRPCDone : public google::protobuf::Closure { +class OnAppHealthCheckDone : public google::protobuf::Closure { public: void Run() { - std::unique_ptr self_guard(this); + std::unique_ptr self_guard(this); SocketUniquePtr ptr; const int rc = Socket::AddressFailedAsWell(id, &ptr); if (rc < 0) { @@ -1020,12 +1020,13 @@ public: return; } if (!cntl.Failed() || ptr->Failed()) { + LOG_IF(INFO, !cntl.Failed()) << "AppRevived " + << ptr->remote_side() << FLAGS_health_check_path; ptr->_ninflight_app_health_check.fetch_sub( 1, butil::memory_order_relaxed); return; } - RPC_VLOG << "Fail to health check using rpc, error=" - << cntl.ErrorText(); + RPC_VLOG << "Fail to AppCheck, " << cntl.ErrorText(); bthread_usleep(interval_s * 1000000); cntl.Reset(); cntl.http_request().uri() = FLAGS_health_check_path; @@ -1049,11 +1050,12 @@ public: << " was abandoned during health checking"; return; } - OnHealthCheckRPCDone* done = new OnHealthCheckRPCDone; + LOG(INFO) << "AppChecking " << ptr->remote_side() << FLAGS_health_check_path; + OnAppHealthCheckDone* done = new OnAppHealthCheckDone; done->id = id; done->interval_s = check_interval_s; brpc::ChannelOptions options; - options.protocol = "http"; + options.protocol = PROTOCOL_HTTP; options.max_retry = 0; options.timeout_ms = FLAGS_health_check_timeout_ms; if (done->channel.Init(id, &options) != 0) { diff --git a/src/brpc/socket.h b/src/brpc/socket.h index d2d1f5aa..45e080bc 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -186,7 +186,7 @@ friend class policy::ConsistentHashingLoadBalancer; friend class policy::RtmpContext; friend class schan::ChannelBalancer; friend class HealthCheckTask; -friend class OnHealthCheckRPCDone; +friend class OnAppHealthCheckDone; friend class HealthCheckManager; friend class policy::H2GlobalStreamCreator; class SharedPart; diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 0d160ce2..93781ad3 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -732,7 +732,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { brpc::SocketUniquePtr ptr; ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); - ptr->_ninflight_app_level_health_check.store(1, butil::memory_order_relaxed); + ptr->_ninflight_app_health_check.store(1, butil::memory_order_relaxed); for (int i = 0; i < 4; ++i) { brpc::SocketUniquePtr ptr; brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; @@ -743,7 +743,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { } ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); - ptr->_ninflight_app_level_health_check.store(1, butil::memory_order_relaxed); + ptr->_ninflight_app_health_check.store(1, butil::memory_order_relaxed); for (int i = 0; i < 4; ++i) { brpc::SocketUniquePtr ptr; brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; @@ -753,9 +753,9 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { } ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); - ptr->_ninflight_app_level_health_check.store(0, butil::memory_order_relaxed); + ptr->_ninflight_app_health_check.store(0, butil::memory_order_relaxed); ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); - ptr->_ninflight_app_level_health_check.store(0, butil::memory_order_relaxed); + ptr->_ninflight_app_health_check.store(0, butil::memory_order_relaxed); // After reset health check state, the lb should work fine bool get_server1 = false; bool get_server2 = false; From 74951b9d55317be34217c38eacaf46ec249934f4 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 26 Mar 2019 15:59:56 +0800 Subject: [PATCH 083/270] health_check_using_rpc: 1.revise docs 2.combine IsLogOff and IsAppHealthCheck into IsAvailable --- docs/cn/client.md | 2 +- src/brpc/channel.cpp | 4 +--- src/brpc/controller.cpp | 3 +-- src/brpc/controller.h | 3 --- .../details/controller_private_accessor.h | 5 +++++ .../consistent_hashing_load_balancer.cpp | 3 +-- src/brpc/policy/dynpart_load_balancer.cpp | 2 +- .../policy/locality_aware_load_balancer.cpp | 3 +-- src/brpc/policy/randomized_load_balancer.cpp | 3 +-- src/brpc/policy/round_robin_load_balancer.cpp | 3 +-- .../weighted_round_robin_load_balancer.cpp | 3 +-- src/brpc/socket.cpp | 20 +++++++++---------- src/brpc/socket.h | 11 ++++------ src/brpc/socket_inl.h | 9 +++------ 14 files changed, 31 insertions(+), 43 deletions(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index 6c2c741b..8892635d 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -242,7 +242,7 @@ locality-aware,优先选择延时低的下游,直到其延时高于其他机 | ------------------------- | ----- | ---------------------------------------- | ----------------------- | | health_check_interval (R) | 3 | seconds between consecutive health-checkings | src/brpc/socket_map.cpp | -在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,协议是Http,只有当Server返回200时,这个server才算恢复,可以通过把-health\_check\_path设置成被检查的路径来打开这个功能(如果下游也是brpc,推荐设置成/health,服务健康的话会返回200),-health\_check\_timeout\_ms设置超时(默认500ms)。如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 +在默认的配置下,一旦server被连接上,它会恢复为可用状态;brpc还提供了应用层健康检查的机制,框架会发送一个HTTP GET请求到该server,请求路径通过-health\_check\_path设置(默认为空),只有当server返回200时,它才会恢复。在两种健康检查机制下,都可通过-health\_check\_timeout\_ms设置超时(默认500ms)。如果在隔离过程中,server从命名服务中删除了,brpc也会停止连接尝试。 # 发起访问 diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index b1aea739..a83d3b43 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -556,9 +556,7 @@ int Channel::Weight() { int Channel::CheckHealth() { if (_lb == NULL) { SocketUniquePtr ptr; - if (Socket::Address(_server_id, &ptr) == 0 && - !ptr->IsLogOff() && - !ptr->IsAppHealthCheck()) { + if (Socket::Address(_server_id, &ptr) == 0 && !ptr->IsAvailable()) { return 0; } return -1; diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 5b857d46..086a9ce8 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -986,8 +986,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { // Don't use _current_call.peer_id which is set to -1 after construction // of the backup call. const int rc = Socket::Address(_single_server_id, &tmp_sock); - if (rc != 0 || tmp_sock->IsLogOff() || - (!is_health_check_call() && tmp_sock->IsAppHealthCheck())) { + if (rc != 0 || (!is_health_check_call() && !tmp_sock->IsAvailable())) { SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, endpoint2str(_remote_side).c_str(), _single_server_id); tmp_sock.reset(); // Release ref ASAP diff --git a/src/brpc/controller.h b/src/brpc/controller.h index c936ef5d..6e896819 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -118,8 +118,6 @@ friend int StreamCreate(StreamId*, Controller&, const StreamOptions*); friend int StreamAccept(StreamId*, Controller&, const StreamOptions*); friend void policy::ProcessMongoRequest(InputMessageBase*); friend void policy::ProcessThriftRequest(InputMessageBase*); -friend class OnAppHealthCheckDone; -friend class HealthCheckManager; // << Flags >> static const uint32_t FLAGS_IGNORE_EOVERCROWDED = 1; static const uint32_t FLAGS_SECURITY_MODE = (1 << 1); @@ -588,7 +586,6 @@ private: } // Tell RPC that this particular call is used to do health check. - void set_health_check_call(bool f) { set_flag(FLAGS_HEALTH_CHECK_CALL, f); } bool is_health_check_call() const { return has_flag(FLAGS_HEALTH_CHECK_CALL); } public: diff --git a/src/brpc/details/controller_private_accessor.h b/src/brpc/details/controller_private_accessor.h index 0b145497..3ea8c76a 100644 --- a/src/brpc/details/controller_private_accessor.h +++ b/src/brpc/details/controller_private_accessor.h @@ -138,6 +138,11 @@ public: return *this; } + ControllerPrivateAccessor& set_health_check_call() { + _cntl->add_flag(Controller::FLAGS_HEALTH_CHECK_CALL); + return *this; + } + private: Controller* _cntl; }; diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 09f61eb3..fa90d185 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -221,8 +221,7 @@ int ConsistentHashingLoadBalancer::SelectServer( if (((i + 1) == s->size() // always take last chance || !ExcludedServers::IsExcluded(in.excluded, choice->server_sock.id)) && Socket::Address(choice->server_sock.id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppHealthCheck()) { + && (*out->ptr)->IsAvailable()) { return 0; } else { if (++choice == s->end()) { diff --git a/src/brpc/policy/dynpart_load_balancer.cpp b/src/brpc/policy/dynpart_load_balancer.cpp index c4c39d7d..379ab795 100644 --- a/src/brpc/policy/dynpart_load_balancer.cpp +++ b/src/brpc/policy/dynpart_load_balancer.cpp @@ -123,7 +123,7 @@ int DynPartLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { const SocketId id = s->server_list[i].id; if ((!exclusion || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, &ptrs[nptr].first) == 0 - && !(*out->ptr)->IsAppHealthCheck()) { + && (ptrs[nptr].first)->IsAvailable()) { int w = schan::GetSubChannelWeight(ptrs[nptr].first->user()); total_weight += w; if (nptr < 8) { diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index 341fbdb7..f6dcf965 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -303,8 +303,7 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) continue; } } else if (Socket::Address(info.server_id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppHealthCheck()) { + && (*out->ptr)->IsAvailable()) { if ((ntry + 1) == n // Instead of fail with EHOSTDOWN, we prefer // choosing the server again. || !ExcludedServers::IsExcluded(in.excluded, info.server_id)) { diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index febb3a01..67c17f91 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -118,8 +118,7 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (((i + 1) == n // always take last chance || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppHealthCheck()) { + && (*out->ptr)->IsAvailable()) { // We found an available server return 0; } diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index d9b9b20c..d2341e1b 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -122,8 +122,7 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (((i + 1) == n // always take last chance || !ExcludedServers::IsExcluded(in.excluded, id)) && Socket::Address(id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppHealthCheck()) { + && (*out->ptr)->IsAvailable()) { s.tls() = tls; return 0; } diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index 7cc5dd46..d72de512 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -180,8 +180,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* SocketId server_id = GetServerInNextStride(s->server_list, filter, tls_temp); if (!ExcludedServers::IsExcluded(in.excluded, server_id) && Socket::Address(server_id, out->ptr) == 0 - && !(*out->ptr)->IsLogOff() - && !(*out->ptr)->IsAppHealthCheck()) { + && !(*out->ptr)->IsAvailable()) { // update tls. tls.remain_server = tls_temp.remain_server; tls.position = tls_temp.position; diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 9e6dcefd..1cb35218 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -50,6 +50,7 @@ #include "brpc/periodic_task.h" #include "brpc/channel.h" #include "brpc/controller.h" +#include "details/controller_private_accessor.h" #include "brpc/global.h" #if defined(OS_MACOSX) #include @@ -100,7 +101,9 @@ DEFINE_string(health_check_path, "", "Http path of health check call." "flag is set, health check is completed not only when server can be" "connected but also an additional http call succeeds indicated by this" "flag and FLAGS_health_check_timeout_ms"); -DEFINE_int32(health_check_timeout_ms, 500, "Timeout of health check call"); +DEFINE_int32(health_check_timeout_ms, 500, "Timeout of health check." + "If FLAGS_health_check_path is empty, it means timeout of connect." + "Otherwise it means timeout of app health check call."); static bool validate_connect_timeout_as_unreachable(const char*, int32_t v) { return v >= 2 && v < 1000/*large enough*/; @@ -1030,7 +1033,7 @@ public: bthread_usleep(interval_s * 1000000); cntl.Reset(); cntl.http_request().uri() = FLAGS_health_check_path; - cntl.set_health_check_call(true); + ControllerPrivateAccessor(&cntl).set_health_check_call(); channel.CallMethod(NULL, &cntl, NULL, NULL, self_guard.release()); } @@ -1066,7 +1069,7 @@ public: return; } done->cntl.http_request().uri() = FLAGS_health_check_path; - done->cntl.set_health_check_call(true); + ControllerPrivateAccessor(&done->cntl).set_health_check_call(); done->channel.CallMethod(NULL, &done->cntl, NULL, NULL, done); } }; @@ -1122,7 +1125,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { } ptr->Revive(); ptr->_hc_count = 0; - if (ptr->IsAppHealthCheck()) { + if (!FLAGS_health_check_path.empty()) { HealthCheckManager::StartCheck(_id, ptr->_health_check_interval_s); } return false; @@ -1313,7 +1316,6 @@ int Socket::Connect(const timespec* abstime, // We need to do async connect (to manage the timeout by ourselves). CHECK_EQ(0, butil::make_non_blocking(sockfd)); - struct sockaddr_in serv_addr; bzero((char*)&serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; @@ -2391,11 +2393,9 @@ int Socket::CheckHealth() { if (_hc_count == 0) { LOG(INFO) << "Checking " << *this; } - // Note: No timeout. Timeout setting is given to Write() which - // we don't know. A drawback is that if a connection takes long - // but finally succeeds(indicating unstable network?), we still - // revive the socket. - const int connected_fd = Connect(NULL/*Note*/, NULL, NULL); + const timespec duetime = + butil::milliseconds_from_now(FLAGS_health_check_timeout_ms); + const int connected_fd = Connect(&duetime, NULL, NULL); if (connected_fd >= 0) { ::close(connected_fd); return 0; diff --git a/src/brpc/socket.h b/src/brpc/socket.h index 45e080bc..706d075c 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -346,15 +346,12 @@ public: // Set ELOGOFF flag to this `Socket' which means further requests // through this `Socket' will receive an ELOGOFF error. This only - // affects return value of `IsLogOff' and won't close the inner fd - // Once set, this flag can only be cleared inside `WaitAndReset' + // affects return value of `IsAvailable' and won't close the inner + // fd. Once set, this flag can only be cleared inside `WaitAndReset'. void SetLogOff(); - bool IsLogOff() const; - // Check Whether the state is in app level health checking state or - // not, which means this socket would not be selected in further - // user request until app level check succeed. - bool IsAppHealthCheck() const; + // Check Whether the socket is available for user requests. + bool IsAvailable() const; // Start to process edge-triggered events from the fd. // This function does not block caller. diff --git a/src/brpc/socket_inl.h b/src/brpc/socket_inl.h index dd5cdb56..5b51913e 100644 --- a/src/brpc/socket_inl.h +++ b/src/brpc/socket_inl.h @@ -241,12 +241,9 @@ inline void Socket::SetLogOff() { } } -inline bool Socket::IsLogOff() const { - return _logoff_flag.load(butil::memory_order_relaxed); -} - -inline bool Socket::IsAppHealthCheck() const { - return (_ninflight_app_health_check.load(butil::memory_order_relaxed) != 0); +inline bool Socket::IsAvailable() const { + return !_logoff_flag.load(butil::memory_order_relaxed) && + (_ninflight_app_health_check.load(butil::memory_order_relaxed) == 0); } static const uint32_t EOF_FLAG = (1 << 31); From 8a0008388ebc16387b8ceedfe52f4ec1318b76da Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 26 Mar 2019 16:13:32 +0800 Subject: [PATCH 084/270] health_check_using_rpc: fix UT --- src/brpc/channel.cpp | 2 +- src/brpc/policy/weighted_round_robin_load_balancer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index a83d3b43..e5d4a45d 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -556,7 +556,7 @@ int Channel::Weight() { int Channel::CheckHealth() { if (_lb == NULL) { SocketUniquePtr ptr; - if (Socket::Address(_server_id, &ptr) == 0 && !ptr->IsAvailable()) { + if (Socket::Address(_server_id, &ptr) == 0 && ptr->IsAvailable()) { return 0; } return -1; diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index d72de512..d426ac7e 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -180,7 +180,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* SocketId server_id = GetServerInNextStride(s->server_list, filter, tls_temp); if (!ExcludedServers::IsExcluded(in.excluded, server_id) && Socket::Address(server_id, out->ptr) == 0 - && !(*out->ptr)->IsAvailable()) { + && (*out->ptr)->IsAvailable()) { // update tls. tls.remain_server = tls_temp.remain_server; tls.position = tls_temp.position; From 7e23ff0d4978a4a6620fdd1b375fcb11636989b6 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 26 Mar 2019 16:30:44 +0800 Subject: [PATCH 085/270] health_check_using_rpc: remove IsAvailable check in dynpart_load_balancer --- src/brpc/policy/dynpart_load_balancer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/brpc/policy/dynpart_load_balancer.cpp b/src/brpc/policy/dynpart_load_balancer.cpp index 379ab795..8da8c622 100644 --- a/src/brpc/policy/dynpart_load_balancer.cpp +++ b/src/brpc/policy/dynpart_load_balancer.cpp @@ -122,8 +122,7 @@ int DynPartLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { for (size_t i = 0; i < n; ++i) { const SocketId id = s->server_list[i].id; if ((!exclusion || !ExcludedServers::IsExcluded(in.excluded, id)) - && Socket::Address(id, &ptrs[nptr].first) == 0 - && (ptrs[nptr].first)->IsAvailable()) { + && Socket::Address(id, &ptrs[nptr].first) == 0) { int w = schan::GetSubChannelWeight(ptrs[nptr].first->user()); total_weight += w; if (nptr < 8) { From 733548deab148042edc6053eb14276edb254aec8 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 26 Mar 2019 16:45:46 +0800 Subject: [PATCH 086/270] health_check_using_rpc: refine logs --- src/brpc/selective_channel.cpp | 2 +- src/brpc/socket.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/brpc/selective_channel.cpp b/src/brpc/selective_channel.cpp index 4a1c0f69..2c495eb7 100644 --- a/src/brpc/selective_channel.cpp +++ b/src/brpc/selective_channel.cpp @@ -56,7 +56,7 @@ public: void AfterRevived(Socket* ptr) { LOG(INFO) << "Revived " << *chan << " chan=0x" << (void*)chan - << " Fake" << *ptr; + << " Fake" << *ptr << " (Connectable)"; } }; diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 1cb35218..3bc57663 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -793,7 +793,7 @@ void Socket::Revive() { if (_user) { _user->AfterRevived(this); } else { - LOG(INFO) << "Revived " << *this; + LOG(INFO) << "Revived " << *this << " (Connectable)"; } return; } @@ -1023,13 +1023,14 @@ public: return; } if (!cntl.Failed() || ptr->Failed()) { - LOG_IF(INFO, !cntl.Failed()) << "AppRevived " + LOG_IF(INFO, !cntl.Failed()) << "Succeeded to call " << ptr->remote_side() << FLAGS_health_check_path; ptr->_ninflight_app_health_check.fetch_sub( 1, butil::memory_order_relaxed); return; } - RPC_VLOG << "Fail to AppCheck, " << cntl.ErrorText(); + RPC_VLOG << "Fail to check path=" << FLAGS_health_check_path + << ", " << cntl.ErrorText(); bthread_usleep(interval_s * 1000000); cntl.Reset(); cntl.http_request().uri() = FLAGS_health_check_path; @@ -1053,7 +1054,7 @@ public: << " was abandoned during health checking"; return; } - LOG(INFO) << "AppChecking " << ptr->remote_side() << FLAGS_health_check_path; + LOG(INFO) << "Checking path=" << ptr->remote_side() << FLAGS_health_check_path; OnAppHealthCheckDone* done = new OnAppHealthCheckDone; done->id = id; done->interval_s = check_interval_s; @@ -2451,7 +2452,7 @@ int SocketUser::CheckHealth(Socket* ptr) { } void SocketUser::AfterRevived(Socket* ptr) { - LOG(INFO) << "Revived " << *ptr; + LOG(INFO) << "Revived " << *ptr << " (Connectable)"; } ////////// SocketPool ////////////// From d10699f637ae9c4e12b301d6a0c10e5fe8adee5a Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 26 Mar 2019 18:46:41 +0800 Subject: [PATCH 087/270] health_check_using_rpc: refine docs --- src/brpc/socket.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 3bc57663..3a96d60e 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -97,13 +97,12 @@ DEFINE_int32(connect_timeout_as_unreachable, 3, "fails the main socket as well when this socket is pooled."); DEFINE_string(health_check_path, "", "Http path of health check call." - "By default health check succeeds if server can be connected. If this" - "flag is set, health check is completed not only when server can be" - "connected but also an additional http call succeeds indicated by this" - "flag and FLAGS_health_check_timeout_ms"); -DEFINE_int32(health_check_timeout_ms, 500, "Timeout of health check." - "If FLAGS_health_check_path is empty, it means timeout of connect." - "Otherwise it means timeout of app health check call."); + "By default health check succeeds if the server is connectable." + "If this flag is set, health check is not completed until a http " + "call to the path succeeds within -health_check_timeout_ms(to make " + "sure the server functions well)."); +DEFINE_int32(health_check_timeout_ms, 500, "The timeout for both establishing " + "the connection and the http call to -health_check_path over the connection"); static bool validate_connect_timeout_as_unreachable(const char*, int32_t v) { return v >= 2 && v < 1000/*large enough*/; From 3068ccbfc733b8e3758486b7e68972f6138b94c2 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 26 Mar 2019 20:29:24 +0800 Subject: [PATCH 088/270] health_check_using_rpc: make hc interval exactly -health_check_interval --- src/brpc/socket.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 3a96d60e..145cdec1 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -1013,6 +1013,8 @@ int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) { class OnAppHealthCheckDone : public google::protobuf::Closure { public: void Run() { + butil::Timer tm; + tm.start(); std::unique_ptr self_guard(this); SocketUniquePtr ptr; const int rc = Socket::AddressFailedAsWell(id, &ptr); @@ -1030,7 +1032,12 @@ public: } RPC_VLOG << "Fail to check path=" << FLAGS_health_check_path << ", " << cntl.ErrorText(); - bthread_usleep(interval_s * 1000000); + tm.stop(); + int64_t sleep_time_ms = + interval_s * 1000 - cntl.latency_us() / 1000 - tm.m_elapsed(); + if (sleep_time_ms > 0) { + bthread_usleep(sleep_time_ms * 1000); + } cntl.Reset(); cntl.http_request().uri() = FLAGS_health_check_path; ControllerPrivateAccessor(&cntl).set_health_check_call(); @@ -1060,7 +1067,8 @@ public: brpc::ChannelOptions options; options.protocol = PROTOCOL_HTTP; options.max_retry = 0; - options.timeout_ms = FLAGS_health_check_timeout_ms; + options.timeout_ms = + std::min((int64_t)FLAGS_health_check_timeout_ms, check_interval_s * 1000); if (done->channel.Init(id, &options) != 0) { LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; ptr->_ninflight_app_health_check.fetch_sub( From f0ba17571a65ac40eb69efc1fd389404a2a79c23 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 27 Mar 2019 14:44:40 +0800 Subject: [PATCH 089/270] health_check_using_rpc: replace bthread_usleep to reduce inflight bthread --- src/brpc/socket.cpp | 91 ++++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 31 deletions(-) diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 145cdec1..78e4b0da 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -1012,42 +1012,13 @@ int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) { class OnAppHealthCheckDone : public google::protobuf::Closure { public: - void Run() { - butil::Timer tm; - tm.start(); - std::unique_ptr self_guard(this); - SocketUniquePtr ptr; - const int rc = Socket::AddressFailedAsWell(id, &ptr); - if (rc < 0) { - RPC_VLOG << "SocketId=" << id - << " was abandoned during health checking"; - return; - } - if (!cntl.Failed() || ptr->Failed()) { - LOG_IF(INFO, !cntl.Failed()) << "Succeeded to call " - << ptr->remote_side() << FLAGS_health_check_path; - ptr->_ninflight_app_health_check.fetch_sub( - 1, butil::memory_order_relaxed); - return; - } - RPC_VLOG << "Fail to check path=" << FLAGS_health_check_path - << ", " << cntl.ErrorText(); - tm.stop(); - int64_t sleep_time_ms = - interval_s * 1000 - cntl.latency_us() / 1000 - tm.m_elapsed(); - if (sleep_time_ms > 0) { - bthread_usleep(sleep_time_ms * 1000); - } - cntl.Reset(); - cntl.http_request().uri() = FLAGS_health_check_path; - ControllerPrivateAccessor(&cntl).set_health_check_call(); - channel.CallMethod(NULL, &cntl, NULL, NULL, self_guard.release()); - } + virtual void Run(); HealthCheckChannel channel; brpc::Controller cntl; SocketId id; int64_t interval_s; + int64_t last_check_time_ms; }; class HealthCheckManager { @@ -1076,12 +1047,70 @@ public: delete done; return; } + AppCheck(done); + } + + static void* AppCheck(void* arg) { + OnAppHealthCheckDone* done = static_cast(arg); + done->cntl.Reset(); done->cntl.http_request().uri() = FLAGS_health_check_path; ControllerPrivateAccessor(&done->cntl).set_health_check_call(); + done->last_check_time_ms = butil::gettimeofday_ms(); done->channel.CallMethod(NULL, &done->cntl, NULL, NULL, done); + return NULL; + } + + static void RunAppCheck(void* arg) { + bthread_t th = 0; + int rc = bthread_start_background( + &th, &BTHREAD_ATTR_NORMAL, AppCheck, arg); + if (rc != 0) { + LOG(ERROR) << "Fail to start AppCheck"; + AppCheck(arg); + return; + } } }; +void OnAppHealthCheckDone::Run() { + std::unique_ptr self_guard(this); + SocketUniquePtr ptr; + const int rc = Socket::AddressFailedAsWell(id, &ptr); + if (rc < 0) { + RPC_VLOG << "SocketId=" << id + << " was abandoned during health checking"; + return; + } + if (!cntl.Failed() || ptr->Failed()) { + LOG_IF(INFO, !cntl.Failed()) << "Succeeded to call " + << ptr->remote_side() << FLAGS_health_check_path; + ptr->_ninflight_app_health_check.fetch_sub( + 1, butil::memory_order_relaxed); + return; + } + RPC_VLOG << "Fail to check path=" << FLAGS_health_check_path + << ", " << cntl.ErrorText(); + + int64_t sleep_time_ms = + last_check_time_ms + interval_s * 1000 - butil::gettimeofday_ms(); + if (sleep_time_ms > 0) { + const timespec abstime = butil::milliseconds_from_now(sleep_time_ms); + bthread_timer_t timer_id; + const int rc = bthread_timer_add( + &timer_id, abstime, HealthCheckManager::RunAppCheck, this); + if (rc != 0) { + LOG(ERROR) << "Fail to add timer for RunAppCheck"; + HealthCheckManager::AppCheck(this); + return; + } + } else { + // the time of next call has passed, just AppCheck immediately + HealthCheckManager::AppCheck(this); + } + self_guard.release(); +} + + bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { SocketUniquePtr ptr; const int rc = Socket::AddressFailedAsWell(_id, &ptr); From 03cc7f8c6e401742f6139b5fb8ab6d4eeb087695 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 27 Mar 2019 16:30:39 +0800 Subject: [PATCH 090/270] health_check_using_rpc: put health check related code into separate file --- src/brpc/details/health_check.cpp | 227 ++++++++++++++++++++++++++++++ src/brpc/details/health_check.h | 41 ++++++ src/brpc/socket.cpp | 212 +--------------------------- 3 files changed, 271 insertions(+), 209 deletions(-) create mode 100644 src/brpc/details/health_check.cpp create mode 100644 src/brpc/details/health_check.h diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp new file mode 100644 index 00000000..2e1b0c19 --- /dev/null +++ b/src/brpc/details/health_check.cpp @@ -0,0 +1,227 @@ +// Copyright (c) 2014 Baidu, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Authors: Ge,Jun (gejun@baidu.com) +// Jiashun Zhu(zhujiashun@baidu.com) + +#include "brpc/details/health_check.h" +#include "brpc/socket.h" +#include "brpc/channel.h" +#include "brpc/controller.h" +#include "brpc/details/controller_private_accessor.h" +#include "brpc/global.h" +#include "brpc/log.h" +#include "bthread/unstable.h" +#include "bthread/bthread.h" + +namespace brpc { + +DEFINE_string(health_check_path, "", "Http path of health check call." "By default health check succeeds if the server is connectable." + "If this flag is set, health check is not completed until a http " + "call to the path succeeds within -health_check_timeout_ms(to make " + "sure the server functions well)."); +DEFINE_int32(health_check_timeout_ms, 500, "The timeout for both establishing " + "the connection and the http call to -health_check_path over the connection"); + +class HealthCheckChannel : public brpc::Channel { +public: + HealthCheckChannel() {} + ~HealthCheckChannel() {} + + int Init(SocketId id, const ChannelOptions* options); +}; + +int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) { + brpc::GlobalInitializeOrDie(); + if (InitChannelOptions(options) != 0) { + return -1; + } + _server_id = id; + return 0; +} + +class OnAppHealthCheckDone : public google::protobuf::Closure { +public: + virtual void Run(); + + HealthCheckChannel channel; + brpc::Controller cntl; + SocketId id; + int64_t interval_s; + int64_t last_check_time_ms; +}; + +class HealthCheckManager { +public: + static void StartCheck(SocketId id, int64_t check_interval_s) { + SocketUniquePtr ptr; + const int rc = Socket::AddressFailedAsWell(id, &ptr); + if (rc < 0) { + RPC_VLOG << "SocketId=" << id + << " was abandoned during health checking"; + return; + } + LOG(INFO) << "Checking path=" << ptr->remote_side() << FLAGS_health_check_path; + OnAppHealthCheckDone* done = new OnAppHealthCheckDone; + done->id = id; + done->interval_s = check_interval_s; + brpc::ChannelOptions options; + options.protocol = PROTOCOL_HTTP; + options.max_retry = 0; + options.timeout_ms = + std::min((int64_t)FLAGS_health_check_timeout_ms, check_interval_s * 1000); + if (done->channel.Init(id, &options) != 0) { + LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; + ptr->_ninflight_app_health_check.fetch_sub( + 1, butil::memory_order_relaxed); + delete done; + return; + } + AppCheck(done); + } + + static void* AppCheck(void* arg) { + OnAppHealthCheckDone* done = static_cast(arg); + done->cntl.Reset(); + done->cntl.http_request().uri() = FLAGS_health_check_path; + ControllerPrivateAccessor(&done->cntl).set_health_check_call(); + done->last_check_time_ms = butil::gettimeofday_ms(); + done->channel.CallMethod(NULL, &done->cntl, NULL, NULL, done); + return NULL; + } + + static void RunAppCheck(void* arg) { + bthread_t th = 0; + int rc = bthread_start_background( + &th, &BTHREAD_ATTR_NORMAL, AppCheck, arg); + if (rc != 0) { + LOG(ERROR) << "Fail to start AppCheck"; + AppCheck(arg); + return; + } + } +}; + +void OnAppHealthCheckDone::Run() { + std::unique_ptr self_guard(this); + SocketUniquePtr ptr; + const int rc = Socket::AddressFailedAsWell(id, &ptr); + if (rc < 0) { + RPC_VLOG << "SocketId=" << id + << " was abandoned during health checking"; + return; + } + if (!cntl.Failed() || ptr->Failed()) { + LOG_IF(INFO, !cntl.Failed()) << "Succeeded to call " + << ptr->remote_side() << FLAGS_health_check_path; + ptr->_ninflight_app_health_check.fetch_sub( + 1, butil::memory_order_relaxed); + return; + } + RPC_VLOG << "Fail to check path=" << FLAGS_health_check_path + << ", " << cntl.ErrorText(); + + int64_t sleep_time_ms = + last_check_time_ms + interval_s * 1000 - butil::gettimeofday_ms(); + if (sleep_time_ms > 0) { + const timespec abstime = butil::milliseconds_from_now(sleep_time_ms); + bthread_timer_t timer_id; + const int rc = bthread_timer_add( + &timer_id, abstime, HealthCheckManager::RunAppCheck, this); + if (rc != 0) { + LOG(ERROR) << "Fail to add timer for RunAppCheck"; + HealthCheckManager::AppCheck(this); + return; + } + } else { + // the time of next call has passed, just AppCheck immediately + HealthCheckManager::AppCheck(this); + } + self_guard.release(); +} + +HealthCheckTask::HealthCheckTask(SocketId id, bvar::Adder* nhealthcheck) + : _id(id) + , _first_time(true) + , _nhealthcheck(nhealthcheck) {} + +bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { + SocketUniquePtr ptr; + const int rc = Socket::AddressFailedAsWell(_id, &ptr); + CHECK(rc != 0); + if (rc < 0) { + RPC_VLOG << "SocketId=" << _id + << " was abandoned before health checking"; + return false; + } + // Note: Making a Socket re-addessable is hard. An alternative is + // creating another Socket with selected internal fields to replace + // failed Socket. Although it avoids concurrent issues with in-place + // revive, it changes SocketId: many code need to watch SocketId + // and update on change, which is impractical. Another issue with + // this method is that it has to move "selected internal fields" + // which may be accessed in parallel, not trivial to be moved. + // Finally we choose a simple-enough solution: wait until the + // reference count hits `expected_nref', which basically means no + // one is addressing the Socket(except here). Because the Socket + // is not addressable, the reference count will not increase + // again. This solution is not perfect because the `expected_nref' + // is implementation specific. In our case, one reference comes + // from SocketMapInsert(socket_map.cpp), one reference is here. + // Although WaitAndReset() could hang when someone is addressing + // the failed Socket forever (also indicating bug), this is not an + // issue in current code. + if (_first_time) { // Only check at first time. + _first_time = false; + if (ptr->WaitAndReset(2/*note*/) != 0) { + LOG(INFO) << "Cancel checking " << *ptr; + return false; + } + } + + (*_nhealthcheck) << 1; + int hc = 0; + if (ptr->_user) { + hc = ptr->_user->CheckHealth(ptr.get()); + } else { + hc = ptr->CheckHealth(); + } + if (hc == 0) { + if (ptr->CreatedByConnect()) { + (*_nhealthcheck) << -1; + } + if (!FLAGS_health_check_path.empty()) { + ptr->_ninflight_app_health_check.fetch_add( + 1, butil::memory_order_relaxed); + } + ptr->Revive(); + ptr->_hc_count = 0; + if (!FLAGS_health_check_path.empty()) { + HealthCheckManager::StartCheck(_id, ptr->_health_check_interval_s); + } + return false; + } else if (hc == ESTOP) { + LOG(INFO) << "Cancel checking " << *ptr; + return false; + } + ++ ptr->_hc_count; + *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); + return true; +} + +void HealthCheckTask::OnDestroyingTask() { + delete this; +} + +} // namespace brpc diff --git a/src/brpc/details/health_check.h b/src/brpc/details/health_check.h new file mode 100644 index 00000000..93fb819c --- /dev/null +++ b/src/brpc/details/health_check.h @@ -0,0 +1,41 @@ +// Copyright (c) 2014 Baidu, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Authors: Ge,Jun (gejun@baidu.com) +// Jiashun Zhu(zhujiashun@baidu.com) + +#ifndef _HEALTH_CHECK_H +#define _HEALTH_CHECK_H + +#include "brpc/socket_id.h" +#include "brpc/periodic_task.h" +#include "bvar/bvar.h" + +namespace brpc { + +class HealthCheckTask : public PeriodicTask { +public: + explicit HealthCheckTask(SocketId id, bvar::Adder* nhealthcheck); + bool OnTriggeringTask(timespec* next_abstime) override; + void OnDestroyingTask() override; + +private: + SocketId _id; + bool _first_time; + bvar::Adder* _nhealthcheck; +}; + +} // namespace brpc + +#endif diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 78e4b0da..0e44bb36 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -48,10 +48,7 @@ #include "brpc/shared_object.h" #include "brpc/policy/rtmp_protocol.h" // FIXME #include "brpc/periodic_task.h" -#include "brpc/channel.h" -#include "brpc/controller.h" -#include "details/controller_private_accessor.h" -#include "brpc/global.h" +#include "brpc/details/health_check.h" #if defined(OS_MACOSX) #include #endif @@ -96,13 +93,7 @@ DEFINE_int32(connect_timeout_as_unreachable, 3, "times *continuously*, the error is changed to ENETUNREACH which " "fails the main socket as well when this socket is pooled."); -DEFINE_string(health_check_path, "", "Http path of health check call." - "By default health check succeeds if the server is connectable." - "If this flag is set, health check is not completed until a http " - "call to the path succeeds within -health_check_timeout_ms(to make " - "sure the server functions well)."); -DEFINE_int32(health_check_timeout_ms, 500, "The timeout for both establishing " - "the connection and the http call to -health_check_path over the connection"); +DECLARE_int32(health_check_timeout_ms); static bool validate_connect_timeout_as_unreachable(const char*, int32_t v) { return v >= 2 && v < 1000/*large enough*/; @@ -799,17 +790,6 @@ void Socket::Revive() { } } -class HealthCheckTask : public PeriodicTask { -public: - explicit HealthCheckTask(SocketId id) : _id(id) , _first_time(true) {} - bool OnTriggeringTask(timespec* next_abstime) override; - void OnDestroyingTask() override; - -private: - SocketId _id; - bool _first_time; -}; - int Socket::ReleaseAdditionalReference() { bool expect = false; // Use `relaxed' fence here since `Dereference' has `released' fence @@ -881,7 +861,7 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) { if (_health_check_interval_s > 0) { GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); PeriodicTaskManager::StartTaskAt( - new HealthCheckTask(id()), + new HealthCheckTask(id(), &s_vars->nhealthcheck), butil::milliseconds_from_now(GetOrNewSharedPart()-> circuit_breaker.isolation_duration_ms())); } @@ -989,192 +969,6 @@ int Socket::Status(SocketId id, int32_t* nref) { return -1; } -void HealthCheckTask::OnDestroyingTask() { - delete this; -} - -class HealthCheckChannel : public brpc::Channel { -public: - HealthCheckChannel() {} - ~HealthCheckChannel() {} - - int Init(SocketId id, const ChannelOptions* options); -}; - -int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) { - brpc::GlobalInitializeOrDie(); - if (InitChannelOptions(options) != 0) { - return -1; - } - _server_id = id; - return 0; -} - -class OnAppHealthCheckDone : public google::protobuf::Closure { -public: - virtual void Run(); - - HealthCheckChannel channel; - brpc::Controller cntl; - SocketId id; - int64_t interval_s; - int64_t last_check_time_ms; -}; - -class HealthCheckManager { -public: - static void StartCheck(SocketId id, int64_t check_interval_s) { - SocketUniquePtr ptr; - const int rc = Socket::AddressFailedAsWell(id, &ptr); - if (rc < 0) { - RPC_VLOG << "SocketId=" << id - << " was abandoned during health checking"; - return; - } - LOG(INFO) << "Checking path=" << ptr->remote_side() << FLAGS_health_check_path; - OnAppHealthCheckDone* done = new OnAppHealthCheckDone; - done->id = id; - done->interval_s = check_interval_s; - brpc::ChannelOptions options; - options.protocol = PROTOCOL_HTTP; - options.max_retry = 0; - options.timeout_ms = - std::min((int64_t)FLAGS_health_check_timeout_ms, check_interval_s * 1000); - if (done->channel.Init(id, &options) != 0) { - LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; - ptr->_ninflight_app_health_check.fetch_sub( - 1, butil::memory_order_relaxed); - delete done; - return; - } - AppCheck(done); - } - - static void* AppCheck(void* arg) { - OnAppHealthCheckDone* done = static_cast(arg); - done->cntl.Reset(); - done->cntl.http_request().uri() = FLAGS_health_check_path; - ControllerPrivateAccessor(&done->cntl).set_health_check_call(); - done->last_check_time_ms = butil::gettimeofday_ms(); - done->channel.CallMethod(NULL, &done->cntl, NULL, NULL, done); - return NULL; - } - - static void RunAppCheck(void* arg) { - bthread_t th = 0; - int rc = bthread_start_background( - &th, &BTHREAD_ATTR_NORMAL, AppCheck, arg); - if (rc != 0) { - LOG(ERROR) << "Fail to start AppCheck"; - AppCheck(arg); - return; - } - } -}; - -void OnAppHealthCheckDone::Run() { - std::unique_ptr self_guard(this); - SocketUniquePtr ptr; - const int rc = Socket::AddressFailedAsWell(id, &ptr); - if (rc < 0) { - RPC_VLOG << "SocketId=" << id - << " was abandoned during health checking"; - return; - } - if (!cntl.Failed() || ptr->Failed()) { - LOG_IF(INFO, !cntl.Failed()) << "Succeeded to call " - << ptr->remote_side() << FLAGS_health_check_path; - ptr->_ninflight_app_health_check.fetch_sub( - 1, butil::memory_order_relaxed); - return; - } - RPC_VLOG << "Fail to check path=" << FLAGS_health_check_path - << ", " << cntl.ErrorText(); - - int64_t sleep_time_ms = - last_check_time_ms + interval_s * 1000 - butil::gettimeofday_ms(); - if (sleep_time_ms > 0) { - const timespec abstime = butil::milliseconds_from_now(sleep_time_ms); - bthread_timer_t timer_id; - const int rc = bthread_timer_add( - &timer_id, abstime, HealthCheckManager::RunAppCheck, this); - if (rc != 0) { - LOG(ERROR) << "Fail to add timer for RunAppCheck"; - HealthCheckManager::AppCheck(this); - return; - } - } else { - // the time of next call has passed, just AppCheck immediately - HealthCheckManager::AppCheck(this); - } - self_guard.release(); -} - - -bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { - SocketUniquePtr ptr; - const int rc = Socket::AddressFailedAsWell(_id, &ptr); - CHECK(rc != 0); - if (rc < 0) { - RPC_VLOG << "SocketId=" << _id - << " was abandoned before health checking"; - return false; - } - // Note: Making a Socket re-addessable is hard. An alternative is - // creating another Socket with selected internal fields to replace - // failed Socket. Although it avoids concurrent issues with in-place - // revive, it changes SocketId: many code need to watch SocketId - // and update on change, which is impractical. Another issue with - // this method is that it has to move "selected internal fields" - // which may be accessed in parallel, not trivial to be moved. - // Finally we choose a simple-enough solution: wait until the - // reference count hits `expected_nref', which basically means no - // one is addressing the Socket(except here). Because the Socket - // is not addressable, the reference count will not increase - // again. This solution is not perfect because the `expected_nref' - // is implementation specific. In our case, one reference comes - // from SocketMapInsert(socket_map.cpp), one reference is here. - // Although WaitAndReset() could hang when someone is addressing - // the failed Socket forever (also indicating bug), this is not an - // issue in current code. - if (_first_time) { // Only check at first time. - _first_time = false; - if (ptr->WaitAndReset(2/*note*/) != 0) { - LOG(INFO) << "Cancel checking " << *ptr; - return false; - } - } - - s_vars->nhealthcheck << 1; - int hc = 0; - if (ptr->_user) { - hc = ptr->_user->CheckHealth(ptr.get()); - } else { - hc = ptr->CheckHealth(); - } - if (hc == 0) { - if (ptr->CreatedByConnect()) { - s_vars->channel_conn << -1; - } - if (!FLAGS_health_check_path.empty()) { - ptr->_ninflight_app_health_check.fetch_add( - 1, butil::memory_order_relaxed); - } - ptr->Revive(); - ptr->_hc_count = 0; - if (!FLAGS_health_check_path.empty()) { - HealthCheckManager::StartCheck(_id, ptr->_health_check_interval_s); - } - return false; - } else if (hc == ESTOP) { - LOG(INFO) << "Cancel checking " << *ptr; - return false; - } - ++ ptr->_hc_count; - *next_abstime = butil::seconds_from_now(ptr->_health_check_interval_s); - return true; -} - void Socket::OnRecycle() { const bool create_by_connect = CreatedByConnect(); if (_app_connect) { From 5a2821096e02a2d20668c5615c50edae589a75dc Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 27 Mar 2019 16:46:39 +0800 Subject: [PATCH 091/270] health_check_using_rpc: refine desc --- src/brpc/details/health_check.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp index 2e1b0c19..8e97260d 100644 --- a/src/brpc/details/health_check.cpp +++ b/src/brpc/details/health_check.cpp @@ -27,7 +27,8 @@ namespace brpc { -DEFINE_string(health_check_path, "", "Http path of health check call." "By default health check succeeds if the server is connectable." +DEFINE_string(health_check_path, "", "Http path of health check call." + "By default health check succeeds if the server is connectable." "If this flag is set, health check is not completed until a http " "call to the path succeeds within -health_check_timeout_ms(to make " "sure the server functions well)."); From 6cb0191249191d6d0bd6691b4f7180c375a7f58f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 27 Mar 2019 18:47:30 +0800 Subject: [PATCH 092/270] health_check_using_rpc: wrap HealthCheckTask --- src/brpc/details/health_check.cpp | 24 ++++++++++++--- src/brpc/details/health_check.h | 13 ++------ src/brpc/socket.cpp | 49 ++++++++----------------------- src/brpc/socket.h | 23 +++++++++++++++ 4 files changed, 58 insertions(+), 51 deletions(-) diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp index 8e97260d..4803d5b1 100644 --- a/src/brpc/details/health_check.cpp +++ b/src/brpc/details/health_check.cpp @@ -152,10 +152,22 @@ void OnAppHealthCheckDone::Run() { self_guard.release(); } -HealthCheckTask::HealthCheckTask(SocketId id, bvar::Adder* nhealthcheck) +class HealthCheckTask : public PeriodicTask { +public: + explicit HealthCheckTask(SocketId id, SocketVarsCollector* nhealthcheck); + bool OnTriggeringTask(timespec* next_abstime) override; + void OnDestroyingTask() override; + +private: + SocketId _id; + bool _first_time; + SocketVarsCollector* _collector; +}; + +HealthCheckTask::HealthCheckTask(SocketId id, SocketVarsCollector* collector) : _id(id) , _first_time(true) - , _nhealthcheck(nhealthcheck) {} + , _collector(collector) {} bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { SocketUniquePtr ptr; @@ -191,7 +203,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { } } - (*_nhealthcheck) << 1; + _collector->nhealthcheck << 1; int hc = 0; if (ptr->_user) { hc = ptr->_user->CheckHealth(ptr.get()); @@ -200,7 +212,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { } if (hc == 0) { if (ptr->CreatedByConnect()) { - (*_nhealthcheck) << -1; + _collector->channel_conn << -1; } if (!FLAGS_health_check_path.empty()) { ptr->_ninflight_app_health_check.fetch_add( @@ -225,4 +237,8 @@ void HealthCheckTask::OnDestroyingTask() { delete this; } +PeriodicTask* NewHealthCheckTask(SocketId id, SocketVarsCollector* collector) { + return new HealthCheckTask(id, collector); +} + } // namespace brpc diff --git a/src/brpc/details/health_check.h b/src/brpc/details/health_check.h index 93fb819c..42485f76 100644 --- a/src/brpc/details/health_check.h +++ b/src/brpc/details/health_check.h @@ -21,20 +21,11 @@ #include "brpc/socket_id.h" #include "brpc/periodic_task.h" #include "bvar/bvar.h" +#include "brpc/socket.h" namespace brpc { -class HealthCheckTask : public PeriodicTask { -public: - explicit HealthCheckTask(SocketId id, bvar::Adder* nhealthcheck); - bool OnTriggeringTask(timespec* next_abstime) override; - void OnDestroyingTask() override; - -private: - SocketId _id; - bool _first_time; - bvar::Adder* _nhealthcheck; -}; +PeriodicTask* NewHealthCheckTask(SocketId id, SocketVarsCollector* collector); } // namespace brpc diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 0e44bb36..aa78431f 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -34,7 +34,6 @@ #include "butil/logging.h" // CHECK #include "butil/macros.h" #include "butil/class_name.h" // butil::class_name -#include "bvar/bvar.h" #include "brpc/log.h" #include "brpc/reloadable_flags.h" // BRPC_VALIDATE_GFLAG #include "brpc/errno.pb.h" @@ -272,33 +271,11 @@ void Socket::SharedPart::UpdateStatsEverySecond(int64_t now_ms) { } } -struct SocketVarsCollector { - SocketVarsCollector() - : nsocket("rpc_socket_count") - , channel_conn("rpc_channel_connection_count") - , neventthread_second("rpc_event_thread_second", &neventthread) - , nhealthcheck("rpc_health_check_count") - , nkeepwrite_second("rpc_keepwrite_second", &nkeepwrite) - , nwaitepollout("rpc_waitepollout_count") - , nwaitepollout_second("rpc_waitepollout_second", &nwaitepollout) - {} - - bvar::Adder nsocket; - bvar::Adder channel_conn; - bvar::Adder neventthread; - bvar::PerSecond > neventthread_second; - bvar::Adder nhealthcheck; - bvar::Adder nkeepwrite; - bvar::PerSecond > nkeepwrite_second; - bvar::Adder nwaitepollout; - bvar::PerSecond > nwaitepollout_second; -}; - -static SocketVarsCollector* s_vars = NULL; +SocketVarsCollector* g_vars = NULL; static pthread_once_t s_create_vars_once = PTHREAD_ONCE_INIT; static void CreateVars() { - s_vars = new SocketVarsCollector; + g_vars = new SocketVarsCollector; } void Socket::CreateVarsOnce() { @@ -307,8 +284,8 @@ void Socket::CreateVarsOnce() { // Used by ConnectionService int64_t GetChannelConnectionCount() { - if (s_vars) { - return s_vars->channel_conn.get_value(); + if (g_vars) { + return g_vars->channel_conn.get_value(); } return 0; } @@ -612,7 +589,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) { LOG(FATAL) << "Fail to get_resource"; return -1; } - s_vars->nsocket << 1; + g_vars->nsocket << 1; CHECK(NULL == m->_shared_part.load(butil::memory_order_relaxed)); m->_nevent.store(0, butil::memory_order_relaxed); m->_keytable_pool = options.keytable_pool; @@ -717,7 +694,7 @@ int Socket::WaitAndReset(int32_t expected_nref) { } close(prev_fd); if (CreatedByConnect()) { - s_vars->channel_conn << -1; + g_vars->channel_conn << -1; } } _local_side = butil::EndPoint(); @@ -861,7 +838,7 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) { if (_health_check_interval_s > 0) { GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); PeriodicTaskManager::StartTaskAt( - new HealthCheckTask(id(), &s_vars->nhealthcheck), + NewHealthCheckTask(id(), g_vars), butil::milliseconds_from_now(GetOrNewSharedPart()-> circuit_breaker.isolation_duration_ms())); } @@ -997,7 +974,7 @@ void Socket::OnRecycle() { } close(prev_fd); if (create_by_connect) { - s_vars->channel_conn << -1; + g_vars->channel_conn << -1; } } reset_parsing_context(NULL); @@ -1032,7 +1009,7 @@ void Socket::OnRecycle() { } } - s_vars->nsocket << -1; + g_vars->nsocket << -1; } void* Socket::ProcessEvent(void* arg) { @@ -1248,7 +1225,7 @@ int Socket::CheckConnected(int sockfd) { << " via fd=" << (int)sockfd << " SocketId=" << id() << " local_port=" << ntohs(client.sin_port); if (CreatedByConnect()) { - s_vars->channel_conn << 1; + g_vars->channel_conn << 1; } // Doing SSL handshake after TCP connected return SSLHandshake(sockfd, false); @@ -1617,7 +1594,7 @@ FAIL_TO_WRITE: static const size_t DATA_LIST_MAX = 256; void* Socket::KeepWrite(void* void_arg) { - s_vars->nkeepwrite << 1; + g_vars->nkeepwrite << 1; WriteRequest* req = static_cast(void_arg); SocketUniquePtr s(req->socket); @@ -1657,7 +1634,7 @@ void* Socket::KeepWrite(void* void_arg) { // Update(8/15/2017): Not working, performance downgraded. //if (nw <= 0 || req->data.empty()/*note*/) { if (nw <= 0) { - s_vars->nwaitepollout << 1; + g_vars->nwaitepollout << 1; bool pollin = (s->_on_edge_triggered_events != NULL); // NOTE: Waiting epollout within timeout is a must to force // KeepWrite to check and setup pending WriteRequests periodically, @@ -1972,7 +1949,7 @@ int Socket::StartInputEvent(SocketId id, uint32_t events, // According to the stats, above fetch_add is very effective. In a // server processing 1 million requests per second, this counter // is just 1500~1700/s - s_vars->neventthread << 1; + g_vars->neventthread << 1; bthread_t tid; // transfer ownership as well, don't use s anymore! diff --git a/src/brpc/socket.h b/src/brpc/socket.h index 706d075c..616fb738 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -37,6 +37,7 @@ #include "brpc/options.pb.h" // ConnectionType #include "brpc/socket_id.h" // SocketId #include "brpc/socket_message.h" // SocketMessagePtr +#include "bvar/bvar.h" namespace brpc { namespace policy { @@ -126,6 +127,28 @@ struct SocketStat { uint32_t out_num_messages_m; }; +struct SocketVarsCollector { + SocketVarsCollector() + : nsocket("rpc_socket_count") + , channel_conn("rpc_channel_connection_count") + , neventthread_second("rpc_event_thread_second", &neventthread) + , nhealthcheck("rpc_health_check_count") + , nkeepwrite_second("rpc_keepwrite_second", &nkeepwrite) + , nwaitepollout("rpc_waitepollout_count") + , nwaitepollout_second("rpc_waitepollout_second", &nwaitepollout) + {} + + bvar::Adder nsocket; + bvar::Adder channel_conn; + bvar::Adder neventthread; + bvar::PerSecond > neventthread_second; + bvar::Adder nhealthcheck; + bvar::Adder nkeepwrite; + bvar::PerSecond > nkeepwrite_second; + bvar::Adder nwaitepollout; + bvar::PerSecond > nwaitepollout_second; +}; + struct PipelinedInfo { PipelinedInfo() { reset(); } void reset() { From 413db42c96e48b3865803902201c62fa277673de Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 27 Mar 2019 19:02:01 +0800 Subject: [PATCH 093/270] health_check_using_rpc: wrap to StartHealthCheckWithDelayMS --- src/brpc/details/health_check.cpp | 20 +++++++++++--------- src/brpc/details/health_check.h | 3 ++- src/brpc/socket.cpp | 6 ++---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp index 4803d5b1..36443c0c 100644 --- a/src/brpc/details/health_check.cpp +++ b/src/brpc/details/health_check.cpp @@ -27,6 +27,9 @@ namespace brpc { +// declared at socket.cpp +extern SocketVarsCollector* g_vars; + DEFINE_string(health_check_path, "", "Http path of health check call." "By default health check succeeds if the server is connectable." "If this flag is set, health check is not completed until a http " @@ -154,20 +157,18 @@ void OnAppHealthCheckDone::Run() { class HealthCheckTask : public PeriodicTask { public: - explicit HealthCheckTask(SocketId id, SocketVarsCollector* nhealthcheck); + explicit HealthCheckTask(SocketId id); bool OnTriggeringTask(timespec* next_abstime) override; void OnDestroyingTask() override; private: SocketId _id; bool _first_time; - SocketVarsCollector* _collector; }; -HealthCheckTask::HealthCheckTask(SocketId id, SocketVarsCollector* collector) +HealthCheckTask::HealthCheckTask(SocketId id) : _id(id) - , _first_time(true) - , _collector(collector) {} + , _first_time(true) {} bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { SocketUniquePtr ptr; @@ -203,7 +204,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { } } - _collector->nhealthcheck << 1; + g_vars->nhealthcheck << 1; int hc = 0; if (ptr->_user) { hc = ptr->_user->CheckHealth(ptr.get()); @@ -212,7 +213,7 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { } if (hc == 0) { if (ptr->CreatedByConnect()) { - _collector->channel_conn << -1; + g_vars->channel_conn << -1; } if (!FLAGS_health_check_path.empty()) { ptr->_ninflight_app_health_check.fetch_add( @@ -237,8 +238,9 @@ void HealthCheckTask::OnDestroyingTask() { delete this; } -PeriodicTask* NewHealthCheckTask(SocketId id, SocketVarsCollector* collector) { - return new HealthCheckTask(id, collector); +void StartHealthCheckWithDelayMS(SocketId id, int64_t delay_ms) { + PeriodicTaskManager::StartTaskAt(new HealthCheckTask(id), + butil::milliseconds_from_now(delay_ms)); } } // namespace brpc diff --git a/src/brpc/details/health_check.h b/src/brpc/details/health_check.h index 42485f76..5e8d2c8c 100644 --- a/src/brpc/details/health_check.h +++ b/src/brpc/details/health_check.h @@ -25,7 +25,8 @@ namespace brpc { -PeriodicTask* NewHealthCheckTask(SocketId id, SocketVarsCollector* collector); +// Start health check for socket id after delay_ms. +void StartHealthCheckWithDelayMS(SocketId id, int64_t delay_ms); } // namespace brpc diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index aa78431f..3200b68a 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -837,10 +837,8 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) { // comes online. if (_health_check_interval_s > 0) { GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); - PeriodicTaskManager::StartTaskAt( - NewHealthCheckTask(id(), g_vars), - butil::milliseconds_from_now(GetOrNewSharedPart()-> - circuit_breaker.isolation_duration_ms())); + StartHealthCheckWithDelayMS(id(), + GetOrNewSharedPart()->circuit_breaker.isolation_duration_ms()); } // Wake up all threads waiting on EPOLLOUT when closing fd _epollout_butex->fetch_add(1, butil::memory_order_relaxed); From 938f2e851f4145b111c3b7336ea25a96d10db430 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 28 Mar 2019 16:21:26 +0800 Subject: [PATCH 094/270] health_check_using_rpc: refine code --- src/brpc/details/health_check.cpp | 103 ++++++++++++++++-------------- 1 file changed, 56 insertions(+), 47 deletions(-) diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp index 36443c0c..d8ed0a28 100644 --- a/src/brpc/details/health_check.cpp +++ b/src/brpc/details/health_check.cpp @@ -68,55 +68,59 @@ public: class HealthCheckManager { public: - static void StartCheck(SocketId id, int64_t check_interval_s) { - SocketUniquePtr ptr; - const int rc = Socket::AddressFailedAsWell(id, &ptr); - if (rc < 0) { - RPC_VLOG << "SocketId=" << id - << " was abandoned during health checking"; - return; - } - LOG(INFO) << "Checking path=" << ptr->remote_side() << FLAGS_health_check_path; - OnAppHealthCheckDone* done = new OnAppHealthCheckDone; - done->id = id; - done->interval_s = check_interval_s; - brpc::ChannelOptions options; - options.protocol = PROTOCOL_HTTP; - options.max_retry = 0; - options.timeout_ms = - std::min((int64_t)FLAGS_health_check_timeout_ms, check_interval_s * 1000); - if (done->channel.Init(id, &options) != 0) { - LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; - ptr->_ninflight_app_health_check.fetch_sub( - 1, butil::memory_order_relaxed); - delete done; - return; - } - AppCheck(done); - } - - static void* AppCheck(void* arg) { - OnAppHealthCheckDone* done = static_cast(arg); - done->cntl.Reset(); - done->cntl.http_request().uri() = FLAGS_health_check_path; - ControllerPrivateAccessor(&done->cntl).set_health_check_call(); - done->last_check_time_ms = butil::gettimeofday_ms(); - done->channel.CallMethod(NULL, &done->cntl, NULL, NULL, done); - return NULL; - } - - static void RunAppCheck(void* arg) { - bthread_t th = 0; - int rc = bthread_start_background( - &th, &BTHREAD_ATTR_NORMAL, AppCheck, arg); - if (rc != 0) { - LOG(ERROR) << "Fail to start AppCheck"; - AppCheck(arg); - return; - } - } + static void StartCheck(SocketId id, int64_t check_interval_s); + static void* AppCheck(void* arg); + static void RunAppCheck(void* arg); }; +void HealthCheckManager::StartCheck(SocketId id, int64_t check_interval_s) { + SocketUniquePtr ptr; + const int rc = Socket::AddressFailedAsWell(id, &ptr); + if (rc < 0) { + RPC_VLOG << "SocketId=" << id + << " was abandoned during health checking"; + return; + } + LOG(INFO) << "Checking path=" << ptr->remote_side() << FLAGS_health_check_path; + OnAppHealthCheckDone* done = new OnAppHealthCheckDone; + done->id = id; + done->interval_s = check_interval_s; + brpc::ChannelOptions options; + options.protocol = PROTOCOL_HTTP; + options.max_retry = 0; + options.timeout_ms = + std::min((int64_t)FLAGS_health_check_timeout_ms, check_interval_s * 1000); + if (done->channel.Init(id, &options) != 0) { + LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; + ptr->_ninflight_app_health_check.fetch_sub( + 1, butil::memory_order_relaxed); + delete done; + return; + } + AppCheck(done); +} + +void* HealthCheckManager::AppCheck(void* arg) { + OnAppHealthCheckDone* done = static_cast(arg); + done->cntl.Reset(); + done->cntl.http_request().uri() = FLAGS_health_check_path; + ControllerPrivateAccessor(&done->cntl).set_health_check_call(); + done->last_check_time_ms = butil::gettimeofday_ms(); + done->channel.CallMethod(NULL, &done->cntl, NULL, NULL, done); + return NULL; +} + +void HealthCheckManager::RunAppCheck(void* arg) { + bthread_t th = 0; + int rc = bthread_start_background( + &th, &BTHREAD_ATTR_NORMAL, AppCheck, arg); + if (rc != 0) { + LOG(ERROR) << "Fail to start AppCheck"; + AppCheck(arg); + return; + } +} + void OnAppHealthCheckDone::Run() { std::unique_ptr self_guard(this); SocketUniquePtr ptr; @@ -129,6 +133,8 @@ void OnAppHealthCheckDone::Run() { if (!cntl.Failed() || ptr->Failed()) { LOG_IF(INFO, !cntl.Failed()) << "Succeeded to call " << ptr->remote_side() << FLAGS_health_check_path; + // if ptr->Failed(), previous SetFailed would trigger next round + // of hc, just return here. ptr->_ninflight_app_health_check.fetch_sub( 1, butil::memory_order_relaxed); return; @@ -145,6 +151,9 @@ void OnAppHealthCheckDone::Run() { &timer_id, abstime, HealthCheckManager::RunAppCheck, this); if (rc != 0) { LOG(ERROR) << "Fail to add timer for RunAppCheck"; + // TODO(zhujiashun): we need to handle the case when timer fails. + // In most situations, the possibility of this case is quite small, + // so currently we just keep sending the hc call. HealthCheckManager::AppCheck(this); return; } From adec01cc6b074f523cc904c332b6fe4a9c1cae7d Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 28 Mar 2019 16:41:57 +0800 Subject: [PATCH 095/270] health_check_using_rpc: change async Appcheck to sync --- src/brpc/details/health_check.cpp | 34 ++++++------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp index d8ed0a28..b5728755 100644 --- a/src/brpc/details/health_check.cpp +++ b/src/brpc/details/health_check.cpp @@ -70,7 +70,6 @@ class HealthCheckManager { public: static void StartCheck(SocketId id, int64_t check_interval_s); static void* AppCheck(void* arg); - static void RunAppCheck(void* arg); }; void HealthCheckManager::StartCheck(SocketId id, int64_t check_interval_s) { @@ -110,17 +109,6 @@ void* HealthCheckManager::AppCheck(void* arg) { return NULL; } -void HealthCheckManager::RunAppCheck(void* arg) { - bthread_t th = 0; - int rc = bthread_start_background( - &th, &BTHREAD_ATTR_NORMAL, AppCheck, arg); - if (rc != 0) { - LOG(ERROR) << "Fail to start AppCheck"; - AppCheck(arg); - return; - } -} - void OnAppHealthCheckDone::Run() { std::unique_ptr self_guard(this); SocketUniquePtr ptr; @@ -145,23 +133,13 @@ void OnAppHealthCheckDone::Run() { int64_t sleep_time_ms = last_check_time_ms + interval_s * 1000 - butil::gettimeofday_ms(); if (sleep_time_ms > 0) { - const timespec abstime = butil::milliseconds_from_now(sleep_time_ms); - bthread_timer_t timer_id; - const int rc = bthread_timer_add( - &timer_id, abstime, HealthCheckManager::RunAppCheck, this); - if (rc != 0) { - LOG(ERROR) << "Fail to add timer for RunAppCheck"; - // TODO(zhujiashun): we need to handle the case when timer fails. - // In most situations, the possibility of this case is quite small, - // so currently we just keep sending the hc call. - HealthCheckManager::AppCheck(this); - return; - } - } else { - // the time of next call has passed, just AppCheck immediately - HealthCheckManager::AppCheck(this); + // TODO(zhujiashun): we need to handle the case when timer fails + // and bthread_usleep returns immediately. In most situations, + // the possibility of this case is quite small, so currently we + // just keep sending the hc call. + bthread_usleep(sleep_time_ms * 1000); } - self_guard.release(); + HealthCheckManager::AppCheck(self_guard.release()); } class HealthCheckTask : public PeriodicTask { From e455431248fd6f930fc80b0cb8bd6c3f5ae1c977 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 29 Mar 2019 11:20:04 +0800 Subject: [PATCH 096/270] health_check_using_rpc: refine comments --- src/brpc/details/health_check.cpp | 6 +++++- src/brpc/details/health_check.h | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp index b5728755..360279fc 100644 --- a/src/brpc/details/health_check.cpp +++ b/src/brpc/details/health_check.cpp @@ -27,7 +27,7 @@ namespace brpc { -// declared at socket.cpp +// Declared at socket.cpp extern SocketVarsCollector* g_vars; DEFINE_string(health_check_path, "", "Http path of health check call." @@ -191,6 +191,10 @@ bool HealthCheckTask::OnTriggeringTask(timespec* next_abstime) { } } + // g_vars must not be NULL because it is newed at the creation of + // first Socket. When g_vars is used, the socket is at health-checking + // state, which means the socket must be created and then g_vars can + // not be NULL. g_vars->nhealthcheck << 1; int hc = 0; if (ptr->_user) { diff --git a/src/brpc/details/health_check.h b/src/brpc/details/health_check.h index 5e8d2c8c..9ada5a34 100644 --- a/src/brpc/details/health_check.h +++ b/src/brpc/details/health_check.h @@ -26,7 +26,9 @@ namespace brpc { // Start health check for socket id after delay_ms. -void StartHealthCheckWithDelayMS(SocketId id, int64_t delay_ms); +// If delay_ms <= 0, HealthCheck would be started +// immediately. +void StartHealthCheck(SocketId id, int64_t delay_ms); } // namespace brpc From 26c9f944ad7fff33426d9d47c12d5e42bc528c7b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 29 Mar 2019 11:23:15 +0800 Subject: [PATCH 097/270] health_check_using_rpc: remove unnecessary space --- src/brpc/controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 086a9ce8..8f1bcacf 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -996,7 +996,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { } else { LoadBalancer::SelectIn sel_in = { start_realtime_us, true, - has_request_code(), _request_code, _accessed }; + has_request_code(), _request_code, _accessed }; LoadBalancer::SelectOut sel_out(&tmp_sock); const int rc = _lb->SelectServer(sel_in, &sel_out); if (rc != 0) { From 5ce7363b89ddcc5b39d6b20461ab683e54bc6077 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 29 Mar 2019 14:47:22 +0800 Subject: [PATCH 098/270] health_check_using_rpc: refine interface name --- src/brpc/details/health_check.cpp | 2 +- src/brpc/socket.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp index 360279fc..7a33a807 100644 --- a/src/brpc/details/health_check.cpp +++ b/src/brpc/details/health_check.cpp @@ -229,7 +229,7 @@ void HealthCheckTask::OnDestroyingTask() { delete this; } -void StartHealthCheckWithDelayMS(SocketId id, int64_t delay_ms) { +void StartHealthCheck(SocketId id, int64_t delay_ms) { PeriodicTaskManager::StartTaskAt(new HealthCheckTask(id), butil::milliseconds_from_now(delay_ms)); } diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 3200b68a..29ff4627 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -837,7 +837,7 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) { // comes online. if (_health_check_interval_s > 0) { GetOrNewSharedPart()->circuit_breaker.MarkAsBroken(); - StartHealthCheckWithDelayMS(id(), + StartHealthCheck(id(), GetOrNewSharedPart()->circuit_breaker.isolation_duration_ms()); } // Wake up all threads waiting on EPOLLOUT when closing fd From c454219ba3b155ea750a65aabe79db7525a61f28 Mon Sep 17 00:00:00 2001 From: tanzhongyibidu Date: Mon, 1 Apr 2019 10:42:20 +0800 Subject: [PATCH 099/270] add NOTICE.txt to address copyright --- NOTICE.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 NOTICE.txt diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 00000000..a416272e --- /dev/null +++ b/NOTICE.txt @@ -0,0 +1,8 @@ +Apache brpc (incubating) +Copyright 2019 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +Based on source code originally developed by +Baidu (http://www.baidu.com/). From fd9a56fb2c42b611baad189e2daa36358ef0e071 Mon Sep 17 00:00:00 2001 From: tanzhongyibidu Date: Mon, 1 Apr 2019 10:52:11 +0800 Subject: [PATCH 100/270] add Disclaimer file --- Disclaimer | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Disclaimer diff --git a/Disclaimer b/Disclaimer new file mode 100644 index 00000000..7a9d438e --- /dev/null +++ b/Disclaimer @@ -0,0 +1,13 @@ +Apache brpc (incubating) is an effort undergoing incubation at The +Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC. + +Incubation is required of all newly accepted +projects until a further review indicates that the +infrastructure, communications, and decision making process have +stabilized in a manner consistent with other successful ASF +projects. + +While incubation status is not necessarily a reflection +of the completeness or stability of the code, it does indicate +that the project has yet to be fully endorsed by the ASF. + From 7c9b0ffd6d0466b26ab776bb60a83e631eb6b1ca Mon Sep 17 00:00:00 2001 From: tanzhongyibidu Date: Tue, 2 Apr 2019 17:25:06 +0800 Subject: [PATCH 101/270] change NOTICE.txt to NOTICE --- NOTICE.txt => NOTICE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename NOTICE.txt => NOTICE (100%) diff --git a/NOTICE.txt b/NOTICE similarity index 100% rename from NOTICE.txt rename to NOTICE From 37d2a3bd9dabc607d557b02d3887a98cce0e0cce Mon Sep 17 00:00:00 2001 From: cdjgit Date: Thu, 4 Apr 2019 18:41:20 +0800 Subject: [PATCH 102/270] some enhancements --- .../consistent_hashing_load_balancer.cpp | 94 +++++++++++-------- .../policy/consistent_hashing_load_balancer.h | 7 +- 2 files changed, 60 insertions(+), 41 deletions(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 58d9d39b..e15180de 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -31,12 +31,43 @@ namespace policy { DEFINE_int32(chash_num_replicas, 100, "default number of replicas per server in chash"); -namespace { +class ReplicaPolicy { +public: + ReplicaPolicy() : _hash_func(nullptr) {} + ReplicaPolicy(HashFunc hash) : _hash_func(hash) {} -bool BuildReplicasDefault(const ServerId server, - const size_t num_replicas, - HashFunc hash, - std::vector* replicas) { + virtual ~ReplicaPolicy(); + virtual bool Build(ServerId server, + size_t num_replicas, + std::vector* replicas) const = 0; + + static const ReplicaPolicy* GetReplicaPolicy(const std::string& name) { + auto iter = _policy_map.find(name); + if (iter != _policy_map.end()) { + return iter->second; + } + return nullptr; + } + +protected: + HashFunc _hash_func = nullptr; + +private: + static const std::map _policy_map; +}; + +class DefaultReplicaPolicy : public ReplicaPolicy { +public: + DefaultReplicaPolicy(HashFunc hash) : ReplicaPolicy(hash) {} + + virtual bool Build(ServerId server, + size_t num_replicas, + std::vector* replicas) const; +}; + +bool DefaultReplicaPolicy::Build(ServerId server, + size_t num_replicas, + std::vector* replicas) const { SocketUniquePtr ptr; if (Socket::AddressFailedAsWell(server.id, &ptr) == -1) { return false; @@ -47,7 +78,7 @@ bool BuildReplicasDefault(const ServerId server, int len = snprintf(host, sizeof(host), "%s-%lu", endpoint2str(ptr->remote_side()).c_str(), i); ConsistentHashingLoadBalancer::Node node; - node.hash = hash(host, len); + node.hash = _hash_func(host, len); node.server_sock = server; node.server_addr = ptr->remote_side(); replicas->push_back(node); @@ -55,9 +86,16 @@ bool BuildReplicasDefault(const ServerId server, return true; } -bool BuildReplicasKetam(const ServerId server, - const size_t num_replicas, - std::vector* replicas) { +class KetamaReplicaPolicy : public ReplicaPolicy { +public: + virtual bool Build(ServerId server, + size_t num_replicas, + std::vector* replicas) const; +}; + +bool KetamaReplicaPolicy::Build(ServerId server, + size_t num_replicas, + std::vector* replicas) const { SocketUniquePtr ptr; if (Socket::AddressFailedAsWell(server.id, &ptr) == -1) { return false; @@ -86,35 +124,17 @@ bool BuildReplicasKetam(const ServerId server, return true; } -} // namespace +const std::map ReplicaPolicy::_policy_map = { + {"murmurhash3", new DefaultReplicaPolicy(MurmurHash32)}, + {"md5", new DefaultReplicaPolicy(MD5Hash32)}, + {"ketama", new KetamaReplicaPolicy} +}; ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(const char* name) : _num_replicas(FLAGS_chash_num_replicas), _name(name) { - Init(_name); -} - -void ConsistentHashingLoadBalancer::Init(const std::string& name) { - if (name == "murmurhash3") { - _build_replicas = std::bind(BuildReplicasDefault, - std::placeholders::_1, - std::placeholders::_2, - MurmurHash32, - std::placeholders::_3); - return; - } - if (name == "md5") { - _build_replicas = std::bind(BuildReplicasDefault, - std::placeholders::_1, - std::placeholders::_2, - MD5Hash32, - std::placeholders::_3); - return; - } - if (name == "ketama") { - _build_replicas = BuildReplicasKetam; - return; - } - CHECK(false) << "Failed to init consistency hash load balancer of \'" << name << '\''; + _replicas_policy = ReplicaPolicy::GetReplicaPolicy(name); + CHECK(_replicas_policy) + << "Fail to find replica policy for consistency lb: '" << name << '\''; } size_t ConsistentHashingLoadBalancer::AddBatch( @@ -188,7 +208,7 @@ size_t ConsistentHashingLoadBalancer::Remove( bool ConsistentHashingLoadBalancer::AddServer(const ServerId& server) { std::vector add_nodes; add_nodes.reserve(_num_replicas); - if (!_build_replicas(server, _num_replicas, &add_nodes)) { + if (!_replicas_policy->Build(server, _num_replicas, &add_nodes)) { return false; } std::sort(add_nodes.begin(), add_nodes.end()); @@ -207,7 +227,7 @@ size_t ConsistentHashingLoadBalancer::AddServersInBatch( replicas.reserve(_num_replicas); for (size_t i = 0; i < servers.size(); ++i) { replicas.clear(); - if (_build_replicas(servers[i], _num_replicas, &replicas)) { + if (_replicas_policy->Build(servers[i], _num_replicas, &replicas)) { add_nodes.insert(add_nodes.end(), replicas.begin(), replicas.end()); } } diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index ebd2ce04..1e535667 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -28,6 +28,8 @@ namespace brpc { namespace policy { +class ReplicaPolicy; + class ConsistentHashingLoadBalancer : public LoadBalancer { public: struct Node { @@ -43,8 +45,6 @@ public: return hash < code; } }; - using BuildReplicasFunc = - std::function* replicas)>; explicit ConsistentHashingLoadBalancer(const char* name); bool AddServer(const ServerId& server); bool RemoveServer(const ServerId& server); @@ -57,7 +57,6 @@ public: virtual bool SetParameters(const butil::StringPiece& params); private: - void Init(const std::string& name); void GetLoads(std::map *load_map); static size_t AddBatch(std::vector &bg, const std::vector &fg, const std::vector &servers, bool *executed); @@ -65,7 +64,7 @@ private: const std::vector &servers, bool *executed); static size_t Remove(std::vector &bg, const std::vector &fg, const ServerId& server, bool *executed); - BuildReplicasFunc _build_replicas; + const ReplicaPolicy* _replicas_policy; size_t _num_replicas; std::string _name; butil::DoublyBufferedData > _db_hash_ring; From 95d61d72acfd85812fd927574ab21444062d6ef4 Mon Sep 17 00:00:00 2001 From: cdjgit Date: Thu, 4 Apr 2019 19:07:57 +0800 Subject: [PATCH 103/270] move GetReplicaPolicy out of class ReplicaPolicy --- .../consistent_hashing_load_balancer.cpp | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index e15180de..ae94775e 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -35,25 +35,14 @@ class ReplicaPolicy { public: ReplicaPolicy() : _hash_func(nullptr) {} ReplicaPolicy(HashFunc hash) : _hash_func(hash) {} - virtual ~ReplicaPolicy(); + virtual bool Build(ServerId server, size_t num_replicas, std::vector* replicas) const = 0; - static const ReplicaPolicy* GetReplicaPolicy(const std::string& name) { - auto iter = _policy_map.find(name); - if (iter != _policy_map.end()) { - return iter->second; - } - return nullptr; - } - protected: - HashFunc _hash_func = nullptr; - -private: - static const std::map _policy_map; + HashFunc _hash_func; }; class DefaultReplicaPolicy : public ReplicaPolicy { @@ -124,15 +113,27 @@ bool KetamaReplicaPolicy::Build(ServerId server, return true; } -const std::map ReplicaPolicy::_policy_map = { +namespace { + +const std::map g_replica_policy_map = { {"murmurhash3", new DefaultReplicaPolicy(MurmurHash32)}, {"md5", new DefaultReplicaPolicy(MD5Hash32)}, {"ketama", new KetamaReplicaPolicy} }; +const ReplicaPolicy* GetReplicaPolicy(const std::string& name) { + auto iter = g_replica_policy_map.find(name); + if (iter != g_replica_policy_map.end()) { + return iter->second; + } + return nullptr; +} + +} // namespace + ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(const char* name) : _num_replicas(FLAGS_chash_num_replicas), _name(name) { - _replicas_policy = ReplicaPolicy::GetReplicaPolicy(name); + _replicas_policy = GetReplicaPolicy(name); CHECK(_replicas_policy) << "Fail to find replica policy for consistency lb: '" << name << '\''; } From 8368bfce2e6292c4fb239e3cb028b95eabe53c5d Mon Sep 17 00:00:00 2001 From: caidaojin Date: Thu, 4 Apr 2019 21:17:58 +0800 Subject: [PATCH 104/270] fix build failure --- src/brpc/policy/consistent_hashing_load_balancer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index ae94775e..53405d91 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -35,7 +35,7 @@ class ReplicaPolicy { public: ReplicaPolicy() : _hash_func(nullptr) {} ReplicaPolicy(HashFunc hash) : _hash_func(hash) {} - virtual ~ReplicaPolicy(); + virtual ~ReplicaPolicy() = default; virtual bool Build(ServerId server, size_t num_replicas, From 8b919c4d1ba8646feb66b936eaa8d29c2099eacf Mon Sep 17 00:00:00 2001 From: caidaojin Date: Fri, 5 Apr 2019 10:34:09 +0800 Subject: [PATCH 105/270] fix for ci comments --- src/brpc/policy/consistent_hashing_load_balancer.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 53405d91..805ecb4b 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -33,25 +33,22 @@ DEFINE_int32(chash_num_replicas, 100, class ReplicaPolicy { public: - ReplicaPolicy() : _hash_func(nullptr) {} - ReplicaPolicy(HashFunc hash) : _hash_func(hash) {} virtual ~ReplicaPolicy() = default; virtual bool Build(ServerId server, size_t num_replicas, std::vector* replicas) const = 0; - -protected: - HashFunc _hash_func; }; class DefaultReplicaPolicy : public ReplicaPolicy { public: - DefaultReplicaPolicy(HashFunc hash) : ReplicaPolicy(hash) {} + DefaultReplicaPolicy(HashFunc hash) : _hash_func(hash) {} virtual bool Build(ServerId server, size_t num_replicas, std::vector* replicas) const; +private: + HashFunc _hash_func; }; bool DefaultReplicaPolicy::Build(ServerId server, From dcc7e003807d0f69493e07f7240066d7f670afea Mon Sep 17 00:00:00 2001 From: cdjgit Date: Mon, 8 Apr 2019 10:28:30 +0800 Subject: [PATCH 106/270] fix for ci comments --- src/brpc/load_balancer.h | 21 ++++++++++--------- .../consistent_hashing_load_balancer.cpp | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 69b2e92b..e27d4f06 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -104,21 +104,12 @@ public: // Caller is responsible for Destroy() the instance after usage. virtual LoadBalancer* New() const = 0; - // Config user passed parameters to lb after constrction which + // Config user passed parameters to lb after construction which // make lb function more flexible. virtual bool SetParameters(const butil::StringPiece& params) { return true; } protected: virtual ~LoadBalancer() { } - static bool SplitParameters(const butil::StringPiece& params, - butil::StringPairs* param_vec) { - std::string params_str(params.data(), params.size()); - if (!butil::SplitStringIntoKeyValuePairs(params_str, '=', ' ', param_vec)) { - param_vec->clear(); - return false; - } - return true; - } }; DECLARE_bool(show_lb_in_vars); @@ -197,6 +188,16 @@ inline Extension* LoadBalancerExtension() { return Extension::instance(); } +inline bool SplitLoadBalancerParameters(const butil::StringPiece& params, + butil::StringPairs* param_vec) { + std::string params_str(params.data(), params.size()); + if (!butil::SplitStringIntoKeyValuePairs(params_str, '=', ' ', param_vec)) { + param_vec->clear(); + return false; + } + return true; +} + } // namespace brpc diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 805ecb4b..efab97fc 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -361,7 +361,7 @@ void ConsistentHashingLoadBalancer::GetLoads( bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& params) { butil::StringPairs param_vec; - if (!SplitParameters(params, ¶m_vec)) { + if (!SplitLoadBalancerParameters(params, ¶m_vec)) { return false; } for (const std::pair& param : param_vec) { From 3d7b54764b0190f1b5f1e441a80b8f033f6a2471 Mon Sep 17 00:00:00 2001 From: cdjgit Date: Mon, 8 Apr 2019 19:10:18 +0800 Subject: [PATCH 107/270] fix for ci comments --- src/brpc/global.cpp | 6 ++-- .../consistent_hashing_load_balancer.cpp | 34 ++++++++++--------- .../policy/consistent_hashing_load_balancer.h | 13 +++++-- test/brpc_load_balancer_unittest.cpp | 15 +++++--- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/brpc/global.cpp b/src/brpc/global.cpp index d694eed4..54e14b31 100755 --- a/src/brpc/global.cpp +++ b/src/brpc/global.cpp @@ -108,9 +108,9 @@ const char* const DUMMY_SERVER_PORT_FILE = "dummy_server.port"; struct GlobalExtensions { GlobalExtensions() - : ch_mh_lb("murmurhash3") - , ch_md5_lb("md5") - , ch_ketama_lb("ketama") + : ch_mh_lb(CONS_HASH_LB_MURMUR3) + , ch_md5_lb(CONS_HASH_LB_MD5) + , ch_ketama_lb(CONS_HASH_LB_KETAMA) , constant_cl(0) { } diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index efab97fc..db24050a 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -112,27 +112,29 @@ bool KetamaReplicaPolicy::Build(ServerId server, namespace { -const std::map g_replica_policy_map = { - {"murmurhash3", new DefaultReplicaPolicy(MurmurHash32)}, - {"md5", new DefaultReplicaPolicy(MD5Hash32)}, - {"ketama", new KetamaReplicaPolicy} +const std::array, CONS_HASH_LB_LAST> + g_replica_policy = { + std::make_pair(new DefaultReplicaPolicy(MurmurHash32), "murmurhash3"), + std::make_pair(new DefaultReplicaPolicy(MD5Hash32), "md5"), + std::make_pair(new KetamaReplicaPolicy, "ketama") }; -const ReplicaPolicy* GetReplicaPolicy(const std::string& name) { - auto iter = g_replica_policy_map.find(name); - if (iter != g_replica_policy_map.end()) { - return iter->second; - } - return nullptr; +inline const ReplicaPolicy* GetReplicaPolicy(ConsistentHashingLoadBalancerType type) { + return g_replica_policy.at(type).first; +} + +inline const std::string& GetLbName(ConsistentHashingLoadBalancerType type) { + return g_replica_policy.at(type).second; } } // namespace -ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(const char* name) - : _num_replicas(FLAGS_chash_num_replicas), _name(name) { - _replicas_policy = GetReplicaPolicy(name); +ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer( + ConsistentHashingLoadBalancerType type) + : _num_replicas(FLAGS_chash_num_replicas), _type(type) { + _replicas_policy = GetReplicaPolicy(_type); CHECK(_replicas_policy) - << "Fail to find replica policy for consistency lb: '" << name << '\''; + << "Fail to find replica policy for consistency lb type: '" << type << '\''; } size_t ConsistentHashingLoadBalancer::AddBatch( @@ -260,7 +262,7 @@ size_t ConsistentHashingLoadBalancer::RemoveServersInBatch( } LoadBalancer *ConsistentHashingLoadBalancer::New() const { - return new (std::nothrow) ConsistentHashingLoadBalancer(_name.c_str()); + return new (std::nothrow) ConsistentHashingLoadBalancer(_type); } void ConsistentHashingLoadBalancer::Destroy() { @@ -311,7 +313,7 @@ void ConsistentHashingLoadBalancer::Describe( return; } os << "ConsistentHashingLoadBalancer {\n" - << " hash function: " << _name << '\n' + << " hash function: " << GetLbName(_type) << '\n' << " replica per host: " << _num_replicas << '\n'; std::map load_map; GetLoads(&load_map); diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index 1e535667..9e8c9be8 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -30,6 +30,15 @@ namespace policy { class ReplicaPolicy; +enum ConsistentHashingLoadBalancerType { + CONS_HASH_LB_MURMUR3 = 0, + CONS_HASH_LB_MD5 = 1, + CONS_HASH_LB_KETAMA = 2, + + // Identify the last one. + CONS_HASH_LB_LAST = 3 +}; + class ConsistentHashingLoadBalancer : public LoadBalancer { public: struct Node { @@ -45,7 +54,7 @@ public: return hash < code; } }; - explicit ConsistentHashingLoadBalancer(const char* name); + explicit ConsistentHashingLoadBalancer(ConsistentHashingLoadBalancerType type); bool AddServer(const ServerId& server); bool RemoveServer(const ServerId& server); size_t AddServersInBatch(const std::vector &servers); @@ -66,7 +75,7 @@ private: const ServerId& server, bool *executed); const ReplicaPolicy* _replicas_policy; size_t _num_replicas; - std::string _name; + ConsistentHashingLoadBalancerType _type; butil::DoublyBufferedData > _db_hash_ring; }; diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index f08a8c21..57941a28 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -251,7 +251,7 @@ TEST_F(LoadBalancerTest, update_while_selection) { } else if (round == 3) { lb = new brpc::policy::WeightedRoundRobinLoadBalancer; } else { - lb = new brpc::policy::ConsistentHashingLoadBalancer("murmurhash3"); + lb = new brpc::policy::ConsistentHashingLoadBalancer(brpc::policy::CONS_HASH_LB_MURMUR3); sa.hash = ::brpc::policy::MurmurHash32; } sa.lb = lb; @@ -364,7 +364,7 @@ TEST_F(LoadBalancerTest, fairness) { } else if (3 == round || 4 == round) { lb = new brpc::policy::WeightedRoundRobinLoadBalancer; } else { - lb = new brpc::policy::ConsistentHashingLoadBalancer("murmurhash3"); + lb = new brpc::policy::ConsistentHashingLoadBalancer(brpc::policy::CONS_HASH_LB_MURMUR3); sa.hash = brpc::policy::MurmurHash32; } sa.lb = lb; @@ -485,12 +485,19 @@ TEST_F(LoadBalancerTest, fairness) { } TEST_F(LoadBalancerTest, consistent_hashing) { - ::brpc::policy::HashFunc hashs[] = { + ::brpc::policy::HashFunc hashs[CONS_HASH_LB_LAST] = { ::brpc::policy::MurmurHash32, ::brpc::policy::MD5Hash32, ::brpc::policy::KetamaHash // ::brpc::policy::CRCHash32 crc is a bad hash function in test }; + + ::brpc::policy::ConsistentHashingLoadBalancerType hash_type[CONS_HASH_LB_LAST] = { + ::brpc::policy::CONS_HASH_LB_MURMUR3, + ::brpc::policy::CONS_HASH_LB_MD5, + ::brpc::policy::CONS_HASH_LB_KETAMA + }; + const char* servers[] = { "10.92.115.19:8833", "10.42.108.25:8833", @@ -499,7 +506,7 @@ TEST_F(LoadBalancerTest, consistent_hashing) { "10.42.122.201:8833", }; for (size_t round = 0; round < ARRAY_SIZE(hashs); ++round) { - brpc::policy::ConsistentHashingLoadBalancer chlb(brpc::policy::GetHashName(hashs[round])); + brpc::policy::ConsistentHashingLoadBalancer chlb(hash_type[round]); std::vector ids; std::vector addrs; for (int j = 0;j < 5; ++j) From f97f4b8938b6c83b82578a3163645501ce2ca319 Mon Sep 17 00:00:00 2001 From: cdjgit Date: Mon, 8 Apr 2019 19:18:18 +0800 Subject: [PATCH 108/270] fix lb ut --- test/brpc_load_balancer_unittest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 57941a28..b0fe4a15 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -485,14 +485,14 @@ TEST_F(LoadBalancerTest, fairness) { } TEST_F(LoadBalancerTest, consistent_hashing) { - ::brpc::policy::HashFunc hashs[CONS_HASH_LB_LAST] = { + ::brpc::policy::HashFunc hashs[::brpc::policy::CONS_HASH_LB_LAST] = { ::brpc::policy::MurmurHash32, ::brpc::policy::MD5Hash32, ::brpc::policy::KetamaHash // ::brpc::policy::CRCHash32 crc is a bad hash function in test }; - ::brpc::policy::ConsistentHashingLoadBalancerType hash_type[CONS_HASH_LB_LAST] = { + ::brpc::policy::ConsistentHashingLoadBalancerType hash_type[::brpc::policy::CONS_HASH_LB_LAST] = { ::brpc::policy::CONS_HASH_LB_MURMUR3, ::brpc::policy::CONS_HASH_LB_MD5, ::brpc::policy::CONS_HASH_LB_KETAMA From c9a9ffa301f575b7f0da9f1f82d8f10a81b5c8ce Mon Sep 17 00:00:00 2001 From: caidaojin Date: Mon, 8 Apr 2019 22:46:49 +0800 Subject: [PATCH 109/270] move SetParameters function to New() --- src/brpc/load_balancer.cpp | 9 ++--- src/brpc/load_balancer.h | 6 +--- .../consistent_hashing_load_balancer.cpp | 36 ++++++++++++------- .../policy/consistent_hashing_load_balancer.h | 4 +-- src/brpc/policy/dynpart_load_balancer.cpp | 2 +- src/brpc/policy/dynpart_load_balancer.h | 2 +- .../policy/locality_aware_load_balancer.cpp | 3 +- .../policy/locality_aware_load_balancer.h | 2 +- src/brpc/policy/randomized_load_balancer.cpp | 3 +- src/brpc/policy/randomized_load_balancer.h | 2 +- src/brpc/policy/round_robin_load_balancer.cpp | 3 +- src/brpc/policy/round_robin_load_balancer.h | 2 +- .../weighted_round_robin_load_balancer.cpp | 3 +- .../weighted_round_robin_load_balancer.h | 2 +- 14 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/brpc/load_balancer.cpp b/src/brpc/load_balancer.cpp index 499f4ea1..877097bd 100644 --- a/src/brpc/load_balancer.cpp +++ b/src/brpc/load_balancer.cpp @@ -74,16 +74,11 @@ int SharedLoadBalancer::Init(const char* lb_protocol) { LOG(FATAL) << "Fail to find LoadBalancer by `" << lb_name << "'"; return -1; } - LoadBalancer* lb_copy = lb->New(); - if (lb_copy == NULL) { + LoadBalancer* _lb = lb->New(lb_params); + if (_lb == NULL) { LOG(FATAL) << "Fail to new LoadBalancer"; return -1; } - _lb = lb_copy; - if (!_lb->SetParameters(lb_params)) { - LOG(FATAL) << "Fail to set parameters of lb `" << lb_protocol << "'"; - return -1; - } if (FLAGS_show_lb_in_vars && !_exposed) { ExposeLB(); } diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index e27d4f06..9745b004 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -102,11 +102,7 @@ public: // Create/destroy an instance. // Caller is responsible for Destroy() the instance after usage. - virtual LoadBalancer* New() const = 0; - - // Config user passed parameters to lb after construction which - // make lb function more flexible. - virtual bool SetParameters(const butil::StringPiece& params) { return true; } + virtual LoadBalancer* New(const butil::StringPiece& params) const = 0; protected: virtual ~LoadBalancer() { } diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index db24050a..35aeb387 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -31,6 +31,9 @@ namespace policy { DEFINE_int32(chash_num_replicas, 100, "default number of replicas per server in chash"); +// Defined in hasher.cpp. +const char* GetHashName(HashFunc hasher); + class ReplicaPolicy { public: virtual ~ReplicaPolicy() = default; @@ -38,6 +41,7 @@ public: virtual bool Build(ServerId server, size_t num_replicas, std::vector* replicas) const = 0; + virtual const char* name() const = 0; }; class DefaultReplicaPolicy : public ReplicaPolicy { @@ -47,6 +51,9 @@ public: virtual bool Build(ServerId server, size_t num_replicas, std::vector* replicas) const; + + virtual const char* name() const { return GetHashName(_hash_func); } + private: HashFunc _hash_func; }; @@ -77,6 +84,8 @@ public: virtual bool Build(ServerId server, size_t num_replicas, std::vector* replicas) const; + + virtual const char* name() const { return "ketama"; } }; bool KetamaReplicaPolicy::Build(ServerId server, @@ -112,19 +121,14 @@ bool KetamaReplicaPolicy::Build(ServerId server, namespace { -const std::array, CONS_HASH_LB_LAST> - g_replica_policy = { - std::make_pair(new DefaultReplicaPolicy(MurmurHash32), "murmurhash3"), - std::make_pair(new DefaultReplicaPolicy(MD5Hash32), "md5"), - std::make_pair(new KetamaReplicaPolicy, "ketama") +const std::array g_replica_policy = { + new DefaultReplicaPolicy(MurmurHash32), + new DefaultReplicaPolicy(MD5Hash32), + new KetamaReplicaPolicy }; inline const ReplicaPolicy* GetReplicaPolicy(ConsistentHashingLoadBalancerType type) { - return g_replica_policy.at(type).first; -} - -inline const std::string& GetLbName(ConsistentHashingLoadBalancerType type) { - return g_replica_policy.at(type).second; + return g_replica_policy.at(type); } } // namespace @@ -261,8 +265,14 @@ size_t ConsistentHashingLoadBalancer::RemoveServersInBatch( return n; } -LoadBalancer *ConsistentHashingLoadBalancer::New() const { - return new (std::nothrow) ConsistentHashingLoadBalancer(_type); +LoadBalancer *ConsistentHashingLoadBalancer::New(const butil::StringPiece& params) const { + ConsistentHashingLoadBalancer* lb = + new (std::nothrow) ConsistentHashingLoadBalancer(_type); + if (lb != nullptr && !lb->SetParameters(params)) { + delete lb; + lb = nullptr; + } + return lb; } void ConsistentHashingLoadBalancer::Destroy() { @@ -313,7 +323,7 @@ void ConsistentHashingLoadBalancer::Describe( return; } os << "ConsistentHashingLoadBalancer {\n" - << " hash function: " << GetLbName(_type) << '\n' + << " hash function: " << _replicas_policy->name() << '\n' << " replica per host: " << _num_replicas << '\n'; std::map load_map; GetLoads(&load_map); diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index 9e8c9be8..fad82a0a 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -59,11 +59,11 @@ public: bool RemoveServer(const ServerId& server); size_t AddServersInBatch(const std::vector &servers); size_t RemoveServersInBatch(const std::vector &servers); - LoadBalancer *New() const; + LoadBalancer *New(const butil::StringPiece& params) const; void Destroy(); int SelectServer(const SelectIn &in, SelectOut *out); void Describe(std::ostream &os, const DescribeOptions& options); - virtual bool SetParameters(const butil::StringPiece& params); + bool SetParameters(const butil::StringPiece& params); private: void GetLoads(std::map *load_map); diff --git a/src/brpc/policy/dynpart_load_balancer.cpp b/src/brpc/policy/dynpart_load_balancer.cpp index 8da8c622..8b0079d3 100644 --- a/src/brpc/policy/dynpart_load_balancer.cpp +++ b/src/brpc/policy/dynpart_load_balancer.cpp @@ -159,7 +159,7 @@ int DynPartLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { return EHOSTDOWN; } -DynPartLoadBalancer* DynPartLoadBalancer::New() const { +DynPartLoadBalancer* DynPartLoadBalancer::New(const butil::StringPiece&) const { return new (std::nothrow) DynPartLoadBalancer; } diff --git a/src/brpc/policy/dynpart_load_balancer.h b/src/brpc/policy/dynpart_load_balancer.h index 343fee0c..ce481b32 100644 --- a/src/brpc/policy/dynpart_load_balancer.h +++ b/src/brpc/policy/dynpart_load_balancer.h @@ -36,7 +36,7 @@ public: size_t AddServersInBatch(const std::vector& servers); size_t RemoveServersInBatch(const std::vector& servers); int SelectServer(const SelectIn& in, SelectOut* out); - DynPartLoadBalancer* New() const; + DynPartLoadBalancer* New(const butil::StringPiece&) const; void Destroy(); void Describe(std::ostream&, const DescribeOptions& options); diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index dde0d2a9..b53fa899 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -460,7 +460,8 @@ int64_t LocalityAwareLoadBalancer::Weight::Update( return ResetWeight(index, end_time_us); } -LocalityAwareLoadBalancer* LocalityAwareLoadBalancer::New() const { +LocalityAwareLoadBalancer* LocalityAwareLoadBalancer::New( + const butil::StringPiece&) const { return new (std::nothrow) LocalityAwareLoadBalancer; } diff --git a/src/brpc/policy/locality_aware_load_balancer.h b/src/brpc/policy/locality_aware_load_balancer.h index a6f7448b..0ff00971 100644 --- a/src/brpc/policy/locality_aware_load_balancer.h +++ b/src/brpc/policy/locality_aware_load_balancer.h @@ -44,7 +44,7 @@ public: bool RemoveServer(const ServerId& id); size_t AddServersInBatch(const std::vector& servers); size_t RemoveServersInBatch(const std::vector& servers); - LocalityAwareLoadBalancer* New() const; + LocalityAwareLoadBalancer* New(const butil::StringPiece&) const; void Destroy(); int SelectServer(const SelectIn& in, SelectOut* out); void Feedback(const CallInfo& info); diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 3e8ac4e9..f9692c4c 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -134,7 +134,8 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { return EHOSTDOWN; } -RandomizedLoadBalancer* RandomizedLoadBalancer::New() const { +RandomizedLoadBalancer* RandomizedLoadBalancer::New( + const butil::StringPiece&) const { return new (std::nothrow) RandomizedLoadBalancer; } diff --git a/src/brpc/policy/randomized_load_balancer.h b/src/brpc/policy/randomized_load_balancer.h index 135258a4..9fb0d6d3 100644 --- a/src/brpc/policy/randomized_load_balancer.h +++ b/src/brpc/policy/randomized_load_balancer.h @@ -36,7 +36,7 @@ public: size_t AddServersInBatch(const std::vector& servers); size_t RemoveServersInBatch(const std::vector& servers); int SelectServer(const SelectIn& in, SelectOut* out); - RandomizedLoadBalancer* New() const; + RandomizedLoadBalancer* New(const butil::StringPiece&) const; void Destroy(); void Describe(std::ostream& os, const DescribeOptions&); diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 5e3f1ab0..eb3b41aa 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -131,7 +131,8 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { return EHOSTDOWN; } -RoundRobinLoadBalancer* RoundRobinLoadBalancer::New() const { +RoundRobinLoadBalancer* RoundRobinLoadBalancer::New( + const butil::StringPiece&) const { return new (std::nothrow) RoundRobinLoadBalancer; } diff --git a/src/brpc/policy/round_robin_load_balancer.h b/src/brpc/policy/round_robin_load_balancer.h index 6f032649..39e4cbe8 100644 --- a/src/brpc/policy/round_robin_load_balancer.h +++ b/src/brpc/policy/round_robin_load_balancer.h @@ -35,7 +35,7 @@ public: size_t AddServersInBatch(const std::vector& servers); size_t RemoveServersInBatch(const std::vector& servers); int SelectServer(const SelectIn& in, SelectOut* out); - RoundRobinLoadBalancer* New() const; + RoundRobinLoadBalancer* New(const butil::StringPiece&) const; void Destroy(); void Describe(std::ostream&, const DescribeOptions& options); diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index 34c5aa6e..447ecabf 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -213,7 +213,8 @@ SocketId WeightedRoundRobinLoadBalancer::GetServerInNextStride( return final_server; } -LoadBalancer* WeightedRoundRobinLoadBalancer::New() const { +LoadBalancer* WeightedRoundRobinLoadBalancer::New( + const butil::StringPiece&) const { return new (std::nothrow) WeightedRoundRobinLoadBalancer; } diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.h b/src/brpc/policy/weighted_round_robin_load_balancer.h index c22f877a..a6fe9590 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.h +++ b/src/brpc/policy/weighted_round_robin_load_balancer.h @@ -34,7 +34,7 @@ public: size_t AddServersInBatch(const std::vector& servers); size_t RemoveServersInBatch(const std::vector& servers); int SelectServer(const SelectIn& in, SelectOut* out); - LoadBalancer* New() const; + LoadBalancer* New(const butil::StringPiece&) const; void Destroy(); void Describe(std::ostream&, const DescribeOptions& options); From bd7e7e31826973eb0242528ca544765e241abced Mon Sep 17 00:00:00 2001 From: cdjgit Date: Tue, 9 Apr 2019 17:35:59 +0800 Subject: [PATCH 110/270] fix for ci comments --- .../consistent_hashing_load_balancer.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 35aeb387..c5d02057 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -121,14 +121,20 @@ bool KetamaReplicaPolicy::Build(ServerId server, namespace { -const std::array g_replica_policy = { - new DefaultReplicaPolicy(MurmurHash32), - new DefaultReplicaPolicy(MD5Hash32), - new KetamaReplicaPolicy -}; +pthread_once_t s_replica_policy_once = PTHREAD_ONCE_INIT; +const std::array* g_replica_policy = nullptr; + +void init_replica_policy() { + g_replica_policy = new std::array({ + new DefaultReplicaPolicy(MurmurHash32), + new DefaultReplicaPolicy(MD5Hash32), + new KetamaReplicaPolicy + }); +} inline const ReplicaPolicy* GetReplicaPolicy(ConsistentHashingLoadBalancerType type) { - return g_replica_policy.at(type); + pthread_once(&s_replica_policy_once, init_replica_policy); + return g_replica_policy->at(type); } } // namespace From 446c0ab3c715247e6311f1e91ebd7713b00f4439 Mon Sep 17 00:00:00 2001 From: cdjgit Date: Tue, 9 Apr 2019 19:43:05 +0800 Subject: [PATCH 111/270] fix ut failure --- src/brpc/load_balancer.cpp | 2 +- src/brpc/policy/consistent_hashing_load_balancer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/load_balancer.cpp b/src/brpc/load_balancer.cpp index 877097bd..16af3c56 100644 --- a/src/brpc/load_balancer.cpp +++ b/src/brpc/load_balancer.cpp @@ -74,7 +74,7 @@ int SharedLoadBalancer::Init(const char* lb_protocol) { LOG(FATAL) << "Fail to find LoadBalancer by `" << lb_name << "'"; return -1; } - LoadBalancer* _lb = lb->New(lb_params); + _lb = lb->New(lb_params); if (_lb == NULL) { LOG(FATAL) << "Fail to new LoadBalancer"; return -1; diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index fad82a0a..c11c01ca 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -63,9 +63,9 @@ public: void Destroy(); int SelectServer(const SelectIn &in, SelectOut *out); void Describe(std::ostream &os, const DescribeOptions& options); - bool SetParameters(const butil::StringPiece& params); private: + bool SetParameters(const butil::StringPiece& params); void GetLoads(std::map *load_map); static size_t AddBatch(std::vector &bg, const std::vector &fg, const std::vector &servers, bool *executed); From f76d338f728c4d31ef3cfe36d05485f440763f9e Mon Sep 17 00:00:00 2001 From: caidaojin Date: Tue, 9 Apr 2019 21:34:51 +0800 Subject: [PATCH 112/270] remove unnecessary member '_replica_policy' --- src/brpc/policy/consistent_hashing_load_balancer.cpp | 11 +++++------ src/brpc/policy/consistent_hashing_load_balancer.h | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index c5d02057..643f918d 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -142,9 +142,8 @@ inline const ReplicaPolicy* GetReplicaPolicy(ConsistentHashingLoadBalancerType t ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer( ConsistentHashingLoadBalancerType type) : _num_replicas(FLAGS_chash_num_replicas), _type(type) { - _replicas_policy = GetReplicaPolicy(_type); - CHECK(_replicas_policy) - << "Fail to find replica policy for consistency lb type: '" << type << '\''; + CHECK(GetReplicaPolicy(_type)) + << "Fail to find replica policy for consistency lb type: '" << _type << '\''; } size_t ConsistentHashingLoadBalancer::AddBatch( @@ -218,7 +217,7 @@ size_t ConsistentHashingLoadBalancer::Remove( bool ConsistentHashingLoadBalancer::AddServer(const ServerId& server) { std::vector add_nodes; add_nodes.reserve(_num_replicas); - if (!_replicas_policy->Build(server, _num_replicas, &add_nodes)) { + if (!GetReplicaPolicy(_type)->Build(server, _num_replicas, &add_nodes)) { return false; } std::sort(add_nodes.begin(), add_nodes.end()); @@ -237,7 +236,7 @@ size_t ConsistentHashingLoadBalancer::AddServersInBatch( replicas.reserve(_num_replicas); for (size_t i = 0; i < servers.size(); ++i) { replicas.clear(); - if (_replicas_policy->Build(servers[i], _num_replicas, &replicas)) { + if (GetReplicaPolicy(_type)->Build(servers[i], _num_replicas, &replicas)) { add_nodes.insert(add_nodes.end(), replicas.begin(), replicas.end()); } } @@ -329,7 +328,7 @@ void ConsistentHashingLoadBalancer::Describe( return; } os << "ConsistentHashingLoadBalancer {\n" - << " hash function: " << _replicas_policy->name() << '\n' + << " hash function: " << GetReplicaPolicy(_type)->name() << '\n' << " replica per host: " << _num_replicas << '\n'; std::map load_map; GetLoads(&load_map); diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index c11c01ca..1786ad16 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -73,7 +73,6 @@ private: const std::vector &servers, bool *executed); static size_t Remove(std::vector &bg, const std::vector &fg, const ServerId& server, bool *executed); - const ReplicaPolicy* _replicas_policy; size_t _num_replicas; ConsistentHashingLoadBalancerType _type; butil::DoublyBufferedData > _db_hash_ring; From 8bd4051c5478ca0bf7e6bd7d80a201700674690a Mon Sep 17 00:00:00 2001 From: caidaojin Date: Tue, 9 Apr 2019 22:20:58 +0800 Subject: [PATCH 113/270] remove KetamaHash() --- src/brpc/policy/hasher.cpp | 7 ------- src/brpc/policy/hasher.h | 2 -- test/brpc_load_balancer_unittest.cpp | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/brpc/policy/hasher.cpp b/src/brpc/policy/hasher.cpp index 4898a349..e53df2b0 100644 --- a/src/brpc/policy/hasher.cpp +++ b/src/brpc/policy/hasher.cpp @@ -39,10 +39,6 @@ uint32_t MD5Hash32(const void* key, size_t len) { | (results[0] & 0xFF); } -uint32_t KetamaHash(const void* key, size_t len) { - return MD5Hash32(key, len); -} - uint32_t MD5Hash32V(const butil::StringPiece* keys, size_t num_keys) { MD5_CTX ctx; MD5_Init(&ctx); @@ -165,9 +161,6 @@ const char *GetHashName(HashFunc hasher) { if (hasher == CRCHash32) { return "crc32"; } - if (hasher == KetamaHash) { - return "ketama"; - } return "user_defined"; } diff --git a/src/brpc/policy/hasher.h b/src/brpc/policy/hasher.h index 09f9c056..a0a23000 100644 --- a/src/brpc/policy/hasher.h +++ b/src/brpc/policy/hasher.h @@ -34,8 +34,6 @@ uint32_t MD5Hash32V(const butil::StringPiece* keys, size_t num_keys); uint32_t MurmurHash32(const void* key, size_t len); uint32_t MurmurHash32V(const butil::StringPiece* keys, size_t num_keys); -uint32_t KetamaHash(const void* key, size_t len); - } // namespace policy } // namespace brpc diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index b0fe4a15..fd92b1f5 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -488,7 +488,7 @@ TEST_F(LoadBalancerTest, consistent_hashing) { ::brpc::policy::HashFunc hashs[::brpc::policy::CONS_HASH_LB_LAST] = { ::brpc::policy::MurmurHash32, ::brpc::policy::MD5Hash32, - ::brpc::policy::KetamaHash + ::brpc::policy::MD5Hash32 // ::brpc::policy::CRCHash32 crc is a bad hash function in test }; From 49d5989390c7cdf1718ed9aa0742b32325ed212b Mon Sep 17 00:00:00 2001 From: cdjgit Date: Wed, 10 Apr 2019 18:10:41 +0800 Subject: [PATCH 114/270] remove SplitLoadBalancerParameters && code style --- src/brpc/load_balancer.h | 10 -------- .../consistent_hashing_load_balancer.cpp | 23 ++++++++----------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 9745b004..8b4e56de 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -184,16 +184,6 @@ inline Extension* LoadBalancerExtension() { return Extension::instance(); } -inline bool SplitLoadBalancerParameters(const butil::StringPiece& params, - butil::StringPairs* param_vec) { - std::string params_str(params.data(), params.size()); - if (!butil::SplitStringIntoKeyValuePairs(params_str, '=', ' ', param_vec)) { - param_vec->clear(); - return false; - } - return true; -} - } // namespace brpc diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 643f918d..aa2489d9 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -377,23 +377,20 @@ void ConsistentHashingLoadBalancer::GetLoads( } bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& params) { - butil::StringPairs param_vec; - if (!SplitLoadBalancerParameters(params, ¶m_vec)) { - return false; - } - for (const std::pair& param : param_vec) { - if (param.first == "replicas") { - size_t replicas = 0; - if (butil::StringToSizeT(param.second, &replicas)) { - _num_replicas = replicas; - } else { + for (butil::StringSplitter sp(params.begin(), params.end(), ' '); sp != nullptr; ++sp) { + butil::StringPiece key_value(sp.field(), sp.length()); + size_t p = key_value.find('='); + if (p == key_value.npos || p == key_value.size() - 1) { + // No value configed. + return false; + } + if (key_value.substr(0, p) == "replicas") { + if (!butil::StringToSizeT(key_value.substr(p + 1), &_num_replicas)) { return false; } - continue; } - LOG(ERROR) << "Failed to set this unknown parameters " << param.first << '=' << param.second; + LOG(ERROR) << "Failed to set this unknown parameters " << key_value; } - return true; } From aca3a0e693732ce57974795770d2f4cda47b7db1 Mon Sep 17 00:00:00 2001 From: cdjgit Date: Wed, 10 Apr 2019 18:23:46 +0800 Subject: [PATCH 115/270] fix bugs --- src/brpc/policy/consistent_hashing_load_balancer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index aa2489d9..c4cd2c4c 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -388,6 +388,7 @@ bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& para if (!butil::StringToSizeT(key_value.substr(p + 1), &_num_replicas)) { return false; } + continue; } LOG(ERROR) << "Failed to set this unknown parameters " << key_value; } From 4a7c3c5a4f5d5f4c95c0a126c5cd2c10fe1b6ac4 Mon Sep 17 00:00:00 2001 From: cdjgit Date: Wed, 10 Apr 2019 18:34:32 +0800 Subject: [PATCH 116/270] code style --- src/brpc/policy/consistent_hashing_load_balancer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index c4cd2c4c..ebb5cee9 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -124,7 +124,7 @@ namespace { pthread_once_t s_replica_policy_once = PTHREAD_ONCE_INIT; const std::array* g_replica_policy = nullptr; -void init_replica_policy() { +void InitReplicaPolicy() { g_replica_policy = new std::array({ new DefaultReplicaPolicy(MurmurHash32), new DefaultReplicaPolicy(MD5Hash32), @@ -133,7 +133,7 @@ void init_replica_policy() { } inline const ReplicaPolicy* GetReplicaPolicy(ConsistentHashingLoadBalancerType type) { - pthread_once(&s_replica_policy_once, init_replica_policy); + pthread_once(&s_replica_policy_once, InitReplicaPolicy); return g_replica_policy->at(type); } From cbeba2d0e3c75d90f3459b1816485fe11e5886fa Mon Sep 17 00:00:00 2001 From: wenweihu86 Date: Fri, 12 Apr 2019 10:35:26 +0800 Subject: [PATCH 117/270] fix build env and add building section for README --- README.md | 6 +++++- config_brpc.sh | 9 +++++++-- docs/cn/getting_started.md | 16 +++++++++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 21009d1a..62ab9d1d 100755 --- a/README.md +++ b/README.md @@ -22,10 +22,14 @@ You can use it to: * Get [better latency and throughput](docs/en/overview.md#better-latency-and-throughput). * [Extend brpc](docs/en/new_protocol.md) with the protocols used in your organization quickly, or customize components, including [naming services](docs/cn/load_balancing.md#命名服务) (dns, zk, etcd), [load balancers](docs/cn/load_balancing.md#负载均衡) (rr, random, consistent hashing) +# How to Build + +* Read [getting started](docs/cn/getting_started.md) for building steps. + # Try it! * Read [overview](docs/en/overview.md) to know where brpc can be used and its advantages. -* Read [getting started](docs/cn/getting_started.md) for building steps and play with [examples](https://github.com/brpc/brpc/tree/master/example/). +* Play with [examples](https://github.com/brpc/brpc/tree/master/example/). * Docs: * [Performance benchmark](docs/cn/benchmark.md) * [bvar](docs/en/bvar.md) diff --git a/config_brpc.sh b/config_brpc.sh index a1934d79..a0d125d1 100755 --- a/config_brpc.sh +++ b/config_brpc.sh @@ -138,7 +138,12 @@ find_dir_of_header_or_die() { # Inconvenient to check these headers in baidu-internal #PTHREAD_HDR=$(find_dir_of_header_or_die pthread.h) -OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h) +if [ "$SYSTEM" = "Darwin" ]; then + OPENSSL_HDR="/usr/local/Cellar/openssl\@1.1/1.1.1b/include" + OPENSSL_LIB="/usr/local/Cellar/openssl\@1.1/1.1.1b/lib" +else + OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h) +fi if [ $WITH_MESALINK != 0 ]; then MESALINK_HDR=$(find_dir_of_header_or_die mesalink/openssl/ssl.h) @@ -233,7 +238,7 @@ PROTOBUF_HDR=$(find_dir_of_header_or_die google/protobuf/message.h) LEVELDB_HDR=$(find_dir_of_header_or_die leveldb/db.h) HDRS=$($ECHO "$GFLAGS_HDR\n$PROTOBUF_HDR\n$LEVELDB_HDR\n$OPENSSL_HDR" | sort | uniq) -LIBS=$($ECHO "$GFLAGS_LIB\n$PROTOBUF_LIB\n$LEVELDB_LIB\n$SNAPPY_LIB" | sort | uniq) +LIBS=$($ECHO "$GFLAGS_LIB\n$PROTOBUF_LIB\n$LEVELDB_LIB\n$OPENSSL_LIB\n$SNAPPY_LIB" | sort | uniq) absent_in_the_list() { TMP=`$ECHO "$1\n$2" | sort | uniq` diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index 8b1bca07..49050876 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -40,7 +40,7 @@ sudo apt-get install libgoogle-perftools-dev If you need to run tests, install and compile libgtest-dev (which is not compiled yet): ```shell -sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv libgtest* /usr/lib/ && cd - +sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv lib/libgtest* /usr/lib/ && cd - ``` The directory of gtest source code may be changed, try `/usr/src/googletest/googletest` if `/usr/src/gtest` is not there. @@ -261,12 +261,18 @@ Note: In the same running environment, the performance of the current Mac versio Install common deps: ```shell -brew install openssl git gnu-getopt coreutils +brew install openssl@1.1 git gnu-getopt coreutils ``` -Install [gflags](https://github.com/gflags/gflags), [protobuf](https://github.com/google/protobuf), [leveldb](https://github.com/google/leveldb): +Install [gflags](https://github.com/gflags/gflags), [leveldb](https://github.com/google/leveldb): ```shell -brew install gflags protobuf leveldb +brew install gflags leveldb +``` + +Install [protobuf](https://github.com/google/protobuf): +```shell +brew install protobuf@3.1 +brew link --force --overwrite protobuf@3.1 ``` If you need to enable cpu/heap profilers in examples: @@ -276,7 +282,7 @@ brew install gperftools If you need to run tests, install and compile googletest (which is not compiled yet): ```shell -git clone https://github.com/google/googletest && cd googletest/googletest && mkdir bld && cd bld && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make && sudo mv libgtest* /usr/lib/ && cd - +git clone https://github.com/google/googletest && cd googletest/googletest && mkdir bld && cd bld && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make && sudo mv lib/libgtest* /usr/lib/ && cd - ``` ### Compile brpc with config_brpc.sh From 0abc0fffe3c541410487ca6b6f80dc00269227e9 Mon Sep 17 00:00:00 2001 From: wenweihu86 Date: Fri, 12 Apr 2019 10:44:22 +0800 Subject: [PATCH 118/270] add building section to README_cn --- README_cn.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README_cn.md b/README_cn.md index 819b25f1..a9ada550 100755 --- a/README_cn.md +++ b/README_cn.md @@ -23,10 +23,14 @@ * 获得[更好的延时和吞吐](docs/cn/overview.md#更好的延时和吞吐). * 把你组织中使用的协议快速地[加入brpc](docs/cn/new_protocol.md),或定制各类组件, 包括[命名服务](docs/cn/load_balancing.md#命名服务) (dns, zk, etcd), [负载均衡](docs/cn/load_balancing.md#负载均衡) (rr, random, consistent hashing) +# 如何编译 + +* 请阅读[编译步骤](docs/cn/getting_started.md)了解如何开始使用. + # 试一下! * 通过[概述](docs/cn/overview.md)了解哪里可以用brpc及其优势。 -* 阅读[编译步骤](docs/cn/getting_started.md)了解如何开始使用, 之后可以运行一下[示例程序](https://github.com/brpc/brpc/tree/master/example/). +* 可以运行一下[示例程序](https://github.com/brpc/brpc/tree/master/example/). * 文档: * [性能测试](docs/cn/benchmark.md) * [bvar](docs/cn/bvar.md) From 67dec96c7a96eca557c414c4c12bfae104169c05 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 12 Apr 2019 14:47:03 +0800 Subject: [PATCH 119/270] fix missing array --- src/brpc/policy/consistent_hashing_load_balancer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index ebb5cee9..39d0fcf2 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -15,6 +15,7 @@ // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) #include // std::set_union +#include #include #include "butil/containers/flat_map.h" #include "butil/errno.h" @@ -23,7 +24,6 @@ #include "brpc/policy/consistent_hashing_load_balancer.h" #include "brpc/policy/hasher.h" - namespace brpc { namespace policy { From 7ec6114e09abc105a185f31d667e2cad517bb9c7 Mon Sep 17 00:00:00 2001 From: Wenwei Hu Date: Fri, 12 Apr 2019 15:35:04 +0800 Subject: [PATCH 120/270] fix missing array (#1) --- src/brpc/policy/consistent_hashing_load_balancer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index ebb5cee9..39d0fcf2 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -15,6 +15,7 @@ // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) #include // std::set_union +#include #include #include "butil/containers/flat_map.h" #include "butil/errno.h" @@ -23,7 +24,6 @@ #include "brpc/policy/consistent_hashing_load_balancer.h" #include "brpc/policy/hasher.h" - namespace brpc { namespace policy { From 66f9e38ffc4a87f908ba2567e7cc1e6c892d74ee Mon Sep 17 00:00:00 2001 From: guohao Date: Mon, 15 Apr 2019 14:11:23 +0800 Subject: [PATCH 121/270] Fix typo --- src/brpc/policy/auto_concurrency_limiter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/policy/auto_concurrency_limiter.cpp b/src/brpc/policy/auto_concurrency_limiter.cpp index 17e21248..547b793a 100644 --- a/src/brpc/policy/auto_concurrency_limiter.cpp +++ b/src/brpc/policy/auto_concurrency_limiter.cpp @@ -35,7 +35,7 @@ DEFINE_int32(auto_cl_max_sample_count, 200, DEFINE_double(auto_cl_sampling_interval_ms, 0.1, "Interval for sampling request in auto concurrency limiter"); DEFINE_int32(auto_cl_initial_max_concurrency, 40, - "Initial max concurrency for grandient concurrency limiter"); + "Initial max concurrency for gradient concurrency limiter"); DEFINE_int32(auto_cl_noload_latency_remeasure_interval_ms, 50000, "Interval for remeasurement of noload_latency. In the period of " "remeasurement of noload_latency will halve max_concurrency."); From 75da0becdb68027fa5c2babcdbf58babba617acf Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 16 Apr 2019 15:11:23 +0800 Subject: [PATCH 122/270] support_kv_pair_splitter: add basic features --- src/brpc/uri.cpp | 13 ------ src/brpc/uri.h | 69 ++++----------------------- src/butil/string_splitter.h | 77 +++++++++++++++++++++++++++++++ src/butil/string_splitter_inl.h | 13 ++++++ test/string_splitter_unittest.cpp | 52 +++++++++++++++++++++ 5 files changed, 152 insertions(+), 72 deletions(-) diff --git a/src/brpc/uri.cpp b/src/brpc/uri.cpp index 5969c47c..6fe0e4d0 100644 --- a/src/brpc/uri.cpp +++ b/src/brpc/uri.cpp @@ -407,19 +407,6 @@ void URI::SetH2Path(const char* h2_path) { } } -void QuerySplitter::split() { - butil::StringPiece query_pair(_sp.field(), _sp.length()); - const size_t pos = query_pair.find('='); - if (pos == butil::StringPiece::npos) { - _key = query_pair; - _value.clear(); - } else { - _key= query_pair.substr(0, pos); - _value = query_pair.substr(pos + 1); - } - _is_split = true; -} - QueryRemover::QueryRemover(const std::string* str) : _query(str) , _qs(str->data(), str->data() + str->size()) diff --git a/src/brpc/uri.h b/src/brpc/uri.h index 23dea25e..d24e19bb 100644 --- a/src/brpc/uri.h +++ b/src/brpc/uri.h @@ -195,68 +195,19 @@ inline std::ostream& operator<<(std::ostream& os, const URI& uri) { } // Split query in the format of "key1=value1&key2&key3=value3" -// This class can also handle some exceptional cases, such as -// consecutive ampersand, only equal sign, only key and so on. -class QuerySplitter { +class QuerySplitter : public butil::KeyValuePairsSplitter { public: - QuerySplitter(const char* str_begin, const char* str_end) - : _sp(str_begin, str_end, '&') - , _is_split(false) { - } + inline QuerySplitter(const char* str_begin, const char* str_end) + : KeyValuePairsSplitter(str_begin, str_end, '=', '&') + {} - QuerySplitter(const char* str_begin) - : _sp(str_begin, '&') - , _is_split(false) { - } + inline QuerySplitter(const char* str_begin) + : KeyValuePairsSplitter(str_begin, '=', '&') + {} - QuerySplitter(const butil::StringPiece &sp) - : _sp(sp.begin(), sp.end(), '&') - , _is_split(false) { - } - - const butil::StringPiece& key() { - if (!_is_split) { - split(); - } - return _key; - } - - const butil::StringPiece& value() { - if (!_is_split) { - split(); - } - return _value; - } - - // Get the current value of key and value - // in the format of "key=value" - butil::StringPiece key_and_value(){ - return butil::StringPiece(_sp.field(), _sp.length()); - } - - // Move splitter forward. - QuerySplitter& operator++() { - ++_sp; - _is_split = false; - return *this; - } - - QuerySplitter operator++(int) { - QuerySplitter tmp = *this; - operator++(); - return tmp; - } - - operator const void*() const { return _sp; } - -private: - void split(); - -private: - butil::StringSplitter _sp; - butil::StringPiece _key; - butil::StringPiece _value; - bool _is_split; + inline QuerySplitter(const butil::StringPiece &sp) + : KeyValuePairsSplitter(sp, '=', '&') + {} }; // A class to remove some specific keys in a query string, diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index 1fe3dc64..5317cc38 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -22,6 +22,7 @@ #include #include +#include "butil/strings/string_piece.h" // It's common to encode data into strings separated by special characters // and decode them back, but functions such as `split_string' has to modify @@ -159,6 +160,82 @@ private: const EmptyFieldAction _empty_field_action; }; +// Split query in the format according to the given delimiters. +// This class can also handle some exceptional cases, such as +// consecutive ampersand, only equal sign, only key and so on. +class KeyValuePairsSplitter { +public: + inline KeyValuePairsSplitter(const char* str_begin, + const char* str_end, + char key_value_delimiter, + char key_value_pair_delimiter) + : _sp(str_begin, str_end, key_value_pair_delimiter) + , _is_split(false) + , _key_value_delimiter(key_value_delimiter) { + } + + inline KeyValuePairsSplitter(const char* str_begin, + char key_value_delimiter, + char key_value_pair_delimiter) + : _sp(str_begin, key_value_pair_delimiter) + , _is_split(false) + , _key_value_delimiter(key_value_delimiter) { + } + + inline KeyValuePairsSplitter(const StringPiece &sp, + char key_value_delimiter, + char key_value_pair_delimiter) + : _sp(sp.begin(), sp.end(), key_value_pair_delimiter) + , _is_split(false) + , _key_value_delimiter(key_value_delimiter) { + } + + inline const StringPiece& key() { + if (!_is_split) { + split(); + } + return _key; + } + + inline const StringPiece& value() { + if (!_is_split) { + split(); + } + return _value; + } + + // Get the current value of key and value + // in the format of "key=value" + inline StringPiece key_and_value(){ + return StringPiece(_sp.field(), _sp.length()); + } + + // Move splitter forward. + inline KeyValuePairsSplitter& operator++() { + ++_sp; + _is_split = false; + return *this; + } + + inline KeyValuePairsSplitter operator++(int) { + KeyValuePairsSplitter tmp = *this; + operator++(); + return tmp; + } + + inline operator const void*() const { return _sp; } + +private: + inline void split(); + +private: + StringSplitter _sp; + StringPiece _key; + StringPiece _value; + bool _is_split; + const char _key_value_delimiter; +}; + } // namespace butil #include "butil/string_splitter_inl.h" diff --git a/src/butil/string_splitter_inl.h b/src/butil/string_splitter_inl.h index c035aaf1..a5ad5288 100644 --- a/src/butil/string_splitter_inl.h +++ b/src/butil/string_splitter_inl.h @@ -309,6 +309,19 @@ int StringMultiSplitter::to_double(double* pv) const { return (endptr == field() + length()) ? 0 : -1; } +void KeyValuePairsSplitter::split() { + StringPiece query_pair(_sp.field(), _sp.length()); + const size_t pos = query_pair.find('='); + if (pos == StringPiece::npos) { + _key = query_pair; + _value.clear(); + } else { + _key= query_pair.substr(0, pos); + _value = query_pair.substr(pos + 1); + } + _is_split = true; +} + } // namespace butil #endif // BUTIL_STRING_SPLITTER_INL_H diff --git a/test/string_splitter_unittest.cpp b/test/string_splitter_unittest.cpp index 64adc6e5..d75e17b3 100644 --- a/test/string_splitter_unittest.cpp +++ b/test/string_splitter_unittest.cpp @@ -321,4 +321,56 @@ TEST_F(StringSplitterTest, split_limit_len) { ASSERT_FALSE(ss2); } +TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { + std::string kvstr = "key1=value1&key2=value2&key3=value3"; + { + butil::KeyValuePairsSplitter splitter(kvstr, '=', '&'); + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key1"); + ASSERT_EQ(splitter.value(), "value1"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key2"); + ASSERT_EQ(splitter.value(), "value2"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key3"); + ASSERT_EQ(splitter.value(), "value3"); + ++splitter; + ASSERT_FALSE(splitter); + } + { + butil::KeyValuePairsSplitter splitter(kvstr.data(), kvstr.data() + kvstr.size(), '=', '&'); + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key1"); + ASSERT_EQ(splitter.value(), "value1"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key2"); + ASSERT_EQ(splitter.value(), "value2"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key3"); + ASSERT_EQ(splitter.value(), "value3"); + ++splitter; + ASSERT_FALSE(splitter); + } + { + butil::KeyValuePairsSplitter splitter(kvstr.c_str(), '=', '&'); + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key1"); + ASSERT_EQ(splitter.value(), "value1"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key2"); + ASSERT_EQ(splitter.value(), "value2"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key3"); + ASSERT_EQ(splitter.value(), "value3"); + ++splitter; + ASSERT_FALSE(splitter); + } +} + } From c43d848c37306fd60dbcff454881750d4ba62f78 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 16 Apr 2019 16:48:55 +0800 Subject: [PATCH 123/270] support_kv_pair_splitter: refactor key()/value() in StringSplitter && add comments --- src/butil/string_splitter.h | 56 +++++++++++++++---------------- src/butil/string_splitter_inl.h | 40 +++++++++++----------- test/string_splitter_unittest.cpp | 18 +++++++++- 3 files changed, 66 insertions(+), 48 deletions(-) diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index 5317cc38..6d2d5143 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -66,7 +66,10 @@ public: // if str_end is not NULL. inline StringSplitter(const char* str_begin, const char* str_end, char separator, - EmptyFieldAction = SKIP_EMPTY_FIELD); + EmptyFieldAction action = SKIP_EMPTY_FIELD); + // Allows containing embedded '\0' characters and separator can be '\0', + inline StringSplitter(const StringPiece& input, char separator, + EmptyFieldAction action = SKIP_EMPTY_FIELD); // Move splitter forward. inline StringSplitter& operator++(); @@ -79,6 +82,7 @@ public: // not be '\0' because we don't modify `input'. inline const char* field() const; inline size_t length() const; + inline StringPiece field_sp() const; // Cast field to specific type, and write the value into `pv'. // Returns 0 on success, -1 otherwise. @@ -133,6 +137,7 @@ public: // not be '\0' because we don't modify `input'. inline const char* field() const; inline size_t length() const; + inline StringPiece field_sp() const; // Cast field to specific type, and write the value into `pv'. // Returns 0 on success, -1 otherwise. @@ -161,8 +166,14 @@ private: }; // Split query in the format according to the given delimiters. -// This class can also handle some exceptional cases, such as -// consecutive ampersand, only equal sign, only key and so on. +// This class can also handle some exceptional cases. +// 1. consecutive key_value_pair_delimiter are omitted, for example, +// suppose key_value_delimiter is '=' and key_value_pair_delimiter +// is '&', then k1=v1&&&k2=v2 is normalized to k1=k2&k2=v2. +// 2. key or value can be empty or both can be empty +// 3. consecutive key_value_delimiter are not omitted, for example, +// suppose input is k1===v2 and key_value_delimiter is '=', then +// key() returns 'k1', value() returns '==v2'. class KeyValuePairsSplitter { public: inline KeyValuePairsSplitter(const char* str_begin, @@ -170,38 +181,29 @@ public: char key_value_delimiter, char key_value_pair_delimiter) : _sp(str_begin, str_end, key_value_pair_delimiter) - , _is_split(false) + , _deli_pos(StringPiece::npos) , _key_value_delimiter(key_value_delimiter) { + UpdateDelimiterPos(); } inline KeyValuePairsSplitter(const char* str_begin, char key_value_delimiter, char key_value_pair_delimiter) - : _sp(str_begin, key_value_pair_delimiter) - , _is_split(false) - , _key_value_delimiter(key_value_delimiter) { - } + : KeyValuePairsSplitter(str_begin, NULL, + key_value_delimiter, key_value_pair_delimiter) {} inline KeyValuePairsSplitter(const StringPiece &sp, char key_value_delimiter, char key_value_pair_delimiter) - : _sp(sp.begin(), sp.end(), key_value_pair_delimiter) - , _is_split(false) - , _key_value_delimiter(key_value_delimiter) { + : KeyValuePairsSplitter(sp.begin(), sp.end(), + key_value_delimiter, key_value_pair_delimiter) {} + + inline StringPiece key() { + return StringPiece(_sp.field(), _sp.length()).substr(0, _deli_pos); } - inline const StringPiece& key() { - if (!_is_split) { - split(); - } - return _key; - } - - inline const StringPiece& value() { - if (!_is_split) { - split(); - } - return _value; + inline StringPiece value() { + return StringPiece(_sp.field(), _sp.length()).substr(_deli_pos + 1); } // Get the current value of key and value @@ -213,7 +215,7 @@ public: // Move splitter forward. inline KeyValuePairsSplitter& operator++() { ++_sp; - _is_split = false; + UpdateDelimiterPos(); return *this; } @@ -226,13 +228,11 @@ public: inline operator const void*() const { return _sp; } private: - inline void split(); + inline void UpdateDelimiterPos(); private: StringSplitter _sp; - StringPiece _key; - StringPiece _value; - bool _is_split; + StringPiece::size_type _deli_pos; const char _key_value_delimiter; }; diff --git a/src/butil/string_splitter_inl.h b/src/butil/string_splitter_inl.h index a5ad5288..61a474dc 100644 --- a/src/butil/string_splitter_inl.h +++ b/src/butil/string_splitter_inl.h @@ -22,15 +22,6 @@ namespace butil { -StringSplitter::StringSplitter(const char* str, char sep, - EmptyFieldAction action) - : _head(str) - , _str_tail(NULL) - , _sep(sep) - , _empty_field_action(action) { - init(); -} - StringSplitter::StringSplitter(const char* str_begin, const char* str_end, const char sep, @@ -42,6 +33,14 @@ StringSplitter::StringSplitter(const char* str_begin, init(); } +StringSplitter::StringSplitter(const char* str, char sep, + EmptyFieldAction action) + : StringSplitter(str, NULL, sep, action) {} + +StringSplitter::StringSplitter(const StringPiece& input, char sep, + EmptyFieldAction action) + : StringSplitter(input.data(), input.data() + input.length(), sep, action) {} + void StringSplitter::init() { // Find the starting _head and _tail. if (__builtin_expect(_head != NULL, 1)) { @@ -86,6 +85,10 @@ size_t StringSplitter::length() const { return static_cast(_tail - _head); } +StringPiece StringSplitter::field_sp() const { + return StringPiece(field(), length()); +} + bool StringSplitter::not_end(const char* p) const { return (_str_tail == NULL) ? *p : (p != _str_tail); } @@ -233,6 +236,10 @@ size_t StringMultiSplitter::length() const { return static_cast(_tail - _head); } +StringPiece StringMultiSplitter::field_sp() const { + return StringPiece(field(), length()); +} + bool StringMultiSplitter::not_end(const char* p) const { return (_str_tail == NULL) ? *p : (p != _str_tail); } @@ -309,17 +316,12 @@ int StringMultiSplitter::to_double(double* pv) const { return (endptr == field() + length()) ? 0 : -1; } -void KeyValuePairsSplitter::split() { - StringPiece query_pair(_sp.field(), _sp.length()); - const size_t pos = query_pair.find('='); - if (pos == StringPiece::npos) { - _key = query_pair; - _value.clear(); - } else { - _key= query_pair.substr(0, pos); - _value = query_pair.substr(pos + 1); +void KeyValuePairsSplitter::UpdateDelimiterPos() { + StringPiece key_value_pair(_sp.field(), _sp.length()); + _deli_pos = key_value_pair.find(_key_value_delimiter); + if (_deli_pos == StringPiece::npos) { + _deli_pos = key_value_pair.length(); } - _is_split = true; } } // namespace butil diff --git a/test/string_splitter_unittest.cpp b/test/string_splitter_unittest.cpp index d75e17b3..3c62e33e 100644 --- a/test/string_splitter_unittest.cpp +++ b/test/string_splitter_unittest.cpp @@ -319,10 +319,26 @@ TEST_F(StringSplitterTest, split_limit_len) { ++ss2; ASSERT_FALSE(ss2); + + butil::StringPiece sp(str, 5); + // Allows using '\0' as separator + butil::StringSplitter ss3(sp, '\0'); + + ASSERT_TRUE(ss3); + ASSERT_EQ(3ul, ss3.length()); + ASSERT_FALSE(strncmp(ss3.field(), "1\t1", ss3.length())); + + ++ss3; + ASSERT_TRUE(ss3); + ASSERT_EQ(1ul, ss3.length()); + ASSERT_FALSE(strncmp(ss3.field(), "3", ss3.length())); + + ++ss3; + ASSERT_FALSE(ss3); } TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { - std::string kvstr = "key1=value1&key2=value2&key3=value3"; + std::string kvstr = "key1=value1&&&key2=value2&key3=value3"; { butil::KeyValuePairsSplitter splitter(kvstr, '=', '&'); ASSERT_TRUE(splitter); From 42435e74657e60f084e0e43ce44e776505a5e12e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 16 Apr 2019 16:54:29 +0800 Subject: [PATCH 124/270] support_kv_pair_splitter: refine fn name --- src/butil/string_splitter.h | 6 +++--- src/butil/string_splitter_inl.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index 6d2d5143..d0d220a4 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -183,7 +183,7 @@ public: : _sp(str_begin, str_end, key_value_pair_delimiter) , _deli_pos(StringPiece::npos) , _key_value_delimiter(key_value_delimiter) { - UpdateDelimiterPos(); + UpdateDelimiterPosition(); } inline KeyValuePairsSplitter(const char* str_begin, @@ -215,7 +215,7 @@ public: // Move splitter forward. inline KeyValuePairsSplitter& operator++() { ++_sp; - UpdateDelimiterPos(); + UpdateDelimiterPosition(); return *this; } @@ -228,7 +228,7 @@ public: inline operator const void*() const { return _sp; } private: - inline void UpdateDelimiterPos(); + inline void UpdateDelimiterPosition(); private: StringSplitter _sp; diff --git a/src/butil/string_splitter_inl.h b/src/butil/string_splitter_inl.h index 61a474dc..27f2a0d0 100644 --- a/src/butil/string_splitter_inl.h +++ b/src/butil/string_splitter_inl.h @@ -316,7 +316,7 @@ int StringMultiSplitter::to_double(double* pv) const { return (endptr == field() + length()) ? 0 : -1; } -void KeyValuePairsSplitter::UpdateDelimiterPos() { +void KeyValuePairsSplitter::UpdateDelimiterPosition() { StringPiece key_value_pair(_sp.field(), _sp.length()); _deli_pos = key_value_pair.find(_key_value_delimiter); if (_deli_pos == StringPiece::npos) { From b944765726c1bd1475b1e5e2abd98bd349f3d353 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 16 Apr 2019 16:59:56 +0800 Subject: [PATCH 125/270] support_kv_pair_splitter: refine code --- src/butil/string_splitter.h | 2 +- src/butil/string_splitter_inl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index d0d220a4..edcd5384 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -208,7 +208,7 @@ public: // Get the current value of key and value // in the format of "key=value" - inline StringPiece key_and_value(){ + inline StringPiece key_and_value() { return StringPiece(_sp.field(), _sp.length()); } diff --git a/src/butil/string_splitter_inl.h b/src/butil/string_splitter_inl.h index 27f2a0d0..c059643a 100644 --- a/src/butil/string_splitter_inl.h +++ b/src/butil/string_splitter_inl.h @@ -317,7 +317,7 @@ int StringMultiSplitter::to_double(double* pv) const { } void KeyValuePairsSplitter::UpdateDelimiterPosition() { - StringPiece key_value_pair(_sp.field(), _sp.length()); + const StringPiece key_value_pair(key_and_value()); _deli_pos = key_value_pair.find(_key_value_delimiter); if (_deli_pos == StringPiece::npos) { _deli_pos = key_value_pair.length(); From 55f184493f363beb438ea2af15cd58d3d14497d3 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 16 Apr 2019 17:09:08 +0800 Subject: [PATCH 126/270] support_kv_pair_splitter: refine code --- src/butil/string_splitter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index edcd5384..5754935a 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -199,11 +199,11 @@ public: key_value_delimiter, key_value_pair_delimiter) {} inline StringPiece key() { - return StringPiece(_sp.field(), _sp.length()).substr(0, _deli_pos); + return key_and_value().substr(0, _deli_pos); } inline StringPiece value() { - return StringPiece(_sp.field(), _sp.length()).substr(_deli_pos + 1); + return key_and_value().substr(_deli_pos + 1); } // Get the current value of key and value From b60143eae477a05ad66a92c3760eb89eafc712d4 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 16 Apr 2019 18:10:09 +0800 Subject: [PATCH 127/270] support_kv_pair_splitter: make tests more robust & refine name --- src/butil/string_splitter.h | 18 +++++----- src/butil/string_splitter_inl.h | 6 ++-- test/string_splitter_unittest.cpp | 55 +++++++++++++++---------------- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index 5754935a..b85f60d7 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -169,10 +169,10 @@ private: // This class can also handle some exceptional cases. // 1. consecutive key_value_pair_delimiter are omitted, for example, // suppose key_value_delimiter is '=' and key_value_pair_delimiter -// is '&', then k1=v1&&&k2=v2 is normalized to k1=k2&k2=v2. -// 2. key or value can be empty or both can be empty +// is '&', then 'k1=v1&&&k2=v2' is normalized to 'k1=k2&k2=v2'. +// 2. key or value can be empty or both can be empty. // 3. consecutive key_value_delimiter are not omitted, for example, -// suppose input is k1===v2 and key_value_delimiter is '=', then +// suppose input is 'k1===v2' and key_value_delimiter is '=', then // key() returns 'k1', value() returns '==v2'. class KeyValuePairsSplitter { public: @@ -181,8 +181,8 @@ public: char key_value_delimiter, char key_value_pair_delimiter) : _sp(str_begin, str_end, key_value_pair_delimiter) - , _deli_pos(StringPiece::npos) - , _key_value_delimiter(key_value_delimiter) { + , _delim_pos(StringPiece::npos) + , _key_value_delim(key_value_delimiter) { UpdateDelimiterPosition(); } @@ -199,11 +199,11 @@ public: key_value_delimiter, key_value_pair_delimiter) {} inline StringPiece key() { - return key_and_value().substr(0, _deli_pos); + return key_and_value().substr(0, _delim_pos); } inline StringPiece value() { - return key_and_value().substr(_deli_pos + 1); + return key_and_value().substr(_delim_pos + 1); } // Get the current value of key and value @@ -232,8 +232,8 @@ private: private: StringSplitter _sp; - StringPiece::size_type _deli_pos; - const char _key_value_delimiter; + StringPiece::size_type _delim_pos; + const char _key_value_delim; }; } // namespace butil diff --git a/src/butil/string_splitter_inl.h b/src/butil/string_splitter_inl.h index c059643a..a0b9fe5c 100644 --- a/src/butil/string_splitter_inl.h +++ b/src/butil/string_splitter_inl.h @@ -318,9 +318,9 @@ int StringMultiSplitter::to_double(double* pv) const { void KeyValuePairsSplitter::UpdateDelimiterPosition() { const StringPiece key_value_pair(key_and_value()); - _deli_pos = key_value_pair.find(_key_value_delimiter); - if (_deli_pos == StringPiece::npos) { - _deli_pos = key_value_pair.length(); + _delim_pos = key_value_pair.find(_key_value_delim); + if (_delim_pos == StringPiece::npos) { + _delim_pos = key_value_pair.length(); } } diff --git a/test/string_splitter_unittest.cpp b/test/string_splitter_unittest.cpp index 3c62e33e..e88e1bc8 100644 --- a/test/string_splitter_unittest.cpp +++ b/test/string_splitter_unittest.cpp @@ -338,9 +338,20 @@ TEST_F(StringSplitterTest, split_limit_len) { } TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { - std::string kvstr = "key1=value1&&&key2=value2&key3=value3"; - { - butil::KeyValuePairsSplitter splitter(kvstr, '=', '&'); + std::string kvstr = "key1=value1&&&key2=value2&key3=value3&===&key4=&=&=value5"; + for (int i = 0 ; i < 3; ++i) { + // Test three constructors + butil::KeyValuePairsSplitter* psplitter = NULL; + if (i == 0) { + psplitter = new butil::KeyValuePairsSplitter(kvstr, '=', '&'); + } else if (i == 1) { + psplitter = new butil::KeyValuePairsSplitter( + kvstr.data(), kvstr.data() + kvstr.size(), '=', '&'); + } else if (i == 2) { + psplitter = new butil::KeyValuePairsSplitter(kvstr.c_str(), '=', '&'); + } + butil::KeyValuePairsSplitter& splitter = *psplitter; + ASSERT_TRUE(splitter); ASSERT_EQ(splitter.key(), "key1"); ASSERT_EQ(splitter.value(), "value1"); @@ -353,39 +364,25 @@ TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { ASSERT_EQ(splitter.key(), "key3"); ASSERT_EQ(splitter.value(), "value3"); ++splitter; - ASSERT_FALSE(splitter); - } - { - butil::KeyValuePairsSplitter splitter(kvstr.data(), kvstr.data() + kvstr.size(), '=', '&'); ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key1"); - ASSERT_EQ(splitter.value(), "value1"); + ASSERT_EQ(splitter.key(), ""); + ASSERT_EQ(splitter.value(), "=="); ++splitter; ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key2"); - ASSERT_EQ(splitter.value(), "value2"); + ASSERT_EQ(splitter.key(), "key4"); + ASSERT_EQ(splitter.value(), ""); ++splitter; ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key3"); - ASSERT_EQ(splitter.value(), "value3"); - ++splitter; - ASSERT_FALSE(splitter); - } - { - butil::KeyValuePairsSplitter splitter(kvstr.c_str(), '=', '&'); - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key1"); - ASSERT_EQ(splitter.value(), "value1"); - ++splitter; - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key2"); - ASSERT_EQ(splitter.value(), "value2"); - ++splitter; - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key3"); - ASSERT_EQ(splitter.value(), "value3"); + ASSERT_EQ(splitter.key(), ""); + ASSERT_EQ(splitter.value(), ""); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), ""); + ASSERT_EQ(splitter.value(), "value5"); ++splitter; ASSERT_FALSE(splitter); + + delete psplitter; } } From f08558d2458f4167896d6c6ad7945cc8eecdf728 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 17 Apr 2019 11:58:21 +0800 Subject: [PATCH 128/270] support_kv_pair_splitter: fix UT --- src/brpc/uri.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/uri.h b/src/brpc/uri.h index d24e19bb..59ccb9bf 100644 --- a/src/brpc/uri.h +++ b/src/brpc/uri.h @@ -217,8 +217,8 @@ class QueryRemover { public: QueryRemover(const std::string* str); - const butil::StringPiece& key() { return _qs.key();} - const butil::StringPiece& value() { return _qs.value(); } + butil::StringPiece key() { return _qs.key();} + butil::StringPiece value() { return _qs.value(); } butil::StringPiece key_and_value() { return _qs.key_and_value(); } // Move splitter forward. From 9b1f6ad02e888136de89cd4bcc6b812b8a6c4d3b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 17 Apr 2019 20:11:22 +0800 Subject: [PATCH 129/270] replace SplitStringIntoKeyValuePairs --- .../consistent_hashing_load_balancer.cpp | 20 ++++++++--------- src/brpc/uri.h | 6 ++--- src/butil/string_splitter.h | 22 +++++++++---------- src/bvar/variable.cpp | 15 +++++-------- test/string_splitter_unittest.cpp | 6 ++--- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 20a043ea..8baacee1 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -270,10 +270,11 @@ size_t ConsistentHashingLoadBalancer::RemoveServersInBatch( return n; } -LoadBalancer *ConsistentHashingLoadBalancer::New(const butil::StringPiece& params) const { +LoadBalancer *ConsistentHashingLoadBalancer::New( + const butil::StringPiece& params) const { ConsistentHashingLoadBalancer* lb = new (std::nothrow) ConsistentHashingLoadBalancer(_type); - if (lb != nullptr && !lb->SetParameters(params)) { + if (lb && !lb->SetParameters(params)) { delete lb; lb = nullptr; } @@ -377,20 +378,19 @@ void ConsistentHashingLoadBalancer::GetLoads( } bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& params) { - for (butil::StringSplitter sp(params.begin(), params.end(), ' '); sp != nullptr; ++sp) { - butil::StringPiece key_value(sp.field(), sp.length()); - size_t p = key_value.find('='); - if (p == key_value.npos || p == key_value.size() - 1) { - // No value configed. + for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), ' ', '='); + sp; ++sp) { + if (sp.value().empty()) { + LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; return false; } - if (key_value.substr(0, p) == "replicas") { - if (!butil::StringToSizeT(key_value.substr(p + 1), &_num_replicas)) { + if (sp.key() == "replicas") { + if (!butil::StringToSizeT(sp.value(), &_num_replicas)) { return false; } continue; } - LOG(ERROR) << "Failed to set this unknown parameters " << key_value; + LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); } return true; } diff --git a/src/brpc/uri.h b/src/brpc/uri.h index 59ccb9bf..706f5470 100644 --- a/src/brpc/uri.h +++ b/src/brpc/uri.h @@ -198,15 +198,15 @@ inline std::ostream& operator<<(std::ostream& os, const URI& uri) { class QuerySplitter : public butil::KeyValuePairsSplitter { public: inline QuerySplitter(const char* str_begin, const char* str_end) - : KeyValuePairsSplitter(str_begin, str_end, '=', '&') + : KeyValuePairsSplitter(str_begin, str_end, '&', '=') {} inline QuerySplitter(const char* str_begin) - : KeyValuePairsSplitter(str_begin, '=', '&') + : KeyValuePairsSplitter(str_begin, '&', '=') {} inline QuerySplitter(const butil::StringPiece &sp) - : KeyValuePairsSplitter(sp, '=', '&') + : KeyValuePairsSplitter(sp, '&', '=') {} }; diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index b85f60d7..b38b9c10 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -167,8 +167,8 @@ private: // Split query in the format according to the given delimiters. // This class can also handle some exceptional cases. -// 1. consecutive key_value_pair_delimiter are omitted, for example, -// suppose key_value_delimiter is '=' and key_value_pair_delimiter +// 1. consecutive pair_delimiter are omitted, for example, +// suppose key_value_delimiter is '=' and pair_delimiter // is '&', then 'k1=v1&&&k2=v2' is normalized to 'k1=k2&k2=v2'. // 2. key or value can be empty or both can be empty. // 3. consecutive key_value_delimiter are not omitted, for example, @@ -178,25 +178,25 @@ class KeyValuePairsSplitter { public: inline KeyValuePairsSplitter(const char* str_begin, const char* str_end, - char key_value_delimiter, - char key_value_pair_delimiter) - : _sp(str_begin, str_end, key_value_pair_delimiter) + char pair_delimiter, + char key_value_delimiter) + : _sp(str_begin, str_end, pair_delimiter) , _delim_pos(StringPiece::npos) , _key_value_delim(key_value_delimiter) { UpdateDelimiterPosition(); } inline KeyValuePairsSplitter(const char* str_begin, - char key_value_delimiter, - char key_value_pair_delimiter) + char pair_delimiter, + char key_value_delimiter) : KeyValuePairsSplitter(str_begin, NULL, - key_value_delimiter, key_value_pair_delimiter) {} + pair_delimiter, key_value_delimiter) {} inline KeyValuePairsSplitter(const StringPiece &sp, - char key_value_delimiter, - char key_value_pair_delimiter) + char pair_delimiter, + char key_value_delimiter) : KeyValuePairsSplitter(sp.begin(), sp.end(), - key_value_delimiter, key_value_pair_delimiter) {} + pair_delimiter, key_value_delimiter) {} inline StringPiece key() { return key_and_value().substr(0, _delim_pos); diff --git a/src/bvar/variable.cpp b/src/bvar/variable.cpp index cfb4c920..d31ba9c7 100644 --- a/src/bvar/variable.cpp +++ b/src/bvar/variable.cpp @@ -24,7 +24,6 @@ #include "butil/containers/flat_map.h" // butil::FlatMap #include "butil/scoped_lock.h" // BAIDU_SCOPE_LOCK #include "butil/string_splitter.h" // butil::StringSplitter -#include "butil/strings/string_split.h" // butil::SplitStringIntoKeyValuePairs #include "butil/errno.h" // berror #include "butil/time.h" // milliseconds_from_now #include "butil/file_util.h" // butil::FilePath @@ -627,15 +626,13 @@ public: // .data will be appended later path = path.RemoveFinalExtension(); } - butil::StringPairs pairs; - pairs.reserve(8); - butil::SplitStringIntoKeyValuePairs(tabs, '=', ';', &pairs); - dumpers.reserve(pairs.size() + 1); - //matchers.reserve(pairs.size()); - for (size_t i = 0; i < pairs.size(); ++i) { + + for (butil::KeyValuePairsSplitter sp(tabs, ';', '='); sp; ++sp) { + std::string key = sp.key().as_string(); + std::string value = sp.value().as_string(); FileDumper *f = new FileDumper( - path.AddExtension(pairs[i].first).AddExtension("data").value(), s); - WildcardMatcher *m = new WildcardMatcher(pairs[i].second, '?', true); + path.AddExtension(key).AddExtension("data").value(), s); + WildcardMatcher *m = new WildcardMatcher(value, '?', true); dumpers.push_back(std::make_pair(f, m)); } dumpers.push_back(std::make_pair( diff --git a/test/string_splitter_unittest.cpp b/test/string_splitter_unittest.cpp index e88e1bc8..da6024c2 100644 --- a/test/string_splitter_unittest.cpp +++ b/test/string_splitter_unittest.cpp @@ -343,12 +343,12 @@ TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { // Test three constructors butil::KeyValuePairsSplitter* psplitter = NULL; if (i == 0) { - psplitter = new butil::KeyValuePairsSplitter(kvstr, '=', '&'); + psplitter = new butil::KeyValuePairsSplitter(kvstr, '&', '='); } else if (i == 1) { psplitter = new butil::KeyValuePairsSplitter( - kvstr.data(), kvstr.data() + kvstr.size(), '=', '&'); + kvstr.data(), kvstr.data() + kvstr.size(), '&', '='); } else if (i == 2) { - psplitter = new butil::KeyValuePairsSplitter(kvstr.c_str(), '=', '&'); + psplitter = new butil::KeyValuePairsSplitter(kvstr.c_str(), '&', '='); } butil::KeyValuePairsSplitter& splitter = *psplitter; From 57b60aa44878d477380f3715913291aea469fe1f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 2 Apr 2019 20:19:32 +0800 Subject: [PATCH 130/270] revived_from_all_failed: add RevivePolicy --- src/brpc/channel.cpp | 4 +- src/brpc/channel.h | 5 + src/brpc/circuit_breaker.cpp | 2 + src/brpc/controller.cpp | 3 +- src/brpc/controller.h | 2 + src/brpc/details/naming_service_thread.h | 4 +- src/brpc/errno.proto | 1 + src/brpc/load_balancer.h | 5 +- src/brpc/policy/randomized_load_balancer.cpp | 8 +- src/brpc/policy/randomized_load_balancer.h | 13 ++ src/brpc/policy/round_robin_load_balancer.cpp | 7 + src/brpc/revive_policy.cpp | 78 +++++++ src/brpc/revive_policy.h | 53 +++++ src/brpc/selective_channel.cpp | 3 +- test/brpc_load_balancer_unittest.cpp | 200 +++++++++++++++++- 15 files changed, 374 insertions(+), 14 deletions(-) create mode 100644 src/brpc/revive_policy.cpp create mode 100644 src/brpc/revive_policy.h diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index e5d4a45d..56e61537 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -52,6 +52,7 @@ ChannelOptions::ChannelOptions() , auth(NULL) , retry_policy(NULL) , ns_filter(NULL) + , revive_policy(NULL) {} ChannelSSLOptions* ChannelOptions::mutable_ssl_options() { @@ -525,6 +526,7 @@ void Channel::CallMethod(const google::protobuf::MethodDescriptor* method, } else { cntl->_deadline_us = -1; } + cntl->_revive_policy = _options.revive_policy; cntl->IssueRPC(start_send_real_us); if (done == NULL) { @@ -562,7 +564,7 @@ int Channel::CheckHealth() { return -1; } else { SocketUniquePtr tmp_sock; - LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL }; + LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL, NULL }; LoadBalancer::SelectOut sel_out(&tmp_sock); return _lb->SelectServer(sel_in, &sel_out); } diff --git a/src/brpc/channel.h b/src/brpc/channel.h index be631cff..a6492074 100644 --- a/src/brpc/channel.h +++ b/src/brpc/channel.h @@ -34,6 +34,7 @@ #include "brpc/details/profiler_linker.h" #include "brpc/retry_policy.h" #include "brpc/naming_service_filter.h" +#include "brpc/revive_policy.h" namespace brpc { @@ -128,6 +129,10 @@ struct ChannelOptions { // Default: "" std::string connection_group; + // TODO(zhujiashun) + // Default: NULL + RevivePolicy* revive_policy; + private: // SSLOptions is large and not often used, allocate it on heap to // prevent ChannelOptions from being bloated in most cases. diff --git a/src/brpc/circuit_breaker.cpp b/src/brpc/circuit_breaker.cpp index 84ec7627..d2b74b23 100644 --- a/src/brpc/circuit_breaker.cpp +++ b/src/brpc/circuit_breaker.cpp @@ -18,6 +18,8 @@ #include #include #include "brpc/circuit_breaker.h" +#include "brpc/errno.pb.h" +#include "butil/logging.h" namespace brpc { diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 8f1bcacf..b7c0557b 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -252,6 +252,7 @@ void Controller::ResetPods() { _request_stream = INVALID_STREAM_ID; _response_stream = INVALID_STREAM_ID; _remote_stream_settings = NULL; + _revive_policy = NULL; } Controller::Call::Call(Controller::Call* rhs) @@ -996,7 +997,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { } else { LoadBalancer::SelectIn sel_in = { start_realtime_us, true, - has_request_code(), _request_code, _accessed }; + has_request_code(), _request_code, _accessed, _revive_policy }; LoadBalancer::SelectOut sel_out(&tmp_sock); const int rc = _lb->SelectServer(sel_in, &sel_out); if (rc != 0) { diff --git a/src/brpc/controller.h b/src/brpc/controller.h index 6e896819..a34164f7 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -41,6 +41,7 @@ #include "brpc/progressive_attachment.h" // ProgressiveAttachment #include "brpc/progressive_reader.h" // ProgressiveReader #include "brpc/grpc.h" +#include "brpc/revive_policy.h" // EAUTH is defined in MAC #ifndef EAUTH @@ -715,6 +716,7 @@ private: uint64_t _request_code; SocketId _single_server_id; butil::intrusive_ptr _lb; + RevivePolicy* _revive_policy; // for passing parameters to created bthread, don't modify it otherwhere. CompletionInfo _tmp_completion_info; diff --git a/src/brpc/details/naming_service_thread.h b/src/brpc/details/naming_service_thread.h index 01c5c85c..570e4c11 100644 --- a/src/brpc/details/naming_service_thread.h +++ b/src/brpc/details/naming_service_thread.h @@ -42,12 +42,14 @@ public: struct GetNamingServiceThreadOptions { GetNamingServiceThreadOptions() : succeed_without_server(false) - , log_succeed_without_server(true) {} + , log_succeed_without_server(true) + , minimum_working_instances(-1) {} bool succeed_without_server; bool log_succeed_without_server; ChannelSignature channel_signature; std::shared_ptr ssl_ctx; + int64_t minimum_working_instances; }; // A dedicated thread to map a name to ServerIds diff --git a/src/brpc/errno.proto b/src/brpc/errno.proto index 71331bb0..712a63f3 100644 --- a/src/brpc/errno.proto +++ b/src/brpc/errno.proto @@ -23,6 +23,7 @@ enum Errno { EUNUSED = 1015; // The socket was not needed ESSL = 1016; // SSL related error EH2RUNOUTSTREAMS = 1017; // The H2 socket was run out of streams + EREJECT = 1018; // The Request is rejected // Errno caused by server EINTERNAL = 2001; // Internal Server Error diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index 8b4e56de..c994a973 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -24,9 +24,7 @@ #include "brpc/shared_object.h" // SharedObject #include "brpc/server_id.h" // ServerId #include "brpc/extension.h" // Extension -#include "butil/strings/string_piece.h" -#include "butil/strings/string_split.h" - +#include "brpc/revive_policy.h" namespace brpc { @@ -42,6 +40,7 @@ public: bool has_request_code; uint64_t request_code; const ExcludedServers* excluded; + RevivePolicy* revive_policy; }; struct SelectOut { diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 2fb64e37..db9ee621 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -110,7 +110,10 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (n == 0) { return ENODATA; } - + if (in.revive_policy && + (in.revive_policy)->RejectDuringReviving(s->server_list)) { + return EREJECT; + } uint32_t stride = 0; size_t offset = butil::fast_rand_less_than(n); for (size_t i = 0; i < n; ++i) { @@ -129,6 +132,9 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { // this failed server won't be visited again inside for offset = (offset + stride) % n; } + if (in.revive_policy) { + in.revive_policy->StartRevive(); + } // After we traversed the whole server list, there is still no // available server return EHOSTDOWN; diff --git a/src/brpc/policy/randomized_load_balancer.h b/src/brpc/policy/randomized_load_balancer.h index 9fb0d6d3..a5c57d35 100644 --- a/src/brpc/policy/randomized_load_balancer.h +++ b/src/brpc/policy/randomized_load_balancer.h @@ -31,6 +31,12 @@ namespace policy { // than RoundRobinLoadBalancer. class RandomizedLoadBalancer : public LoadBalancer { public: + RandomizedLoadBalancer() + : _reviving(false) + //TODO(zhujiashun) + , _minimum_working_instances(2) + , _last_usable(0) + , _last_usable_change_time_ms(0) {} bool AddServer(const ServerId& id); bool RemoveServer(const ServerId& id); size_t AddServersInBatch(const std::vector& servers); @@ -51,6 +57,13 @@ private: static size_t BatchRemove(Servers& bg, const std::vector& servers); butil::DoublyBufferedData _db_servers; + bool _reviving; + int64_t _minimum_working_instances; + + // TODO(zhujiashun): remove mutex + butil::Mutex _mutex; + int64_t _last_usable; + int64_t _last_usable_change_time_ms; }; } // namespace policy diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 095954f7..1bd3e60e 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -110,6 +110,10 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (n == 0) { return ENODATA; } + if (in.revive_policy && + (in.revive_policy)->RejectDuringReviving(s->server_list)) { + return EREJECT; + } TLS tls = s.tls(); if (tls.stride == 0) { tls.stride = GenRandomStride(); @@ -127,6 +131,9 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { return 0; } } + if (in.revive_policy) { + in.revive_policy->StartRevive(); + } s.tls() = tls; return EHOSTDOWN; } diff --git a/src/brpc/revive_policy.cpp b/src/brpc/revive_policy.cpp new file mode 100644 index 00000000..89fd2e67 --- /dev/null +++ b/src/brpc/revive_policy.cpp @@ -0,0 +1,78 @@ +// Copyright (c) 2014 Baidu, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Authors: Jiashun Zhu(zhujiashun@bilibili.com) + +#include +#include "brpc/revive_policy.h" +#include "butil/scoped_lock.h" +#include "butil/synchronization/lock.h" +#include "brpc/server_id.h" +#include "brpc/socket.h" +#include "butil/fast_rand.h" +#include "butil/time.h" + +namespace brpc { + +DefaultRevivePolicy::DefaultRevivePolicy( + int64_t minimum_working_instances, int64_t hold_time_ms) + : _reviving(false) + , _minimum_working_instances(minimum_working_instances) + , _last_usable(0) + , _last_usable_change_time_ms(0) + , _hold_time_ms(hold_time_ms) { } + + +void DefaultRevivePolicy::StartRevive() { + _reviving = true; +} + +bool DefaultRevivePolicy::RejectDuringReviving( + const std::vector& server_list) { + if (!_reviving) { + return false; + } + size_t n = server_list.size(); + int usable = 0; + // TODO(zhujiashun): optimize looking process + SocketUniquePtr ptr; + for (size_t i = 0; i < n; ++i) { + if (Socket::Address(server_list[i].id, &ptr) == 0 + && !ptr->IsLogOff()) { + usable++; + } + } + std::unique_lock mu(_mutex); + if (_last_usable_change_time_ms != 0 && usable != 0 && + (butil::gettimeofday_ms() - _last_usable_change_time_ms > _hold_time_ms) + && _last_usable == usable) { + _reviving = false; + _last_usable_change_time_ms = 0; + mu.unlock(); + } else { + if (_last_usable != usable) { + _last_usable = usable; + _last_usable_change_time_ms = butil::gettimeofday_ms(); + } + mu.unlock(); + int rand = butil::fast_rand_less_than(_minimum_working_instances); + if (rand >= usable) { + return true; + } + } + return false; +} + +} // namespace brpc + diff --git a/src/brpc/revive_policy.h b/src/brpc/revive_policy.h new file mode 100644 index 00000000..19b4f203 --- /dev/null +++ b/src/brpc/revive_policy.h @@ -0,0 +1,53 @@ +// Copyright (c) 2014 Baidu, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Authors: Jiashun Zhu(zhujiashun@bilibili.com) + +#ifndef BRPC_REVIVE_POLICY +#define BRPC_REVIVE_POLICY + +#include +#include + +namespace brpc { + +class ServerId; +class RevivePolicy { +public: + // TODO(zhujiashun): + + virtual void StartRevive() = 0; + virtual bool RejectDuringReviving(const std::vector& server_list) = 0; +}; + +class DefaultRevivePolicy : public RevivePolicy { +public: + DefaultRevivePolicy(int64_t minimum_working_instances, int64_t hold_time_ms); + + void StartRevive() override; + bool RejectDuringReviving(const std::vector& server_list) override; + +private: + bool _reviving; + int64_t _minimum_working_instances; + butil::Mutex _mutex; + int64_t _last_usable; + int64_t _last_usable_change_time_ms; + int64_t _hold_time_ms; +}; + +} // namespace brpc + +#endif + diff --git a/src/brpc/selective_channel.cpp b/src/brpc/selective_channel.cpp index 2c495eb7..ae468698 100644 --- a/src/brpc/selective_channel.cpp +++ b/src/brpc/selective_channel.cpp @@ -290,7 +290,8 @@ int Sender::IssueRPC(int64_t start_realtime_us) { true, _main_cntl->has_request_code(), _main_cntl->_request_code, - _main_cntl->_accessed }; + _main_cntl->_accessed, + NULL }; ChannelBalancer::SelectOut sel_out; const int rc = static_cast(_main_cntl->_lb.get()) ->SelectChannel(sel_in, &sel_out); diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index f1fbc7a4..9398dda2 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -22,8 +22,15 @@ #include "brpc/policy/locality_aware_load_balancer.h" #include "brpc/policy/consistent_hashing_load_balancer.h" #include "brpc/policy/hasher.h" +#include "brpc/errno.pb.h" +#include "echo.pb.h" +#include "brpc/channel.h" +#include "brpc/controller.h" +#include "brpc/server.h" +#include "brpc/revive_policy.h" namespace brpc { +DECLARE_int32(health_check_interval); namespace policy { extern uint32_t CRCHash32(const char *key, size_t len); extern const char* GetHashName(uint32_t (*hasher)(const void* key, size_t len)); @@ -206,7 +213,7 @@ void* select_server(void* arg) { brpc::LoadBalancer* c = sa->lb; brpc::SocketUniquePtr ptr; CountMap *selected_count = new CountMap; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); uint32_t rand_seed = rand(); if (sa->hash) { @@ -259,7 +266,7 @@ TEST_F(LoadBalancerTest, update_while_selection) { // Accessing empty lb should result in error. brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, NULL, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); ASSERT_EQ(ENODATA, lb->SelectServer(in, &out)); @@ -562,7 +569,7 @@ TEST_F(LoadBalancerTest, consistent_hashing) { const size_t SELECT_TIMES = 1000000; std::map times; brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, NULL }; ::brpc::LoadBalancer::SelectOut out(&ptr); for (size_t i = 0; i < SELECT_TIMES; ++i) { in.has_request_code = true; @@ -639,7 +646,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) { // consistent with weight configured. std::map select_result; brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); int total_weight = 12; std::vector select_servers; @@ -697,7 +704,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin_no_valid_server) { // The first socket is excluded. The second socket is logfoff. // The third socket is invalid. brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, exclude }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, exclude, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); EXPECT_EQ(EHOSTDOWN, wrrlb.SelectServer(in, &out)); brpc::ExcludedServers::Destroy(exclude); @@ -708,7 +715,6 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { "10.92.115.19:8832", "10.42.122.201:8833", }; - std::vector lbs; lbs.push_back(new brpc::policy::RoundRobinLoadBalancer); lbs.push_back(new brpc::policy::RandomizedLoadBalancer); @@ -782,4 +788,186 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { } } +TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { + brpc::LoadBalancer* lb = new brpc::policy::RandomizedLoadBalancer; + brpc::SocketUniquePtr ptr[2]; + for (size_t i = 0; i < ARRAY_SIZE(servers); ++i) { + butil::EndPoint dummy; + ASSERT_EQ(0, str2endpoint(servers[i], &dummy)); + brpc::SocketOptions options; + options.remote_side = dummy; + brpc::ServerId id(8888); + ASSERT_EQ(0, brpc::Socket::Create(options, &id.id)); + ASSERT_EQ(0, brpc::Socket::Address(id.id, &ptr[i])); + lb->AddServer(id); + } + brpc::SocketUniquePtr sptr; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, NULL }; + brpc::LoadBalancer::SelectOut out(&sptr); + ASSERT_EQ(0, lb->SelectServer(in, &out)); + + ptr[0]->SetFailed(); + ptr[1]->SetFailed(); + ASSERT_EQ(EHOSTDOWN, lb->SelectServer(in, &out)); + // should reject all request since there is no available server + for (int i = 0; i < 10; ++i) { + ASSERT_EQ(brpc::EREJECT, lb->SelectServer(in, &out)); + } + { + brpc::SocketUniquePtr dummy_ptr; + ASSERT_EQ(1, brpc::Socket::AddressFailedAsWell(ptr[0]->id(), &dummy_ptr)); + dummy_ptr->Revive(); + } + // After one server is revived, the reject rate should be 50% + int num_ereject = 0; + int num_ok = 0; + for (int i = 0; i < 100; ++i) { + int rc = lb->SelectServer(in, &out); + if (rc == brpc::EREJECT) { + num_ereject++; + } else if (rc == 0) { + num_ok++; + } else { + ASSERT_TRUE(false); + } + } + ASSERT_TRUE(abs(num_ereject - num_ok) < 20); + // TODO(zhujiashun): longer than interval + int64_t sleep_time_ms = 2010; + bthread_usleep(sleep_time_ms * 1000); + + // After enough waiting time, traffic should be sent to all available servers. + for (int i = 0; i < 10; ++i) { + ASSERT_EQ(0, lb->SelectServer(in, &out)); + } +} + +class EchoServiceImpl : public test::EchoService { +public: + EchoServiceImpl() + : _num_request(0) {} + virtual ~EchoServiceImpl() {} + virtual void Echo(google::protobuf::RpcController* cntl_base, + const test::EchoRequest* req, + test::EchoResponse* res, + google::protobuf::Closure* done) { + //brpc::Controller* cntl = + // static_cast(cntl_base); + brpc::ClosureGuard done_guard(done); + int p = _num_request.fetch_add(1, butil::memory_order_relaxed); + // max qps is 50 + if (p < 70) { + bthread_usleep(100 * 1000); + _num_request.fetch_sub(1, butil::memory_order_relaxed); + res->set_message("OK"); + } else { + _num_request.fetch_sub(1, butil::memory_order_relaxed); + bthread_usleep(1000 * 1000); + } + return; + } + + butil::atomic _num_request; +}; + +class Done : public google::protobuf::Closure { +public: + Done() + : num_failed(NULL) + , num_reject(NULL) {} + void Run() { + if (cntl.Failed()) { + if (num_failed) { + num_failed->fetch_add(1, butil::memory_order_relaxed); + } + if (cntl.ErrorCode() == brpc::EREJECT && num_reject) { + num_reject->fetch_add(1, butil::memory_order_relaxed); + } + } + } + + brpc::Controller cntl; + test::EchoRequest req; + test::EchoResponse res; + butil::atomic* num_failed; + butil::atomic* num_reject; +}; + +TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { + GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_size", "20"); + GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_error_percent", "30"); + GFLAGS_NS::SetCommandLineOption("circuit_breaker_max_isolation_duration_ms", "5000"); + + + char* lb_algo[] = { "rr" , "random" }; + + + brpc::Channel channel; + brpc::ChannelOptions options; + options.protocol = "http"; + options.timeout_ms = 300; + options.enable_circuit_breaker = true; + options.revive_policy = new brpc::DefaultRevivePolicy(2, 2000 /*2s*/); + // Set max_retry to 0 so that health check of servers + // are not continuous. + options.max_retry = 0; + + ASSERT_EQ(channel.Init("list://127.0.0.1:7777,127.0.0.1:7778", + lb_algo[butil::fast_rand_less_than(ARRAY_SIZE(lb_algo))], + &options), 0); + + test::EchoRequest req; + req.set_message("123"); + test::EchoResponse res; + test::EchoService_Stub stub(&channel); + // trigger one server to health check + { + brpc::Controller cntl; + stub.Echo(&cntl, &req, &res, NULL); + } + bthread_usleep(500000); + // trigger the other server to health check + { + brpc::Controller cntl; + stub.Echo(&cntl, &req, &res, NULL); + } + bthread_usleep(500000); + + butil::EndPoint point(butil::IP_ANY, 7777); + brpc::Server server; + EchoServiceImpl service; + ASSERT_EQ(0, server.AddService(&service, brpc::SERVER_DOESNT_OWN_SERVICE)); + ASSERT_EQ(0, server.Start(point, NULL)); + + butil::EndPoint point2(butil::IP_ANY, 7778); + brpc::Server server2; + EchoServiceImpl service2; + ASSERT_EQ(0, server2.AddService(&service2, brpc::SERVER_DOESNT_OWN_SERVICE)); + ASSERT_EQ(0, server2.Start(point2, NULL)); + + int64_t start_ms = butil::gettimeofday_ms(); + butil::atomic num_reject(0); + while ((butil::gettimeofday_ms() - start_ms) < + brpc::FLAGS_health_check_interval * 1000 + 10) { + Done* done = new Done; + done->num_reject = &num_reject; + done->req.set_message("123"); + stub.Echo(&done->cntl, &done->req, &done->res, done); + bthread_usleep(1000); + } + + // should recover now + butil::atomic num_failed(0); + for (int i = 0; i < 1000; ++i) { + Done* done = new Done; + done->req.set_message("123"); + done->num_failed = &num_failed; + stub.Echo(&done->cntl, &done->req, &done->res, done); + bthread_usleep(1000); + } + bthread_usleep(1050*1000 /* sleep longer than timeout of service */); + ASSERT_EQ(0, num_failed.load(butil::memory_order_relaxed)); + ASSERT_TRUE(num_reject.load(butil::memory_order_relaxed) > 1500); +} + } //namespace From 593082c446971a9c4f58b6ff36bb087f8ad9770e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 3 Apr 2019 16:40:29 +0800 Subject: [PATCH 131/270] revived_from_all_failed: refine comments and UT --- src/brpc/channel.h | 5 +- .../consistent_hashing_load_balancer.cpp | 17 ++++++ .../policy/locality_aware_load_balancer.cpp | 3 +- src/brpc/policy/randomized_load_balancer.cpp | 13 +++-- src/brpc/policy/randomized_load_balancer.h | 13 ----- src/brpc/policy/round_robin_load_balancer.cpp | 13 +++-- .../weighted_round_robin_load_balancer.cpp | 16 ++++++ src/brpc/revive_policy.cpp | 52 +++++++++++-------- src/brpc/revive_policy.h | 30 +++++++++-- test/brpc_load_balancer_unittest.cpp | 19 ++++--- 10 files changed, 122 insertions(+), 59 deletions(-) diff --git a/src/brpc/channel.h b/src/brpc/channel.h index a6492074..9379413a 100644 --- a/src/brpc/channel.h +++ b/src/brpc/channel.h @@ -129,7 +129,10 @@ struct ChannelOptions { // Default: "" std::string connection_group; - // TODO(zhujiashun) + // Customize the revive policy after all servers are shutdown. The + // interface is defined in src/brpc/revive_policy.h + // This object is NOT owned by channel and should remain valid when + // channel is used. // Default: NULL RevivePolicy* revive_policy; diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 8baacee1..5205c6f4 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -302,6 +302,20 @@ int ConsistentHashingLoadBalancer::SelectServer( if (s->empty()) { return ENODATA; } + RevivePolicy* rp = in.revive_policy; + if (rp) { + std::set server_list; + for (auto server: *s) { + server_list.insert(server.server_sock); + } + std::vector server_list_distinct( + server_list.begin(), server_list.end()); + if (rp->DoReject(server_list_distinct)) { + return EREJECT; + } + rp->StopRevivingIfNecessary(); + } + std::vector::const_iterator choice = std::lower_bound(s->begin(), s->end(), (uint32_t)in.request_code); if (choice == s->end()) { @@ -319,6 +333,9 @@ int ConsistentHashingLoadBalancer::SelectServer( } } } + if (rp) { + rp->StartReviving(); + } return EHOSTDOWN; } diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index 7fe9f6bd..22a3ca2b 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -22,7 +22,7 @@ #include "brpc/socket.h" #include "brpc/reloadable_flags.h" #include "brpc/policy/locality_aware_load_balancer.h" - +#include "brpc/revive_policy.h" namespace brpc { namespace policy { @@ -270,7 +270,6 @@ int LocalityAwareLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) if (n == 0) { return ENODATA; } - size_t ntry = 0; size_t nloop = 0; int64_t total = _total.load(butil::memory_order_relaxed); diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index db9ee621..0ade3edd 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -110,9 +110,12 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (n == 0) { return ENODATA; } - if (in.revive_policy && - (in.revive_policy)->RejectDuringReviving(s->server_list)) { - return EREJECT; + RevivePolicy* rp = in.revive_policy; + if (rp) { + if (rp->DoReject(s->server_list)) { + return EREJECT; + } + rp->StopRevivingIfNecessary(); } uint32_t stride = 0; size_t offset = butil::fast_rand_less_than(n); @@ -132,8 +135,8 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { // this failed server won't be visited again inside for offset = (offset + stride) % n; } - if (in.revive_policy) { - in.revive_policy->StartRevive(); + if (rp) { + rp->StartReviving(); } // After we traversed the whole server list, there is still no // available server diff --git a/src/brpc/policy/randomized_load_balancer.h b/src/brpc/policy/randomized_load_balancer.h index a5c57d35..9fb0d6d3 100644 --- a/src/brpc/policy/randomized_load_balancer.h +++ b/src/brpc/policy/randomized_load_balancer.h @@ -31,12 +31,6 @@ namespace policy { // than RoundRobinLoadBalancer. class RandomizedLoadBalancer : public LoadBalancer { public: - RandomizedLoadBalancer() - : _reviving(false) - //TODO(zhujiashun) - , _minimum_working_instances(2) - , _last_usable(0) - , _last_usable_change_time_ms(0) {} bool AddServer(const ServerId& id); bool RemoveServer(const ServerId& id); size_t AddServersInBatch(const std::vector& servers); @@ -57,13 +51,6 @@ private: static size_t BatchRemove(Servers& bg, const std::vector& servers); butil::DoublyBufferedData _db_servers; - bool _reviving; - int64_t _minimum_working_instances; - - // TODO(zhujiashun): remove mutex - butil::Mutex _mutex; - int64_t _last_usable; - int64_t _last_usable_change_time_ms; }; } // namespace policy diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 1bd3e60e..3190282d 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -110,9 +110,12 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (n == 0) { return ENODATA; } - if (in.revive_policy && - (in.revive_policy)->RejectDuringReviving(s->server_list)) { - return EREJECT; + RevivePolicy* rp = in.revive_policy; + if (rp) { + if (rp->DoReject(s->server_list)) { + return EREJECT; + } + rp->StopRevivingIfNecessary(); } TLS tls = s.tls(); if (tls.stride == 0) { @@ -131,8 +134,8 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { return 0; } } - if (in.revive_policy) { - in.revive_policy->StartRevive(); + if (rp) { + rp->StartReviving(); } s.tls() = tls; return EHOSTDOWN; diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index 5b977820..902b4b6e 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -20,6 +20,7 @@ #include "brpc/socket.h" #include "brpc/policy/weighted_round_robin_load_balancer.h" #include "butil/strings/string_number_conversions.h" +#include "brpc/revive_policy.h" namespace { @@ -157,6 +158,18 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* if (s->server_list.empty()) { return ENODATA; } + RevivePolicy* rp = in.revive_policy; + if (rp) { + std::vector server_list; + server_list.reserve(s->server_list.size()); + for (auto server: s->server_list) { + server_list.emplace_back(server.id); + } + if (rp->DoReject(server_list)) { + return EREJECT; + } + rp->StopRevivingIfNecessary(); + } TLS& tls = s.tls(); if (tls.IsNeededCaculateNewStride(s->weight_sum, s->server_list.size())) { if (tls.stride == 0) { @@ -198,6 +211,9 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* tls_temp.remain_server = tls.remain_server; } } + if (rp) { + rp->StartReviving(); + } return EHOSTDOWN; } diff --git a/src/brpc/revive_policy.cpp b/src/brpc/revive_policy.cpp index 89fd2e67..f2a1f5e7 100644 --- a/src/brpc/revive_policy.cpp +++ b/src/brpc/revive_policy.cpp @@ -34,45 +34,55 @@ DefaultRevivePolicy::DefaultRevivePolicy( , _hold_time_ms(hold_time_ms) { } -void DefaultRevivePolicy::StartRevive() { +void DefaultRevivePolicy::StartReviving() { + std::unique_lock mu(_mutex); _reviving = true; } -bool DefaultRevivePolicy::RejectDuringReviving( - const std::vector& server_list) { - if (!_reviving) { - return false; +void DefaultRevivePolicy::StopRevivingIfNecessary() { + int64_t now_ms = butil::gettimeofday_ms(); + { + std::unique_lock mu(_mutex); + if (_last_usable_change_time_ms != 0 && _last_usable != 0 && + (now_ms - _last_usable_change_time_ms > _hold_time_ms)) { + _reviving = false; + _last_usable_change_time_ms = 0; + } + } + return; +} + +bool DefaultRevivePolicy::DoReject(const std::vector& server_list) { + { + std::unique_lock mu(_mutex); + if (!_reviving) { + mu.unlock(); + return false; + } } size_t n = server_list.size(); int usable = 0; - // TODO(zhujiashun): optimize looking process SocketUniquePtr ptr; + // TODO(zhujiashun): optimize O(N) for (size_t i = 0; i < n; ++i) { if (Socket::Address(server_list[i].id, &ptr) == 0 && !ptr->IsLogOff()) { usable++; } } - std::unique_lock mu(_mutex); - if (_last_usable_change_time_ms != 0 && usable != 0 && - (butil::gettimeofday_ms() - _last_usable_change_time_ms > _hold_time_ms) - && _last_usable == usable) { - _reviving = false; - _last_usable_change_time_ms = 0; - mu.unlock(); - } else { + int64_t now_ms = butil::gettimeofday_ms(); + { + std::unique_lock mu(_mutex); if (_last_usable != usable) { _last_usable = usable; - _last_usable_change_time_ms = butil::gettimeofday_ms(); - } - mu.unlock(); - int rand = butil::fast_rand_less_than(_minimum_working_instances); - if (rand >= usable) { - return true; + _last_usable_change_time_ms = now_ms; } } + int rand = butil::fast_rand_less_than(_minimum_working_instances); + if (rand >= usable) { + return true; + } return false; } } // namespace brpc - diff --git a/src/brpc/revive_policy.h b/src/brpc/revive_policy.h index 19b4f203..e1fb8113 100644 --- a/src/brpc/revive_policy.h +++ b/src/brpc/revive_policy.h @@ -23,20 +23,40 @@ namespace brpc { class ServerId; + +// After all servers are shutdown and health check happens, servers are +// online one by one. Once one server is up, all the request that should +// be sent to all servers, would be sent to one server, which may be a +// disastrous behaviour. In the worst case it would cause the server shutdown +// again if circuit breaker is enabled and the server cluster would never +// recover. This class controls the amount of requests that sent to the revived +// servers when recovering from all servers are shutdown. class RevivePolicy { public: - // TODO(zhujiashun): + // Indicate that reviving from the shutdown of all server is happening. + virtual void StartReviving() = 0; - virtual void StartRevive() = 0; - virtual bool RejectDuringReviving(const std::vector& server_list) = 0; + // Return true if some customized policies are satisfied. + virtual bool DoReject(const std::vector& server_list) = 0; + + // Stop reviving state and do not reject the request if some condition is + // satisfied. + virtual void StopRevivingIfNecessary() = 0; }; +// The default revive policy. Once no servers are available, reviving is start. +// If in reviving state, the probability that a request is accepted is q/n, in +// which q is the number of current available server, n is the number of minimum +// working instances setting by user. If q is not changed during a given time, +// hold_time_ms, then the cluster is considered recovered and all the request +// would be sent to the current available servers. class DefaultRevivePolicy : public RevivePolicy { public: DefaultRevivePolicy(int64_t minimum_working_instances, int64_t hold_time_ms); - void StartRevive() override; - bool RejectDuringReviving(const std::vector& server_list) override; + void StartReviving(); + bool DoReject(const std::vector& server_list); + void StopRevivingIfNecessary(); private: bool _reviving; diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 9398dda2..304bd32e 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -884,6 +884,7 @@ public: num_reject->fetch_add(1, butil::memory_order_relaxed); } } + delete this; } brpc::Controller cntl; @@ -898,24 +899,22 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_error_percent", "30"); GFLAGS_NS::SetCommandLineOption("circuit_breaker_max_isolation_duration_ms", "5000"); - - char* lb_algo[] = { "rr" , "random" }; - - + const char* lb_algo[] = { "rr" , "random", "wrr", "c_murmurhash" }; brpc::Channel channel; brpc::ChannelOptions options; options.protocol = "http"; options.timeout_ms = 300; options.enable_circuit_breaker = true; options.revive_policy = new brpc::DefaultRevivePolicy(2, 2000 /*2s*/); - // Set max_retry to 0 so that health check of servers + // Set max_retry to 0 so that the time of health check of different servers // are not continuous. options.max_retry = 0; - ASSERT_EQ(channel.Init("list://127.0.0.1:7777,127.0.0.1:7778", + ASSERT_EQ(channel.Init("list://127.0.0.1:7777 50,127.0.0.1:7778 50", lb_algo[butil::fast_rand_less_than(ARRAY_SIZE(lb_algo))], &options), 0); + uint64_t request_code = 0; test::EchoRequest req; req.set_message("123"); test::EchoResponse res; @@ -923,12 +922,14 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { // trigger one server to health check { brpc::Controller cntl; + cntl.set_request_code(brpc::policy::MurmurHash32(&++request_code, 8)); stub.Echo(&cntl, &req, &res, NULL); } bthread_usleep(500000); // trigger the other server to health check { brpc::Controller cntl; + cntl.set_request_code(brpc::policy::MurmurHash32(&++request_code, 8)); stub.Echo(&cntl, &req, &res, NULL); } bthread_usleep(500000); @@ -947,14 +948,18 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { int64_t start_ms = butil::gettimeofday_ms(); butil::atomic num_reject(0); + int64_t q = 0; while ((butil::gettimeofday_ms() - start_ms) < brpc::FLAGS_health_check_interval * 1000 + 10) { Done* done = new Done; done->num_reject = &num_reject; done->req.set_message("123"); + done->cntl.set_request_code(brpc::policy::MurmurHash32(&++request_code, 8)); stub.Echo(&done->cntl, &done->req, &done->res, done); + q++; bthread_usleep(1000); } + ASSERT_TRUE(num_reject.load(butil::memory_order_relaxed) > 1700); // should recover now butil::atomic num_failed(0); @@ -962,12 +967,12 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { Done* done = new Done; done->req.set_message("123"); done->num_failed = &num_failed; + done->cntl.set_request_code(brpc::policy::MurmurHash32(&++request_code, 8)); stub.Echo(&done->cntl, &done->req, &done->res, done); bthread_usleep(1000); } bthread_usleep(1050*1000 /* sleep longer than timeout of service */); ASSERT_EQ(0, num_failed.load(butil::memory_order_relaxed)); - ASSERT_TRUE(num_reject.load(butil::memory_order_relaxed) > 1500); } } //namespace From b17bcc8b75ff8be041b0252ba6d164e0fa6b128b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 3 Apr 2019 17:27:37 +0800 Subject: [PATCH 132/270] revived_from_all_failed: fix UT --- .../consistent_hashing_load_balancer.cpp | 3 +-- src/brpc/policy/randomized_load_balancer.cpp | 3 +-- src/brpc/policy/round_robin_load_balancer.cpp | 3 +-- .../weighted_round_robin_load_balancer.cpp | 3 +-- src/brpc/revive_policy.cpp | 10 ++++++-- src/brpc/revive_policy.h | 5 ++-- test/brpc_load_balancer_unittest.cpp | 25 +++++++++++++------ 7 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 5205c6f4..9a08a3a9 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -303,7 +303,7 @@ int ConsistentHashingLoadBalancer::SelectServer( return ENODATA; } RevivePolicy* rp = in.revive_policy; - if (rp) { + if (rp && rp->StopRevivingIfNecessary()) { std::set server_list; for (auto server: *s) { server_list.insert(server.server_sock); @@ -313,7 +313,6 @@ int ConsistentHashingLoadBalancer::SelectServer( if (rp->DoReject(server_list_distinct)) { return EREJECT; } - rp->StopRevivingIfNecessary(); } std::vector::const_iterator choice = diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 0ade3edd..522aea91 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -111,11 +111,10 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { return ENODATA; } RevivePolicy* rp = in.revive_policy; - if (rp) { + if (rp && rp->StopRevivingIfNecessary()) { if (rp->DoReject(s->server_list)) { return EREJECT; } - rp->StopRevivingIfNecessary(); } uint32_t stride = 0; size_t offset = butil::fast_rand_less_than(n); diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 3190282d..67e474b7 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -111,11 +111,10 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { return ENODATA; } RevivePolicy* rp = in.revive_policy; - if (rp) { + if (rp && rp->StopRevivingIfNecessary()) { if (rp->DoReject(s->server_list)) { return EREJECT; } - rp->StopRevivingIfNecessary(); } TLS tls = s.tls(); if (tls.stride == 0) { diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index 902b4b6e..daacc656 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -159,7 +159,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* return ENODATA; } RevivePolicy* rp = in.revive_policy; - if (rp) { + if (rp && rp->StopRevivingIfNecessary()) { std::vector server_list; server_list.reserve(s->server_list.size()); for (auto server: s->server_list) { @@ -168,7 +168,6 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* if (rp->DoReject(server_list)) { return EREJECT; } - rp->StopRevivingIfNecessary(); } TLS& tls = s.tls(); if (tls.IsNeededCaculateNewStride(s->weight_sum, s->server_list.size())) { diff --git a/src/brpc/revive_policy.cpp b/src/brpc/revive_policy.cpp index f2a1f5e7..0a76e264 100644 --- a/src/brpc/revive_policy.cpp +++ b/src/brpc/revive_policy.cpp @@ -39,17 +39,23 @@ void DefaultRevivePolicy::StartReviving() { _reviving = true; } -void DefaultRevivePolicy::StopRevivingIfNecessary() { +bool DefaultRevivePolicy::StopRevivingIfNecessary() { int64_t now_ms = butil::gettimeofday_ms(); { std::unique_lock mu(_mutex); + if (!_reviving) { + mu.unlock(); + return false; + } if (_last_usable_change_time_ms != 0 && _last_usable != 0 && (now_ms - _last_usable_change_time_ms > _hold_time_ms)) { _reviving = false; _last_usable_change_time_ms = 0; + mu.unlock(); + return false; } } - return; + return true; } bool DefaultRevivePolicy::DoReject(const std::vector& server_list) { diff --git a/src/brpc/revive_policy.h b/src/brpc/revive_policy.h index e1fb8113..0104e0ab 100644 --- a/src/brpc/revive_policy.h +++ b/src/brpc/revive_policy.h @@ -41,7 +41,8 @@ public: // Stop reviving state and do not reject the request if some condition is // satisfied. - virtual void StopRevivingIfNecessary() = 0; + // Return true if the current state is still in reviving. + virtual bool StopRevivingIfNecessary() = 0; }; // The default revive policy. Once no servers are available, reviving is start. @@ -56,7 +57,7 @@ public: void StartReviving(); bool DoReject(const std::vector& server_list); - void StopRevivingIfNecessary(); + bool StopRevivingIfNecessary(); private: bool _reviving; diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 304bd32e..7271dc3e 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -789,7 +789,18 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { } TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { - brpc::LoadBalancer* lb = new brpc::policy::RandomizedLoadBalancer; + brpc::LoadBalancer* lb = NULL; + int rand = butil::fast_rand_less_than(4); + if (rand == 0) { + lb = new brpc::policy::RoundRobinLoadBalancer; + } else if (rand == 1) { + lb = new brpc::policy::RandomizedLoadBalancer; + } else if (rand == 2) { + lb = new brpc::policy::WeightedRoundRobinLoadBalancer; + } else { + lb = new brpc::policy::ConsistentHashingLoadBalancer(brpc::policy::MurmurHash32); + } + LOG(INFO) << "r=" << rand; brpc::SocketUniquePtr ptr[2]; for (size_t i = 0; i < ARRAY_SIZE(servers); ++i) { butil::EndPoint dummy; @@ -797,12 +808,15 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { brpc::SocketOptions options; options.remote_side = dummy; brpc::ServerId id(8888); + id.tag = "50"; ASSERT_EQ(0, brpc::Socket::Create(options, &id.id)); ASSERT_EQ(0, brpc::Socket::Address(id.id, &ptr[i])); lb->AddServer(id); } brpc::SocketUniquePtr sptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, NULL }; + int64_t hold_time_ms = 2000; + brpc::RevivePolicy* rp = new brpc::DefaultRevivePolicy(2, hold_time_ms); + brpc::LoadBalancer::SelectIn in = { 0, false, true, 0u, NULL, rp }; brpc::LoadBalancer::SelectOut out(&sptr); ASSERT_EQ(0, lb->SelectServer(in, &out)); @@ -831,10 +845,8 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { ASSERT_TRUE(false); } } - ASSERT_TRUE(abs(num_ereject - num_ok) < 20); - // TODO(zhujiashun): longer than interval - int64_t sleep_time_ms = 2010; - bthread_usleep(sleep_time_ms * 1000); + ASSERT_TRUE(abs(num_ereject - num_ok) < 30); + bthread_usleep((hold_time_ms + 10) * 1000); // After enough waiting time, traffic should be sent to all available servers. for (int i = 0; i < 10; ++i) { @@ -932,7 +944,6 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { cntl.set_request_code(brpc::policy::MurmurHash32(&++request_code, 8)); stub.Echo(&cntl, &req, &res, NULL); } - bthread_usleep(500000); butil::EndPoint point(butil::IP_ANY, 7777); brpc::Server server; From 890679ec6729a9a7573aa19a8db85b0bc2fb7415 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 3 Apr 2019 17:40:10 +0800 Subject: [PATCH 133/270] revived_from_all_failed: refine comments --- test/brpc_load_balancer_unittest.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 7271dc3e..4ea79180 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -800,7 +800,6 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { } else { lb = new brpc::policy::ConsistentHashingLoadBalancer(brpc::policy::MurmurHash32); } - LOG(INFO) << "r=" << rand; brpc::SocketUniquePtr ptr[2]; for (size_t i = 0; i < ARRAY_SIZE(servers); ++i) { butil::EndPoint dummy; @@ -867,7 +866,7 @@ public: // static_cast(cntl_base); brpc::ClosureGuard done_guard(done); int p = _num_request.fetch_add(1, butil::memory_order_relaxed); - // max qps is 50 + // concurrency in normal case is 50 if (p < 70) { bthread_usleep(100 * 1000); _num_request.fetch_sub(1, butil::memory_order_relaxed); From 6cb4475aca00b849e66679542f9a7f281adae4eb Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 3 Apr 2019 18:44:38 +0800 Subject: [PATCH 134/270] revived_from_all_failed: optimize get availble server process --- src/brpc/revive_policy.cpp | 42 ++++++++++++++++++---------- src/brpc/revive_policy.h | 5 ++++ test/brpc_load_balancer_unittest.cpp | 2 ++ 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/brpc/revive_policy.cpp b/src/brpc/revive_policy.cpp index 0a76e264..c3782596 100644 --- a/src/brpc/revive_policy.cpp +++ b/src/brpc/revive_policy.cpp @@ -15,6 +15,7 @@ // Authors: Jiashun Zhu(zhujiashun@bilibili.com) #include +#include #include "brpc/revive_policy.h" #include "butil/scoped_lock.h" #include "butil/synchronization/lock.h" @@ -25,14 +26,18 @@ namespace brpc { +DEFINE_int64(detect_available_server_interval_ms, 10, "The interval " + "to detect available server count in DefaultRevivePolicy"); + DefaultRevivePolicy::DefaultRevivePolicy( int64_t minimum_working_instances, int64_t hold_time_ms) : _reviving(false) , _minimum_working_instances(minimum_working_instances) , _last_usable(0) , _last_usable_change_time_ms(0) - , _hold_time_ms(hold_time_ms) { } - + , _hold_time_ms(hold_time_ms) + , _usable_cache(0) + , _usable_cache_time_ms(0) { } void DefaultRevivePolicy::StartReviving() { std::unique_lock mu(_mutex); @@ -41,12 +46,11 @@ void DefaultRevivePolicy::StartReviving() { bool DefaultRevivePolicy::StopRevivingIfNecessary() { int64_t now_ms = butil::gettimeofday_ms(); + if (!_reviving) { + return false; + } { std::unique_lock mu(_mutex); - if (!_reviving) { - mu.unlock(); - return false; - } if (_last_usable_change_time_ms != 0 && _last_usable != 0 && (now_ms - _last_usable_change_time_ms > _hold_time_ms)) { _reviving = false; @@ -58,25 +62,33 @@ bool DefaultRevivePolicy::StopRevivingIfNecessary() { return true; } -bool DefaultRevivePolicy::DoReject(const std::vector& server_list) { - { - std::unique_lock mu(_mutex); - if (!_reviving) { - mu.unlock(); - return false; - } +int DefaultRevivePolicy::GetUsableServerCount( + int64_t now_ms, const std::vector& server_list) { + if (now_ms - _usable_cache_time_ms < FLAGS_detect_available_server_interval_ms) { + return _usable_cache; } - size_t n = server_list.size(); int usable = 0; + size_t n = server_list.size(); SocketUniquePtr ptr; - // TODO(zhujiashun): optimize O(N) for (size_t i = 0; i < n; ++i) { if (Socket::Address(server_list[i].id, &ptr) == 0 && !ptr->IsLogOff()) { usable++; } } + std::unique_lock mu(_mutex); + _usable_cache = usable; + _usable_cache_time_ms = now_ms; + return _usable_cache; +} + + +bool DefaultRevivePolicy::DoReject(const std::vector& server_list) { + if (!_reviving) { + return false; + } int64_t now_ms = butil::gettimeofday_ms(); + int usable = GetUsableServerCount(now_ms, server_list); { std::unique_lock mu(_mutex); if (_last_usable != usable) { diff --git a/src/brpc/revive_policy.h b/src/brpc/revive_policy.h index 0104e0ab..ac0a3339 100644 --- a/src/brpc/revive_policy.h +++ b/src/brpc/revive_policy.h @@ -59,6 +59,9 @@ public: bool DoReject(const std::vector& server_list); bool StopRevivingIfNecessary(); +private: + int GetUsableServerCount(int64_t now_ms, const std::vector& server_list); + private: bool _reviving; int64_t _minimum_working_instances; @@ -66,6 +69,8 @@ private: int64_t _last_usable; int64_t _last_usable_change_time_ms; int64_t _hold_time_ms; + int64_t _usable_cache; + int64_t _usable_cache_time_ms; }; } // namespace brpc diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 4ea79180..c2471bbc 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -31,6 +31,7 @@ namespace brpc { DECLARE_int32(health_check_interval); +DECLARE_int64(detect_available_server_interval_ms); namespace policy { extern uint32_t CRCHash32(const char *key, size_t len); extern const char* GetHashName(uint32_t (*hasher)(const void* key, size_t len)); @@ -831,6 +832,7 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { ASSERT_EQ(1, brpc::Socket::AddressFailedAsWell(ptr[0]->id(), &dummy_ptr)); dummy_ptr->Revive(); } + bthread_usleep(brpc::FLAGS_detect_available_server_interval_ms * 1000); // After one server is revived, the reject rate should be 50% int num_ereject = 0; int num_ok = 0; From 6e0b81595e3b864af9a76564ee58f48dc0e771fd Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 3 Apr 2019 18:54:40 +0800 Subject: [PATCH 135/270] revived_from_all_failed: optimize lock --- src/brpc/details/naming_service_thread.h | 3 +-- src/brpc/revive_policy.cpp | 26 ++++++++++++------------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/brpc/details/naming_service_thread.h b/src/brpc/details/naming_service_thread.h index 570e4c11..dd5b78b1 100644 --- a/src/brpc/details/naming_service_thread.h +++ b/src/brpc/details/naming_service_thread.h @@ -42,8 +42,7 @@ public: struct GetNamingServiceThreadOptions { GetNamingServiceThreadOptions() : succeed_without_server(false) - , log_succeed_without_server(true) - , minimum_working_instances(-1) {} + , log_succeed_without_server(true) {} bool succeed_without_server; bool log_succeed_without_server; diff --git a/src/brpc/revive_policy.cpp b/src/brpc/revive_policy.cpp index c3782596..2901e4a0 100644 --- a/src/brpc/revive_policy.cpp +++ b/src/brpc/revive_policy.cpp @@ -45,19 +45,17 @@ void DefaultRevivePolicy::StartReviving() { } bool DefaultRevivePolicy::StopRevivingIfNecessary() { - int64_t now_ms = butil::gettimeofday_ms(); if (!_reviving) { return false; } - { - std::unique_lock mu(_mutex); - if (_last_usable_change_time_ms != 0 && _last_usable != 0 && - (now_ms - _last_usable_change_time_ms > _hold_time_ms)) { - _reviving = false; - _last_usable_change_time_ms = 0; - mu.unlock(); - return false; - } + int64_t now_ms = butil::gettimeofday_ms(); + std::unique_lock mu(_mutex); + if (_last_usable_change_time_ms != 0 && _last_usable != 0 && + (now_ms - _last_usable_change_time_ms > _hold_time_ms)) { + _reviving = false; + _last_usable_change_time_ms = 0; + mu.unlock(); + return false; } return true; } @@ -76,9 +74,11 @@ int DefaultRevivePolicy::GetUsableServerCount( usable++; } } - std::unique_lock mu(_mutex); - _usable_cache = usable; - _usable_cache_time_ms = now_ms; + { + std::unique_lock mu(_mutex); + _usable_cache = usable; + _usable_cache_time_ms = now_ms; + } return _usable_cache; } From 52d76d46ab5e7ca011b01e0035b89a877e318a3e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 3 Apr 2019 19:00:43 +0800 Subject: [PATCH 136/270] revived_from_all_failed: add double lock --- src/brpc/revive_policy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/brpc/revive_policy.cpp b/src/brpc/revive_policy.cpp index 2901e4a0..3d54ad9f 100644 --- a/src/brpc/revive_policy.cpp +++ b/src/brpc/revive_policy.cpp @@ -57,6 +57,7 @@ bool DefaultRevivePolicy::StopRevivingIfNecessary() { mu.unlock(); return false; } + mu.unlock(); return true; } @@ -89,7 +90,7 @@ bool DefaultRevivePolicy::DoReject(const std::vector& server_list) { } int64_t now_ms = butil::gettimeofday_ms(); int usable = GetUsableServerCount(now_ms, server_list); - { + if (_last_usable != usable) { std::unique_lock mu(_mutex); if (_last_usable != usable) { _last_usable = usable; From e3c341af3d626b1a6054b160de3300bba0380eda Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 3 Apr 2019 19:17:19 +0800 Subject: [PATCH 137/270] revived_from_all_failed: remove unnecessary code --- src/brpc/details/naming_service_thread.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/brpc/details/naming_service_thread.h b/src/brpc/details/naming_service_thread.h index dd5b78b1..01c5c85c 100644 --- a/src/brpc/details/naming_service_thread.h +++ b/src/brpc/details/naming_service_thread.h @@ -48,7 +48,6 @@ struct GetNamingServiceThreadOptions { bool log_succeed_without_server; ChannelSignature channel_signature; std::shared_ptr ssl_ctx; - int64_t minimum_working_instances; }; // A dedicated thread to map a name to ServerIds From a1c05b584624c12253dcc9e16f32aa940c8abfaa Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 11 Apr 2019 18:00:22 +0800 Subject: [PATCH 138/270] revived_from_all_failed: add KeyValuePairsSplitter & remove revive_policy in channelOptions --- src/brpc/channel.cpp | 4 +- src/brpc/channel.h | 8 --- src/brpc/controller.cpp | 3 +- src/brpc/controller.h | 2 - src/brpc/load_balancer.h | 2 - .../consistent_hashing_load_balancer.cpp | 17 +----- src/brpc/policy/randomized_load_balancer.cpp | 28 +++++++--- src/brpc/policy/randomized_load_balancer.h | 5 +- src/brpc/policy/round_robin_load_balancer.cpp | 23 +++++--- src/brpc/policy/round_robin_load_balancer.h | 4 +- .../weighted_round_robin_load_balancer.cpp | 14 ----- src/brpc/revive_policy.cpp | 40 ++++++++++++++ src/brpc/revive_policy.h | 10 +++- src/brpc/selective_channel.cpp | 3 +- test/brpc_load_balancer_unittest.cpp | 36 ++++++------- test/brpc_uri_unittest.cpp | 51 ------------------ test/string_splitter_unittest.cpp | 52 +++++++++++++++++++ 17 files changed, 163 insertions(+), 139 deletions(-) diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index 56e61537..e5d4a45d 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -52,7 +52,6 @@ ChannelOptions::ChannelOptions() , auth(NULL) , retry_policy(NULL) , ns_filter(NULL) - , revive_policy(NULL) {} ChannelSSLOptions* ChannelOptions::mutable_ssl_options() { @@ -526,7 +525,6 @@ void Channel::CallMethod(const google::protobuf::MethodDescriptor* method, } else { cntl->_deadline_us = -1; } - cntl->_revive_policy = _options.revive_policy; cntl->IssueRPC(start_send_real_us); if (done == NULL) { @@ -564,7 +562,7 @@ int Channel::CheckHealth() { return -1; } else { SocketUniquePtr tmp_sock; - LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL, NULL }; + LoadBalancer::SelectIn sel_in = { 0, false, false, 0, NULL }; LoadBalancer::SelectOut sel_out(&tmp_sock); return _lb->SelectServer(sel_in, &sel_out); } diff --git a/src/brpc/channel.h b/src/brpc/channel.h index 9379413a..be631cff 100644 --- a/src/brpc/channel.h +++ b/src/brpc/channel.h @@ -34,7 +34,6 @@ #include "brpc/details/profiler_linker.h" #include "brpc/retry_policy.h" #include "brpc/naming_service_filter.h" -#include "brpc/revive_policy.h" namespace brpc { @@ -129,13 +128,6 @@ struct ChannelOptions { // Default: "" std::string connection_group; - // Customize the revive policy after all servers are shutdown. The - // interface is defined in src/brpc/revive_policy.h - // This object is NOT owned by channel and should remain valid when - // channel is used. - // Default: NULL - RevivePolicy* revive_policy; - private: // SSLOptions is large and not often used, allocate it on heap to // prevent ChannelOptions from being bloated in most cases. diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index b7c0557b..8f1bcacf 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -252,7 +252,6 @@ void Controller::ResetPods() { _request_stream = INVALID_STREAM_ID; _response_stream = INVALID_STREAM_ID; _remote_stream_settings = NULL; - _revive_policy = NULL; } Controller::Call::Call(Controller::Call* rhs) @@ -997,7 +996,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { } else { LoadBalancer::SelectIn sel_in = { start_realtime_us, true, - has_request_code(), _request_code, _accessed, _revive_policy }; + has_request_code(), _request_code, _accessed }; LoadBalancer::SelectOut sel_out(&tmp_sock); const int rc = _lb->SelectServer(sel_in, &sel_out); if (rc != 0) { diff --git a/src/brpc/controller.h b/src/brpc/controller.h index a34164f7..6e896819 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -41,7 +41,6 @@ #include "brpc/progressive_attachment.h" // ProgressiveAttachment #include "brpc/progressive_reader.h" // ProgressiveReader #include "brpc/grpc.h" -#include "brpc/revive_policy.h" // EAUTH is defined in MAC #ifndef EAUTH @@ -716,7 +715,6 @@ private: uint64_t _request_code; SocketId _single_server_id; butil::intrusive_ptr _lb; - RevivePolicy* _revive_policy; // for passing parameters to created bthread, don't modify it otherwhere. CompletionInfo _tmp_completion_info; diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index c994a973..b6020dc6 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -24,7 +24,6 @@ #include "brpc/shared_object.h" // SharedObject #include "brpc/server_id.h" // ServerId #include "brpc/extension.h" // Extension -#include "brpc/revive_policy.h" namespace brpc { @@ -40,7 +39,6 @@ public: bool has_request_code; uint64_t request_code; const ExcludedServers* excluded; - RevivePolicy* revive_policy; }; struct SelectOut { diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 9a08a3a9..0b761079 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -20,6 +20,7 @@ #include "butil/containers/flat_map.h" #include "butil/errno.h" #include "butil/strings/string_number_conversions.h" +#include "butil/strings/string_split.h" #include "brpc/socket.h" #include "brpc/policy/consistent_hashing_load_balancer.h" #include "brpc/policy/hasher.h" @@ -302,19 +303,6 @@ int ConsistentHashingLoadBalancer::SelectServer( if (s->empty()) { return ENODATA; } - RevivePolicy* rp = in.revive_policy; - if (rp && rp->StopRevivingIfNecessary()) { - std::set server_list; - for (auto server: *s) { - server_list.insert(server.server_sock); - } - std::vector server_list_distinct( - server_list.begin(), server_list.end()); - if (rp->DoReject(server_list_distinct)) { - return EREJECT; - } - } - std::vector::const_iterator choice = std::lower_bound(s->begin(), s->end(), (uint32_t)in.request_code); if (choice == s->end()) { @@ -332,9 +320,6 @@ int ConsistentHashingLoadBalancer::SelectServer( } } } - if (rp) { - rp->StartReviving(); - } return EHOSTDOWN; } diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 522aea91..17c454ef 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -18,7 +18,7 @@ #include "butil/fast_rand.h" #include "brpc/socket.h" #include "brpc/policy/randomized_load_balancer.h" - +#include "butil/strings/string_number_conversions.h" namespace brpc { namespace policy { @@ -31,6 +31,10 @@ inline uint32_t GenRandomStride() { return prime_offset[butil::fast_rand_less_than(ARRAY_SIZE(prime_offset))]; } +RandomizedLoadBalancer::RandomizedLoadBalancer() + : _revive_policy(NULL) +{} + bool RandomizedLoadBalancer::Add(Servers& bg, const ServerId& id) { if (bg.server_list.capacity() < 128) { bg.server_list.reserve(128); @@ -110,9 +114,8 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (n == 0) { return ENODATA; } - RevivePolicy* rp = in.revive_policy; - if (rp && rp->StopRevivingIfNecessary()) { - if (rp->DoReject(s->server_list)) { + if (_revive_policy && _revive_policy->StopRevivingIfNecessary()) { + if (_revive_policy->DoReject(s->server_list)) { return EREJECT; } } @@ -134,8 +137,8 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { // this failed server won't be visited again inside for offset = (offset + stride) % n; } - if (rp) { - rp->StartReviving(); + if (_revive_policy) { + _revive_policy->StartReviving(); } // After we traversed the whole server list, there is still no // available server @@ -143,8 +146,13 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { } RandomizedLoadBalancer* RandomizedLoadBalancer::New( - const butil::StringPiece&) const { - return new (std::nothrow) RandomizedLoadBalancer; + const butil::StringPiece& params) const { + RandomizedLoadBalancer* lb = new (std::nothrow) RandomizedLoadBalancer; + if (lb && !lb->SetParameters(params)) { + delete lb; + lb = NULL; + } + return lb; } void RandomizedLoadBalancer::Destroy() { @@ -170,5 +178,9 @@ void RandomizedLoadBalancer::Describe( os << '}'; } +bool RandomizedLoadBalancer::SetParameters(const butil::StringPiece& params) { + return GetRevivePolicyByParams(params, &_revive_policy); +} + } // namespace policy } // namespace brpc diff --git a/src/brpc/policy/randomized_load_balancer.h b/src/brpc/policy/randomized_load_balancer.h index 9fb0d6d3..9ec6d229 100644 --- a/src/brpc/policy/randomized_load_balancer.h +++ b/src/brpc/policy/randomized_load_balancer.h @@ -21,7 +21,7 @@ #include // std::map #include "butil/containers/doubly_buffered_data.h" #include "brpc/load_balancer.h" - +#include "brpc/revive_policy.h" namespace brpc { namespace policy { @@ -31,6 +31,7 @@ namespace policy { // than RoundRobinLoadBalancer. class RandomizedLoadBalancer : public LoadBalancer { public: + RandomizedLoadBalancer(); bool AddServer(const ServerId& id); bool RemoveServer(const ServerId& id); size_t AddServersInBatch(const std::vector& servers); @@ -45,12 +46,14 @@ private: std::vector server_list; std::map server_map; }; + bool SetParameters(const butil::StringPiece& params); static bool Add(Servers& bg, const ServerId& id); static bool Remove(Servers& bg, const ServerId& id); static size_t BatchAdd(Servers& bg, const std::vector& servers); static size_t BatchRemove(Servers& bg, const std::vector& servers); butil::DoublyBufferedData _db_servers; + std::shared_ptr _revive_policy; }; } // namespace policy diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 67e474b7..4c778f57 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -110,9 +110,8 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (n == 0) { return ENODATA; } - RevivePolicy* rp = in.revive_policy; - if (rp && rp->StopRevivingIfNecessary()) { - if (rp->DoReject(s->server_list)) { + if (_revive_policy && _revive_policy->StopRevivingIfNecessary()) { + if (_revive_policy->DoReject(s->server_list)) { return EREJECT; } } @@ -133,16 +132,21 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { return 0; } } - if (rp) { - rp->StartReviving(); + if (_revive_policy) { + _revive_policy->StartReviving(); } s.tls() = tls; return EHOSTDOWN; } RoundRobinLoadBalancer* RoundRobinLoadBalancer::New( - const butil::StringPiece&) const { - return new (std::nothrow) RoundRobinLoadBalancer; + const butil::StringPiece& params) const { + RoundRobinLoadBalancer* lb = new (std::nothrow) RoundRobinLoadBalancer; + if (lb && !lb->SetParameters(params)) { + delete lb; + lb = NULL; + } + return lb; } void RoundRobinLoadBalancer::Destroy() { @@ -168,5 +172,10 @@ void RoundRobinLoadBalancer::Describe( os << '}'; } +bool RoundRobinLoadBalancer::SetParameters(const butil::StringPiece& params) { + return GetRevivePolicyByParams(params, &_revive_policy); +} + + } // namespace policy } // namespace brpc diff --git a/src/brpc/policy/round_robin_load_balancer.h b/src/brpc/policy/round_robin_load_balancer.h index 39e4cbe8..1bcf600d 100644 --- a/src/brpc/policy/round_robin_load_balancer.h +++ b/src/brpc/policy/round_robin_load_balancer.h @@ -21,7 +21,7 @@ #include // std::map #include "butil/containers/doubly_buffered_data.h" #include "brpc/load_balancer.h" - +#include "brpc/revive_policy.h" namespace brpc { namespace policy { @@ -49,12 +49,14 @@ private: uint32_t stride; uint32_t offset; }; + bool SetParameters(const butil::StringPiece& params); static bool Add(Servers& bg, const ServerId& id); static bool Remove(Servers& bg, const ServerId& id); static size_t BatchAdd(Servers& bg, const std::vector& servers); static size_t BatchRemove(Servers& bg, const std::vector& servers); butil::DoublyBufferedData _db_servers; + std::shared_ptr _revive_policy; }; } // namespace policy diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index daacc656..6f0973d5 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -158,17 +158,6 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* if (s->server_list.empty()) { return ENODATA; } - RevivePolicy* rp = in.revive_policy; - if (rp && rp->StopRevivingIfNecessary()) { - std::vector server_list; - server_list.reserve(s->server_list.size()); - for (auto server: s->server_list) { - server_list.emplace_back(server.id); - } - if (rp->DoReject(server_list)) { - return EREJECT; - } - } TLS& tls = s.tls(); if (tls.IsNeededCaculateNewStride(s->weight_sum, s->server_list.size())) { if (tls.stride == 0) { @@ -210,9 +199,6 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* tls_temp.remain_server = tls.remain_server; } } - if (rp) { - rp->StartReviving(); - } return EHOSTDOWN; } diff --git a/src/brpc/revive_policy.cpp b/src/brpc/revive_policy.cpp index 3d54ad9f..6327548f 100644 --- a/src/brpc/revive_policy.cpp +++ b/src/brpc/revive_policy.cpp @@ -23,6 +23,7 @@ #include "brpc/socket.h" #include "butil/fast_rand.h" #include "butil/time.h" +#include "butil/string_splitter.h" namespace brpc { @@ -104,4 +105,43 @@ bool DefaultRevivePolicy::DoReject(const std::vector& server_list) { return false; } +bool GetRevivePolicyByParams(const butil::StringPiece& params, + std::shared_ptr* ptr_out) { + int64_t minimum_working_instances = -1; + int64_t hold_time_ms = -1; + bool has_meet_params = false; + for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), '=', ' '); + sp; ++sp) { + if (sp.value().empty()) { + LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; + return false; + } + if (sp.key() == "minimum_working_instances") { + if (!butil::StringToInt64(sp.value(), &minimum_working_instances)) { + return false; + } + has_meet_params = true; + continue; + } else if (sp.key() == "hold_time_ms") { + if (!butil::StringToInt64(sp.value(), &hold_time_ms)) { + return false; + } + has_meet_params = true; + continue; + } + LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); + } + if (minimum_working_instances > 0 && hold_time_ms > 0) { + ptr_out->reset( + new DefaultRevivePolicy(minimum_working_instances, hold_time_ms)); + } else if (has_meet_params) { + // In this case, user set some params but not in the right way, just return + // false to let user take care of this situation. + LOG(ERROR) << "Invalid params=`" << params << "'"; + return false; + } + return true; +} + + } // namespace brpc diff --git a/src/brpc/revive_policy.h b/src/brpc/revive_policy.h index ac0a3339..73ac95ed 100644 --- a/src/brpc/revive_policy.h +++ b/src/brpc/revive_policy.h @@ -18,7 +18,10 @@ #define BRPC_REVIVE_POLICY #include -#include +#include +#include "butil/synchronization/lock.h" +#include "butil/strings/string_piece.h" +#include "butil/strings/string_number_conversions.h" namespace brpc { @@ -73,6 +76,11 @@ private: int64_t _usable_cache_time_ms; }; +// Return a DefaultRevivePolicy object by params. The caller is responsible +// for memory management of the return value. +bool GetRevivePolicyByParams(const butil::StringPiece& params, + std::shared_ptr* ptr_out); + } // namespace brpc #endif diff --git a/src/brpc/selective_channel.cpp b/src/brpc/selective_channel.cpp index ae468698..2c495eb7 100644 --- a/src/brpc/selective_channel.cpp +++ b/src/brpc/selective_channel.cpp @@ -290,8 +290,7 @@ int Sender::IssueRPC(int64_t start_realtime_us) { true, _main_cntl->has_request_code(), _main_cntl->_request_code, - _main_cntl->_accessed, - NULL }; + _main_cntl->_accessed }; ChannelBalancer::SelectOut sel_out; const int rc = static_cast(_main_cntl->_lb.get()) ->SelectChannel(sel_in, &sel_out); diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index c2471bbc..c673aad8 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -27,7 +27,6 @@ #include "brpc/channel.h" #include "brpc/controller.h" #include "brpc/server.h" -#include "brpc/revive_policy.h" namespace brpc { DECLARE_int32(health_check_interval); @@ -214,7 +213,7 @@ void* select_server(void* arg) { brpc::LoadBalancer* c = sa->lb; brpc::SocketUniquePtr ptr; CountMap *selected_count = new CountMap; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); uint32_t rand_seed = rand(); if (sa->hash) { @@ -267,7 +266,7 @@ TEST_F(LoadBalancerTest, update_while_selection) { // Accessing empty lb should result in error. brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, NULL, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, true, 0, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); ASSERT_EQ(ENODATA, lb->SelectServer(in, &out)); @@ -570,7 +569,7 @@ TEST_F(LoadBalancerTest, consistent_hashing) { const size_t SELECT_TIMES = 1000000; std::map times; brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; ::brpc::LoadBalancer::SelectOut out(&ptr); for (size_t i = 0; i < SELECT_TIMES; ++i) { in.has_request_code = true; @@ -647,7 +646,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) { // consistent with weight configured. std::map select_result; brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&ptr); int total_weight = 12; std::vector select_servers; @@ -705,7 +704,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin_no_valid_server) { // The first socket is excluded. The second socket is logfoff. // The third socket is invalid. brpc::SocketUniquePtr ptr; - brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, exclude, NULL }; + brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, exclude }; brpc::LoadBalancer::SelectOut out(&ptr); EXPECT_EQ(EHOSTDOWN, wrrlb.SelectServer(in, &out)); brpc::ExcludedServers::Destroy(exclude); @@ -791,15 +790,13 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { brpc::LoadBalancer* lb = NULL; - int rand = butil::fast_rand_less_than(4); + // TODO(zhujiashun) + int rand = butil::fast_rand_less_than(1); if (rand == 0) { - lb = new brpc::policy::RoundRobinLoadBalancer; + brpc::policy::RandomizedLoadBalancer rlb; + lb = rlb.New("minimum_working_instances=2 hold_time_ms=2000"); } else if (rand == 1) { - lb = new brpc::policy::RandomizedLoadBalancer; - } else if (rand == 2) { - lb = new brpc::policy::WeightedRoundRobinLoadBalancer; - } else { - lb = new brpc::policy::ConsistentHashingLoadBalancer(brpc::policy::MurmurHash32); + lb = new brpc::policy::RoundRobinLoadBalancer; } brpc::SocketUniquePtr ptr[2]; for (size_t i = 0; i < ARRAY_SIZE(servers); ++i) { @@ -814,9 +811,7 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { lb->AddServer(id); } brpc::SocketUniquePtr sptr; - int64_t hold_time_ms = 2000; - brpc::RevivePolicy* rp = new brpc::DefaultRevivePolicy(2, hold_time_ms); - brpc::LoadBalancer::SelectIn in = { 0, false, true, 0u, NULL, rp }; + brpc::LoadBalancer::SelectIn in = { 0, false, true, 0u, NULL }; brpc::LoadBalancer::SelectOut out(&sptr); ASSERT_EQ(0, lb->SelectServer(in, &out)); @@ -847,7 +842,7 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { } } ASSERT_TRUE(abs(num_ereject - num_ok) < 30); - bthread_usleep((hold_time_ms + 10) * 1000); + bthread_usleep((2000 + 10) * 1000); // After enough waiting time, traffic should be sent to all available servers. for (int i = 0; i < 10; ++i) { @@ -912,18 +907,17 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_error_percent", "30"); GFLAGS_NS::SetCommandLineOption("circuit_breaker_max_isolation_duration_ms", "5000"); - const char* lb_algo[] = { "rr" , "random", "wrr", "c_murmurhash" }; + const char* lb_algo[] = { "random:minimum_working_instances=2 hold_time_ms=2000", + "rr:minimum_working_instances=2 hold_time_ms=2000" }; brpc::Channel channel; brpc::ChannelOptions options; options.protocol = "http"; options.timeout_ms = 300; options.enable_circuit_breaker = true; - options.revive_policy = new brpc::DefaultRevivePolicy(2, 2000 /*2s*/); // Set max_retry to 0 so that the time of health check of different servers // are not continuous. options.max_retry = 0; - - ASSERT_EQ(channel.Init("list://127.0.0.1:7777 50,127.0.0.1:7778 50", + ASSERT_EQ(channel.Init("list://127.0.0.1:7777 50, 127.0.0.1:7778 50", lb_algo[butil::fast_rand_less_than(ARRAY_SIZE(lb_algo))], &options), 0); diff --git a/test/brpc_uri_unittest.cpp b/test/brpc_uri_unittest.cpp index 97eae25b..6cd0e36e 100644 --- a/test/brpc_uri_unittest.cpp +++ b/test/brpc_uri_unittest.cpp @@ -475,54 +475,3 @@ TEST(URITest, query_remover_key_value_not_changed_after_modified_query) { ASSERT_EQ(qr.value(), "value2"); } -TEST(URITest, query_splitter_sanity) { - std::string query = "key1=value1&key2=value2&key3=value3"; - { - brpc::QuerySplitter qs(query); - ASSERT_TRUE(qs); - ASSERT_EQ(qs.key(), "key1"); - ASSERT_EQ(qs.value(), "value1"); - ++qs; - ASSERT_TRUE(qs); - ASSERT_EQ(qs.key(), "key2"); - ASSERT_EQ(qs.value(), "value2"); - ++qs; - ASSERT_TRUE(qs); - ASSERT_EQ(qs.key(), "key3"); - ASSERT_EQ(qs.value(), "value3"); - ++qs; - ASSERT_FALSE(qs); - } - { - brpc::QuerySplitter qs(query.data(), query.data() + query.size()); - ASSERT_TRUE(qs); - ASSERT_EQ(qs.key(), "key1"); - ASSERT_EQ(qs.value(), "value1"); - ++qs; - ASSERT_TRUE(qs); - ASSERT_EQ(qs.key(), "key2"); - ASSERT_EQ(qs.value(), "value2"); - ++qs; - ASSERT_TRUE(qs); - ASSERT_EQ(qs.key(), "key3"); - ASSERT_EQ(qs.value(), "value3"); - ++qs; - ASSERT_FALSE(qs); - } - { - brpc::QuerySplitter qs(query.c_str()); - ASSERT_TRUE(qs); - ASSERT_EQ(qs.key(), "key1"); - ASSERT_EQ(qs.value(), "value1"); - ++qs; - ASSERT_TRUE(qs); - ASSERT_EQ(qs.key(), "key2"); - ASSERT_EQ(qs.value(), "value2"); - ++qs; - ASSERT_TRUE(qs); - ASSERT_EQ(qs.key(), "key3"); - ASSERT_EQ(qs.value(), "value3"); - ++qs; - ASSERT_FALSE(qs); - } -} diff --git a/test/string_splitter_unittest.cpp b/test/string_splitter_unittest.cpp index da6024c2..6963e089 100644 --- a/test/string_splitter_unittest.cpp +++ b/test/string_splitter_unittest.cpp @@ -386,4 +386,56 @@ TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { } } +TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { + std::string kvstr = "key1=value1&key2=value2&key3=value3"; + { + butil::KeyValuePairsSplitter splitter(kvstr, '=', '&'); + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key1"); + ASSERT_EQ(splitter.value(), "value1"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key2"); + ASSERT_EQ(splitter.value(), "value2"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key3"); + ASSERT_EQ(splitter.value(), "value3"); + ++splitter; + ASSERT_FALSE(splitter); + } + { + butil::KeyValuePairsSplitter splitter(kvstr.data(), kvstr.data() + kvstr.size(), '=', '&'); + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key1"); + ASSERT_EQ(splitter.value(), "value1"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key2"); + ASSERT_EQ(splitter.value(), "value2"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key3"); + ASSERT_EQ(splitter.value(), "value3"); + ++splitter; + ASSERT_FALSE(splitter); + } + { + butil::KeyValuePairsSplitter splitter(kvstr.c_str(), '=', '&'); + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key1"); + ASSERT_EQ(splitter.value(), "value1"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key2"); + ASSERT_EQ(splitter.value(), "value2"); + ++splitter; + ASSERT_TRUE(splitter); + ASSERT_EQ(splitter.key(), "key3"); + ASSERT_EQ(splitter.value(), "value3"); + ++splitter; + ASSERT_FALSE(splitter); + } +} + } From 2b550fd0c735f58012273ba772becdb495b9002d Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 11 Apr 2019 18:21:44 +0800 Subject: [PATCH 139/270] revived_from_all_failed: remove RevivePolicy to ClusterRecoverPolicy --- ..._policy.cpp => cluster_recover_policy.cpp} | 31 ++++++------ ...vive_policy.h => cluster_recover_policy.h} | 47 +++++++++---------- .../policy/locality_aware_load_balancer.cpp | 1 - src/brpc/policy/randomized_load_balancer.cpp | 12 ++--- src/brpc/policy/randomized_load_balancer.h | 4 +- src/brpc/policy/round_robin_load_balancer.cpp | 11 ++--- src/brpc/policy/round_robin_load_balancer.h | 4 +- .../weighted_round_robin_load_balancer.cpp | 1 - 8 files changed, 53 insertions(+), 58 deletions(-) rename src/brpc/{revive_policy.cpp => cluster_recover_policy.cpp} (83%) rename src/brpc/{revive_policy.h => cluster_recover_policy.h} (59%) diff --git a/src/brpc/revive_policy.cpp b/src/brpc/cluster_recover_policy.cpp similarity index 83% rename from src/brpc/revive_policy.cpp rename to src/brpc/cluster_recover_policy.cpp index 6327548f..2636577d 100644 --- a/src/brpc/revive_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -16,7 +16,7 @@ #include #include -#include "brpc/revive_policy.h" +#include "brpc/cluster_recover_policy.h" #include "butil/scoped_lock.h" #include "butil/synchronization/lock.h" #include "brpc/server_id.h" @@ -28,11 +28,11 @@ namespace brpc { DEFINE_int64(detect_available_server_interval_ms, 10, "The interval " - "to detect available server count in DefaultRevivePolicy"); + "to detect available server count in DefaultClusterRecoverPolicy"); -DefaultRevivePolicy::DefaultRevivePolicy( +DefaultClusterRecoverPolicy::DefaultClusterRecoverPolicy( int64_t minimum_working_instances, int64_t hold_time_ms) - : _reviving(false) + : _recovering(false) , _minimum_working_instances(minimum_working_instances) , _last_usable(0) , _last_usable_change_time_ms(0) @@ -40,20 +40,20 @@ DefaultRevivePolicy::DefaultRevivePolicy( , _usable_cache(0) , _usable_cache_time_ms(0) { } -void DefaultRevivePolicy::StartReviving() { +void DefaultClusterRecoverPolicy::StartRecover() { std::unique_lock mu(_mutex); - _reviving = true; + _recovering = true; } -bool DefaultRevivePolicy::StopRevivingIfNecessary() { - if (!_reviving) { +bool DefaultClusterRecoverPolicy::StopRecoverIfNecessary() { + if (!_recovering) { return false; } int64_t now_ms = butil::gettimeofday_ms(); std::unique_lock mu(_mutex); if (_last_usable_change_time_ms != 0 && _last_usable != 0 && (now_ms - _last_usable_change_time_ms > _hold_time_ms)) { - _reviving = false; + _recovering = false; _last_usable_change_time_ms = 0; mu.unlock(); return false; @@ -62,7 +62,7 @@ bool DefaultRevivePolicy::StopRevivingIfNecessary() { return true; } -int DefaultRevivePolicy::GetUsableServerCount( +int DefaultClusterRecoverPolicy::GetUsableServerCount( int64_t now_ms, const std::vector& server_list) { if (now_ms - _usable_cache_time_ms < FLAGS_detect_available_server_interval_ms) { return _usable_cache; @@ -85,8 +85,8 @@ int DefaultRevivePolicy::GetUsableServerCount( } -bool DefaultRevivePolicy::DoReject(const std::vector& server_list) { - if (!_reviving) { +bool DefaultClusterRecoverPolicy::DoReject(const std::vector& server_list) { + if (!_recovering) { return false; } int64_t now_ms = butil::gettimeofday_ms(); @@ -105,8 +105,8 @@ bool DefaultRevivePolicy::DoReject(const std::vector& server_list) { return false; } -bool GetRevivePolicyByParams(const butil::StringPiece& params, - std::shared_ptr* ptr_out) { +bool GetRecoverPolicyByParams(const butil::StringPiece& params, + std::shared_ptr* ptr_out) { int64_t minimum_working_instances = -1; int64_t hold_time_ms = -1; bool has_meet_params = false; @@ -133,7 +133,7 @@ bool GetRevivePolicyByParams(const butil::StringPiece& params, } if (minimum_working_instances > 0 && hold_time_ms > 0) { ptr_out->reset( - new DefaultRevivePolicy(minimum_working_instances, hold_time_ms)); + new DefaultClusterRecoverPolicy(minimum_working_instances, hold_time_ms)); } else if (has_meet_params) { // In this case, user set some params but not in the right way, just return // false to let user take care of this situation. @@ -143,5 +143,4 @@ bool GetRevivePolicyByParams(const butil::StringPiece& params, return true; } - } // namespace brpc diff --git a/src/brpc/revive_policy.h b/src/brpc/cluster_recover_policy.h similarity index 59% rename from src/brpc/revive_policy.h rename to src/brpc/cluster_recover_policy.h index 73ac95ed..d6ae44a4 100644 --- a/src/brpc/revive_policy.h +++ b/src/brpc/cluster_recover_policy.h @@ -14,8 +14,8 @@ // Authors: Jiashun Zhu(zhujiashun@bilibili.com) -#ifndef BRPC_REVIVE_POLICY -#define BRPC_REVIVE_POLICY +#ifndef BRPC_CLUSTER_RECOVER_POLICY +#define BRPC_CLUSTER_RECOVER_POLICY #include #include @@ -27,46 +27,45 @@ namespace brpc { class ServerId; -// After all servers are shutdown and health check happens, servers are +// After all servers are down and health check happens, servers are // online one by one. Once one server is up, all the request that should // be sent to all servers, would be sent to one server, which may be a -// disastrous behaviour. In the worst case it would cause the server shutdown -// again if circuit breaker is enabled and the server cluster would never -// recover. This class controls the amount of requests that sent to the revived -// servers when recovering from all servers are shutdown. -class RevivePolicy { +// disastrous behaviour. In the worst case it would cause the server being down +// again if circuit breaker is enabled and the cluster would never recover. +// This class controls the amount of requests that sent to the revived +// servers when recovering from all servers are down. +class ClusterRecoverPolicy { public: - // Indicate that reviving from the shutdown of all server is happening. - virtual void StartReviving() = 0; + // Indicate that recover from all server being down is happening. + virtual void StartRecover() = 0; // Return true if some customized policies are satisfied. virtual bool DoReject(const std::vector& server_list) = 0; - // Stop reviving state and do not reject the request if some condition is - // satisfied. - // Return true if the current state is still in reviving. - virtual bool StopRevivingIfNecessary() = 0; + // Stop recover state and do not reject the request if some condition is + // satisfied. Return true if the current state is still in recovering. + virtual bool StopRecoverIfNecessary() = 0; }; -// The default revive policy. Once no servers are available, reviving is start. -// If in reviving state, the probability that a request is accepted is q/n, in +// The default cluster recover policy. Once no servers are available, recover is start. +// If in recover state, the probability that a request is accepted is q/n, in // which q is the number of current available server, n is the number of minimum // working instances setting by user. If q is not changed during a given time, // hold_time_ms, then the cluster is considered recovered and all the request // would be sent to the current available servers. -class DefaultRevivePolicy : public RevivePolicy { +class DefaultClusterRecoverPolicy : public ClusterRecoverPolicy { public: - DefaultRevivePolicy(int64_t minimum_working_instances, int64_t hold_time_ms); + DefaultClusterRecoverPolicy(int64_t minimum_working_instances, int64_t hold_time_ms); - void StartReviving(); + void StartRecover(); bool DoReject(const std::vector& server_list); - bool StopRevivingIfNecessary(); + bool StopRecoverIfNecessary(); private: int GetUsableServerCount(int64_t now_ms, const std::vector& server_list); private: - bool _reviving; + bool _recovering; int64_t _minimum_working_instances; butil::Mutex _mutex; int64_t _last_usable; @@ -76,10 +75,10 @@ private: int64_t _usable_cache_time_ms; }; -// Return a DefaultRevivePolicy object by params. The caller is responsible +// Return a DefaultClusterRecoverPolicy object by params. The caller is responsible // for memory management of the return value. -bool GetRevivePolicyByParams(const butil::StringPiece& params, - std::shared_ptr* ptr_out); +bool GetRecoverPolicyByParams(const butil::StringPiece& params, + std::shared_ptr* ptr_out); } // namespace brpc diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index 22a3ca2b..f28941c5 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -22,7 +22,6 @@ #include "brpc/socket.h" #include "brpc/reloadable_flags.h" #include "brpc/policy/locality_aware_load_balancer.h" -#include "brpc/revive_policy.h" namespace brpc { namespace policy { diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 17c454ef..e5832e9d 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -32,7 +32,7 @@ inline uint32_t GenRandomStride() { } RandomizedLoadBalancer::RandomizedLoadBalancer() - : _revive_policy(NULL) + : _cluster_recover_policy(NULL) {} bool RandomizedLoadBalancer::Add(Servers& bg, const ServerId& id) { @@ -114,8 +114,8 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (n == 0) { return ENODATA; } - if (_revive_policy && _revive_policy->StopRevivingIfNecessary()) { - if (_revive_policy->DoReject(s->server_list)) { + if (_cluster_recover_policy && _cluster_recover_policy->StopRecoverIfNecessary()) { + if (_cluster_recover_policy->DoReject(s->server_list)) { return EREJECT; } } @@ -137,8 +137,8 @@ int RandomizedLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { // this failed server won't be visited again inside for offset = (offset + stride) % n; } - if (_revive_policy) { - _revive_policy->StartReviving(); + if (_cluster_recover_policy) { + _cluster_recover_policy->StartRecover(); } // After we traversed the whole server list, there is still no // available server @@ -179,7 +179,7 @@ void RandomizedLoadBalancer::Describe( } bool RandomizedLoadBalancer::SetParameters(const butil::StringPiece& params) { - return GetRevivePolicyByParams(params, &_revive_policy); + return GetRecoverPolicyByParams(params, &_cluster_recover_policy); } } // namespace policy diff --git a/src/brpc/policy/randomized_load_balancer.h b/src/brpc/policy/randomized_load_balancer.h index 9ec6d229..d6b15fb6 100644 --- a/src/brpc/policy/randomized_load_balancer.h +++ b/src/brpc/policy/randomized_load_balancer.h @@ -21,7 +21,7 @@ #include // std::map #include "butil/containers/doubly_buffered_data.h" #include "brpc/load_balancer.h" -#include "brpc/revive_policy.h" +#include "brpc/cluster_recover_policy.h" namespace brpc { namespace policy { @@ -53,7 +53,7 @@ private: static size_t BatchRemove(Servers& bg, const std::vector& servers); butil::DoublyBufferedData _db_servers; - std::shared_ptr _revive_policy; + std::shared_ptr _cluster_recover_policy; }; } // namespace policy diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index 4c778f57..d0cbd8b6 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -110,8 +110,8 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { if (n == 0) { return ENODATA; } - if (_revive_policy && _revive_policy->StopRevivingIfNecessary()) { - if (_revive_policy->DoReject(s->server_list)) { + if (_cluster_recover_policy && _cluster_recover_policy->StopRecoverIfNecessary()) { + if (_cluster_recover_policy->DoReject(s->server_list)) { return EREJECT; } } @@ -132,8 +132,8 @@ int RoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut* out) { return 0; } } - if (_revive_policy) { - _revive_policy->StartReviving(); + if (_cluster_recover_policy) { + _cluster_recover_policy->StartRecover(); } s.tls() = tls; return EHOSTDOWN; @@ -173,9 +173,8 @@ void RoundRobinLoadBalancer::Describe( } bool RoundRobinLoadBalancer::SetParameters(const butil::StringPiece& params) { - return GetRevivePolicyByParams(params, &_revive_policy); + return GetRecoverPolicyByParams(params, &_cluster_recover_policy); } - } // namespace policy } // namespace brpc diff --git a/src/brpc/policy/round_robin_load_balancer.h b/src/brpc/policy/round_robin_load_balancer.h index 1bcf600d..9a5d779b 100644 --- a/src/brpc/policy/round_robin_load_balancer.h +++ b/src/brpc/policy/round_robin_load_balancer.h @@ -21,7 +21,7 @@ #include // std::map #include "butil/containers/doubly_buffered_data.h" #include "brpc/load_balancer.h" -#include "brpc/revive_policy.h" +#include "brpc/cluster_recover_policy.h" namespace brpc { namespace policy { @@ -56,7 +56,7 @@ private: static size_t BatchRemove(Servers& bg, const std::vector& servers); butil::DoublyBufferedData _db_servers; - std::shared_ptr _revive_policy; + std::shared_ptr _cluster_recover_policy; }; } // namespace policy diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index 6f0973d5..5b977820 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -20,7 +20,6 @@ #include "brpc/socket.h" #include "brpc/policy/weighted_round_robin_load_balancer.h" #include "butil/strings/string_number_conversions.h" -#include "brpc/revive_policy.h" namespace { From cc3815785a1e3609cb31adbaeaf5c6a2a0d28c48 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 11 Apr 2019 18:32:29 +0800 Subject: [PATCH 140/270] revived_from_all_failed: remove unnecessary logs and comments --- src/brpc/circuit_breaker.cpp | 2 -- src/brpc/cluster_recover_policy.h | 3 +-- src/brpc/policy/randomized_load_balancer.cpp | 4 ---- src/brpc/policy/randomized_load_balancer.h | 1 - test/brpc_load_balancer_unittest.cpp | 6 +++--- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/brpc/circuit_breaker.cpp b/src/brpc/circuit_breaker.cpp index d2b74b23..84ec7627 100644 --- a/src/brpc/circuit_breaker.cpp +++ b/src/brpc/circuit_breaker.cpp @@ -18,8 +18,6 @@ #include #include #include "brpc/circuit_breaker.h" -#include "brpc/errno.pb.h" -#include "butil/logging.h" namespace brpc { diff --git a/src/brpc/cluster_recover_policy.h b/src/brpc/cluster_recover_policy.h index d6ae44a4..58600ba0 100644 --- a/src/brpc/cluster_recover_policy.h +++ b/src/brpc/cluster_recover_policy.h @@ -75,8 +75,7 @@ private: int64_t _usable_cache_time_ms; }; -// Return a DefaultClusterRecoverPolicy object by params. The caller is responsible -// for memory management of the return value. +// Return a DefaultClusterRecoverPolicy object by params. bool GetRecoverPolicyByParams(const butil::StringPiece& params, std::shared_ptr* ptr_out); diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index e5832e9d..97bc9146 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -31,10 +31,6 @@ inline uint32_t GenRandomStride() { return prime_offset[butil::fast_rand_less_than(ARRAY_SIZE(prime_offset))]; } -RandomizedLoadBalancer::RandomizedLoadBalancer() - : _cluster_recover_policy(NULL) -{} - bool RandomizedLoadBalancer::Add(Servers& bg, const ServerId& id) { if (bg.server_list.capacity() < 128) { bg.server_list.reserve(128); diff --git a/src/brpc/policy/randomized_load_balancer.h b/src/brpc/policy/randomized_load_balancer.h index d6b15fb6..e242d93d 100644 --- a/src/brpc/policy/randomized_load_balancer.h +++ b/src/brpc/policy/randomized_load_balancer.h @@ -31,7 +31,6 @@ namespace policy { // than RoundRobinLoadBalancer. class RandomizedLoadBalancer : public LoadBalancer { public: - RandomizedLoadBalancer(); bool AddServer(const ServerId& id); bool RemoveServer(const ServerId& id); size_t AddServersInBatch(const std::vector& servers); diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index c673aad8..c8fdf3a3 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -790,13 +790,13 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { brpc::LoadBalancer* lb = NULL; - // TODO(zhujiashun) - int rand = butil::fast_rand_less_than(1); + int rand = butil::fast_rand_less_than(2); if (rand == 0) { brpc::policy::RandomizedLoadBalancer rlb; lb = rlb.New("minimum_working_instances=2 hold_time_ms=2000"); } else if (rand == 1) { - lb = new brpc::policy::RoundRobinLoadBalancer; + brpc::policy::RoundRobinLoadBalancer rrlb; + lb = rrlb.New("minimum_working_instances=2 hold_time_ms=2000"); } brpc::SocketUniquePtr ptr[2]; for (size_t i = 0; i < ARRAY_SIZE(servers); ++i) { From f0224fcc948ca889b144c6d0b0966a251e4c1d86 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 11 Apr 2019 18:47:18 +0800 Subject: [PATCH 141/270] revived_from_all_failed: remove unnecessary code --- test/brpc_load_balancer_unittest.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index c8fdf3a3..8a4efdae 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -842,7 +842,7 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { } } ASSERT_TRUE(abs(num_ereject - num_ok) < 30); - bthread_usleep((2000 + 10) * 1000); + bthread_usleep((2000 /* hold_time_ms */ + 10) * 1000); // After enough waiting time, traffic should be sent to all available servers. for (int i = 0; i < 10; ++i) { @@ -921,7 +921,6 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { lb_algo[butil::fast_rand_less_than(ARRAY_SIZE(lb_algo))], &options), 0); - uint64_t request_code = 0; test::EchoRequest req; req.set_message("123"); test::EchoResponse res; @@ -929,14 +928,12 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { // trigger one server to health check { brpc::Controller cntl; - cntl.set_request_code(brpc::policy::MurmurHash32(&++request_code, 8)); stub.Echo(&cntl, &req, &res, NULL); } bthread_usleep(500000); // trigger the other server to health check { brpc::Controller cntl; - cntl.set_request_code(brpc::policy::MurmurHash32(&++request_code, 8)); stub.Echo(&cntl, &req, &res, NULL); } @@ -960,7 +957,6 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { Done* done = new Done; done->num_reject = &num_reject; done->req.set_message("123"); - done->cntl.set_request_code(brpc::policy::MurmurHash32(&++request_code, 8)); stub.Echo(&done->cntl, &done->req, &done->res, done); q++; bthread_usleep(1000); @@ -973,7 +969,6 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { Done* done = new Done; done->req.set_message("123"); done->num_failed = &num_failed; - done->cntl.set_request_code(brpc::policy::MurmurHash32(&++request_code, 8)); stub.Echo(&done->cntl, &done->req, &done->res, done); bthread_usleep(1000); } From 75f89a5af32639c4d0d8062a4e0fea73d8305d72 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 11 Apr 2019 19:01:31 +0800 Subject: [PATCH 142/270] revived_from_all_failed: optimize code --- src/brpc/cluster_recover_policy.cpp | 9 ++++----- src/brpc/cluster_recover_policy.h | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index 2636577d..0003c34a 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -62,12 +62,12 @@ bool DefaultClusterRecoverPolicy::StopRecoverIfNecessary() { return true; } -int DefaultClusterRecoverPolicy::GetUsableServerCount( +uint64_t DefaultClusterRecoverPolicy::GetUsableServerCount( int64_t now_ms, const std::vector& server_list) { if (now_ms - _usable_cache_time_ms < FLAGS_detect_available_server_interval_ms) { return _usable_cache; } - int usable = 0; + uint64_t usable = 0; size_t n = server_list.size(); SocketUniquePtr ptr; for (size_t i = 0; i < n; ++i) { @@ -90,7 +90,7 @@ bool DefaultClusterRecoverPolicy::DoReject(const std::vector& server_l return false; } int64_t now_ms = butil::gettimeofday_ms(); - int usable = GetUsableServerCount(now_ms, server_list); + uint64_t usable = GetUsableServerCount(now_ms, server_list); if (_last_usable != usable) { std::unique_lock mu(_mutex); if (_last_usable != usable) { @@ -98,8 +98,7 @@ bool DefaultClusterRecoverPolicy::DoReject(const std::vector& server_l _last_usable_change_time_ms = now_ms; } } - int rand = butil::fast_rand_less_than(_minimum_working_instances); - if (rand >= usable) { + if (butil::fast_rand_less_than(_minimum_working_instances) >= usable) { return true; } return false; diff --git a/src/brpc/cluster_recover_policy.h b/src/brpc/cluster_recover_policy.h index 58600ba0..71aea831 100644 --- a/src/brpc/cluster_recover_policy.h +++ b/src/brpc/cluster_recover_policy.h @@ -62,16 +62,16 @@ public: bool StopRecoverIfNecessary(); private: - int GetUsableServerCount(int64_t now_ms, const std::vector& server_list); + uint64_t GetUsableServerCount(int64_t now_ms, const std::vector& server_list); private: bool _recovering; int64_t _minimum_working_instances; butil::Mutex _mutex; - int64_t _last_usable; + uint64_t _last_usable; int64_t _last_usable_change_time_ms; int64_t _hold_time_ms; - int64_t _usable_cache; + uint64_t _usable_cache; int64_t _usable_cache_time_ms; }; From 662ff4a43c703389dc474055b0a0376c822f8099 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 15 Apr 2019 16:17:40 +0800 Subject: [PATCH 143/270] revived_from_all_failed: fix ut after rebasing latest master --- src/brpc/cluster_recover_policy.cpp | 2 +- test/brpc_load_balancer_unittest.cpp | 58 ++++++++++++---------------- 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index 0003c34a..b859004d 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -72,7 +72,7 @@ uint64_t DefaultClusterRecoverPolicy::GetUsableServerCount( SocketUniquePtr ptr; for (size_t i = 0; i < n; ++i) { if (Socket::Address(server_list[i].id, &ptr) == 0 - && !ptr->IsLogOff()) { + && ptr->IsAvailable()) { usable++; } } diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 8a4efdae..cb5c31c0 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -789,6 +789,10 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { } TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { + const char* servers[] = { + "10.92.115.19:8832", + "10.42.122.201:8833", + }; brpc::LoadBalancer* lb = NULL; int rand = butil::fast_rand_less_than(2); if (rand == 0) { @@ -878,34 +882,31 @@ public: butil::atomic _num_request; }; +butil::atomic num_failed; +butil::atomic num_reject; + class Done : public google::protobuf::Closure { public: - Done() - : num_failed(NULL) - , num_reject(NULL) {} void Run() { if (cntl.Failed()) { - if (num_failed) { - num_failed->fetch_add(1, butil::memory_order_relaxed); - } - if (cntl.ErrorCode() == brpc::EREJECT && num_reject) { - num_reject->fetch_add(1, butil::memory_order_relaxed); + num_failed.fetch_add(1, butil::memory_order_relaxed); + if (cntl.ErrorCode() == brpc::EREJECT) { + num_reject.fetch_add(1, butil::memory_order_relaxed); } } delete this; } - brpc::Controller cntl; test::EchoRequest req; test::EchoResponse res; - butil::atomic* num_failed; - butil::atomic* num_reject; }; TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_size", "20"); GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_error_percent", "30"); - GFLAGS_NS::SetCommandLineOption("circuit_breaker_max_isolation_duration_ms", "5000"); + // Those two lines force the interval of first hc to 3s + GFLAGS_NS::SetCommandLineOption("circuit_breaker_max_isolation_duration_ms", "3000"); + GFLAGS_NS::SetCommandLineOption("circuit_breaker_min_isolation_duration_ms", "3000"); const char* lb_algo[] = { "random:minimum_working_instances=2 hold_time_ms=2000", "rr:minimum_working_instances=2 hold_time_ms=2000" }; @@ -914,24 +915,15 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { options.protocol = "http"; options.timeout_ms = 300; options.enable_circuit_breaker = true; - // Set max_retry to 0 so that the time of health check of different servers - // are not continuous. - options.max_retry = 0; ASSERT_EQ(channel.Init("list://127.0.0.1:7777 50, 127.0.0.1:7778 50", lb_algo[butil::fast_rand_less_than(ARRAY_SIZE(lb_algo))], &options), 0); - test::EchoRequest req; req.set_message("123"); test::EchoResponse res; test::EchoService_Stub stub(&channel); - // trigger one server to health check - { - brpc::Controller cntl; - stub.Echo(&cntl, &req, &res, NULL); - } - bthread_usleep(500000); - // trigger the other server to health check + int64_t start_ms = butil::gettimeofday_ms(); + // trigger to health check { brpc::Controller cntl; stub.Echo(&cntl, &req, &res, NULL); @@ -949,30 +941,28 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { ASSERT_EQ(0, server2.AddService(&service2, brpc::SERVER_DOESNT_OWN_SERVICE)); ASSERT_EQ(0, server2.Start(point2, NULL)); - int64_t start_ms = butil::gettimeofday_ms(); - butil::atomic num_reject(0); - int64_t q = 0; - while ((butil::gettimeofday_ms() - start_ms) < - brpc::FLAGS_health_check_interval * 1000 + 10) { + // keep sending for 2900ms(100ms less than hc interval) to make sure all requests + // are sent during hc. Those requests should be all failed and error code should + // be brpc::EREJECT. + while ((butil::gettimeofday_ms() - start_ms) < 2900) { Done* done = new Done; - done->num_reject = &num_reject; done->req.set_message("123"); stub.Echo(&done->cntl, &done->req, &done->res, done); - q++; bthread_usleep(1000); } - ASSERT_TRUE(num_reject.load(butil::memory_order_relaxed) > 1700); + ASSERT_EQ(num_reject.load(butil::memory_order_relaxed), + num_failed.load(butil::memory_order_relaxed)); + num_failed.store(0, butil::memory_order_relaxed); + bthread_usleep(500000); // should recover now - butil::atomic num_failed(0); for (int i = 0; i < 1000; ++i) { Done* done = new Done; done->req.set_message("123"); - done->num_failed = &num_failed; stub.Echo(&done->cntl, &done->req, &done->res, done); bthread_usleep(1000); } - bthread_usleep(1050*1000 /* sleep longer than timeout of service */); + bthread_usleep(500000 /* sleep longer than timeout of channel */); ASSERT_EQ(0, num_failed.load(butil::memory_order_relaxed)); } From f98fd01f9cab026b0b8d391ae5f272b1c05d8826 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 16 Apr 2019 15:02:59 +0800 Subject: [PATCH 144/270] revived_from_all_failed: split KeyValuePairSplitter into different pr --- src/brpc/cluster_recover_policy.cpp | 20 +++---- src/brpc/cluster_recover_policy.h | 2 + .../consistent_hashing_load_balancer.cpp | 6 +-- src/butil/string_splitter.h | 1 - test/string_splitter_unittest.cpp | 52 ------------------- 5 files changed, 16 insertions(+), 65 deletions(-) diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index b859004d..dced236b 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -54,6 +54,7 @@ bool DefaultClusterRecoverPolicy::StopRecoverIfNecessary() { if (_last_usable_change_time_ms != 0 && _last_usable != 0 && (now_ms - _last_usable_change_time_ms > _hold_time_ms)) { _recovering = false; + _last_usable = 0; _last_usable_change_time_ms = 0; mu.unlock(); return false; @@ -109,26 +110,27 @@ bool GetRecoverPolicyByParams(const butil::StringPiece& params, int64_t minimum_working_instances = -1; int64_t hold_time_ms = -1; bool has_meet_params = false; - for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), '=', ' '); - sp; ++sp) { - if (sp.value().empty()) { - LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; + for (butil::StringSplitter sp(params.begin(), params.end(), ' '); sp != nullptr; ++sp) { + butil::StringPiece key_value(sp.field(), sp.length()); + size_t p = key_value.find('='); + if (p == key_value.npos || p == key_value.size() - 1) { + // No value configed. return false; } - if (sp.key() == "minimum_working_instances") { - if (!butil::StringToInt64(sp.value(), &minimum_working_instances)) { + if (key_value.substr(0, p) == "minimum_working_instances") { + if (!butil::StringToInt64(key_value.substr(p + 1), &minimum_working_instances)) { return false; } has_meet_params = true; continue; - } else if (sp.key() == "hold_time_ms") { - if (!butil::StringToInt64(sp.value(), &hold_time_ms)) { + } else if (key_value.substr(0, p) == "hold_time_ms") { + if (!butil::StringToInt64(key_value.substr(p + 1), &hold_time_ms)) { return false; } has_meet_params = true; continue; } - LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); + LOG(ERROR) << "Failed to set this unknown parameters " << key_value; } if (minimum_working_instances > 0 && hold_time_ms > 0) { ptr_out->reset( diff --git a/src/brpc/cluster_recover_policy.h b/src/brpc/cluster_recover_policy.h index 71aea831..8a5a0565 100644 --- a/src/brpc/cluster_recover_policy.h +++ b/src/brpc/cluster_recover_policy.h @@ -36,6 +36,8 @@ class ServerId; // servers when recovering from all servers are down. class ClusterRecoverPolicy { public: + virtual ~ClusterRecoverPolicy() {} + // Indicate that recover from all server being down is happening. virtual void StartRecover() = 0; diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 0b761079..0c06264f 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -385,13 +385,13 @@ bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& para LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; return false; } - if (sp.key() == "replicas") { - if (!butil::StringToSizeT(sp.value(), &_num_replicas)) { + if (key_value.substr(0, p) == "replicas") { + if (!butil::StringToSizeT(key_value.substr(p + 1), &_num_replicas)) { return false; } continue; } - LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); + LOG(ERROR) << "Failed to set this unknown parameters " << key_value; } return true; } diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index b38b9c10..c920706a 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -22,7 +22,6 @@ #include #include -#include "butil/strings/string_piece.h" // It's common to encode data into strings separated by special characters // and decode them back, but functions such as `split_string' has to modify diff --git a/test/string_splitter_unittest.cpp b/test/string_splitter_unittest.cpp index 6963e089..da6024c2 100644 --- a/test/string_splitter_unittest.cpp +++ b/test/string_splitter_unittest.cpp @@ -386,56 +386,4 @@ TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { } } -TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { - std::string kvstr = "key1=value1&key2=value2&key3=value3"; - { - butil::KeyValuePairsSplitter splitter(kvstr, '=', '&'); - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key1"); - ASSERT_EQ(splitter.value(), "value1"); - ++splitter; - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key2"); - ASSERT_EQ(splitter.value(), "value2"); - ++splitter; - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key3"); - ASSERT_EQ(splitter.value(), "value3"); - ++splitter; - ASSERT_FALSE(splitter); - } - { - butil::KeyValuePairsSplitter splitter(kvstr.data(), kvstr.data() + kvstr.size(), '=', '&'); - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key1"); - ASSERT_EQ(splitter.value(), "value1"); - ++splitter; - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key2"); - ASSERT_EQ(splitter.value(), "value2"); - ++splitter; - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key3"); - ASSERT_EQ(splitter.value(), "value3"); - ++splitter; - ASSERT_FALSE(splitter); - } - { - butil::KeyValuePairsSplitter splitter(kvstr.c_str(), '=', '&'); - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key1"); - ASSERT_EQ(splitter.value(), "value1"); - ++splitter; - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key2"); - ASSERT_EQ(splitter.value(), "value2"); - ++splitter; - ASSERT_TRUE(splitter); - ASSERT_EQ(splitter.key(), "key3"); - ASSERT_EQ(splitter.value(), "value3"); - ++splitter; - ASSERT_FALSE(splitter); - } -} - } From 24d216231d89f55fc82a991eccd707097d67fc50 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 16 Apr 2019 15:13:31 +0800 Subject: [PATCH 145/270] revived_from_all_failed: restore uri.cpp --- src/brpc/uri.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/brpc/uri.cpp b/src/brpc/uri.cpp index 6fe0e4d0..5969c47c 100644 --- a/src/brpc/uri.cpp +++ b/src/brpc/uri.cpp @@ -407,6 +407,19 @@ void URI::SetH2Path(const char* h2_path) { } } +void QuerySplitter::split() { + butil::StringPiece query_pair(_sp.field(), _sp.length()); + const size_t pos = query_pair.find('='); + if (pos == butil::StringPiece::npos) { + _key = query_pair; + _value.clear(); + } else { + _key= query_pair.substr(0, pos); + _value = query_pair.substr(pos + 1); + } + _is_split = true; +} + QueryRemover::QueryRemover(const std::string* str) : _query(str) , _qs(str->data(), str->data() + str->size()) From df189862334b7194d783f230dc32dd7d1369475c Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 17 Apr 2019 14:42:11 +0800 Subject: [PATCH 146/270] revived_from_all_failed: replace StringSplitter with KeyValyePairsSplitter --- src/brpc/cluster_recover_policy.cpp | 19 +++++++++---------- .../consistent_hashing_load_balancer.cpp | 6 +++--- src/butil/string_splitter.h | 1 + 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index dced236b..e6d085b0 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -110,27 +110,26 @@ bool GetRecoverPolicyByParams(const butil::StringPiece& params, int64_t minimum_working_instances = -1; int64_t hold_time_ms = -1; bool has_meet_params = false; - for (butil::StringSplitter sp(params.begin(), params.end(), ' '); sp != nullptr; ++sp) { - butil::StringPiece key_value(sp.field(), sp.length()); - size_t p = key_value.find('='); - if (p == key_value.npos || p == key_value.size() - 1) { - // No value configed. + for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), '=', ' '); + sp; ++sp) { + if (sp.value().empty()) { + LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; return false; } - if (key_value.substr(0, p) == "minimum_working_instances") { - if (!butil::StringToInt64(key_value.substr(p + 1), &minimum_working_instances)) { + if (sp.key() == "minimum_working_instances") { + if (!butil::StringToInt64(sp.value(), &minimum_working_instances)) { return false; } has_meet_params = true; continue; - } else if (key_value.substr(0, p) == "hold_time_ms") { - if (!butil::StringToInt64(key_value.substr(p + 1), &hold_time_ms)) { + } else if (sp.key() == "hold_time_ms") { + if (!butil::StringToInt64(sp.value(), &hold_time_ms)) { return false; } has_meet_params = true; continue; } - LOG(ERROR) << "Failed to set this unknown parameters " << key_value; + LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); } if (minimum_working_instances > 0 && hold_time_ms > 0) { ptr_out->reset( diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 0c06264f..0b761079 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -385,13 +385,13 @@ bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& para LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; return false; } - if (key_value.substr(0, p) == "replicas") { - if (!butil::StringToSizeT(key_value.substr(p + 1), &_num_replicas)) { + if (sp.key() == "replicas") { + if (!butil::StringToSizeT(sp.value(), &_num_replicas)) { return false; } continue; } - LOG(ERROR) << "Failed to set this unknown parameters " << key_value; + LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); } return true; } diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index c920706a..b38b9c10 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -22,6 +22,7 @@ #include #include +#include "butil/strings/string_piece.h" // It's common to encode data into strings separated by special characters // and decode them back, but functions such as `split_string' has to modify From 30d1fbb044b0e57c227947d93ccdc3aad2ed2737 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 17 Apr 2019 14:55:13 +0800 Subject: [PATCH 147/270] revived_from_all_failed: restore uri.* after rebase --- src/brpc/uri.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/brpc/uri.cpp b/src/brpc/uri.cpp index 5969c47c..6fe0e4d0 100644 --- a/src/brpc/uri.cpp +++ b/src/brpc/uri.cpp @@ -407,19 +407,6 @@ void URI::SetH2Path(const char* h2_path) { } } -void QuerySplitter::split() { - butil::StringPiece query_pair(_sp.field(), _sp.length()); - const size_t pos = query_pair.find('='); - if (pos == butil::StringPiece::npos) { - _key = query_pair; - _value.clear(); - } else { - _key= query_pair.substr(0, pos); - _value = query_pair.substr(pos + 1); - } - _is_split = true; -} - QueryRemover::QueryRemover(const std::string* str) : _query(str) , _qs(str->data(), str->data() + str->size()) From 2c820f8f20be2cf7bbeb7e8b2b754eb6371f937b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 17 Apr 2019 15:33:15 +0800 Subject: [PATCH 148/270] revived_from_all_failed: enhance UT --- test/brpc_load_balancer_unittest.cpp | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index cb5c31c0..2ea874b2 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -882,8 +882,8 @@ public: butil::atomic _num_request; }; -butil::atomic num_failed; -butil::atomic num_reject; +butil::atomic num_failed(0); +butil::atomic num_reject(0); class Done : public google::protobuf::Closure { public: @@ -915,6 +915,8 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { options.protocol = "http"; options.timeout_ms = 300; options.enable_circuit_breaker = true; + // Disable retry to make health check happen one by one + options.max_retry = 0; ASSERT_EQ(channel.Init("list://127.0.0.1:7777 50, 127.0.0.1:7778 50", lb_algo[butil::fast_rand_less_than(ARRAY_SIZE(lb_algo))], &options), 0); @@ -922,9 +924,16 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { req.set_message("123"); test::EchoResponse res; test::EchoService_Stub stub(&channel); - int64_t start_ms = butil::gettimeofday_ms(); - // trigger to health check { + // trigger one server to health check + brpc::Controller cntl; + stub.Echo(&cntl, &req, &res, NULL); + } + // This sleep make one server revived 700ms earlier than the other server, which + // can make the server down again if no request limit policy are applied here. + bthread_usleep(700000); + { + // trigger the other server to health check brpc::Controller cntl; stub.Echo(&cntl, &req, &res, NULL); } @@ -941,20 +950,21 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { ASSERT_EQ(0, server2.AddService(&service2, brpc::SERVER_DOESNT_OWN_SERVICE)); ASSERT_EQ(0, server2.Start(point2, NULL)); - // keep sending for 2900ms(100ms less than hc interval) to make sure all requests - // are sent during hc. Those requests should be all failed and error code should - // be brpc::EREJECT. - while ((butil::gettimeofday_ms() - start_ms) < 2900) { + int64_t start_ms = butil::gettimeofday_ms(); + while ((butil::gettimeofday_ms() - start_ms) < 3500) { Done* done = new Done; done->req.set_message("123"); stub.Echo(&done->cntl, &done->req, &done->res, done); bthread_usleep(1000); } - ASSERT_EQ(num_reject.load(butil::memory_order_relaxed), - num_failed.load(butil::memory_order_relaxed)); + // All error code should be equal to EREJECT, except when the situation + // all servers are down, the very first call that trigger recovering would + // fail with EHOSTDOWN instead of EREJECT. This is where the number 1 comes + // in following ASSERT. + ASSERT_TRUE(num_failed.load(butil::memory_order_relaxed) - + num_reject.load(butil::memory_order_relaxed) == 1); num_failed.store(0, butil::memory_order_relaxed); - bthread_usleep(500000); // should recover now for (int i = 0; i < 1000; ++i) { Done* done = new Done; From d8fa3d510d188de06cfc2862600185c5be8fed84 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 17 Apr 2019 18:01:30 +0800 Subject: [PATCH 149/270] revived_from_all_failed: change delim order in Splitter & enhance UT & replace SplitStringIntoKeyValuePairs --- src/brpc/cluster_recover_policy.cpp | 28 +++++++++---------- src/brpc/cluster_recover_policy.h | 8 +++--- .../consistent_hashing_load_balancer.cpp | 1 - test/brpc_load_balancer_unittest.cpp | 21 ++++++++++---- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index e6d085b0..b32b9938 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -31,12 +31,12 @@ DEFINE_int64(detect_available_server_interval_ms, 10, "The interval " "to detect available server count in DefaultClusterRecoverPolicy"); DefaultClusterRecoverPolicy::DefaultClusterRecoverPolicy( - int64_t minimum_working_instances, int64_t hold_time_ms) + int64_t min_working_instances, int64_t hold_seconds) : _recovering(false) - , _minimum_working_instances(minimum_working_instances) + , _min_working_instances(min_working_instances) , _last_usable(0) , _last_usable_change_time_ms(0) - , _hold_time_ms(hold_time_ms) + , _hold_seconds(hold_seconds) , _usable_cache(0) , _usable_cache_time_ms(0) { } @@ -52,7 +52,7 @@ bool DefaultClusterRecoverPolicy::StopRecoverIfNecessary() { int64_t now_ms = butil::gettimeofday_ms(); std::unique_lock mu(_mutex); if (_last_usable_change_time_ms != 0 && _last_usable != 0 && - (now_ms - _last_usable_change_time_ms > _hold_time_ms)) { + (now_ms - _last_usable_change_time_ms > _hold_seconds)) { _recovering = false; _last_usable = 0; _last_usable_change_time_ms = 0; @@ -99,7 +99,7 @@ bool DefaultClusterRecoverPolicy::DoReject(const std::vector& server_l _last_usable_change_time_ms = now_ms; } } - if (butil::fast_rand_less_than(_minimum_working_instances) >= usable) { + if (butil::fast_rand_less_than(_min_working_instances) >= usable) { return true; } return false; @@ -107,23 +107,23 @@ bool DefaultClusterRecoverPolicy::DoReject(const std::vector& server_l bool GetRecoverPolicyByParams(const butil::StringPiece& params, std::shared_ptr* ptr_out) { - int64_t minimum_working_instances = -1; - int64_t hold_time_ms = -1; + int64_t min_working_instances = -1; + int64_t hold_seconds = -1; bool has_meet_params = false; - for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), '=', ' '); + for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), ' ', '='); sp; ++sp) { if (sp.value().empty()) { LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; return false; } - if (sp.key() == "minimum_working_instances") { - if (!butil::StringToInt64(sp.value(), &minimum_working_instances)) { + if (sp.key() == "min_working_instances") { + if (!butil::StringToInt64(sp.value(), &min_working_instances)) { return false; } has_meet_params = true; continue; - } else if (sp.key() == "hold_time_ms") { - if (!butil::StringToInt64(sp.value(), &hold_time_ms)) { + } else if (sp.key() == "hold_seconds") { + if (!butil::StringToInt64(sp.value(), &hold_seconds)) { return false; } has_meet_params = true; @@ -131,9 +131,9 @@ bool GetRecoverPolicyByParams(const butil::StringPiece& params, } LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); } - if (minimum_working_instances > 0 && hold_time_ms > 0) { + if (min_working_instances > 0 && hold_seconds > 0) { ptr_out->reset( - new DefaultClusterRecoverPolicy(minimum_working_instances, hold_time_ms)); + new DefaultClusterRecoverPolicy(min_working_instances, hold_seconds)); } else if (has_meet_params) { // In this case, user set some params but not in the right way, just return // false to let user take care of this situation. diff --git a/src/brpc/cluster_recover_policy.h b/src/brpc/cluster_recover_policy.h index 8a5a0565..c09933b4 100644 --- a/src/brpc/cluster_recover_policy.h +++ b/src/brpc/cluster_recover_policy.h @@ -53,11 +53,11 @@ public: // If in recover state, the probability that a request is accepted is q/n, in // which q is the number of current available server, n is the number of minimum // working instances setting by user. If q is not changed during a given time, -// hold_time_ms, then the cluster is considered recovered and all the request +// hold_seconds, then the cluster is considered recovered and all the request // would be sent to the current available servers. class DefaultClusterRecoverPolicy : public ClusterRecoverPolicy { public: - DefaultClusterRecoverPolicy(int64_t minimum_working_instances, int64_t hold_time_ms); + DefaultClusterRecoverPolicy(int64_t min_working_instances, int64_t hold_seconds); void StartRecover(); bool DoReject(const std::vector& server_list); @@ -68,11 +68,11 @@ private: private: bool _recovering; - int64_t _minimum_working_instances; + int64_t _min_working_instances; butil::Mutex _mutex; uint64_t _last_usable; int64_t _last_usable_change_time_ms; - int64_t _hold_time_ms; + int64_t _hold_seconds; uint64_t _usable_cache; int64_t _usable_cache_time_ms; }; diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 0b761079..8baacee1 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -20,7 +20,6 @@ #include "butil/containers/flat_map.h" #include "butil/errno.h" #include "butil/strings/string_number_conversions.h" -#include "butil/strings/string_split.h" #include "brpc/socket.h" #include "brpc/policy/consistent_hashing_load_balancer.h" #include "brpc/policy/hasher.h" diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index 2ea874b2..af484fb0 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -797,10 +797,10 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { int rand = butil::fast_rand_less_than(2); if (rand == 0) { brpc::policy::RandomizedLoadBalancer rlb; - lb = rlb.New("minimum_working_instances=2 hold_time_ms=2000"); + lb = rlb.New("min_working_instances=2 hold_seconds=2000"); } else if (rand == 1) { brpc::policy::RoundRobinLoadBalancer rrlb; - lb = rrlb.New("minimum_working_instances=2 hold_time_ms=2000"); + lb = rrlb.New("min_working_instances=2 hold_seconds=2000"); } brpc::SocketUniquePtr ptr[2]; for (size_t i = 0; i < ARRAY_SIZE(servers); ++i) { @@ -846,7 +846,7 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { } } ASSERT_TRUE(abs(num_ereject - num_ok) < 30); - bthread_usleep((2000 /* hold_time_ms */ + 10) * 1000); + bthread_usleep((2000 /* hold_seconds */ + 10) * 1000); // After enough waiting time, traffic should be sent to all available servers. for (int i = 0; i < 10; ++i) { @@ -901,6 +901,17 @@ public: test::EchoResponse res; }; +TEST_F(LoadBalancerTest, invalid_lb_params) { + const char* lb_algo[] = { "random:mi_working_instances=2 hold_seconds=2000", + "rr:min_working_instances=2 hold_secon=2000" }; + brpc::Channel channel; + brpc::ChannelOptions options; + options.protocol = "http"; + ASSERT_EQ(channel.Init("list://127.0.0.1:7777 50, 127.0.0.1:7778 50", + lb_algo[butil::fast_rand_less_than(ARRAY_SIZE(lb_algo))], + &options), -1); +} + TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_size", "20"); GFLAGS_NS::SetCommandLineOption("circuit_breaker_short_window_error_percent", "30"); @@ -908,8 +919,8 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { GFLAGS_NS::SetCommandLineOption("circuit_breaker_max_isolation_duration_ms", "3000"); GFLAGS_NS::SetCommandLineOption("circuit_breaker_min_isolation_duration_ms", "3000"); - const char* lb_algo[] = { "random:minimum_working_instances=2 hold_time_ms=2000", - "rr:minimum_working_instances=2 hold_time_ms=2000" }; + const char* lb_algo[] = { "random:min_working_instances=2 hold_seconds=2000", + "rr:min_working_instances=2 hold_seconds=2000" }; brpc::Channel channel; brpc::ChannelOptions options; options.protocol = "http"; From 3aa31a2c7d149d686e7fafccc511b284ec9888e1 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 17 Apr 2019 18:07:29 +0800 Subject: [PATCH 150/270] revived_from_all_failed: return false when met unknown lb params --- src/brpc/cluster_recover_policy.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index b32b9938..7da58846 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -130,6 +130,7 @@ bool GetRecoverPolicyByParams(const butil::StringPiece& params, continue; } LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); + return false; } if (min_working_instances > 0 && hold_seconds > 0) { ptr_out->reset( From 686771fe45683905aa52a4331639004e0c90da74 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 17 Apr 2019 19:24:24 +0800 Subject: [PATCH 151/270] revived_from_all_failed: revert unrelated files --- .../consistent_hashing_load_balancer.cpp | 20 ++++++++--------- src/brpc/uri.h | 6 ++--- src/butil/string_splitter.h | 22 +++++++++---------- src/bvar/variable.cpp | 15 ++++++++----- test/string_splitter_unittest.cpp | 6 ++--- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 8baacee1..20a043ea 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -270,11 +270,10 @@ size_t ConsistentHashingLoadBalancer::RemoveServersInBatch( return n; } -LoadBalancer *ConsistentHashingLoadBalancer::New( - const butil::StringPiece& params) const { +LoadBalancer *ConsistentHashingLoadBalancer::New(const butil::StringPiece& params) const { ConsistentHashingLoadBalancer* lb = new (std::nothrow) ConsistentHashingLoadBalancer(_type); - if (lb && !lb->SetParameters(params)) { + if (lb != nullptr && !lb->SetParameters(params)) { delete lb; lb = nullptr; } @@ -378,19 +377,20 @@ void ConsistentHashingLoadBalancer::GetLoads( } bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& params) { - for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), ' ', '='); - sp; ++sp) { - if (sp.value().empty()) { - LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; + for (butil::StringSplitter sp(params.begin(), params.end(), ' '); sp != nullptr; ++sp) { + butil::StringPiece key_value(sp.field(), sp.length()); + size_t p = key_value.find('='); + if (p == key_value.npos || p == key_value.size() - 1) { + // No value configed. return false; } - if (sp.key() == "replicas") { - if (!butil::StringToSizeT(sp.value(), &_num_replicas)) { + if (key_value.substr(0, p) == "replicas") { + if (!butil::StringToSizeT(key_value.substr(p + 1), &_num_replicas)) { return false; } continue; } - LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); + LOG(ERROR) << "Failed to set this unknown parameters " << key_value; } return true; } diff --git a/src/brpc/uri.h b/src/brpc/uri.h index 706f5470..59ccb9bf 100644 --- a/src/brpc/uri.h +++ b/src/brpc/uri.h @@ -198,15 +198,15 @@ inline std::ostream& operator<<(std::ostream& os, const URI& uri) { class QuerySplitter : public butil::KeyValuePairsSplitter { public: inline QuerySplitter(const char* str_begin, const char* str_end) - : KeyValuePairsSplitter(str_begin, str_end, '&', '=') + : KeyValuePairsSplitter(str_begin, str_end, '=', '&') {} inline QuerySplitter(const char* str_begin) - : KeyValuePairsSplitter(str_begin, '&', '=') + : KeyValuePairsSplitter(str_begin, '=', '&') {} inline QuerySplitter(const butil::StringPiece &sp) - : KeyValuePairsSplitter(sp, '&', '=') + : KeyValuePairsSplitter(sp, '=', '&') {} }; diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index b38b9c10..b85f60d7 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -167,8 +167,8 @@ private: // Split query in the format according to the given delimiters. // This class can also handle some exceptional cases. -// 1. consecutive pair_delimiter are omitted, for example, -// suppose key_value_delimiter is '=' and pair_delimiter +// 1. consecutive key_value_pair_delimiter are omitted, for example, +// suppose key_value_delimiter is '=' and key_value_pair_delimiter // is '&', then 'k1=v1&&&k2=v2' is normalized to 'k1=k2&k2=v2'. // 2. key or value can be empty or both can be empty. // 3. consecutive key_value_delimiter are not omitted, for example, @@ -178,25 +178,25 @@ class KeyValuePairsSplitter { public: inline KeyValuePairsSplitter(const char* str_begin, const char* str_end, - char pair_delimiter, - char key_value_delimiter) - : _sp(str_begin, str_end, pair_delimiter) + char key_value_delimiter, + char key_value_pair_delimiter) + : _sp(str_begin, str_end, key_value_pair_delimiter) , _delim_pos(StringPiece::npos) , _key_value_delim(key_value_delimiter) { UpdateDelimiterPosition(); } inline KeyValuePairsSplitter(const char* str_begin, - char pair_delimiter, - char key_value_delimiter) + char key_value_delimiter, + char key_value_pair_delimiter) : KeyValuePairsSplitter(str_begin, NULL, - pair_delimiter, key_value_delimiter) {} + key_value_delimiter, key_value_pair_delimiter) {} inline KeyValuePairsSplitter(const StringPiece &sp, - char pair_delimiter, - char key_value_delimiter) + char key_value_delimiter, + char key_value_pair_delimiter) : KeyValuePairsSplitter(sp.begin(), sp.end(), - pair_delimiter, key_value_delimiter) {} + key_value_delimiter, key_value_pair_delimiter) {} inline StringPiece key() { return key_and_value().substr(0, _delim_pos); diff --git a/src/bvar/variable.cpp b/src/bvar/variable.cpp index d31ba9c7..cfb4c920 100644 --- a/src/bvar/variable.cpp +++ b/src/bvar/variable.cpp @@ -24,6 +24,7 @@ #include "butil/containers/flat_map.h" // butil::FlatMap #include "butil/scoped_lock.h" // BAIDU_SCOPE_LOCK #include "butil/string_splitter.h" // butil::StringSplitter +#include "butil/strings/string_split.h" // butil::SplitStringIntoKeyValuePairs #include "butil/errno.h" // berror #include "butil/time.h" // milliseconds_from_now #include "butil/file_util.h" // butil::FilePath @@ -626,13 +627,15 @@ public: // .data will be appended later path = path.RemoveFinalExtension(); } - - for (butil::KeyValuePairsSplitter sp(tabs, ';', '='); sp; ++sp) { - std::string key = sp.key().as_string(); - std::string value = sp.value().as_string(); + butil::StringPairs pairs; + pairs.reserve(8); + butil::SplitStringIntoKeyValuePairs(tabs, '=', ';', &pairs); + dumpers.reserve(pairs.size() + 1); + //matchers.reserve(pairs.size()); + for (size_t i = 0; i < pairs.size(); ++i) { FileDumper *f = new FileDumper( - path.AddExtension(key).AddExtension("data").value(), s); - WildcardMatcher *m = new WildcardMatcher(value, '?', true); + path.AddExtension(pairs[i].first).AddExtension("data").value(), s); + WildcardMatcher *m = new WildcardMatcher(pairs[i].second, '?', true); dumpers.push_back(std::make_pair(f, m)); } dumpers.push_back(std::make_pair( diff --git a/test/string_splitter_unittest.cpp b/test/string_splitter_unittest.cpp index da6024c2..e88e1bc8 100644 --- a/test/string_splitter_unittest.cpp +++ b/test/string_splitter_unittest.cpp @@ -343,12 +343,12 @@ TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { // Test three constructors butil::KeyValuePairsSplitter* psplitter = NULL; if (i == 0) { - psplitter = new butil::KeyValuePairsSplitter(kvstr, '&', '='); + psplitter = new butil::KeyValuePairsSplitter(kvstr, '=', '&'); } else if (i == 1) { psplitter = new butil::KeyValuePairsSplitter( - kvstr.data(), kvstr.data() + kvstr.size(), '&', '='); + kvstr.data(), kvstr.data() + kvstr.size(), '=', '&'); } else if (i == 2) { - psplitter = new butil::KeyValuePairsSplitter(kvstr.c_str(), '&', '='); + psplitter = new butil::KeyValuePairsSplitter(kvstr.c_str(), '=', '&'); } butil::KeyValuePairsSplitter& splitter = *psplitter; From fd3295d3791faea2c3386e2bb48b4f40e24b500b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 18 Apr 2019 11:53:52 +0800 Subject: [PATCH 152/270] revived_from_all_failed: fix UT --- src/brpc/cluster_recover_policy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index 7da58846..c262a75e 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -110,7 +110,7 @@ bool GetRecoverPolicyByParams(const butil::StringPiece& params, int64_t min_working_instances = -1; int64_t hold_seconds = -1; bool has_meet_params = false; - for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), ' ', '='); + for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), '=', ' '); sp; ++sp) { if (sp.value().empty()) { LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; From f3acf3d887aa8394bf7e4de15a8d7ca723a528cb Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 18 Apr 2019 12:16:28 +0800 Subject: [PATCH 153/270] revived_from_all_failed: fix codes after rebase --- src/brpc/cluster_recover_policy.cpp | 2 +- .../consistent_hashing_load_balancer.cpp | 17 +++++++------ src/brpc/uri.h | 6 ++--- src/butil/string_splitter.h | 24 +++++++++---------- src/bvar/variable.cpp | 15 +++++------- test/string_splitter_unittest.cpp | 6 ++--- 6 files changed, 33 insertions(+), 37 deletions(-) diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index c262a75e..7da58846 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -110,7 +110,7 @@ bool GetRecoverPolicyByParams(const butil::StringPiece& params, int64_t min_working_instances = -1; int64_t hold_seconds = -1; bool has_meet_params = false; - for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), '=', ' '); + for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), ' ', '='); sp; ++sp) { if (sp.value().empty()) { LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 20a043ea..56a2096d 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -273,7 +273,7 @@ size_t ConsistentHashingLoadBalancer::RemoveServersInBatch( LoadBalancer *ConsistentHashingLoadBalancer::New(const butil::StringPiece& params) const { ConsistentHashingLoadBalancer* lb = new (std::nothrow) ConsistentHashingLoadBalancer(_type); - if (lb != nullptr && !lb->SetParameters(params)) { + if (lb && !lb->SetParameters(params)) { delete lb; lb = nullptr; } @@ -377,20 +377,19 @@ void ConsistentHashingLoadBalancer::GetLoads( } bool ConsistentHashingLoadBalancer::SetParameters(const butil::StringPiece& params) { - for (butil::StringSplitter sp(params.begin(), params.end(), ' '); sp != nullptr; ++sp) { - butil::StringPiece key_value(sp.field(), sp.length()); - size_t p = key_value.find('='); - if (p == key_value.npos || p == key_value.size() - 1) { - // No value configed. + for (butil::KeyValuePairsSplitter sp(params.begin(), params.end(), ' ', '='); + sp; ++sp) { + if (sp.value().empty()) { + LOG(ERROR) << "Empty value for " << sp.key() << " in lb parameter"; return false; } - if (key_value.substr(0, p) == "replicas") { - if (!butil::StringToSizeT(key_value.substr(p + 1), &_num_replicas)) { + if (sp.key() == "replicas") { + if (!butil::StringToSizeT(sp.value(), &_num_replicas)) { return false; } continue; } - LOG(ERROR) << "Failed to set this unknown parameters " << key_value; + LOG(ERROR) << "Failed to set this unknown parameters " << sp.key_and_value(); } return true; } diff --git a/src/brpc/uri.h b/src/brpc/uri.h index 59ccb9bf..706f5470 100644 --- a/src/brpc/uri.h +++ b/src/brpc/uri.h @@ -198,15 +198,15 @@ inline std::ostream& operator<<(std::ostream& os, const URI& uri) { class QuerySplitter : public butil::KeyValuePairsSplitter { public: inline QuerySplitter(const char* str_begin, const char* str_end) - : KeyValuePairsSplitter(str_begin, str_end, '=', '&') + : KeyValuePairsSplitter(str_begin, str_end, '&', '=') {} inline QuerySplitter(const char* str_begin) - : KeyValuePairsSplitter(str_begin, '=', '&') + : KeyValuePairsSplitter(str_begin, '&', '=') {} inline QuerySplitter(const butil::StringPiece &sp) - : KeyValuePairsSplitter(sp, '=', '&') + : KeyValuePairsSplitter(sp, '&', '=') {} }; diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index b85f60d7..aeb9e13e 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -167,8 +167,8 @@ private: // Split query in the format according to the given delimiters. // This class can also handle some exceptional cases. -// 1. consecutive key_value_pair_delimiter are omitted, for example, -// suppose key_value_delimiter is '=' and key_value_pair_delimiter +// 1. consecutive pair_delimiter are omitted, for example, +// suppose key_value_delimiter is '=' and pair_delimiter // is '&', then 'k1=v1&&&k2=v2' is normalized to 'k1=k2&k2=v2'. // 2. key or value can be empty or both can be empty. // 3. consecutive key_value_delimiter are not omitted, for example, @@ -178,25 +178,25 @@ class KeyValuePairsSplitter { public: inline KeyValuePairsSplitter(const char* str_begin, const char* str_end, - char key_value_delimiter, - char key_value_pair_delimiter) - : _sp(str_begin, str_end, key_value_pair_delimiter) + char pair_delimiter, + char key_value_delimiter) + : _sp(str_begin, str_end, pair_delimiter) , _delim_pos(StringPiece::npos) , _key_value_delim(key_value_delimiter) { UpdateDelimiterPosition(); } inline KeyValuePairsSplitter(const char* str_begin, - char key_value_delimiter, - char key_value_pair_delimiter) + char pair_delimiter, + char key_value_delimiter) : KeyValuePairsSplitter(str_begin, NULL, - key_value_delimiter, key_value_pair_delimiter) {} + pair_delimiter, key_value_delimiter) {} inline KeyValuePairsSplitter(const StringPiece &sp, - char key_value_delimiter, - char key_value_pair_delimiter) + char pair_delimiter, + char key_value_delimiter) : KeyValuePairsSplitter(sp.begin(), sp.end(), - key_value_delimiter, key_value_pair_delimiter) {} + pair_delimiter, key_value_delimiter) {} inline StringPiece key() { return key_and_value().substr(0, _delim_pos); @@ -206,7 +206,7 @@ public: return key_and_value().substr(_delim_pos + 1); } - // Get the current value of key and value + // Get the current value of key and value // in the format of "key=value" inline StringPiece key_and_value() { return StringPiece(_sp.field(), _sp.length()); diff --git a/src/bvar/variable.cpp b/src/bvar/variable.cpp index cfb4c920..d31ba9c7 100644 --- a/src/bvar/variable.cpp +++ b/src/bvar/variable.cpp @@ -24,7 +24,6 @@ #include "butil/containers/flat_map.h" // butil::FlatMap #include "butil/scoped_lock.h" // BAIDU_SCOPE_LOCK #include "butil/string_splitter.h" // butil::StringSplitter -#include "butil/strings/string_split.h" // butil::SplitStringIntoKeyValuePairs #include "butil/errno.h" // berror #include "butil/time.h" // milliseconds_from_now #include "butil/file_util.h" // butil::FilePath @@ -627,15 +626,13 @@ public: // .data will be appended later path = path.RemoveFinalExtension(); } - butil::StringPairs pairs; - pairs.reserve(8); - butil::SplitStringIntoKeyValuePairs(tabs, '=', ';', &pairs); - dumpers.reserve(pairs.size() + 1); - //matchers.reserve(pairs.size()); - for (size_t i = 0; i < pairs.size(); ++i) { + + for (butil::KeyValuePairsSplitter sp(tabs, ';', '='); sp; ++sp) { + std::string key = sp.key().as_string(); + std::string value = sp.value().as_string(); FileDumper *f = new FileDumper( - path.AddExtension(pairs[i].first).AddExtension("data").value(), s); - WildcardMatcher *m = new WildcardMatcher(pairs[i].second, '?', true); + path.AddExtension(key).AddExtension("data").value(), s); + WildcardMatcher *m = new WildcardMatcher(value, '?', true); dumpers.push_back(std::make_pair(f, m)); } dumpers.push_back(std::make_pair( diff --git a/test/string_splitter_unittest.cpp b/test/string_splitter_unittest.cpp index e88e1bc8..da6024c2 100644 --- a/test/string_splitter_unittest.cpp +++ b/test/string_splitter_unittest.cpp @@ -343,12 +343,12 @@ TEST_F(StringSplitterTest, key_value_pairs_splitter_sanity) { // Test three constructors butil::KeyValuePairsSplitter* psplitter = NULL; if (i == 0) { - psplitter = new butil::KeyValuePairsSplitter(kvstr, '=', '&'); + psplitter = new butil::KeyValuePairsSplitter(kvstr, '&', '='); } else if (i == 1) { psplitter = new butil::KeyValuePairsSplitter( - kvstr.data(), kvstr.data() + kvstr.size(), '=', '&'); + kvstr.data(), kvstr.data() + kvstr.size(), '&', '='); } else if (i == 2) { - psplitter = new butil::KeyValuePairsSplitter(kvstr.c_str(), '=', '&'); + psplitter = new butil::KeyValuePairsSplitter(kvstr.c_str(), '&', '='); } butil::KeyValuePairsSplitter& splitter = *psplitter; From cde9a4a04a5e9d4960412214586b50914a2d68b1 Mon Sep 17 00:00:00 2001 From: gejun Date: Thu, 18 Apr 2019 18:32:19 +0800 Subject: [PATCH 154/270] Make some timeout in UT larger --- test/brpc_channel_unittest.cpp | 8 ++++---- test/brpc_server_unittest.cpp | 8 ++++---- test/bthread_timer_thread_unittest.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/brpc_channel_unittest.cpp b/test/brpc_channel_unittest.cpp index 049a4975..cf7b1e26 100644 --- a/test/brpc_channel_unittest.cpp +++ b/test/brpc_channel_unittest.cpp @@ -1166,7 +1166,7 @@ protected: CallMethod(&channel, &cntl, &req, &res, async); tm.stop(); EXPECT_EQ(brpc::ERPCTIMEDOUT, cntl.ErrorCode()) << cntl.ErrorText(); - EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 10); + EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 15); StopAndJoin(); } @@ -1202,7 +1202,7 @@ protected: for (int i = 0; i < cntl.sub_count(); ++i) { EXPECT_EQ(ECANCELED, cntl.sub(i)->ErrorCode()) << "i=" << i; } - EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 10); + EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 15); StopAndJoin(); } @@ -1255,7 +1255,7 @@ protected: EXPECT_EQ(0, cntl.sub(i)->ErrorCode()); } } - EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 10); + EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 15); StopAndJoin(); } @@ -1288,7 +1288,7 @@ protected: EXPECT_EQ(brpc::ERPCTIMEDOUT, cntl.ErrorCode()) << cntl.ErrorText(); EXPECT_EQ(1, cntl.sub_count()); EXPECT_EQ(brpc::ERPCTIMEDOUT, cntl.sub(0)->ErrorCode()); - EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 10); + EXPECT_LT(labs(tm.m_elapsed() - cntl.timeout_ms()), 15); StopAndJoin(); } diff --git a/test/brpc_server_unittest.cpp b/test/brpc_server_unittest.cpp index 575c88ec..f000bf3c 100644 --- a/test/brpc_server_unittest.cpp +++ b/test/brpc_server_unittest.cpp @@ -1043,7 +1043,7 @@ TEST_F(ServerTest, logoff_and_multiple_start) { ASSERT_EQ(0, server.Stop(-1)); ASSERT_EQ(0, server.Join()); timer.stop(); - EXPECT_TRUE(labs(timer.m_elapsed() - 100) < 10) << timer.m_elapsed(); + EXPECT_TRUE(labs(timer.m_elapsed() - 100) < 15) << timer.m_elapsed(); bthread_join(tid, NULL); } @@ -1066,7 +1066,7 @@ TEST_F(ServerTest, logoff_and_multiple_start) { timer.stop(); // Assertion will fail since EchoServiceImpl::Echo is holding // additional reference to the `Socket' - // EXPECT_TRUE(timer.m_elapsed() < 10) << timer.m_elapsed(); + // EXPECT_TRUE(timer.m_elapsed() < 15) << timer.m_elapsed(); bthread_join(tid, NULL); } @@ -1089,7 +1089,7 @@ TEST_F(ServerTest, logoff_and_multiple_start) { timer.stop(); // Assertion will fail since EchoServiceImpl::Echo is holding // additional reference to the `Socket' - // EXPECT_TRUE(labs(timer.m_elapsed() - 50) < 10) << timer.m_elapsed(); + // EXPECT_TRUE(labs(timer.m_elapsed() - 50) < 15) << timer.m_elapsed(); bthread_join(tid, NULL); } @@ -1109,7 +1109,7 @@ TEST_F(ServerTest, logoff_and_multiple_start) { ASSERT_EQ(0, server.Stop(1000)); ASSERT_EQ(0, server.Join()); timer.stop(); - EXPECT_TRUE(labs(timer.m_elapsed() - 100) < 10) << timer.m_elapsed(); + EXPECT_TRUE(labs(timer.m_elapsed() - 100) < 15) << timer.m_elapsed(); bthread_join(tid, NULL); } } diff --git a/test/bthread_timer_thread_unittest.cpp b/test/bthread_timer_thread_unittest.cpp index 0276fb64..c44566ba 100644 --- a/test/bthread_timer_thread_unittest.cpp +++ b/test/bthread_timer_thread_unittest.cpp @@ -131,7 +131,7 @@ TEST(TimerThreadTest, RunTasks) { tm.start(); timer_thread.stop_and_join(); tm.stop(); - ASSERT_LE(tm.m_elapsed(), 10); + ASSERT_LE(tm.m_elapsed(), 15); // verify all runs in expected time range. keeper1.expect_first_run(); From 67ff7f1f1383801d381eb6270cb9a20bd386bc3d Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 19 Apr 2019 12:10:16 +0800 Subject: [PATCH 155/270] add docs for cluster recover & fix parameter unit --- docs/cn/client.md | 19 +++++++++++++++++++ docs/cn/consistent_hashing.md | 20 ++++++++++++-------- docs/en/client.md | 4 ++++ src/brpc/cluster_recover_policy.cpp | 2 +- test/brpc_load_balancer_unittest.cpp | 12 ++++++------ 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index 8892635d..faace644 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -234,6 +234,15 @@ locality-aware,优先选择延时低的下游,直到其延时高于其他机 实现原理请查看[Consistent Hashing](consistent_hashing.md)。 +### 从集群宕机后恢复时的客户端限流 + +集群宕机指的是集群中所有server都处于不可用的状态。由于健康检查机制,当集群恢复正常后,server会间隔性地上线。当某一个server上线后,所有的流量会发送过去,可能导致服务再次过载。若熔断开启,则可能导致其它server上线前该server再次熔断,集群永远无法恢复。作为解决方案,brpc提供了在集群宕机后恢复时的限流机制:当集群中没有可用server时,集群进入恢复状态,假设根据峰值QPS估算出能满足所有请求的最小server数量为min_working_instances,当前集群可用的server数量为q,则在恢复状态时,client接受请求的概率为q/min_working_instances,否则丢弃;若一段时间hold_seconds内q保持不变,则把流量重新发送全部可用的机器上,并离开恢复状态。在恢复阶段时,可以通过判断controller.ErrorCode()是否等于brpc::ERJECT来判断该次请求是否被拒绝,被拒绝的请求不会被框架重试。 + +此恢复机制要求下游server的能力是类似的,所以目前只针对rr和random有效,开启方式是在*load_balancer_name*后面加上min_working_instances和hold_seconds参数的值,例如: +```c++ +channel.Init("http://...", "random:min_working_instances=6 hold_seconds=10", &options); +``` + ## 健康检查 连接断开的server会被暂时隔离而不会被负载均衡算法选中,brpc会定期连接被隔离的server,以检查他们是否恢复正常,间隔由参数-health_check_interval控制: @@ -515,6 +524,12 @@ r34717后Controller.has_backup_request()获知是否发送过backup_request。 **重试时框架会尽量避开之前尝试过的server。** 重试的触发条件有(条件之间是AND关系): + +* 连接出错 +* 没到超时 +* 有剩余重试次数 +* 错误值得重试 + ### 连接出错 如果server一直没有返回,但连接没有问题,这种情况下不会重试。如果你需要在一定时间后发送另一个请求,使用backup request。 @@ -570,6 +585,10 @@ options.retry_policy = &g_my_retry_policy; 由于成本的限制,大部分线上server的冗余度是有限的,主要是满足多机房互备的需求。而激进的重试逻辑很容易导致众多client对server集群造成2-3倍的压力,最终使集群雪崩:由于server来不及处理导致队列越积越长,使所有的请求得经过很长的排队才被处理而最终超时,相当于服务停摆。默认的重试是比较安全的: 只要连接不断RPC就不会重试,一般不会产生大量的重试请求。用户可以通过RetryPolicy定制重试策略,但也可能使重试变成一场“风暴”。当你定制RetryPolicy时,你需要仔细考虑client和server的协作关系,并设计对应的异常测试,以确保行为符合预期。 +## 熔断 + +具体方法见[这里](circuit_breaker.md)。 + ## 协议 Channel的默认协议是baidu_std,可通过设置ChannelOptions.protocol换为其他协议,这个字段既接受enum也接受字符串。 diff --git a/docs/cn/consistent_hashing.md b/docs/cn/consistent_hashing.md index 5886bbb2..3e7f01b5 100644 --- a/docs/cn/consistent_hashing.md +++ b/docs/cn/consistent_hashing.md @@ -9,29 +9,33 @@ - 分散性 (Spread) : 当上游的机器看到不同的下游列表时(在上线时及不稳定的网络中比较常见), 同一个请求尽量映射到少量的节点中。 - 负载 (Load) : 当上游的机器看到不同的下游列表的时候, 保证每台下游分到的请求数量尽量一致。 - - # 实现方式 所有server的32位hash值在32位整数值域上构成一个环(Hash Ring),环上的每个区间和一个server唯一对应,如果一个key落在某个区间内, 它就被分流到对应的server上。 ![img](../images/chash.png) -当删除一个server的, 它对应的区间会归属于相邻的server,所有的请求都会跑过去。当增加一个server时,它会分割某个server的区间并承载落在这个区间上的所有请求。单纯使用Hash Ring很难满足我们上节提到的属性,主要两个问题: +当删除一个server的,它对应的区间会归属于相邻的server,所有的请求都会跑过去。当增加一个server时,它会分割某个server的区间并承载落在这个区间上的所有请求。单纯使用Hash Ring很难满足我们上节提到的属性,主要两个问题: - 在机器数量较少的时候, 区间大小会不平衡。 - 当一台机器故障的时候, 它的压力会完全转移到另外一台机器, 可能无法承载。 -为了解决这个问题,我们为每个server计算m个hash值,从而把32位整数值域划分为n*m个区间,当key落到某个区间时,分流到对应的server上。那些额外的hash值使得区间划分更加均匀,被称为Virtual Node。当删除一个server时,它对应的m个区间会分别合入相邻的区间中,那个server上的请求会较为平均地转移到其他server上。当增加server时,它会分割m个现有区间,从对应server上分别转移一些请求过来。 +为了解决这个问题,我们为每个server计算m个hash值,从而把32位整数值域划分为n*m个区间,当key落到某个区间时,分流到对应的server上。那些额外的hash值使得区间划分更加均匀,被称为虚拟节点(Virtual Node)。当删除一个server时,它对应的m个区间会分别合入相邻的区间中,那个server上的请求会较为平均地转移到其他server上。当增加server时,它会分割m个现有区间,从对应server上分别转移一些请求过来。 -由于节点故障和变化不常发生, 我们选择了修改复杂度为O(n)的有序数组来存储hash ring,每次分流使用二分查找来选择对应的机器, 由于存储是连续的,查找效率比基于平衡二叉树的实现高。 线程安全性请参照[Double Buffered Data](lalb.md#doublybuffereddata)章节. +由于节点故障和变化不常发生,我们选择了修改复杂度为O(n)的有序数组来存储hash ring,每次分流使用二分查找来选择对应的机器,由于存储是连续的,查找效率比基于平衡二叉树的实现高。线程安全性请参照[Double Buffered Data](lalb.md#doublybuffereddata)章节. # 使用方式 -我们内置了分别基于murmurhash3和md5两种hash算法的实现, 使用要做两件事: +我们内置了分别基于murmurhash3和md5两种hash算法的实现,使用要做两件事: - 在Channel.Init 时指定*load_balancer_name*为 "c_murmurhash" 或 "c_md5"。 +- 发起rpc时通过Controller::set_request_code(uint64_t)填入请求的hash code。 -- 发起rpc时通过Controller::set_request_code()填入请求的hash code。 +> request的hash算法并不需要和lb的hash算法保持一致,只需要hash的值域是32位无符号整数。由于memcache默认使用md5,访问memcached集群时请选择c_md5保证兼容性,其他场景可以选择c_murmurhash以获得更高的性能和更均匀的分布。 -> request的hash算法并不需要和lb的hash算法保持一致,只需要hash的值域是32位无符号整数。由于memcache默认使用md5,访问memcached集群时请选择c_md5保证兼容性, 其他场景可以选择c_murmurhash以获得更高的性能和更均匀的分布。 +# 虚拟节点个数 + +通过-chash\_num\_replicas可设置默认的虚拟节点个数,默认值为100。对于某些特殊场合,对虚拟节点个数有自定义的需求,可以通过将*load_balancer_name*加上参数replicas=配置,如: +```c++ +channel.Init("http://...", "c_murmurhash:replicas=150", &options); +``` diff --git a/docs/en/client.md b/docs/en/client.md index 3c5160f7..d8fd031e 100644 --- a/docs/en/client.md +++ b/docs/en/client.md @@ -579,6 +579,10 @@ Some tips: Due to maintaining costs, even very large scale clusters are deployed with "just enough" instances to survive major defects, namely offline of one IDC, which is at most 1/2 of all machines. However aggressive retries may easily make pressures from all clients double or even tripple against servers, and make the whole cluster down: More and more requests stuck in buffers, because servers can't process them in-time. All requests have to wait for a very long time to be processed and finally gets timed out, as if the whole cluster is crashed. The default retrying policy is safe generally: unless the connection is broken, retries are rarely sent. However users are able to customize starting conditions for retries by inheriting RetryPolicy, which may turn retries to be "a storm". When you customized RetryPolicy, you need to carefully consider how clients and servers interact and design corresponding tests to verify that retries work as expected. +## Circuit breaker + +Check out [circuit_breaker](../cn/circuit_breaker.md) for more details. + ## Protocols The default protocol used by Channel is baidu_std, which is changeable by setting ChannelOptions.protocol. The field accepts both enum and string. diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index 7da58846..ff8ed79a 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -52,7 +52,7 @@ bool DefaultClusterRecoverPolicy::StopRecoverIfNecessary() { int64_t now_ms = butil::gettimeofday_ms(); std::unique_lock mu(_mutex); if (_last_usable_change_time_ms != 0 && _last_usable != 0 && - (now_ms - _last_usable_change_time_ms > _hold_seconds)) { + (now_ms - _last_usable_change_time_ms > _hold_seconds * 1000)) { _recovering = false; _last_usable = 0; _last_usable_change_time_ms = 0; diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index af484fb0..c00f17e6 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -797,10 +797,10 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_sanity) { int rand = butil::fast_rand_less_than(2); if (rand == 0) { brpc::policy::RandomizedLoadBalancer rlb; - lb = rlb.New("min_working_instances=2 hold_seconds=2000"); + lb = rlb.New("min_working_instances=2 hold_seconds=2"); } else if (rand == 1) { brpc::policy::RoundRobinLoadBalancer rrlb; - lb = rrlb.New("min_working_instances=2 hold_seconds=2000"); + lb = rrlb.New("min_working_instances=2 hold_seconds=2"); } brpc::SocketUniquePtr ptr[2]; for (size_t i = 0; i < ARRAY_SIZE(servers); ++i) { @@ -902,8 +902,8 @@ public: }; TEST_F(LoadBalancerTest, invalid_lb_params) { - const char* lb_algo[] = { "random:mi_working_instances=2 hold_seconds=2000", - "rr:min_working_instances=2 hold_secon=2000" }; + const char* lb_algo[] = { "random:mi_working_instances=2 hold_seconds=2", + "rr:min_working_instances=2 hold_secon=2" }; brpc::Channel channel; brpc::ChannelOptions options; options.protocol = "http"; @@ -919,8 +919,8 @@ TEST_F(LoadBalancerTest, revived_from_all_failed_intergrated) { GFLAGS_NS::SetCommandLineOption("circuit_breaker_max_isolation_duration_ms", "3000"); GFLAGS_NS::SetCommandLineOption("circuit_breaker_min_isolation_duration_ms", "3000"); - const char* lb_algo[] = { "random:min_working_instances=2 hold_seconds=2000", - "rr:min_working_instances=2 hold_seconds=2000" }; + const char* lb_algo[] = { "random:min_working_instances=2 hold_seconds=2", + "rr:min_working_instances=2 hold_seconds=2" }; brpc::Channel channel; brpc::ChannelOptions options; options.protocol = "http"; From 2ce30e8266f6c3c92bb8a238e67dcf7b1ac07e2a Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 19 Apr 2019 13:58:51 +0800 Subject: [PATCH 156/270] add en docs for cluster recover --- docs/cn/client.md | 2 +- docs/en/client.md | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index faace644..47192ae1 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -236,7 +236,7 @@ locality-aware,优先选择延时低的下游,直到其延时高于其他机 ### 从集群宕机后恢复时的客户端限流 -集群宕机指的是集群中所有server都处于不可用的状态。由于健康检查机制,当集群恢复正常后,server会间隔性地上线。当某一个server上线后,所有的流量会发送过去,可能导致服务再次过载。若熔断开启,则可能导致其它server上线前该server再次熔断,集群永远无法恢复。作为解决方案,brpc提供了在集群宕机后恢复时的限流机制:当集群中没有可用server时,集群进入恢复状态,假设根据峰值QPS估算出能满足所有请求的最小server数量为min_working_instances,当前集群可用的server数量为q,则在恢复状态时,client接受请求的概率为q/min_working_instances,否则丢弃;若一段时间hold_seconds内q保持不变,则把流量重新发送全部可用的机器上,并离开恢复状态。在恢复阶段时,可以通过判断controller.ErrorCode()是否等于brpc::ERJECT来判断该次请求是否被拒绝,被拒绝的请求不会被框架重试。 +集群宕机指的是集群中所有server都处于不可用的状态。由于健康检查机制,当集群恢复正常后,server会间隔性地上线。当某一个server上线后,所有的流量会发送过去,可能导致服务再次过载。若熔断开启,则可能导致其它server上线前该server再次熔断,集群永远无法恢复。作为解决方案,brpc提供了在集群宕机后恢复时的限流机制:当集群中没有可用server时,集群进入恢复状态,假设根据峰值QPS估算出能服务所有请求的最小server数量为min_working_instances,当前集群可用的server数量为q,则在恢复状态时,client接受请求的概率为q/min_working_instances,否则丢弃;若一段时间hold_seconds内q保持不变,则把流量重新发送全部可用的server上,并离开恢复状态。在恢复阶段时,可以通过判断controller.ErrorCode()是否等于brpc::ERJECT来判断该次请求是否被拒绝,被拒绝的请求不会被框架重试。 此恢复机制要求下游server的能力是类似的,所以目前只针对rr和random有效,开启方式是在*load_balancer_name*后面加上min_working_instances和hold_seconds参数的值,例如: ```c++ diff --git a/docs/en/client.md b/docs/en/client.md index d8fd031e..17821477 100644 --- a/docs/en/client.md +++ b/docs/en/client.md @@ -236,6 +236,15 @@ Do distinguish "key" and "attributes" of the request. Don't compute request_code Check out [Consistent Hashing](consistent_hashing.md) for more details. +### Client-side throttling for recovery from cluster downtime + +Cluster downtime refers to the state in which all servers in the cluster are unavailable. Due to the health check mechanism, when the cluster returns to normal, server will go online one by one. When a server is online, all traffic will be sent to it, which may cause the service to be overloaded again. If circuit breaker is enabled, server may be offline again before the other servers go online, and the cluster can never be recovered. As a solution, brpc provides a client-side throttling mechanism for recovery after cluster downtime. When no server is available in the cluster, the cluster enters a recovery state. Assuming that the minimum number of servers that can serve all requests based on peak QPS is min_working_instances, current The number of servers available for the cluster is q, then in the recovery state, the probability of client accepting the request is q/min_working_instances, otherwise it is discarded. If q remains unchanged for a period of time(hold_seconds), the traffic is resent to all available servers and leaves recovery state. Whether the request is rejected in the recovery state is indicated by whether controller.ErrorCode() is equal to brpc::ERJECT, and the rejected request will not be retried by the framework. + +This recovery mechanism requires the capabilities of downstream servers to be similar, so it is currently only valid for rr and random. The way to enable it is to add the values of min_working_instances and hold_seconds parameters after *load_balancer_name*, for example: +```c++ +channel.Init("http://...", "random:min_working_instances=6 hold_seconds=10", &options); +``` + ## Health checking Servers whose connections are lost are isolated temporarily to prevent them from being selected by LoadBalancer. brpc connects isolated servers periodically to test if they're healthy again. The interval is controlled by gflag -health_check_interval: From e7db73878edf1dc5ec76bed43c12b80c81caee12 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 19 Apr 2019 17:47:48 +0800 Subject: [PATCH 157/270] refine docs for cluster recover --- docs/cn/client.md | 2 +- docs/en/client.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index 47192ae1..8e0961ad 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -236,7 +236,7 @@ locality-aware,优先选择延时低的下游,直到其延时高于其他机 ### 从集群宕机后恢复时的客户端限流 -集群宕机指的是集群中所有server都处于不可用的状态。由于健康检查机制,当集群恢复正常后,server会间隔性地上线。当某一个server上线后,所有的流量会发送过去,可能导致服务再次过载。若熔断开启,则可能导致其它server上线前该server再次熔断,集群永远无法恢复。作为解决方案,brpc提供了在集群宕机后恢复时的限流机制:当集群中没有可用server时,集群进入恢复状态,假设根据峰值QPS估算出能服务所有请求的最小server数量为min_working_instances,当前集群可用的server数量为q,则在恢复状态时,client接受请求的概率为q/min_working_instances,否则丢弃;若一段时间hold_seconds内q保持不变,则把流量重新发送全部可用的server上,并离开恢复状态。在恢复阶段时,可以通过判断controller.ErrorCode()是否等于brpc::ERJECT来判断该次请求是否被拒绝,被拒绝的请求不会被框架重试。 +集群宕机指的是集群中所有server都处于不可用的状态。由于健康检查机制,当集群恢复正常后,server会间隔性地上线。当某一个server上线后,所有的流量会发送过去,可能导致服务再次过载。若熔断开启,则可能导致其它server上线前该server再次熔断,集群永远无法恢复。作为解决方案,brpc提供了在集群宕机后恢复时的限流机制:当集群中没有可用server时,集群进入恢复状态,假设正好能服务所有请求的server数量为min_working_instances,当前集群可用的server数量为q,则在恢复状态时,client接受请求的概率为q/min_working_instances,否则丢弃;若一段时间hold_seconds内q保持不变,则把流量重新发送全部可用的server上,并离开恢复状态。在恢复阶段时,可以通过判断controller.ErrorCode()是否等于brpc::ERJECT来判断该次请求是否被拒绝,被拒绝的请求不会被框架重试。 此恢复机制要求下游server的能力是类似的,所以目前只针对rr和random有效,开启方式是在*load_balancer_name*后面加上min_working_instances和hold_seconds参数的值,例如: ```c++ diff --git a/docs/en/client.md b/docs/en/client.md index 17821477..eaf136e6 100644 --- a/docs/en/client.md +++ b/docs/en/client.md @@ -238,7 +238,7 @@ Check out [Consistent Hashing](consistent_hashing.md) for more details. ### Client-side throttling for recovery from cluster downtime -Cluster downtime refers to the state in which all servers in the cluster are unavailable. Due to the health check mechanism, when the cluster returns to normal, server will go online one by one. When a server is online, all traffic will be sent to it, which may cause the service to be overloaded again. If circuit breaker is enabled, server may be offline again before the other servers go online, and the cluster can never be recovered. As a solution, brpc provides a client-side throttling mechanism for recovery after cluster downtime. When no server is available in the cluster, the cluster enters a recovery state. Assuming that the minimum number of servers that can serve all requests based on peak QPS is min_working_instances, current The number of servers available for the cluster is q, then in the recovery state, the probability of client accepting the request is q/min_working_instances, otherwise it is discarded. If q remains unchanged for a period of time(hold_seconds), the traffic is resent to all available servers and leaves recovery state. Whether the request is rejected in the recovery state is indicated by whether controller.ErrorCode() is equal to brpc::ERJECT, and the rejected request will not be retried by the framework. +Cluster downtime refers to the state in which all servers in the cluster are unavailable. Due to the health check mechanism, when the cluster returns to normal, server will go online one by one. When a server is online, all traffic will be sent to it, which may cause the service to be overloaded again. If circuit breaker is enabled, server may be offline again before the other servers go online, and the cluster can never be recovered. As a solution, brpc provides a client-side throttling mechanism for recovery after cluster downtime. When no server is available in the cluster, the cluster enters recovery state. Assuming that the minimum number of servers that can serve all requests is min_working_instances, current number of servers available in the cluster is q, then in recovery state, the probability of client accepting the request is q/min_working_instances, otherwise it is discarded. If q remains unchanged for a period of time(hold_seconds), the traffic is resent to all available servers and leaves recovery state. Whether the request is rejected in recovery state is indicated by whether controller.ErrorCode() is equal to brpc::ERJECT, and the rejected request will not be retried by the framework. This recovery mechanism requires the capabilities of downstream servers to be similar, so it is currently only valid for rr and random. The way to enable it is to add the values of min_working_instances and hold_seconds parameters after *load_balancer_name*, for example: ```c++ From 65762708cc245258a43cb92c28f8a9858dffd551 Mon Sep 17 00:00:00 2001 From: LingBin Date: Sun, 28 Apr 2019 19:14:16 +0800 Subject: [PATCH 158/270] Fix a typo in bvar_c++.md --- docs/cn/bvar_c++.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/cn/bvar_c++.md b/docs/cn/bvar_c++.md index 671cac1d..b2743592 100644 --- a/docs/cn/bvar_c++.md +++ b/docs/cn/bvar_c++.md @@ -135,7 +135,7 @@ public: Variable是所有bvar的基类,主要提供全局注册,列举,查询等功能。 -用户以默认参数建立一个bvar时,这个bvar并未注册到任何全局结构中,在这种情况下,bvar纯粹是一个更快的计数器。我们称把一个bvar注册到全局表中的行为为”曝光“,可通过**expose**函数曝光: +用户以默认参数建立一个bvar时,这个bvar并未注册到任何全局结构中,在这种情况下,bvar纯粹是一个更快的计数器。我们称把一个bvar注册到全局表中的行为为“曝光”,可通过`expose`函数曝光: ```c++ // Expose this variable globally so that it's counted in following functions: // list_exposed @@ -319,7 +319,7 @@ reducer << e1 << e2 << e3的作用等价于reducer = e1 op e2 op e3。 顾名思义,用于累加,Op为+。 ```c++ bvar::Adder value; -value<< 1 << 2 << 3 << -4; +value << 1 << 2 << 3 << -4; CHECK_EQ(2, value.get_value()); bvar::Adder fp_value; // 可能有warning @@ -340,7 +340,7 @@ CHECK_EQ("hello world", concater.get_value()); 用于取最大值,运算符为std::max。 ```c++ bvar::Maxer value; -value<< 1 << 2 << 3 << -4; +value << 1 << 2 << 3 << -4; CHECK_EQ(3, value.get_value()); ``` Since Maxer<> use std::numeric_limits::min() as the identity, it cannot be applied to generic types unless you specialized std::numeric_limits<> (and overloaded operator<, yes, not operator>). @@ -350,7 +350,7 @@ Since Maxer<> use std::numeric_limits::min() as the identity, it cannot be ap 用于取最小值,运算符为std::min。 ```c++ bvar::Maxer value; -value<< 1 << 2 << 3 << -4; +value << 1 << 2 << 3 << -4; CHECK_EQ(-4, value.get_value()); ``` Since Miner<> use std::numeric_limits::max() as the identity, it cannot be applied to generic types unless you specialized std::numeric_limits<> (and overloaded operator<). From a2bb114e00cacd0c70abce5fd5ef7b89976d36e8 Mon Sep 17 00:00:00 2001 From: helei Date: Tue, 7 May 2019 10:35:19 +0800 Subject: [PATCH 159/270] fix data race for circuit breaker --- src/brpc/circuit_breaker.cpp | 28 ++++++++++++++++++---------- src/brpc/circuit_breaker.h | 17 +++++++++-------- src/brpc/socket.cpp | 11 ++++++----- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/brpc/circuit_breaker.cpp b/src/brpc/circuit_breaker.cpp index 84ec7627..7380b1bd 100644 --- a/src/brpc/circuit_breaker.cpp +++ b/src/brpc/circuit_breaker.cpp @@ -39,7 +39,7 @@ DEFINE_int32(circuit_breaker_min_isolation_duration_ms, 100, "Minimum isolation duration in milliseconds"); DEFINE_int32(circuit_breaker_max_isolation_duration_ms, 30000, "Maximum isolation duration in milliseconds"); -DEFINE_double(circuit_breaker_epsilon_value, 0.02, +DEFINE_double(circuit_breaker_epsilon_value, 0.02, "ema_alpha = 1 - std::pow(epsilon, 1.0 / window_size)"); namespace { @@ -81,14 +81,14 @@ bool CircuitBreaker::EmaErrorRecorder::OnCallEnd(int error_code, healthy = UpdateErrorCost(latency, ema_latency); } - // When the window is initializing, use error_rate to determine + // When the window is initializing, use error_rate to determine // if it needs to be isolated. if (_sample_count_when_initializing.load(butil::memory_order_relaxed) < _window_size && _sample_count_when_initializing.fetch_add(1, butil::memory_order_relaxed) < _window_size) { if (error_code != 0) { const int32_t error_count = _error_count_when_initializing.fetch_add(1, butil::memory_order_relaxed); - return error_count < _window_size * _max_error_percent / 100; + return error_count < _window_size * _max_error_percent / 100; } // Because once OnCallEnd returned false, the node will be ioslated soon, // so when error_code=0, we no longer check the error count. @@ -99,10 +99,12 @@ bool CircuitBreaker::EmaErrorRecorder::OnCallEnd(int error_code, } void CircuitBreaker::EmaErrorRecorder::Reset() { - _sample_count_when_initializing.store(0, butil::memory_order_relaxed); - _error_count_when_initializing.store(0, butil::memory_order_relaxed); + if (_sample_count_when_initializing.load(butil::memory_order_relaxed) < _window_size) { + _sample_count_when_initializing.store(0, butil::memory_order_relaxed); + _error_count_when_initializing.store(0, butil::memory_order_relaxed); + _ema_latency.store(0, butil::memory_order_relaxed); + } _ema_error_cost.store(0, butil::memory_order_relaxed); - _ema_latency.store(0, butil::memory_order_relaxed); } int64_t CircuitBreaker::EmaErrorRecorder::UpdateLatency(int64_t latency) { @@ -162,9 +164,10 @@ CircuitBreaker::CircuitBreaker() FLAGS_circuit_breaker_long_window_error_percent) , _short_window(FLAGS_circuit_breaker_short_window_size, FLAGS_circuit_breaker_short_window_error_percent) - , _last_reset_time_ms(butil::cpuwide_time_ms()) + , _last_revived_time_ms(butil::cpuwide_time_ms()) , _isolation_duration_ms(FLAGS_circuit_breaker_min_isolation_duration_ms) - , _isolated_times(0) + , _isolated_times(0) + , _is_first_call_after_revived(true) , _broken(false) { } @@ -172,6 +175,10 @@ bool CircuitBreaker::OnCallEnd(int error_code, int64_t latency) { if (_broken.load(butil::memory_order_relaxed)) { return false; } + if (_is_first_call_after_revived.load(butil::memory_order_relaxed) && + _is_first_call_after_revived.exchange(false, butil::memory_order_relaxed)) { + _last_revived_time_ms.store(butil::cpuwide_time_ms(), butil::memory_order_relaxed); + } if (_long_window.OnCallEnd(error_code, latency) && _short_window.OnCallEnd(error_code, latency)) { return true; @@ -183,7 +190,8 @@ bool CircuitBreaker::OnCallEnd(int error_code, int64_t latency) { void CircuitBreaker::Reset() { _long_window.Reset(); _short_window.Reset(); - _last_reset_time_ms = butil::cpuwide_time_ms(); + _last_revived_time_ms.store(butil::cpuwide_time_ms(), butil::memory_order_relaxed); + _is_first_call_after_revived.store(true, butil::memory_order_relaxed); _broken.store(false, butil::memory_order_release); } @@ -201,7 +209,7 @@ void CircuitBreaker::UpdateIsolationDuration() { FLAGS_circuit_breaker_max_isolation_duration_ms; const int min_isolation_duration_ms = FLAGS_circuit_breaker_min_isolation_duration_ms; - if (now_time_ms - _last_reset_time_ms < max_isolation_duration_ms) { + if (now_time_ms - _last_revived_time_ms < max_isolation_duration_ms) { isolation_duration_ms = std::min(isolation_duration_ms * 2, max_isolation_duration_ms); } else { diff --git a/src/brpc/circuit_breaker.h b/src/brpc/circuit_breaker.h index cce3ace1..3b2cd756 100644 --- a/src/brpc/circuit_breaker.h +++ b/src/brpc/circuit_breaker.h @@ -1,5 +1,5 @@ // Copyright (c) 2014 Baidu, Inc.G -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -16,7 +16,7 @@ #ifndef BRPC_CIRCUIT_BREAKER_H #define BRPC_CIRCUIT_BREAKER_H - + #include "butil/atomicops.h" namespace brpc { @@ -27,22 +27,22 @@ public: ~CircuitBreaker() {} - // Sampling the current rpc. Returns false if a node needs to + // Sampling the current rpc. Returns false if a node needs to // be isolated. Otherwise return true. // error_code: Error_code of this call, 0 means success. // latency: Time cost of this call. // Note: Once OnCallEnd() determined that a node needs to be isolated, - // it will always return false until you call Reset(). Usually Reset() + // it will always return false until you call Reset(). Usually Reset() // will be called in the health check thread. bool OnCallEnd(int error_code, int64_t latency); - // Reset CircuitBreaker and clear history data. will erase the historical + // Reset CircuitBreaker and clear history data. will erase the historical // data and start sampling again. Before you call this method, you need to // ensure that no one else is accessing CircuitBreaker. void Reset(); - // Mark the Socket as broken. Call this method when you want to isolate a - // node in advance. When this method is called multiple times in succession, + // Mark the Socket as broken. Call this method when you want to isolate a + // node in advance. When this method is called multiple times in succession, // only the first call will take effect. void MarkAsBroken(); @@ -82,9 +82,10 @@ private: EmaErrorRecorder _long_window; EmaErrorRecorder _short_window; - int64_t _last_reset_time_ms; + butil::atomic _last_revived_time_ms; butil::atomic _isolation_duration_ms; butil::atomic _isolated_times; + butil::atomic _is_first_call_after_revived; butil::atomic _broken; }; diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 29ff4627..92f56925 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -728,6 +728,12 @@ int Socket::WaitAndReset(int32_t expected_nref) { _pipeline_q->clear(); } } + + SharedPart* sp = GetSharedPart(); + if (sp) { + sp->circuit_breaker.Reset(); + sp->recent_error_count.store(0, butil::memory_order_relaxed); + } return 0; } @@ -750,11 +756,6 @@ void Socket::Revive() { vref, MakeVRef(id_ver, nref + 1/*note*/), butil::memory_order_release, butil::memory_order_relaxed)) { - SharedPart* sp = GetSharedPart(); - if (sp) { - sp->circuit_breaker.Reset(); - sp->recent_error_count.store(0, butil::memory_order_relaxed); - } // Set this flag to true since we add additional ref again _recycle_flag.store(false, butil::memory_order_relaxed); if (_user) { From 6eaa4bc698558b21f8dc5fe63fbc3a3e13c147e8 Mon Sep 17 00:00:00 2001 From: helei Date: Tue, 7 May 2019 10:39:10 +0800 Subject: [PATCH 160/270] add unit test for circuit breaker --- test/brpc_circuit_breaker_unittest.cpp | 52 +++++++++++++++++++++----- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/test/brpc_circuit_breaker_unittest.cpp b/test/brpc_circuit_breaker_unittest.cpp index 93fdd179..2e8c6fb8 100644 --- a/test/brpc_circuit_breaker_unittest.cpp +++ b/test/brpc_circuit_breaker_unittest.cpp @@ -22,8 +22,8 @@ const int kShortWindowSize = 500; const int kLongWindowSize = 1000; const int kShortWindowErrorPercent = 10; const int kLongWindowErrorPercent = 5; -const int kMinIsolationDurationMs = 100; -const int kMaxIsolationDurationMs = 1000; +const int kMinIsolationDurationMs = 10; +const int kMaxIsolationDurationMs = 200; const int kErrorCodeForFailed = 131; const int kErrorCodeForSucc = 0; const int kErrorCost = 1000; @@ -60,8 +60,8 @@ struct FeedbackControl { : _req_num(req_num) , _error_percent(error_percent) , _circuit_breaker(circuit_breaker) - , _healthy_cnt(0) - , _unhealthy_cnt(0) + , _healthy_cnt(0) + , _unhealthy_cnt(0) , _healthy(true) {} int _req_num; int _error_percent; @@ -86,7 +86,7 @@ protected: for (int i = 0; i < fc->_req_num; ++i) { bool healthy = false; if (rand() % 100 < fc->_error_percent) { - healthy = fc->_circuit_breaker->OnCallEnd(kErrorCodeForFailed, kErrorCost); + healthy = fc->_circuit_breaker->OnCallEnd(kErrorCodeForFailed, kErrorCost); } else { healthy = fc->_circuit_breaker->OnCallEnd(kErrorCodeForSucc, kLatency); } @@ -100,7 +100,7 @@ protected: return fc; } - void StartFeedbackThread(std::vector* thread_list, + void StartFeedbackThread(std::vector* thread_list, std::vector>* fc_list, int error_percent) { thread_list->clear(); @@ -129,7 +129,7 @@ TEST_F(CircuitBreakerTest, should_not_isolate) { EXPECT_EQ(fc->_unhealthy_cnt, 0); EXPECT_TRUE(fc->_healthy); } -} +} TEST_F(CircuitBreakerTest, should_isolate) { std::vector thread_list; @@ -160,7 +160,6 @@ TEST_F(CircuitBreakerTest, isolation_duration_grow) { EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), kMinIsolationDurationMs * 2); _circuit_breaker.Reset(); - bthread_usleep(kMinIsolationDurationMs * 1000); StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { void* ret_data = NULL; @@ -173,7 +172,25 @@ TEST_F(CircuitBreakerTest, isolation_duration_grow) { EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), kMinIsolationDurationMs * 4); _circuit_breaker.Reset(); - bthread_usleep((kMaxIsolationDurationMs + kMinIsolationDurationMs) * 1000); + ::usleep((kMaxIsolationDurationMs + kMinIsolationDurationMs) * 1000); + StartFeedbackThread(&thread_list, &fc_list, 100); + for (int i = 0; i < kThreadNum; ++i) { + void* ret_data = NULL; + EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); + FeedbackControl* fc = static_cast(ret_data); + EXPECT_FALSE(fc->_healthy); + EXPECT_LE(fc->_healthy_cnt, kShortWindowSize); + EXPECT_GT(fc->_unhealthy_cnt, 0); + } + EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), kMinIsolationDurationMs * 8); +} + +TEST_F(CircuitBreakerTest, isolation_duration_reset) { + std::vector thread_list; + std::vector> fc_list; + _circuit_breaker.Reset(); + _circuit_breaker.OnCallEnd(kErrorCodeForFailed, kLatency); + ::usleep((kMaxIsolationDurationMs + kMinIsolationDurationMs) * 1000); StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { void* ret_data = NULL; @@ -185,3 +202,20 @@ TEST_F(CircuitBreakerTest, isolation_duration_grow) { } EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), kMinIsolationDurationMs); } + +TEST_F(CircuitBreakerTest, isolation_duration_compute) { + std::vector thread_list; + std::vector> fc_list; + _circuit_breaker.Reset(); + ::usleep((kMaxIsolationDurationMs + kMinIsolationDurationMs) * 1000); + StartFeedbackThread(&thread_list, &fc_list, 100); + for (int i = 0; i < kThreadNum; ++i) { + void* ret_data = NULL; + EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); + FeedbackControl* fc = static_cast(ret_data); + EXPECT_FALSE(fc->_healthy); + EXPECT_LE(fc->_healthy_cnt, kShortWindowSize); + EXPECT_GT(fc->_unhealthy_cnt, 0); + } + EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), 2 * kMinIsolationDurationMs); +} From b4bb02b2725dfb1cc13589746329391666e109f4 Mon Sep 17 00:00:00 2001 From: helei Date: Tue, 7 May 2019 10:42:52 +0800 Subject: [PATCH 161/270] adjust unittest --- test/brpc_circuit_breaker_unittest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/brpc_circuit_breaker_unittest.cpp b/test/brpc_circuit_breaker_unittest.cpp index 2e8c6fb8..3de53479 100644 --- a/test/brpc_circuit_breaker_unittest.cpp +++ b/test/brpc_circuit_breaker_unittest.cpp @@ -172,7 +172,6 @@ TEST_F(CircuitBreakerTest, isolation_duration_grow) { EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), kMinIsolationDurationMs * 4); _circuit_breaker.Reset(); - ::usleep((kMaxIsolationDurationMs + kMinIsolationDurationMs) * 1000); StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { void* ret_data = NULL; From a13730a4a1b5c31939810b3a2c27daab8f8493f9 Mon Sep 17 00:00:00 2001 From: helei Date: Tue, 7 May 2019 17:06:24 +0800 Subject: [PATCH 162/270] add explicit key word --- src/brpc/adaptive_connection_type.h | 10 +- src/brpc/adaptive_max_concurrency.h | 14 +-- src/brpc/adaptive_protocol_type.h | 14 +-- src/brpc/server.cpp | 130 +++++++++++++------------- test/brpc_adaptive_class_unittest.cpp | 56 +++++++++++ 5 files changed, 140 insertions(+), 84 deletions(-) create mode 100755 test/brpc_adaptive_class_unittest.cpp diff --git a/src/brpc/adaptive_connection_type.h b/src/brpc/adaptive_connection_type.h index ca808476..65bd44c8 100644 --- a/src/brpc/adaptive_connection_type.h +++ b/src/brpc/adaptive_connection_type.h @@ -1,11 +1,11 @@ // Copyright (c) 2015 Baidu, Inc. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,7 +38,7 @@ const char* ConnectionTypeToString(ConnectionType); // Assignable by both ConnectionType and names. class AdaptiveConnectionType { -public: +public: AdaptiveConnectionType() : _type(CONNECTION_TYPE_UNKNOWN), _error(false) {} AdaptiveConnectionType(ConnectionType type) : _type(type), _error(false) {} ~AdaptiveConnectionType() {} @@ -52,7 +52,7 @@ public: operator ConnectionType() const { return _type; } const char* name() const { return ConnectionTypeToString(_type); } bool has_error() const { return _error; } - + private: ConnectionType _type; // Since this structure occupies 8 bytes in 64-bit machines anyway, diff --git a/src/brpc/adaptive_max_concurrency.h b/src/brpc/adaptive_max_concurrency.h index 4fc60d3d..b4e45294 100644 --- a/src/brpc/adaptive_max_concurrency.h +++ b/src/brpc/adaptive_max_concurrency.h @@ -1,5 +1,5 @@ // Copyright (c) 2014 Baidu, Inc.G -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -27,13 +27,13 @@ namespace brpc { class AdaptiveMaxConcurrency{ public: - AdaptiveMaxConcurrency(); - AdaptiveMaxConcurrency(int max_concurrency); - AdaptiveMaxConcurrency(const butil::StringPiece& value); - - // Non-trivial destructor to prevent AdaptiveMaxConcurrency from being + explicit AdaptiveMaxConcurrency(); + explicit AdaptiveMaxConcurrency(int max_concurrency); + explicit AdaptiveMaxConcurrency(const butil::StringPiece& value); + + // Non-trivial destructor to prevent AdaptiveMaxConcurrency from being // passed to variadic arguments without explicit type conversion. - // eg: + // eg: // printf("%d", options.max_concurrency) // compile error // printf("%s", options.max_concurrency.value().c_str()) // ok ~AdaptiveMaxConcurrency() {} diff --git a/src/brpc/adaptive_protocol_type.h b/src/brpc/adaptive_protocol_type.h index 4a96070f..0ebff3b0 100644 --- a/src/brpc/adaptive_protocol_type.h +++ b/src/brpc/adaptive_protocol_type.h @@ -1,11 +1,11 @@ // Copyright (c) 2015 Baidu, Inc. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,9 +38,9 @@ const char* ProtocolTypeToString(ProtocolType); // Assignable by both ProtocolType and names. class AdaptiveProtocolType { -public: - AdaptiveProtocolType() : _type(PROTOCOL_UNKNOWN) {} - AdaptiveProtocolType(ProtocolType type) : _type(type) {} +public: + explicit AdaptiveProtocolType() : _type(PROTOCOL_UNKNOWN) {} + explicit AdaptiveProtocolType(ProtocolType type) : _type(type) {} ~AdaptiveProtocolType() {} void operator=(ProtocolType type) { @@ -77,7 +77,7 @@ public: bool has_param() const { return !_param.empty(); } const std::string& param() const { return _param; } - + private: ProtocolType _type; std::string _name; diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 383b6438..1eefe063 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -1,11 +1,11 @@ // Copyright (c) 2014 Baidu, Inc. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -133,7 +133,7 @@ ServerOptions::ServerOptions() , bthread_init_fn(NULL) , bthread_init_args(NULL) , bthread_init_count(0) - , internal_port(-1) + , internal_port(-1) , has_builtin_services(true) , http_master_service(NULL) , health_reporter(NULL) @@ -271,12 +271,12 @@ std::string Server::ServerPrefix() const { void* Server::UpdateDerivedVars(void* arg) { const int64_t start_us = butil::cpuwide_time_us(); - + Server* server = static_cast(arg); const std::string prefix = server->ServerPrefix(); std::vector conns; std::vector internal_conns; - + server->_nerror_bvar.expose_as(prefix, "error"); bvar::PassiveStatus uptime_st( @@ -284,10 +284,10 @@ void* Server::UpdateDerivedVars(void* arg) { bvar::PassiveStatus start_time_st( prefix, "start_time", PrintStartTime, server); - + bvar::PassiveStatus nconn_st( prefix, "connection_count", GetConnectionCount, server); - + bvar::PassiveStatus nservice_st( prefix, "service_count", GetServiceCount, server); @@ -339,7 +339,7 @@ void* Server::UpdateDerivedVars(void* arg) { } } last_time = butil::gettimeofday_us(); - + // Update stats of accepted sockets. if (server->_am) { server->_am->ListConnections(&conns); @@ -388,7 +388,7 @@ Server::Server(ProfilerLinker) , _derivative_thread(INVALID_BTHREAD) , _keytable_pool(NULL) , _concurrency(0) { - BAIDU_CASSERT(offsetof(Server, _concurrency) % 64 == 0, + BAIDU_CASSERT(offsetof(Server, _concurrency) % 64 == 0, Server_concurrency_must_be_aligned_by_cacheline); } @@ -411,7 +411,7 @@ Server::~Server() { delete _options.http_master_service; _options.http_master_service = NULL; - + delete _am; _am = NULL; delete _internal_am; @@ -422,7 +422,7 @@ Server::~Server() { delete _global_restful_map; _global_restful_map = NULL; - + if (!_options.pid_file.empty()) { unlink(_options.pid_file.c_str()); } @@ -513,7 +513,7 @@ int Server::AddBuiltinServices() { if (AddBuiltinService(new (std::nothrow) BthreadsService)) { LOG(ERROR) << "Fail to add BthreadsService"; return -1; - } + } if (AddBuiltinService(new (std::nothrow) IdsService)) { LOG(ERROR) << "Fail to add IdsService"; return -1; @@ -521,7 +521,7 @@ int Server::AddBuiltinServices() { if (AddBuiltinService(new (std::nothrow) SocketsService)) { LOG(ERROR) << "Fail to add SocketsService"; return -1; - } + } if (AddBuiltinService(new (std::nothrow) GetFaviconService)) { LOG(ERROR) << "Fail to add GetFaviconService"; return -1; @@ -601,7 +601,7 @@ int Server::InitializeOnce() { return 0; } GlobalInitializeOrDie(); - + if (_status != UNINITIALIZED) { return 0; } @@ -690,7 +690,7 @@ static bool CreateConcurrencyLimiter(const AdaptiveMaxConcurrency& amc, return true; } -static AdaptiveMaxConcurrency g_default_max_concurrency_of_method = 0; +static AdaptiveMaxConcurrency g_default_max_concurrency_of_method(0); int Server::StartInternal(const butil::ip_t& ip, const PortRange& port_range, @@ -710,7 +710,7 @@ int Server::StartInternal(const butil::ip_t& ip, if (st != READY) { if (st == RUNNING) { LOG(ERROR) << "Server[" << version() << "] is already running on " - << _listen_addr; + << _listen_addr; } else { LOG(ERROR) << "Can't start Server[" << version() << "] which is " << status_str(status()); @@ -780,7 +780,7 @@ int Server::StartInternal(const butil::ip_t& ip, _keytable_pool = NULL; return -1; } - + if (_options.thread_local_data_factory) { _tl_options.thread_local_data_factory = _options.thread_local_data_factory; if (bthread_key_create2(&_tl_options.tls_key, DestroyServerTLS, @@ -872,7 +872,7 @@ int Server::StartInternal(const butil::ip_t& ip, } _concurrency = 0; - + if (_options.has_builtin_services && _builtin_service_count <= 0 && AddBuiltinServices() != 0) { @@ -926,7 +926,7 @@ int Server::StartInternal(const butil::ip_t& ip, it->second.status->SetConcurrencyLimiter(cl); } } - + // Create listening ports if (port_range.min_port > port_range.max_port) { LOG(ERROR) << "Invalid port_range=[" << port_range.min_port << '-' @@ -1016,7 +1016,7 @@ int Server::StartInternal(const butil::ip_t& ip, } sockfd.release(); } - + PutPidFileIfNeeded(); // Launch _derivative_thread. @@ -1090,7 +1090,7 @@ int Server::Stop(int timeout_ms) { return -1; } _status = STOPPING; - + LOG(INFO) << "Server[" << version() << "] is going to quit"; if (_am) { @@ -1120,7 +1120,7 @@ int Server::Join() { // this pool in _derivative_thread which does not quit yet. _session_local_data_pool->Reset(NULL); } - + if (_keytable_pool) { // Destroy _keytable_pool to delete keytables inside. This has to be // done here (before leaving Join) because it's legal for users to @@ -1133,7 +1133,7 @@ int Server::Join() { // the leak is acceptable in most scenarios. _keytable_pool = NULL; } - + // Delete tls_key as well since we don't need it anymore. if (_tl_options.tls_key != INVALID_BTHREAD_KEY) { CHECK_EQ(0, bthread_key_delete(_tl_options.tls_key)); @@ -1148,7 +1148,7 @@ int Server::Join() { bthread_join(_derivative_thread, NULL); _derivative_thread = INVALID_BTHREAD; } - + g_running_server_count.fetch_sub(1, butil::memory_order_relaxed); _status = READY; return 0; @@ -1167,7 +1167,7 @@ int Server::AddServiceInternal(google::protobuf::Service* service, << " does not have any method."; return -1; } - + if (InitializeOnce() != 0) { LOG(ERROR) << "Fail to initialize Server[" << version() << ']'; return -1; @@ -1177,7 +1177,7 @@ int Server::AddServiceInternal(google::protobuf::Service* service, << version() << "] which is " << status_str(status()); return -1; } - + if (_fullname_service_map.seek(sd->full_name()) != NULL) { LOG(ERROR) << "service=" << sd->full_name() << " already exists"; return -1; @@ -1279,7 +1279,7 @@ int Server::AddServiceInternal(google::protobuf::Service* service, RemoveService(service); return -1; } - + const std::string& svc_name = mappings[i].path.service_name; if (svc_name.empty()) { if (_global_restful_map == NULL) { @@ -1475,41 +1475,41 @@ void Server::RemoveMethodsOf(google::protobuf::Service* service) { } } -int Server::RemoveService(google::protobuf::Service* service) { - if (NULL == service) { - LOG(ERROR) << "Parameter[service] is NULL"; - return -1; - } - if (status() != READY) { - LOG(ERROR) << "Can't remove service=" - << service->GetDescriptor()->full_name() << " from Server[" - << version() << "] which is " << status_str(status()); - return -1; +int Server::RemoveService(google::protobuf::Service* service) { + if (NULL == service) { + LOG(ERROR) << "Parameter[service] is NULL"; + return -1; + } + if (status() != READY) { + LOG(ERROR) << "Can't remove service=" + << service->GetDescriptor()->full_name() << " from Server[" + << version() << "] which is " << status_str(status()); + return -1; + } + + const google::protobuf::ServiceDescriptor* sd = service->GetDescriptor(); + ServiceProperty* ss = _fullname_service_map.seek(sd->full_name()); + if (ss == NULL) { + RPC_VLOG << "Fail to find service=" << sd->full_name().c_str(); + return -1; } - - const google::protobuf::ServiceDescriptor* sd = service->GetDescriptor(); - ServiceProperty* ss = _fullname_service_map.seek(sd->full_name()); - if (ss == NULL) { - RPC_VLOG << "Fail to find service=" << sd->full_name().c_str(); - return -1; - } RemoveMethodsOf(service); if (ss->ownership == SERVER_OWNS_SERVICE) { - delete ss->service; - } - const bool is_builtin_service = ss->is_builtin_service; - _fullname_service_map.erase(sd->full_name()); - _service_map.erase(sd->name()); - - // Note: ss is invalidated. - if (is_builtin_service) { - --_builtin_service_count; + delete ss->service; + } + const bool is_builtin_service = ss->is_builtin_service; + _fullname_service_map.erase(sd->full_name()); + _service_map.erase(sd->name()); + + // Note: ss is invalidated. + if (is_builtin_service) { + --_builtin_service_count; } else { if (_first_service == service) { _first_service = NULL; } } - return 0; + return 0; } void Server::ClearServices() { @@ -1519,7 +1519,7 @@ void Server::ClearServices() { << "] which is " << status_str(status()); return; } - for (ServiceMap::const_iterator it = _fullname_service_map.begin(); + for (ServiceMap::const_iterator it = _fullname_service_map.begin(); it != _fullname_service_map.end(); ++it) { if (it->second.ownership == SERVER_OWNS_SERVICE) { delete it->second.service; @@ -1643,7 +1643,7 @@ void Server::PutPidFileIfNeeded() { for (size_t pos = _options.pid_file.find('/'); pos != std::string::npos; pos = _options.pid_file.find('/', pos + 1)) { std::string dir_name =_options.pid_file.substr(0, pos + 1); - int rc = mkdir(dir_name.c_str(), + int rc = mkdir(dir_name.c_str(), S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP); if (rc != 0 && errno != EEXIST #if defined(OS_MACOSX) @@ -1676,14 +1676,14 @@ void Server::RunUntilAskedToQuit() { } void* thread_local_data() { - const Server::ThreadLocalOptions* tl_options = + const Server::ThreadLocalOptions* tl_options = static_cast(bthread_get_assigned_data()); if (tl_options == NULL) { // not in server threads. return NULL; } if (BAIDU_UNLIKELY(tl_options->thread_local_data_factory == NULL)) { CHECK(false) << "The protocol impl. may not set tls correctly"; - return NULL; + return NULL; } void* data = bthread_getspecific(tl_options->tls_key); if (data == NULL) { @@ -1832,7 +1832,7 @@ int Server::AddCertificate(const CertInfo& cert) { SSL_CTX_set_tlsext_servername_callback(ssl_ctx.ctx->raw_ctx, SSLSwitchCTXByHostname); SSL_CTX_set_tlsext_servername_arg(ssl_ctx.ctx->raw_ctx, this); #endif - + if (!_reload_cert_maps.Modify(AddCertMapping, ssl_ctx)) { LOG(ERROR) << "Fail to add mappings into _reload_cert_maps"; return -1; @@ -1893,7 +1893,7 @@ int Server::RemoveCertificate(const CertInfo& cert) { LOG(ERROR) << "Fail to remove mappings from _reload_cert_maps"; return -1; } - + _ssl_ctx_map.erase(cert_key); return 0; } @@ -1928,7 +1928,7 @@ int Server::ResetCertificates(const std::vector& certs) { return -1; } - // Add default certficiate into tmp_map first since it can't be reloaded + // Add default certficiate into tmp_map first since it can't be reloaded std::string default_cert_key = _options.ssl_options().default_cert.certificate + _options.ssl_options().default_cert.private_key; @@ -1951,7 +1951,7 @@ int Server::ResetCertificates(const std::vector& certs) { if (ssl_ctx.ctx->raw_ctx == NULL) { return -1; } - + #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME SSL_CTX_set_tlsext_servername_callback(ssl_ctx.ctx->raw_ctx, SSLSwitchCTXByHostname); SSL_CTX_set_tlsext_servername_arg(ssl_ctx.ctx->raw_ctx, this); @@ -2107,7 +2107,7 @@ int Server::SSLSwitchCTXByHostname(struct ssl_st* ssl, if (server->_reload_cert_maps.Read(&s) != 0) { return SSL_TLSEXT_ERR_ALERT_FATAL; } - + std::shared_ptr* pctx = s->cert_map.seek(hostname); if (pctx == NULL) { const char* dot = hostname; @@ -2126,7 +2126,7 @@ int Server::SSLSwitchCTXByHostname(struct ssl_st* ssl, return SSL_TLSEXT_ERR_ALERT_FATAL; } // Use default SSL_CTX which is the current one - return SSL_TLSEXT_ERR_OK; + return SSL_TLSEXT_ERR_OK; } // Switch SSL_CTX to the one with correct hostname diff --git a/test/brpc_adaptive_class_unittest.cpp b/test/brpc_adaptive_class_unittest.cpp new file mode 100755 index 00000000..a79a3ff3 --- /dev/null +++ b/test/brpc_adaptive_class_unittest.cpp @@ -0,0 +1,56 @@ +// brpc - A framework to host and access services throughout Baidu. +// Copyright (c) 2014 Baidu, Inc. + +// Date: 2019/04/16 23:41:04 + +#include +#include "brpc/adaptive_max_concurrency.h" +#include "brpc/adaptive_protocol_type.h" +#include "brpc/adaptive_connection_type.h" + +const std::string kAutoCL = "aUto"; +const std::string kHttp = "hTTp"; +const std::string kPooled = "PoOled"; + +TEST(AdaptiveMaxConcurrencyTest, ShouldConvertCorrectly) { + brpc::AdaptiveMaxConcurrency amc(0); + + EXPECT_EQ(brpc::AdaptiveMaxConcurrency::UNLIMITED(), amc.type()); + EXPECT_EQ(brpc::AdaptiveMaxConcurrency::UNLIMITED(), amc.value()); + EXPECT_EQ(0, int(amc)); + EXPECT_TRUE(amc == brpc::AdaptiveMaxConcurrency::UNLIMITED()); + + amc = 10; + EXPECT_EQ(brpc::AdaptiveMaxConcurrency::CONSTANT(), amc.type()); + EXPECT_EQ("10", amc.value()); + EXPECT_EQ(10, int(amc)); + EXPECT_EQ(amc, "10"); + + amc = kAutoCL; + EXPECT_EQ(kAutoCL, amc.type()); + EXPECT_EQ(kAutoCL, amc.value()); + EXPECT_EQ(int(amc), -1); + EXPECT_TRUE(amc == "auto"); +} + +TEST(AdaptiveProtocolType, ShouldConvertCorrectly) { + brpc::AdaptiveProtocolType apt; + + apt = kHttp; + EXPECT_EQ(apt, brpc::ProtocolType::PROTOCOL_HTTP); + + apt = brpc::ProtocolType::PROTOCOL_HTTP; + EXPECT_EQ(apt, brpc::ProtocolType::PROTOCOL_HTTP); +} + +TEST(AdaptiveConnectionTypeTest, ShouldConvertCorrectly) { + brpc::AdaptiveConnectionType act; + + act = brpc::ConnectionType::CONNECTION_TYPE_POOLED; + EXPECT_EQ(act, brpc::ConnectionType::CONNECTION_TYPE_POOLED); + + act = kPooled; + EXPECT_EQ(act, brpc::ConnectionType::CONNECTION_TYPE_POOLED); +} + + From fdc39b6b8c84a30391488c23375186b101e150f1 Mon Sep 17 00:00:00 2001 From: helei Date: Tue, 7 May 2019 17:18:54 +0800 Subject: [PATCH 163/270] adjust unit test --- test/brpc_adaptive_class_unittest.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/brpc_adaptive_class_unittest.cpp b/test/brpc_adaptive_class_unittest.cpp index a79a3ff3..c426cb51 100755 --- a/test/brpc_adaptive_class_unittest.cpp +++ b/test/brpc_adaptive_class_unittest.cpp @@ -33,14 +33,16 @@ TEST(AdaptiveMaxConcurrencyTest, ShouldConvertCorrectly) { EXPECT_TRUE(amc == "auto"); } -TEST(AdaptiveProtocolType, ShouldConvertCorrectly) { +TEST(AdaptiveProtocolTypeTest, ShouldConvertCorrectly) { brpc::AdaptiveProtocolType apt; apt = kHttp; EXPECT_EQ(apt, brpc::ProtocolType::PROTOCOL_HTTP); + EXPECT_NE(apt, brpc::ProtocolType::PROTOCOL_BAIDU_STD); apt = brpc::ProtocolType::PROTOCOL_HTTP; EXPECT_EQ(apt, brpc::ProtocolType::PROTOCOL_HTTP); + EXPECT_NE(apt, brpc::ProtocolType::PROTOCOL_BAIDU_STD); } TEST(AdaptiveConnectionTypeTest, ShouldConvertCorrectly) { @@ -48,9 +50,10 @@ TEST(AdaptiveConnectionTypeTest, ShouldConvertCorrectly) { act = brpc::ConnectionType::CONNECTION_TYPE_POOLED; EXPECT_EQ(act, brpc::ConnectionType::CONNECTION_TYPE_POOLED); + EXPECT_NE(act, brpc::ConnectionType::CONNECTION_TYPE_SINGLE); act = kPooled; EXPECT_EQ(act, brpc::ConnectionType::CONNECTION_TYPE_POOLED); + EXPECT_NE(act, brpc::ConnectionType::CONNECTION_TYPE_SINGLE); } - From ebbe9ebd382e66714303ddbca538eaf10b2e31df Mon Sep 17 00:00:00 2001 From: helei Date: Tue, 7 May 2019 17:22:56 +0800 Subject: [PATCH 164/270] adjust unittest --- test/brpc_circuit_breaker_unittest.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/brpc_circuit_breaker_unittest.cpp b/test/brpc_circuit_breaker_unittest.cpp index 3de53479..c7e8a177 100644 --- a/test/brpc_circuit_breaker_unittest.cpp +++ b/test/brpc_circuit_breaker_unittest.cpp @@ -110,7 +110,7 @@ protected: FeedbackControl* fc = new FeedbackControl(2 * kLongWindowSize, error_percent, &_circuit_breaker); fc_list->emplace_back(fc); - pthread_create(&tid, NULL, feed_back_thread, fc); + pthread_create(&tid, nullptr, feed_back_thread, fc); thread_list->push_back(tid); } } @@ -123,7 +123,7 @@ TEST_F(CircuitBreakerTest, should_not_isolate) { std::vector> fc_list; StartFeedbackThread(&thread_list, &fc_list, 3); for (int i = 0; i < kThreadNum; ++i) { - void* ret_data = NULL; + void* ret_data = nullptr; EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_EQ(fc->_unhealthy_cnt, 0); @@ -136,7 +136,7 @@ TEST_F(CircuitBreakerTest, should_isolate) { std::vector> fc_list; StartFeedbackThread(&thread_list, &fc_list, 50); for (int i = 0; i < kThreadNum; ++i) { - void* ret_data = NULL; + void* ret_data = nullptr; EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_GT(fc->_unhealthy_cnt, 0); @@ -150,7 +150,7 @@ TEST_F(CircuitBreakerTest, isolation_duration_grow) { std::vector> fc_list; StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { - void* ret_data = NULL; + void* ret_data = nullptr; EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_FALSE(fc->_healthy); @@ -162,7 +162,7 @@ TEST_F(CircuitBreakerTest, isolation_duration_grow) { _circuit_breaker.Reset(); StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { - void* ret_data = NULL; + void* ret_data = nullptr; EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_FALSE(fc->_healthy); @@ -174,7 +174,7 @@ TEST_F(CircuitBreakerTest, isolation_duration_grow) { _circuit_breaker.Reset(); StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { - void* ret_data = NULL; + void* ret_data = nullptr; EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_FALSE(fc->_healthy); @@ -192,7 +192,7 @@ TEST_F(CircuitBreakerTest, isolation_duration_reset) { ::usleep((kMaxIsolationDurationMs + kMinIsolationDurationMs) * 1000); StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { - void* ret_data = NULL; + void* ret_data = nullptr; EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_FALSE(fc->_healthy); @@ -209,7 +209,7 @@ TEST_F(CircuitBreakerTest, isolation_duration_compute) { ::usleep((kMaxIsolationDurationMs + kMinIsolationDurationMs) * 1000); StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { - void* ret_data = NULL; + void* ret_data = nullptr; EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_FALSE(fc->_healthy); From f70f93510a0af9df070a7cbc82505b86264ba841 Mon Sep 17 00:00:00 2001 From: Jason S Zang Date: Fri, 10 May 2019 04:13:00 +0100 Subject: [PATCH 165/270] Fix typo --- src/bvar/variable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bvar/variable.cpp b/src/bvar/variable.cpp index d31ba9c7..da53833c 100644 --- a/src/bvar/variable.cpp +++ b/src/bvar/variable.cpp @@ -201,7 +201,7 @@ void Variable::list_exposed(std::vector* names, return; } names->clear(); - if (names->size() < 32) { + if (names->capacity() < 32) { names->reserve(count_exposed()); } VarMapWithLock* var_maps = get_var_maps(); From 775a385bdc2b5143eceba49a30be6a502410e5b3 Mon Sep 17 00:00:00 2001 From: Wangweizhen Date: Thu, 9 May 2019 21:58:41 +0800 Subject: [PATCH 166/270] chore: update bazel --- .travis.yml | 4 ++-- WORKSPACE | 48 +++++++++++++++++++++++++++++++++++++++++++-- bazel/workspace.bzl | 40 ------------------------------------- 3 files changed, 48 insertions(+), 44 deletions(-) delete mode 100644 bazel/workspace.bzl diff --git a/.travis.yml b/.travis.yml index 87a183b9..82e75cf9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,8 @@ before_script: - ulimit -c unlimited -S # enable core dumps before_install: -- wget --no-clobber https://github.com/bazelbuild/bazel/releases/download/0.8.1/bazel_0.8.1-linux-x86_64.deb -- sudo dpkg -i bazel_0.8.1-linux-x86_64.deb +- wget --no-clobber https://github.com/bazelbuild/bazel/releases/download/0.25.1/bazel_0.25.1-linux-x86_64.deb +- sudo dpkg -i bazel_0.25.1-linux-x86_64.deb - wget http://www.us.apache.org/dist/thrift/0.11.0/thrift-0.11.0.tar.gz && tar -xf thrift-0.11.0.tar.gz && cd thrift-0.11.0/ && ./configure --prefix=/usr --with-ruby=no --with-python=no --with-java=no --with-go=no --with-perl=no --with-php=no --with-csharp=no --with-erlang=no --with-lua=no --with-nodejs=no && make CPPFLAGS=-DFORCE_BOOST_SMART_PTR -j 3 -s && sudo make install && cd - install: diff --git a/WORKSPACE b/WORKSPACE index 618f6b4a..978272fb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,6 +1,50 @@ workspace(name = "com_github_brpc_brpc") -load("//:bazel/workspace.bzl", "brpc_workspace") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -brpc_workspace() +skylib_version = "0.8.0" +http_archive( + name = "bazel_skylib", + type = "tar.gz", + url = "https://github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib.{}.tar.gz".format (skylib_version, skylib_version), + sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e", +) +http_archive( + name = "com_google_protobuf", + strip_prefix = "protobuf-3.6.1.3", + sha256 = "9510dd2afc29e7245e9e884336f848c8a6600a14ae726adb6befdb4f786f0be2", + type = "zip", + url = "https://github.com/protocolbuffers/protobuf/archive/v3.6.1.3.zip", +) + +http_archive( + name = "com_github_gflags_gflags", + strip_prefix = "gflags-46f73f88b18aee341538c0dfc22b1710a6abedef", + url = "https://github.com/gflags/gflags/archive/46f73f88b18aee341538c0dfc22b1710a6abedef.tar.gz", +) + +bind( + name = "gflags", + actual = "@com_github_gflags_gflags//:gflags", +) + +http_archive( + name = "com_github_google_leveldb", + build_file = "//:leveldb.BUILD", + strip_prefix = "leveldb-a53934a3ae1244679f812d998a4f16f2c7f309a6", + url = "https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f16f2c7f309a6.tar.gz" +) + +http_archive( + name = "com_github_google_glog", + build_file = "//:glog.BUILD", + strip_prefix = "glog-a6a166db069520dbbd653c97c2e5b12e08a8bb26", + url = "https://github.com/google/glog/archive/a6a166db069520dbbd653c97c2e5b12e08a8bb26.tar.gz" +) + +http_archive( + name = "com_google_googletest", + strip_prefix = "googletest-0fe96607d85cf3a25ac40da369db62bbee2939a5", + url = "https://github.com/google/googletest/archive/0fe96607d85cf3a25ac40da369db62bbee2939a5.tar.gz", +) diff --git a/bazel/workspace.bzl b/bazel/workspace.bzl deleted file mode 100644 index ce108d22..00000000 --- a/bazel/workspace.bzl +++ /dev/null @@ -1,40 +0,0 @@ -# brpc external dependencies - -def brpc_workspace(): - native.http_archive( - name = "com_google_protobuf", - strip_prefix = "protobuf-ab8edf1dbe2237b4717869eaab11a2998541ad8d", - url = "https://github.com/google/protobuf/archive/ab8edf1dbe2237b4717869eaab11a2998541ad8d.tar.gz", - ) - - - native.http_archive( - name = "com_github_gflags_gflags", - strip_prefix = "gflags-46f73f88b18aee341538c0dfc22b1710a6abedef", - url = "https://github.com/gflags/gflags/archive/46f73f88b18aee341538c0dfc22b1710a6abedef.tar.gz", - ) - - native.bind( - name = "gflags", - actual = "@com_github_gflags_gflags//:gflags", - ) - - native.new_http_archive( - name = "com_github_google_leveldb", - build_file = str(Label("//:leveldb.BUILD")), - strip_prefix = "leveldb-a53934a3ae1244679f812d998a4f16f2c7f309a6", - url = "https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f16f2c7f309a6.tar.gz" - ) - - native.new_http_archive( - name = "com_github_google_glog", - build_file = str(Label("//:glog.BUILD")), - strip_prefix = "glog-a6a166db069520dbbd653c97c2e5b12e08a8bb26", - url = "https://github.com/google/glog/archive/a6a166db069520dbbd653c97c2e5b12e08a8bb26.tar.gz" - ) - - native.http_archive( - name = "com_google_googletest", - strip_prefix = "googletest-0fe96607d85cf3a25ac40da369db62bbee2939a5", - url = "https://github.com/google/googletest/archive/0fe96607d85cf3a25ac40da369db62bbee2939a5.tar.gz", - ) From f4a6c92a39251888871e693db0b2e88fe5336371 Mon Sep 17 00:00:00 2001 From: LingBin Date: Fri, 10 May 2019 17:25:23 +0800 Subject: [PATCH 167/270] Fix typo in bvar_c++.md There are two method to expose a bvar, one is `expose`, the other is `expose_as` --- docs/cn/bvar_c++.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cn/bvar_c++.md b/docs/cn/bvar_c++.md index b2743592..bc47d430 100644 --- a/docs/cn/bvar_c++.md +++ b/docs/cn/bvar_c++.md @@ -144,7 +144,7 @@ Variable是所有bvar的基类,主要提供全局注册,列举,查询等 // find_exposed // Return 0 on success, -1 otherwise. int expose(const butil::StringPiece& name); -int expose(const butil::StringPiece& prefix, const butil::StringPiece& name); +int expose_as(const butil::StringPiece& prefix, const butil::StringPiece& name); ``` 全局曝光后的bvar名字便为name或prefix + name,可通过以_exposed为后缀的static函数查询。比如Variable::describe_exposed(name)会返回名为name的bvar的描述。 From 46ad4f89d2ebbc85bd1877a31812a05324c8ce55 Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 14 May 2019 15:40:11 +0800 Subject: [PATCH 168/270] Add fast_rand_bytes in fast_rand.h --- src/butil/fast_rand.cpp | 16 ++++++++++++++++ src/butil/fast_rand.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/butil/fast_rand.cpp b/src/butil/fast_rand.cpp index b6f083fc..fc91135b 100644 --- a/src/butil/fast_rand.cpp +++ b/src/butil/fast_rand.cpp @@ -160,4 +160,20 @@ double fast_rand_double() { return fast_rand_double(&_tls_seed); } +void fast_rand_bytes(void* output, size_t output_length) { + const size_t n = output_length / 8; + for (size_t i = 0; i < n; ++i) { + static_cast(output)[i] = fast_rand(); + } + const size_t m = output_length - n * 8; + if (m) { + uint8_t* p = static_cast(output) + n * 8; + uint64_t r = fast_rand(); + for (size_t i = 0; i < m; ++i) { + p[i] = (r & 0xFF); + r = (r >> 8); + } + } +} + } // namespace butil diff --git a/src/butil/fast_rand.h b/src/butil/fast_rand.h index 5a4ed962..c17a130e 100644 --- a/src/butil/fast_rand.h +++ b/src/butil/fast_rand.h @@ -63,6 +63,9 @@ template T fast_rand_in(T min, T max) { // Cost: ~15ns double fast_rand_double(); +// Fills |output_length| bytes of |output| with random data. +void fast_rand_bytes(void* output, size_t output_length, uint8_t min); + } #endif // BUTIL_FAST_RAND_H From d51301f96dda2c3744f73ac5621946be1832cfdf Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 14 May 2019 15:40:40 +0800 Subject: [PATCH 169/270] Remove unused variable from threads_service.cpp --- src/brpc/builtin/threads_service.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/brpc/builtin/threads_service.cpp b/src/brpc/builtin/threads_service.cpp index 88a21952..c9327dd9 100644 --- a/src/brpc/builtin/threads_service.cpp +++ b/src/brpc/builtin/threads_service.cpp @@ -34,7 +34,6 @@ void ThreadsService::default_method(::google::protobuf::RpcController* cntl_base cntl->http_response().set_content_type("text/plain"); butil::IOBuf& resp = cntl->response_attachment(); - butil::IOPortal read_portal; std::string cmd = butil::string_printf("pstack %lld", (long long)getpid()); butil::Timer tm; tm.start(); From 0d415ce32a148e9536c8a9ab360b979e565a2e97 Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 14 May 2019 16:01:43 +0800 Subject: [PATCH 170/270] Remove self-defined memcpy from murmurhash3.cpp --- .../third_party/murmurhash3/murmurhash3.cpp | 68 ++----------------- 1 file changed, 6 insertions(+), 62 deletions(-) diff --git a/src/butil/third_party/murmurhash3/murmurhash3.cpp b/src/butil/third_party/murmurhash3/murmurhash3.cpp index d27f0196..f590c92b 100644 --- a/src/butil/third_party/murmurhash3/murmurhash3.cpp +++ b/src/butil/third_party/murmurhash3/murmurhash3.cpp @@ -305,62 +305,6 @@ void MurmurHash3_x64_128 ( const void * key, const int len, // ============= iterative versions ================== -namespace murmurhash3 { -static const size_t FAST_MEMCPY_MAXSIZE = 123; -template struct FastMemcpyBlock { - int data[size]; -}; -template <> struct FastMemcpyBlock<0> { }; - -template class FastMemcpy { -public: - typedef FastMemcpyBlock Block; - - static void* copy(void *dest, const void *src) { - *(Block*)dest = *(Block*)src; - if ((size % sizeof(int)) > 2) { - ((char*)dest)[size-3] = ((char*)src)[size-3]; - } - if ((size % sizeof(int)) > 1) { - ((char*)dest)[size-2] = ((char*)src)[size-2]; - } - if ((size % sizeof(int)) > 0) { - ((char*)dest)[size-1] = ((char*)src)[size-1]; - } - return dest; - } -}; - -typedef void* (*CopyFn)(void*, const void*); -static CopyFn s_fast_memcpy_fn[FAST_MEMCPY_MAXSIZE + 1]; - -template -struct InitFastMemcpy : public InitFastMemcpy { - InitFastMemcpy() { - s_fast_memcpy_fn[size] = FastMemcpy::copy; - } -}; -template <> -class InitFastMemcpy<0> { -public: - InitFastMemcpy() { - s_fast_memcpy_fn[0] = FastMemcpy<0>::copy; - } -}; -inline void* cp(void *__restrict dest, const void *__restrict src, size_t n) { -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) - // memcpy in gcc 4.8 seems to be faster. - return memcpy(dest, src, n); -#else - if (n <= FAST_MEMCPY_MAXSIZE) { - static InitFastMemcpy _init_cp_dummy; - return s_fast_memcpy_fn[n](dest, src); - } - return memcpy(dest, src, n); -#endif -} -} // namespace murmurhash3 - void MurmurHash3_x86_128_Init(MurmurHash3_x86_128_Context* ctx, uint32_t seed) { ctx->h1 = seed; @@ -388,7 +332,7 @@ void MurmurHash3_x86_128_Update( if (ctx->tail_len > 0) { const int append = std::min(len, 16 - ctx->tail_len); - murmurhash3::cp(ctx->tail + ctx->tail_len, data, append); + memcpy(ctx->tail + ctx->tail_len, data, append); ctx->total_len += append; ctx->tail_len += append; data += append; @@ -455,7 +399,7 @@ void MurmurHash3_x86_128_Update( const int tail_len = len & 15; if (tail_len > 0) { - murmurhash3::cp(ctx->tail, data + nblocks * 16, tail_len); + memcpy(ctx->tail, data + nblocks * 16, tail_len); ctx->tail_len = tail_len; } ctx->h1 = h1; @@ -556,7 +500,7 @@ void MurmurHash3_x64_128_Update( const uint8_t * data = (const uint8_t*)key; if (ctx->tail_len > 0) { const int append = std::min(len, 16 - ctx->tail_len); - murmurhash3::cp(ctx->tail + ctx->tail_len, data, append); + memcpy(ctx->tail + ctx->tail_len, data, append); ctx->total_len += append; ctx->tail_len += append; data += append; @@ -600,7 +544,7 @@ void MurmurHash3_x64_128_Update( // tail const int tail_len = len & 15; if (tail_len > 0) { - murmurhash3::cp(ctx->tail, data + nblocks * 16, tail_len); + memcpy(ctx->tail, data + nblocks * 16, tail_len); ctx->tail_len = tail_len; } @@ -679,7 +623,7 @@ void MurmurHash3_x86_32_Update(MurmurHash3_x86_32_Context* ctx, const void* key, const uint8_t * data = (const uint8_t*)key; if (ctx->tail_len > 0) { const int append = std::min(len, 4 - ctx->tail_len); - murmurhash3::cp(ctx->tail + ctx->tail_len, data, append); + memcpy(ctx->tail + ctx->tail_len, data, append); ctx->total_len += append; ctx->tail_len += append; data += append; @@ -723,7 +667,7 @@ void MurmurHash3_x86_32_Update(MurmurHash3_x86_32_Context* ctx, const void* key, const int tail_len = len & 3; if (tail_len > 0) { - murmurhash3::cp(ctx->tail, data + nblocks * 4, tail_len); + memcpy(ctx->tail, data + nblocks * 4, tail_len); ctx->tail_len = tail_len; } From 6840e36d05c7862c904941a882819b6db3e24f0e Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 14 May 2019 16:02:55 +0800 Subject: [PATCH 171/270] reformatting some comments in http_message.h --- src/brpc/details/http_message.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/brpc/details/http_message.h b/src/brpc/details/http_message.h index 4b9346e1..5d8db12d 100644 --- a/src/brpc/details/http_message.h +++ b/src/brpc/details/http_message.h @@ -18,10 +18,10 @@ #ifndef BRPC_HTTP_MESSAGE_H #define BRPC_HTTP_MESSAGE_H -#include // std::string +#include // std::string #include "butil/macros.h" -#include "butil/iobuf.h" // butil::IOBuf -#include "butil/scoped_lock.h" // butil::unique_lock +#include "butil/iobuf.h" // butil::IOBuf +#include "butil/scoped_lock.h" // butil::unique_lock #include "butil/endpoint.h" #include "brpc/details/http_parser.h" // http_parser #include "brpc/http_header.h" // HttpHeader From 3b4b0e6a76dc16390ab571a8de8f86ce52b71016 Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 14 May 2019 16:04:07 +0800 Subject: [PATCH 172/270] Add IOBufCutter --- src/butil/iobuf.cpp | 215 ++++++++++++++++++++++++++++++------------ src/butil/iobuf.h | 64 ++++++++++++- src/butil/iobuf_inl.h | 96 ++++++++++++++++--- 3 files changed, 300 insertions(+), 75 deletions(-) diff --git a/src/butil/iobuf.cpp b/src/butil/iobuf.cpp index 2219ff8b..daeaa391 100644 --- a/src/butil/iobuf.cpp +++ b/src/butil/iobuf.cpp @@ -312,12 +312,6 @@ inline IOBuf::Block* create_block() { // release_tls_block_chain() may exceed this limit sometimes. const int MAX_BLOCKS_PER_THREAD = 8; -// NOTE: not see differences in examples when CACHE_IOBUF_BLOCKREFS is turned on -// (tcmalloc linked) -#ifdef CACHE_IOBUF_BLOCKREFS -const int MAX_BLOCKREFS_PER_THREAD = 8; -#endif - struct TLSData { // Head of the TLS block chain. IOBuf::Block* block_head; @@ -327,19 +321,9 @@ struct TLSData { // True if the remote_tls_block_chain is registered to the thread. bool registered; - -#ifdef CACHE_IOBUF_BLOCKREFS - // Reuse array of BlockRef - int num_blockrefs; - IOBuf::BlockRef* blockrefs[MAX_BLOCKREFS_PER_THREAD]; -#endif }; -#ifdef CACHE_IOBUF_BLOCKREFS -static __thread TLSData g_tls_data = { NULL, 0, false, 0, {} }; -#else static __thread TLSData g_tls_data = { NULL, 0, false }; -#endif // Used in UT IOBuf::Block* get_tls_block_head() { return g_tls_data.block_head; } @@ -477,37 +461,16 @@ IOBuf::Block* acquire_tls_block() { return b; } -inline IOBuf::BlockRef* acquire_blockref_array() { -#ifdef CACHE_IOBUF_BLOCKREFS - TLSData& tls_data = g_tls_data; - if (tls_data.num_blockrefs) { - return tls_data.blockrefs[--tls_data.num_blockrefs]; - } -#endif - iobuf::g_newbigview.fetch_add(1, butil::memory_order_relaxed); - return new IOBuf::BlockRef[IOBuf::INITIAL_CAP]; -} - inline IOBuf::BlockRef* acquire_blockref_array(size_t cap) { -#ifdef CACHE_IOBUF_BLOCKREFS - if (cap == IOBuf::INITIAL_CAP) { - return acquire_blockref_array(); - } -#endif iobuf::g_newbigview.fetch_add(1, butil::memory_order_relaxed); return new IOBuf::BlockRef[cap]; } +inline IOBuf::BlockRef* acquire_blockref_array() { + return acquire_blockref_array(IOBuf::INITIAL_CAP); +} + inline void release_blockref_array(IOBuf::BlockRef* refs, size_t cap) { -#ifdef CACHE_IOBUF_BLOCKREFS - if (cap == IOBuf::INITIAL_CAP) { - TLSData& tls_data = g_tls_data; - if (tls_data.num_blockrefs < MAX_BLOCKREFS_PER_THREAD) { - tls_data.blockrefs[tls_data.num_blockrefs++] = refs; - return; - } - } -#endif delete[] refs; } @@ -668,10 +631,13 @@ void IOBuf::_push_or_move_back_ref_to_bigview(const BlockRef& r) { template void IOBuf::_push_or_move_back_ref_to_bigview(const BlockRef&); template void IOBuf::_push_or_move_back_ref_to_bigview(const BlockRef&); -int IOBuf::_pop_front_ref() { +template +int IOBuf::_pop_or_moveout_front_ref() { if (_small()) { if (_sv.refs[0].block != NULL) { - _sv.refs[0].block->dec_ref(); + if (!MOVEOUT) { + _sv.refs[0].block->dec_ref(); + } _sv.refs[0] = _sv.refs[1]; reset_block_ref(_sv.refs[1]); return 0; @@ -680,7 +646,9 @@ int IOBuf::_pop_front_ref() { } else { // _bv.nref must be greater than 2 const uint32_t start = _bv.start; - _bv.refs[start].block->dec_ref(); + if (!MOVEOUT) { + _bv.refs[start].block->dec_ref(); + } if (--_bv.nref > 2) { _bv.start = (start + 1) & _bv.cap_mask; _bv.nbytes -= _bv.refs[start].length; @@ -694,6 +662,9 @@ int IOBuf::_pop_front_ref() { return 0; } } +// Explicitly initialize templates. +template int IOBuf::_pop_or_moveout_front_ref(); +template int IOBuf::_pop_or_moveout_front_ref(); int IOBuf::_pop_back_ref() { if (_small()) { @@ -768,12 +739,12 @@ size_t IOBuf::pop_front(size_t n) { return saved_n; } -bool IOBuf::cut1(char* c) { +bool IOBuf::cut1(void* c) { if (empty()) { return false; } IOBuf::BlockRef &r = _front_ref(); - *c = r.block->data[r.offset]; + *(char*)c = r.block->data[r.offset]; if (r.length > 1) { ++r.offset; --r.length; @@ -817,9 +788,9 @@ size_t IOBuf::cutn(IOBuf* out, size_t n) { while (n) { // length() == 0 does not enter IOBuf::BlockRef &r = _front_ref(); if (r.length <= n) { - out->_push_back_ref(r); n -= r.length; - _pop_front_ref(); + out->_move_back_ref(r); + _moveout_front_ref(); } else { const IOBuf::BlockRef cr = { r.offset, (uint32_t)n, r.block }; out->_push_back_ref(cr); @@ -872,8 +843,7 @@ size_t IOBuf::cutn(std::string* out, size_t n) { } const size_t old_size = out->size(); out->resize(out->size() + n); - cutn(&out[0][old_size], n); - return n; + return cutn(&(*out)[old_size], n); } int IOBuf::_cut_by_char(IOBuf* out, char d) { @@ -1412,10 +1382,10 @@ size_t IOBuf::copy_to(void* d, size_t n, size_t pos) const { size_t IOBuf::copy_to(std::string* s, size_t n, size_t pos) const { const size_t len = length(); - if (n + pos > len) { - if (len <= pos) { - return 0; - } + if (len <= pos) { + return 0; + } + if (n > len - pos) { // note: n + pos may overflow n = len - pos; } s->resize(n); @@ -1424,10 +1394,10 @@ size_t IOBuf::copy_to(std::string* s, size_t n, size_t pos) const { size_t IOBuf::append_to(std::string* s, size_t n, size_t pos) const { const size_t len = length(); - if (n + pos > len) { - if (len <= pos) { - return 0; - } + if (len <= pos) { + return 0; + } + if (n > len - pos) { // note: n + pos may overflow n = len - pos; } const size_t old_size = s->size(); @@ -1737,6 +1707,135 @@ void IOPortal::return_cached_blocks_impl(Block* b) { iobuf::release_tls_block_chain(b); } +//////////////// IOBufCutter //////////////// + +IOBufCutter::IOBufCutter(butil::IOBuf* buf) + : _data(NULL) + , _data_end(NULL) + , _block(NULL) + , _buf(buf) { +} + +IOBufCutter::~IOBufCutter() { + if (_block) { + if (_data != _data_end) { + IOBuf::BlockRef& fr = _buf->_front_ref(); + CHECK_EQ(fr.block, _block); + fr.offset = (uint32_t)((char*)_data - _block->data); + fr.length = (uint32_t)((char*)_data_end - (char*)_data); + } else { + _buf->_pop_front_ref(); + } + } +} +bool IOBufCutter::load_next_ref() { + if (_block) { + _buf->_pop_front_ref(); + } + if (!_buf->_ref_num()) { + _data = NULL; + _data_end = NULL; + _block = NULL; + return false; + } else { + const IOBuf::BlockRef& r = _buf->_front_ref(); + _data = r.block->data + r.offset; + _data_end = (char*)_data + r.length; + _block = r.block; + return true; + } +} + +size_t IOBufCutter::slower_copy_to(void* dst, size_t n) { + size_t size = (char*)_data_end - (char*)_data; + if (size == 0) { + if (!load_next_ref()) { + return 0; + } + size = (char*)_data_end - (char*)_data; + if (n <= size) { + memcpy(dst, _data, n); + return n; + } + } + void* const saved_dst = dst; + memcpy(dst, _data, size); + dst = (char*)dst + size; + n -= size; + const size_t nref = _buf->_ref_num(); + for (size_t i = 1; i < nref; ++i) { + const IOBuf::BlockRef& r = _buf->_ref_at(i); + const size_t nc = std::min(n, (size_t)r.length); + memcpy(dst, r.block->data + r.offset, nc); + dst = (char*)dst + nc; + n -= nc; + if (n == 0) { + break; + } + } + return (char*)dst - (char*)saved_dst; +} + +size_t IOBufCutter::cutn(butil::IOBuf* out, size_t n) { + if (n == 0) { + return 0; + } + const size_t size = (char*)_data_end - (char*)_data; + if (n <= size) { + const IOBuf::BlockRef r = { (uint32_t)((char*)_data - _block->data), + (uint32_t)n, + _block }; + out->_push_back_ref(r); + _data = (char*)_data + n; + return n; + } else if (size != 0) { + const IOBuf::BlockRef r = { (uint32_t)((char*)_data - _block->data), + (uint32_t)size, + _block }; + out->_move_back_ref(r); + _buf->_moveout_front_ref(); + _data = NULL; + _data_end = NULL; + _block = NULL; + return _buf->cutn(out, n - size) + size; + } else { + if (_block) { + _data = NULL; + _data_end = NULL; + _block = NULL; + _buf->_pop_front_ref(); + } + return _buf->cutn(out, n); + } +} + +size_t IOBufCutter::cutn(void* out, size_t n) { + if (n == 0) { + return 0; + } + const size_t size = (char*)_data_end - (char*)_data; + if (n <= size) { + memcpy(out, _data, n); + _data = (char*)_data + n; + return n; + } else if (size != 0) { + memcpy(out, _data, size); + _buf->_pop_front_ref(); + _data = NULL; + _data_end = NULL; + _block = NULL; + return _buf->cutn((char*)out + size, n - size) + size; + } else { + if (_block) { + _data = NULL; + _data_end = NULL; + _block = NULL; + _buf->_pop_front_ref(); + } + return _buf->cutn(out, n); + } +} + IOBufAsZeroCopyInputStream::IOBufAsZeroCopyInputStream(const IOBuf& buf) : _ref_index(0) , _add_offset(0) diff --git a/src/butil/iobuf.h b/src/butil/iobuf.h index 13474367..40f015ad 100644 --- a/src/butil/iobuf.h +++ b/src/butil/iobuf.h @@ -59,6 +59,7 @@ class IOBuf { friend class IOBufAsZeroCopyInputStream; friend class IOBufAsZeroCopyOutputStream; friend class IOBufBytesIterator; +friend class IOBufCutter; public: static const size_t DEFAULT_BLOCK_SIZE = 8192; static const size_t INITIAL_CAP = 32; // must be power of 2 @@ -128,7 +129,7 @@ public: // Returns bytes popped. size_t pop_back(size_t n); - // Cut off `n' bytes from front side and APPEND to `out' + // Cut off n bytes from front side and APPEND to `out' // If n == 0, nothing cut; if n >= length(), all bytes are cut // Returns bytes cut. size_t cutn(IOBuf* out, size_t n); @@ -136,7 +137,7 @@ public: size_t cutn(std::string* out, size_t n); // Cut off 1 byte from the front side and set to *c // Return true on cut, false otherwise. - bool cut1(char* c); + bool cut1(void* c); // Cut from front side until the characters matches `delim', append // data before the matched characters to `out'. @@ -319,7 +320,8 @@ public: // the internal buffer. // If n == 0 and buffer is empty, return value is undefined. const void* fetch(void* aux_buffer, size_t n) const; - // Just fetch one character. + // Fetch one character from front side. + // Returns pointer to the character, NULL on empty. const void* fetch1() const; // Remove all data @@ -373,7 +375,14 @@ protected: // Pop a BlockRef from front side. // Returns: 0 on success and -1 on empty. - int _pop_front_ref(); + int _pop_front_ref() { return _pop_or_moveout_front_ref(); } + + // Move a BlockRef out from front side. + // Returns: 0 on success and -1 on empty. + int _moveout_front_ref() { return _pop_or_moveout_front_ref(); } + + template + int _pop_or_moveout_front_ref(); // Pop a BlockRef from back side. // Returns: 0 on success and -1 on empty. @@ -467,6 +476,51 @@ private: Block* _block; }; +// Specialized utility to cut from IOBuf faster than using corresponding +// methods in IOBuf. +// Designed for efficiently parsing data from IOBuf. +// The cut IOBuf can be appended during cutting. +class IOBufCutter { +public: + explicit IOBufCutter(butil::IOBuf* buf); + ~IOBufCutter(); + + // Cut off n bytes and APPEND to `out' + // Returns bytes cut. + size_t cutn(butil::IOBuf* out, size_t n); + size_t cutn(std::string* out, size_t n); + size_t cutn(void* out, size_t n); + + // Cut off 1 byte from the front side and set to *c + // Return true on cut, false otherwise. + bool cut1(void* data); + + // Copy n bytes into `data' + // Returns bytes copied. + size_t copy_to(void* data, size_t n); + + // Fetch one character. + // Returns pointer to the character, NULL on empty + const void* fetch1(); + + // Pop n bytes from front side + // Returns bytes popped. + size_t pop_front(size_t n); + + // Uncut bytes + size_t remaining_bytes() const; + +private: + size_t slower_copy_to(void* data, size_t n); + bool load_next_ref(); + +private: + void* _data; + void* _data_end; + IOBuf::Block* _block; + IOBuf* _buf; +}; + // Parse protobuf message from IOBuf. Notice that this wrapper does not change // source IOBuf, which also should not change during lifetime of the wrapper. // Even if a IOBufAsZeroCopyInputStream is created but parsed, the source @@ -631,6 +685,8 @@ private: int add_block(); void* _data; + // Saving _data_end instead of _size avoid modifying _data and _size + // in each push_back() which is probably a hotspot. void* _data_end; IOBuf _buf; IOBufAsZeroCopyOutputStream _zc_stream; diff --git a/src/butil/iobuf_inl.h b/src/butil/iobuf_inl.h index 0b3c0364..2538f4d2 100644 --- a/src/butil/iobuf_inl.h +++ b/src/butil/iobuf_inl.h @@ -189,22 +189,92 @@ inline void IOBuf::_move_back_ref(const BlockRef& r) { } } -inline int IOBufAppender::append(const void* src, size_t n) { - const size_t size = (char*)_data_end - (char*)_data; +//////////////// IOBufCutter //////////////// +inline size_t IOBufCutter::remaining_bytes() const { + if (_block) { + return (char*)_data_end - (char*)_data + _buf->size() - _buf->_front_ref().length; + } else { + return _buf->size(); + } +} + +inline bool IOBufCutter::cut1(void* c) { + if (_data == _data_end) { + if (!load_next_ref()) { + return false; + } + } + *(char*)c = *(const char*)_data; + _data = (char*)_data + 1; + return true; +} + +inline const void* IOBufCutter::fetch1() { + if (_data == _data_end) { + if (!load_next_ref()) { + return NULL; + } + } + return _data; +} + +inline size_t IOBufCutter::copy_to(void* out, size_t n) { + size_t size = (char*)_data_end - (char*)_data; if (n <= size) { - fast_memcpy(_data, src, n); - _data = (char*)_data + n; + memcpy(out, _data, n); + return n; + } + return slower_copy_to(out, n); +} + +inline size_t IOBufCutter::pop_front(size_t n) { + const size_t saved_n = n; + do { + const size_t size = (char*)_data_end - (char*)_data; + if (n <= size) { + _data = (char*)_data + n; + return saved_n; + } + if (size != 0) { + n -= size; + } + if (!load_next_ref()) { + return saved_n; + } + } while (true); +} + +inline size_t IOBufCutter::cutn(std::string* out, size_t n) { + if (n == 0) { return 0; - } - if (size != 0) { - fast_memcpy(_data, src, size); - src = (const char*)src + size; - n -= size; } - if (add_block() != 0) { - return -1; + const size_t len = remaining_bytes(); + if (n > len) { + n = len; } - return append(src, n); // tailr + const size_t old_size = out->size(); + out->resize(out->size() + n); + return cutn(&(*out)[old_size], n); +} + +/////////////// IOBufAppender ///////////////// +inline int IOBufAppender::append(const void* src, size_t n) { + do { + const size_t size = (char*)_data_end - (char*)_data; + if (n <= size) { + memcpy(_data, src, n); + _data = (char*)_data + n; + return 0; + } + if (size != 0) { + memcpy(_data, src, size); + src = (const char*)src + size; + n -= size; + } + if (add_block() != 0) { + return -1; + } + } while (true); } inline int IOBufAppender::append(const StringPiece& str) { @@ -292,7 +362,7 @@ inline size_t IOBufBytesIterator::copy_and_forward(void* buf, size_t n) { while (nc < n && _bytes_left != 0) { const size_t block_size = _block_end - _block_begin; const size_t to_copy = std::min(block_size, n - nc); - fast_memcpy((char*)buf + nc, _block_begin, to_copy); + memcpy((char*)buf + nc, _block_begin, to_copy); _block_begin += to_copy; _bytes_left -= to_copy; nc += to_copy; From a68868077ca830853de952db7e488cd93aac0ea4 Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 14 May 2019 17:26:23 +0800 Subject: [PATCH 173/270] Add reader and writer for binary records --- Makefile | 1 + src/butil/recordio.cc | 359 +++++++++++++++++++++++++++++++++++++ src/butil/recordio.h | 131 ++++++++++++++ test/Makefile | 1 + test/recordio_unittest.cpp | 254 ++++++++++++++++++++++++++ 5 files changed, 746 insertions(+) create mode 100755 src/butil/recordio.cc create mode 100755 src/butil/recordio.h create mode 100755 test/recordio_unittest.cpp diff --git a/Makefile b/Makefile index 21e30811..cdd1ff51 100644 --- a/Makefile +++ b/Makefile @@ -146,6 +146,7 @@ BUTIL_SOURCES = \ src/butil/containers/case_ignored_flat_map.cpp \ src/butil/iobuf.cpp \ src/butil/binary_printer.cpp \ + src/butil/recordio.cc \ src/butil/popen.cpp ifeq ($(SYSTEM), Linux) diff --git a/src/butil/recordio.cc b/src/butil/recordio.cc new file mode 100755 index 00000000..f4e2b198 --- /dev/null +++ b/src/butil/recordio.cc @@ -0,0 +1,359 @@ +#include +#include "butil/logging.h" +#include "butil/recordio.h" +#include "butil/sys_byteorder.h" + +namespace butil { + +DEFINE_int64(recordio_max_record_size, 67108864, + "Records exceeding this size will be rejected"); + +#define BRPC_RECORDIO_MAGIC "RDIO" + +const size_t MAX_NAME_SIZE = 256; + +// 8-bit CRC using the polynomial x^8+x^6+x^3+x^2+1, 0x14D. +// Chosen based on Koopman, et al. (0xA6 in his notation = 0x14D >> 1): +// http://www.ece.cmu.edu/~koopman/roses/dsn04/koopman04_crc_poly_embedded.pdf +// +// This implementation is reflected, processing the least-significant bit of the +// input first, has an initial CRC register value of 0xff, and exclusive-or's +// the final register value with 0xff. As a result the CRC of an empty string, +// and therefore the initial CRC value, is zero. +// +// The standard description of this CRC is: +// width=8 poly=0x4d init=0xff refin=true refout=true xorout=0xff check=0xd8 +// name="CRC-8/KOOP" +static unsigned char const crc8_table[] = { + 0xea, 0xd4, 0x96, 0xa8, 0x12, 0x2c, 0x6e, 0x50, 0x7f, 0x41, 0x03, 0x3d, + 0x87, 0xb9, 0xfb, 0xc5, 0xa5, 0x9b, 0xd9, 0xe7, 0x5d, 0x63, 0x21, 0x1f, + 0x30, 0x0e, 0x4c, 0x72, 0xc8, 0xf6, 0xb4, 0x8a, 0x74, 0x4a, 0x08, 0x36, + 0x8c, 0xb2, 0xf0, 0xce, 0xe1, 0xdf, 0x9d, 0xa3, 0x19, 0x27, 0x65, 0x5b, + 0x3b, 0x05, 0x47, 0x79, 0xc3, 0xfd, 0xbf, 0x81, 0xae, 0x90, 0xd2, 0xec, + 0x56, 0x68, 0x2a, 0x14, 0xb3, 0x8d, 0xcf, 0xf1, 0x4b, 0x75, 0x37, 0x09, + 0x26, 0x18, 0x5a, 0x64, 0xde, 0xe0, 0xa2, 0x9c, 0xfc, 0xc2, 0x80, 0xbe, + 0x04, 0x3a, 0x78, 0x46, 0x69, 0x57, 0x15, 0x2b, 0x91, 0xaf, 0xed, 0xd3, + 0x2d, 0x13, 0x51, 0x6f, 0xd5, 0xeb, 0xa9, 0x97, 0xb8, 0x86, 0xc4, 0xfa, + 0x40, 0x7e, 0x3c, 0x02, 0x62, 0x5c, 0x1e, 0x20, 0x9a, 0xa4, 0xe6, 0xd8, + 0xf7, 0xc9, 0x8b, 0xb5, 0x0f, 0x31, 0x73, 0x4d, 0x58, 0x66, 0x24, 0x1a, + 0xa0, 0x9e, 0xdc, 0xe2, 0xcd, 0xf3, 0xb1, 0x8f, 0x35, 0x0b, 0x49, 0x77, + 0x17, 0x29, 0x6b, 0x55, 0xef, 0xd1, 0x93, 0xad, 0x82, 0xbc, 0xfe, 0xc0, + 0x7a, 0x44, 0x06, 0x38, 0xc6, 0xf8, 0xba, 0x84, 0x3e, 0x00, 0x42, 0x7c, + 0x53, 0x6d, 0x2f, 0x11, 0xab, 0x95, 0xd7, 0xe9, 0x89, 0xb7, 0xf5, 0xcb, + 0x71, 0x4f, 0x0d, 0x33, 0x1c, 0x22, 0x60, 0x5e, 0xe4, 0xda, 0x98, 0xa6, + 0x01, 0x3f, 0x7d, 0x43, 0xf9, 0xc7, 0x85, 0xbb, 0x94, 0xaa, 0xe8, 0xd6, + 0x6c, 0x52, 0x10, 0x2e, 0x4e, 0x70, 0x32, 0x0c, 0xb6, 0x88, 0xca, 0xf4, + 0xdb, 0xe5, 0xa7, 0x99, 0x23, 0x1d, 0x5f, 0x61, 0x9f, 0xa1, 0xe3, 0xdd, + 0x67, 0x59, 0x1b, 0x25, 0x0a, 0x34, 0x76, 0x48, 0xf2, 0xcc, 0x8e, 0xb0, + 0xd0, 0xee, 0xac, 0x92, 0x28, 0x16, 0x54, 0x6a, 0x45, 0x7b, 0x39, 0x07, + 0xbd, 0x83, 0xc1, 0xff +}; + +static uint8_t SizeChecksum(uint32_t input) { + uint8_t crc = 0; + crc = crc8_table[crc ^ (input & 0xFF)]; + crc = crc8_table[crc ^ ((input >> 8) & 0xFF)]; + crc = crc8_table[crc ^ ((input >> 16) & 0xFF)]; + crc = crc8_table[crc ^ ((input >> 24) & 0xFF)]; + return crc; +} + +const butil::IOBuf* Record::Meta(const char* name) const { + for (size_t i = 0; i < _metas.size(); ++i) { + if (_metas[i].name == name) { + return _metas[i].data.get(); + } + } + return NULL; +} + +butil::IOBuf* Record::MutableMeta(const char* name_cstr, bool null_on_found) { + const butil::StringPiece name = name_cstr; + for (size_t i = 0; i < _metas.size(); ++i) { + if (_metas[i].name == name) { + return null_on_found ? NULL : _metas[i].data.get(); + } + } + if (name.size() > MAX_NAME_SIZE) { + LOG(ERROR) << "Too long name=" << name; + return NULL; + } else if (name.empty()) { + LOG(ERROR) << "Empty name"; + return NULL; + } + NamedMeta p; + name.CopyToString(&p.name); + p.data = std::make_shared(); + _metas.push_back(p); + return p.data.get(); +} + +butil::IOBuf* Record::MutableMeta(const std::string& name, bool null_on_found) { + for (size_t i = 0; i < _metas.size(); ++i) { + if (_metas[i].name == name) { + return null_on_found ? NULL : _metas[i].data.get(); + } + } + if (name.size() > MAX_NAME_SIZE) { + LOG(ERROR) << "Too long name" << name; + return NULL; + } else if (name.empty()) { + LOG(ERROR) << "Empty name"; + return NULL; + } + NamedMeta p; + p.name = name; + p.data = std::make_shared(); + _metas.push_back(p); + return p.data.get(); +} + +bool Record::RemoveMeta(const butil::StringPiece& name) { + for (size_t i = 0; i < _metas.size(); ++i) { + if (_metas[i].name == name) { + _metas[i] = _metas.back(); + _metas.pop_back(); + return true; + } + } + return false; +} + +void Record::Clear() { + _payload.clear(); + _metas.clear(); +} + +size_t Record::ByteSize() const { + size_t n = 9 + _payload.size(); + for (size_t i = 0; i < _metas.size(); ++i) { + const NamedMeta& m = _metas[i]; + n += 5 + m.name.size() + m.data->size(); + } + return n; +} + +RecordReader::RecordReader(IReader* reader) + : _reader(reader) + , _cutter(&_portal) + , _ncut(0) + , _last_error(0) { +} + +bool RecordReader::ReadNext(Record* out) { + const size_t MAX_READ = 1024 * 1024; + do { + const int rc = CutRecord(out); + if (rc > 0) { + _last_error = 0; + return true; + } else if (rc < 0) { + while (!CutUntilNextRecordCandidate()) { + const ssize_t nr = _portal.append_from_reader(_reader, MAX_READ); + if (nr <= 0) { + _last_error = (nr < 0 ? errno : END_OF_READER); + return false; + } + } + } else { // rc == 0, not enough data to parse + const ssize_t nr = _portal.append_from_reader(_reader, MAX_READ); + if (nr <= 0) { + _last_error = (nr < 0 ? errno : END_OF_READER); + return false; + } + } + } while (true); +} + +bool RecordReader::CutUntilNextRecordCandidate() { + const size_t old_ncut = _ncut; + // Skip beginning magic + char magic[4]; + if (_cutter.copy_to(magic, sizeof(magic)) != sizeof(magic)) { + return false; + } + if (*(const uint32_t*)magic == *(const uint32_t*)BRPC_RECORDIO_MAGIC) { + _cutter.pop_front(sizeof(magic)); + _ncut += sizeof(magic); + } + char buf[512]; + do { + const size_t nc = _cutter.copy_to(buf, sizeof(buf)); + if (nc < sizeof(magic)) { + return false; + } + const size_t m = nc + 1 - sizeof(magic); + for (size_t i = 0; i < m; ++i) { + if (*(const uint32_t*)(buf + i) == *(const uint32_t*)BRPC_RECORDIO_MAGIC) { + _cutter.pop_front(i); + _ncut += i; + LOG(INFO) << "Found record candidate after " << _ncut - old_ncut << " bytes"; + return true; + } + } + _cutter.pop_front(m); + _ncut += m; + if (nc < sizeof(buf)) { + return false; + } + } while (true); +} + +int RecordReader::CutRecord(Record* rec) { + uint8_t headbuf[9]; + if (_cutter.copy_to(headbuf, sizeof(headbuf)) != sizeof(headbuf)) { + return 0; + } + if (*(const uint32_t*)headbuf != *(const uint32_t*)BRPC_RECORDIO_MAGIC) { + LOG(ERROR) << "Invalid magic_num=" + << butil::PrintedAsBinary(std::string((char*)headbuf, 4)) + << ", offset=" << read_bytes(); + return -1; + } + uint32_t tmp = NetToHost32(*(const uint32_t*)(headbuf + 4)); + const uint8_t checksum = SizeChecksum(tmp); + bool has_meta = (tmp & 0x80000000); + // NOTE: use size_t rather than uint32_t for sizes to avoid potential + // addition overflows + const size_t data_size = (tmp & 0x7FFFFFFF); + if (checksum != headbuf[8]) { + LOG(ERROR) << "Unmatched checksum of 0x" + << std::hex << tmp << std::dec + << "(metabit=" << has_meta + << " size=" << data_size + << " offset=" << read_bytes() + << "), expected=" << (unsigned)headbuf[8] + << " actual=" << (unsigned)checksum; + return -1; + } + if (data_size > (size_t)FLAGS_recordio_max_record_size) { + LOG(ERROR) << "data_size=" << data_size + << " is larger than -recordio_max_record_size=" + << FLAGS_recordio_max_record_size + << ", offset=" << read_bytes(); + return -1; + } + if (_cutter.remaining_bytes() < data_size) { + return 0; + } + rec->Clear(); + _cutter.pop_front(sizeof(headbuf)); + _ncut += sizeof(headbuf); + size_t consumed_bytes = 0; + while (has_meta) { + char name_size_buf = 0; + CHECK(_cutter.cut1(&name_size_buf)); + const size_t name_size = (uint8_t)name_size_buf; + std::string name; + _cutter.cutn(&name, name_size); + _cutter.cutn(&tmp, 4); + tmp = NetToHost32(tmp); + has_meta = (tmp & 0x80000000); + const size_t meta_size = (tmp & 0x7FFFFFFF); + _ncut += 5 + name_size; + if (consumed_bytes + 5 + name_size + meta_size > data_size) { + LOG(ERROR) << name << ".meta_size=" << meta_size + << " is inconsistent with its data_size=" << data_size + << ", offset=" << read_bytes(); + return -1; + } + butil::IOBuf* meta = rec->MutableMeta(name, true/*null_on_found*/); + if (meta == NULL) { + LOG(ERROR) << "Fail to add meta=" << name + << ", offset=" << read_bytes(); + return -1; + } + _cutter.cutn(meta, meta_size); + _ncut += meta_size; + consumed_bytes += 5 + name_size + meta_size; + } + _cutter.cutn(rec->MutablePayload(), data_size - consumed_bytes); + _ncut += data_size - consumed_bytes; + return 1; +} + +RecordWriter::RecordWriter(IWriter* writer) + :_writer(writer) { +} + +int RecordWriter::WriteWithoutFlush(const Record& rec) { + const size_t old_size = _buf.size(); + uint8_t headbuf[9]; + const IOBuf::Area headarea = _buf.reserve(sizeof(headbuf)); + for (size_t i = 0; i < rec.MetaCount(); ++i) { + auto& s = rec.MetaAt(i); + if (s.name.size() > MAX_NAME_SIZE) { + LOG(ERROR) << "Too long name=" << s.name; + _buf.pop_back(_buf.size() - old_size); + return -1; + } + char metabuf[s.name.size() + 5]; + char* p = metabuf; + *p = s.name.size(); + ++p; + memcpy(p, s.name.data(), s.name.size()); + p += s.name.size(); + if (s.data->size() > 0x7FFFFFFFULL) { + LOG(ERROR) << "Meta named `" << s.name << "' is too long, size=" + << s.data->size(); + _buf.pop_back(_buf.size() - old_size); + return -1; + } + uint32_t tmp = s.data->size() & 0x7FFFFFFF; + if (i < rec.MetaCount() - 1) { + tmp |= 0x80000000; + } + *(uint32_t*)p = HostToNet32(tmp); + _buf.append(metabuf, sizeof(metabuf)); + _buf.append(*s.data.get()); + } + if (!rec.Payload().empty()) { + _buf.append(rec.Payload()); + } + *(uint32_t*)headbuf = *(const uint32_t*)BRPC_RECORDIO_MAGIC; + const size_t data_size = _buf.size() - old_size - sizeof(headbuf); + if (data_size > 0x7FFFFFFFULL) { + LOG(ERROR) << "data_size=" << data_size << " is too long"; + _buf.pop_back(_buf.size() - old_size); + return -1; + } + uint32_t tmp = (data_size & 0x7FFFFFFF); + if (rec.MetaCount() > 0) { + tmp |= 0x80000000; + } + *(uint32_t*)(headbuf + 4) = HostToNet32(tmp); + headbuf[8] = SizeChecksum(tmp); + _buf.unsafe_assign(headarea, headbuf); + return 0; +} + +int RecordWriter::Flush() { + size_t total_nw = 0; + do { + const ssize_t nw = _buf.cut_into_writer(_writer); + if (nw > 0) { + total_nw += nw; + } else { + if (total_nw) { + // We've flushed sth., return as success. + return 0; + } + if (nw == 0) { + return _buf.empty() ? 0 : EAGAIN; + } else { + return errno; + } + } + } while (true); +} + +int RecordWriter::Write(const Record& record) { + const int rc = WriteWithoutFlush(record); + if (rc) { + return rc; + } + return Flush(); +} + + +} // namespace butil diff --git a/src/butil/recordio.h b/src/butil/recordio.h new file mode 100755 index 00000000..e1a711cd --- /dev/null +++ b/src/butil/recordio.h @@ -0,0 +1,131 @@ +// recordio - A binary format to transport data from end to end. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Author: Ge,Jun (jge666@gmail.com) +// Date: Thu Nov 22 13:57:56 CST 2012 + +#ifndef BUTIL_RECORDIO_H +#define BUTIL_RECORDIO_H + +#include "butil/iobuf.h" +#include + +namespace butil { + +class Record { +public: + struct NamedMeta { + std::string name; + std::shared_ptr data; + }; + + // Number of meta + size_t MetaCount() const { return _metas.size(); } + + // Get i-th Meta, out-of-range accesses may crash. + const NamedMeta& MetaAt(size_t i) const { return _metas[i]; } + + // Get meta by name. + const butil::IOBuf* Meta(const char* name) const; + + // Add meta. + // Returns a modifiable pointer to the meta with the name. + // If null_on_found is true and meta with the name is present, NULL is returned. + butil::IOBuf* MutableMeta(const char* name, bool null_on_found = false); + butil::IOBuf* MutableMeta(const std::string& name, bool null_on_found = false); + + // Remove meta with the name. + // Returns true on erased. + bool RemoveMeta(const butil::StringPiece& name); + + // Get the payload. + const butil::IOBuf& Payload() const { return _payload; } + + // Get a modifiable pointer to the payload. + butil::IOBuf* MutablePayload() { return &_payload; } + + // Clear payload and remove all meta. + void Clear(); + + // Byte size of serialized form of this record. + size_t ByteSize() const; + +private: + butil::IOBuf _payload; + std::vector _metas; +}; + +// Parse records from the IReader, corrupted records will be skipped. +// Example: +// RecordReader rd(ireader); +// Record rec; +// while (rd.ReadNext(&rec)) { +// HandleRecord(rec); +// } +// if (rd.last_error() != RecordReader::END_OF_READER) { +// LOG(FATAL) << "Critical error occurred"; +// } +class RecordReader { +public: + static const int END_OF_READER = -1; + + explicit RecordReader(IReader* reader); + + // Returns true on success and `out' is overwritten by the record. + // False otherwise, check last_error() for the error which is treated as permanent. + bool ReadNext(Record* out); + + // 0 means no error. + // END_OF_READER means all bytes in the input reader are consumed and + // turned into records. + int last_error() const { return _last_error; } + + // Total bytes of all read records. + size_t read_bytes() const { return _ncut; } + +private: + bool CutUntilNextRecordCandidate(); + int CutRecord(Record* rec); + +private: + IReader* _reader; + IOPortal _portal; + IOBufCutter _cutter; + size_t _ncut; + int _last_error; +}; + +// Write records into the IWriter. +class RecordWriter { +public: + explicit RecordWriter(IWriter* writer); + + // Serialize the record into internal buffer and NOT flush into the IWriter. + int WriteWithoutFlush(const Record&); + + // Serialize the record into internal buffer and flush into the IWriter. + int Write(const Record&); + + // Flush internal buffer into the IWriter. + // Returns 0 on success, error code otherwise. + int Flush(); + +private: + IOBuf _buf; + IWriter* _writer; +}; + +} // namespace butil + +#endif // BUTIL_RECORDIO_H diff --git a/test/Makefile b/test/Makefile index 969535af..db4d7d81 100644 --- a/test/Makefile +++ b/test/Makefile @@ -110,6 +110,7 @@ TEST_BUTIL_SOURCES = \ flat_map_unittest.cpp \ crc32c_unittest.cc \ iobuf_unittest.cpp \ + recordio_unittest.cpp \ test_switches.cc \ scoped_locale.cc \ popen_unittest.cpp \ diff --git a/test/recordio_unittest.cpp b/test/recordio_unittest.cpp new file mode 100755 index 00000000..d4a2c429 --- /dev/null +++ b/test/recordio_unittest.cpp @@ -0,0 +1,254 @@ +#include +#include "butil/recordio.h" +#include "butil/fast_rand.h" +#include "butil/string_printf.h" +#include "butil/file_util.h" + +namespace { + +class StringReader : public butil::IReader { +public: + StringReader(const std::string& str) + : _str(str), _offset(0) {} + + ssize_t ReadV(const iovec* iov, int iovcnt) override { + size_t total_nc = 0; + for (int i = 0; i < iovcnt; ++i) { + void* dst = iov[i].iov_base; + size_t len = iov[i].iov_len; + size_t remain = _str.size() - _offset; + size_t nc = std::min(len, remain); + memcpy(dst, _str.data() + _offset, nc); + _offset += nc; + total_nc += nc; + if (_offset == _str.size()) { + break; + } + } + return total_nc; + } +private: + std::string _str; + size_t _offset; +}; + +class StringWriter : public butil::IWriter { +public: + ssize_t WriteV(const iovec* iov, int iovcnt) override { + const size_t old_size = _str.size(); + for (int i = 0; i < iovcnt; ++i) { + _str.append((char*)iov[i].iov_base, iov[i].iov_len); + } + return _str.size() - old_size; + } + const std::string& str() const { return _str; } +private: + std::string _str; +}; + +TEST(RecordIOTest, empty_record) { + butil::Record r; + ASSERT_EQ((size_t)0, r.MetaCount()); + ASSERT_TRUE(r.Meta("foo") == NULL); + ASSERT_FALSE(r.RemoveMeta("foo")); + ASSERT_TRUE(r.Payload().empty()); + ASSERT_TRUE(r.MutablePayload()->empty()); +} + +TEST(RecordIOTest, manipulate_record) { + butil::Record r1; + ASSERT_EQ((size_t)0, r1.MetaCount()); + butil::IOBuf* foo_val = r1.MutableMeta("foo"); + ASSERT_EQ((size_t)1, r1.MetaCount()); + ASSERT_TRUE(foo_val->empty()); + foo_val->append("foo_data"); + ASSERT_EQ(foo_val, r1.MutableMeta("foo")); + ASSERT_EQ((size_t)1, r1.MetaCount()); + ASSERT_EQ("foo_data", *foo_val); + ASSERT_EQ(foo_val, r1.Meta("foo")); + + butil::IOBuf* bar_val = r1.MutableMeta("bar"); + ASSERT_EQ((size_t)2, r1.MetaCount()); + ASSERT_TRUE(bar_val->empty()); + bar_val->append("bar_data"); + ASSERT_EQ(bar_val, r1.MutableMeta("bar")); + ASSERT_EQ((size_t)2, r1.MetaCount()); + ASSERT_EQ("bar_data", *bar_val); + ASSERT_EQ(bar_val, r1.Meta("bar")); + + butil::Record r2 = r1; + + ASSERT_TRUE(r1.RemoveMeta("foo")); + ASSERT_EQ((size_t)1, r1.MetaCount()); + ASSERT_TRUE(r1.Meta("foo") == NULL); + + ASSERT_EQ(foo_val, r2.Meta("foo")); + ASSERT_EQ("foo_data", *foo_val); +} + +TEST(RecordIOTest, invalid_name) { + char name[258]; + for (size_t i = 0; i < sizeof(name); ++i) { + name[i] = 'a'; + } + name[sizeof(name) - 1] = 0; + butil::Record r; + ASSERT_EQ(NULL, r.MutableMeta(name)); +} + +TEST(RecordIOTest, write_read_basic) { + StringWriter sw; + butil::RecordWriter rw(&sw); + + butil::Record src; + ASSERT_EQ(0, rw.Write(src)); + + butil::IOBuf* foo_val = src.MutableMeta("foo"); + foo_val->append("foo_data"); + ASSERT_EQ(0, rw.Write(src)); + + butil::IOBuf* bar_val = src.MutableMeta("bar"); + bar_val->append("bar_data"); + ASSERT_EQ(0, rw.Write(src)); + + src.MutablePayload()->append("payload_data"); + ASSERT_EQ(0, rw.Write(src)); + + ASSERT_EQ(0, rw.Flush()); + std::cout << "len=" << sw.str().size() + << " content=" << butil::PrintedAsBinary(sw.str(), 256) << std::endl; + + StringReader sr(sw.str()); + butil::RecordReader rr(&sr); + butil::Record r1; + ASSERT_TRUE(rr.ReadNext(&r1)); + ASSERT_EQ(0, rr.last_error()); + ASSERT_EQ((size_t)0, r1.MetaCount()); + ASSERT_TRUE(r1.Payload().empty()); + + butil::Record r2; + ASSERT_TRUE(rr.ReadNext(&r2)); + ASSERT_EQ(0, rr.last_error()); + ASSERT_EQ((size_t)1, r2.MetaCount()); + ASSERT_EQ("foo", r2.MetaAt(0).name); + ASSERT_EQ("foo_data", *r2.MetaAt(0).data); + ASSERT_TRUE(r2.Payload().empty()); + + butil::Record r3; + ASSERT_TRUE(rr.ReadNext(&r3)); + ASSERT_EQ(0, rr.last_error()); + ASSERT_EQ((size_t)2, r3.MetaCount()); + ASSERT_EQ("foo", r3.MetaAt(0).name); + ASSERT_EQ("foo_data", *r3.MetaAt(0).data); + ASSERT_EQ("bar", r3.MetaAt(1).name); + ASSERT_EQ("bar_data", *r3.MetaAt(1).data); + ASSERT_TRUE(r3.Payload().empty()); + + butil::Record r4; + ASSERT_TRUE(rr.ReadNext(&r4)); + ASSERT_EQ(0, rr.last_error()); + ASSERT_EQ((size_t)2, r4.MetaCount()); + ASSERT_EQ("foo", r4.MetaAt(0).name); + ASSERT_EQ("foo_data", *r4.MetaAt(0).data); + ASSERT_EQ("bar", r4.MetaAt(1).name); + ASSERT_EQ("bar_data", *r4.MetaAt(1).data); + ASSERT_EQ("payload_data", r4.Payload()); + + ASSERT_FALSE(rr.ReadNext(NULL)); + ASSERT_EQ((int)butil::RecordReader::END_OF_READER, rr.last_error()); + ASSERT_EQ(sw.str().size(), rr.read_bytes()); +} + +static std::string rand_string(int min_len, int max_len) { + const int len = butil::fast_rand_in(min_len, max_len); + std::string str; + str.reserve(len); + for (int i = 0; i < len; ++i) { + str.push_back(butil::fast_rand_in('a', 'Z')); + } + return str; +} + +TEST(RecordIOTest, write_read_random) { + StringWriter sw; + butil::RecordWriter rw(&sw); + + const int N = 1024; + std::vector> name_value_list; + size_t nbytes = 0; + std::map breaking_offsets; + for (int i = 0; i < N; ++i) { + butil::Record src; + std::string value = rand_string(10, 20); + std::string name = butil::string_printf("name_%d_", i) + value; + src.MutableMeta(name)->append(value); + ASSERT_EQ(0, rw.Write(src)); + if (butil::fast_rand_less_than(70) == 0) { + breaking_offsets[i] = nbytes; + } else { + name_value_list.push_back(std::make_pair(name, value)); + } + nbytes += src.ByteSize(); + } + ASSERT_EQ(0, rw.Flush()); + std::string str = sw.str(); + ASSERT_EQ(nbytes, str.size()); + // break some records + int break_idx = 0; + for (auto it = breaking_offsets.begin(); it != breaking_offsets.end(); ++it) { + switch (break_idx++ % 10) { + case 0: + str[it->second] = 'r'; + break; + case 1: + str[it->second + 1] = 'd'; + break; + case 2: + str[it->second + 2] = 'i'; + break; + case 3: + str[it->second + 3] = 'o'; + break; + case 4: + ++str[it->second + 4]; + break; + case 5: + str[it->second + 4] = 8; + break; + case 6: + ++str[it->second + 5]; + break; + case 7: + ++str[it->second + 6]; + break; + case 8: + ++str[it->second + 7]; + break; + case 9: + ++str[it->second + 8]; + break; + default: + ASSERT_TRUE(false) << "never"; + } + } + ASSERT_EQ((size_t)N - breaking_offsets.size(), name_value_list.size()); + std::cout << "sw.size=" << str.size() + << " nbreak=" << breaking_offsets.size() << std::endl; + + StringReader sr(str); + ASSERT_LT(0, butil::WriteFile(butil::FilePath("recordio_ref.io"), str.data(), str.size())); + butil::RecordReader rr(&sr); + size_t j = 0; + butil::Record r; + for (; rr.ReadNext(&r); ++j) { + ASSERT_LT(j, name_value_list.size()); + ASSERT_EQ((size_t)1, r.MetaCount()); + ASSERT_EQ(name_value_list[j].first, r.MetaAt(0).name) << j; + ASSERT_EQ(name_value_list[j].second, *r.MetaAt(0).data); + } + ASSERT_EQ((int)butil::RecordReader::END_OF_READER, rr.last_error()); + ASSERT_EQ(str.size(), rr.read_bytes()); + ASSERT_EQ(j, name_value_list.size()); +} + +} // namespace From cb998b9e55ca62afa7f1fdce890f0cb7d200f003 Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 14 May 2019 18:11:02 +0800 Subject: [PATCH 174/270] Polish comments in recordio.h --- src/butil/recordio.h | 51 +++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/butil/recordio.h b/src/butil/recordio.h index e1a711cd..5c1369f2 100755 --- a/src/butil/recordio.h +++ b/src/butil/recordio.h @@ -23,6 +23,11 @@ namespace butil { +// One Payload + Zero or multiple Metas. +// Payload and metas are often serialized form of protobuf messages. As a +// correspondence, the implementation is not optimized for very small blobs, +// which should be batched properly before inserting(e.g. using repeated +// field in pb) class Record { public: struct NamedMeta { @@ -30,35 +35,41 @@ public: std::shared_ptr data; }; - // Number of meta + // Number of metas. Could be 0. size_t MetaCount() const { return _metas.size(); } // Get i-th Meta, out-of-range accesses may crash. + // This method is mainly for iterating all metas. const NamedMeta& MetaAt(size_t i) const { return _metas[i]; } - // Get meta by name. + // Get meta by |name|. NULL on not found. const butil::IOBuf* Meta(const char* name) const; - // Add meta. - // Returns a modifiable pointer to the meta with the name. - // If null_on_found is true and meta with the name is present, NULL is returned. + // Returns a mutable pointer to the meta with |name|. If the meta does + // not exist, add it first. + // If |null_on_found| is true and meta with |name| is present, NULL is + // returned. This is useful for detecting uniqueness of meta names in some + // scenarios. + // NOTE: With the assumption that there won't be many metas, the impl. + // tests presence by scaning all fields, which may perform badly when metas + // are a lot. butil::IOBuf* MutableMeta(const char* name, bool null_on_found = false); butil::IOBuf* MutableMeta(const std::string& name, bool null_on_found = false); - // Remove meta with the name. - // Returns true on erased. + // Remove meta with the name. The impl. may scan all fields. + // Returns true on erased, false on absent. bool RemoveMeta(const butil::StringPiece& name); // Get the payload. const butil::IOBuf& Payload() const { return _payload; } - // Get a modifiable pointer to the payload. + // Get a mutable pointer to the payload. butil::IOBuf* MutablePayload() { return &_payload; } // Clear payload and remove all meta. void Clear(); - // Byte size of serialized form of this record. + // Serialized size of this record. size_t ByteSize() const; private: @@ -71,24 +82,24 @@ private: // RecordReader rd(ireader); // Record rec; // while (rd.ReadNext(&rec)) { -// HandleRecord(rec); +// // Handle the rec // } // if (rd.last_error() != RecordReader::END_OF_READER) { // LOG(FATAL) << "Critical error occurred"; // } class RecordReader { public: + // A special error code to mark end of input data. static const int END_OF_READER = -1; explicit RecordReader(IReader* reader); - - // Returns true on success and `out' is overwritten by the record. - // False otherwise, check last_error() for the error which is treated as permanent. + + // Returns true on success and |out| is overwritten by the record. + // False otherwise and last_error() is the error which is treated as permanent. bool ReadNext(Record* out); // 0 means no error. - // END_OF_READER means all bytes in the input reader are consumed and - // turned into records. + // END_OF_READER means all data in the IReader are successfully consumed. int last_error() const { return _last_error; } // Total bytes of all read records. @@ -110,12 +121,12 @@ private: class RecordWriter { public: explicit RecordWriter(IWriter* writer); - - // Serialize the record into internal buffer and NOT flush into the IWriter. - int WriteWithoutFlush(const Record&); - // Serialize the record into internal buffer and flush into the IWriter. - int Write(const Record&); + // Serialize |record| into internal buffer and NOT flush into the IWriter. + int WriteWithoutFlush(const Record& record); + + // Serialize |record| into internal buffer and flush into the IWriter. + int Write(const Record& record); // Flush internal buffer into the IWriter. // Returns 0 on success, error code otherwise. From 727dd4cd2b76e1c0d507a384f550a8f646a4fbc8 Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 14 May 2019 18:13:27 +0800 Subject: [PATCH 175/270] Minor change to the comment --- src/butil/recordio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/butil/recordio.h b/src/butil/recordio.h index 5c1369f2..67b49941 100755 --- a/src/butil/recordio.h +++ b/src/butil/recordio.h @@ -23,7 +23,7 @@ namespace butil { -// One Payload + Zero or multiple Metas. +// 0-or-1 Payload + 0-or-multiple Metas. // Payload and metas are often serialized form of protobuf messages. As a // correspondence, the implementation is not optimized for very small blobs, // which should be batched properly before inserting(e.g. using repeated @@ -60,7 +60,7 @@ public: // Returns true on erased, false on absent. bool RemoveMeta(const butil::StringPiece& name); - // Get the payload. + // Get the payload. Empty by default. const butil::IOBuf& Payload() const { return _payload; } // Get a mutable pointer to the payload. From 7e85374b27266291909db1cdfce3b797def3502d Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 14 May 2019 21:11:45 +0800 Subject: [PATCH 176/270] Add UT for returning EAGAIN from the IReader --- src/butil/recordio.h | 2 +- test/recordio_unittest.cpp | 56 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/butil/recordio.h b/src/butil/recordio.h index 67b49941..cd50592a 100755 --- a/src/butil/recordio.h +++ b/src/butil/recordio.h @@ -79,7 +79,7 @@ private: // Parse records from the IReader, corrupted records will be skipped. // Example: -// RecordReader rd(ireader); +// RecordReader rd(...); // Record rec; // while (rd.ReadNext(&rec)) { // // Handle the rec diff --git a/test/recordio_unittest.cpp b/test/recordio_unittest.cpp index d4a2c429..2fe9a08c 100755 --- a/test/recordio_unittest.cpp +++ b/test/recordio_unittest.cpp @@ -8,8 +8,11 @@ namespace { class StringReader : public butil::IReader { public: - StringReader(const std::string& str) - : _str(str), _offset(0) {} + StringReader(const std::string& str, + bool report_eagain_on_end = false) + : _str(str) + , _offset(0) + , _report_eagain_on_end(report_eagain_on_end) {} ssize_t ReadV(const iovec* iov, int iovcnt) override { size_t total_nc = 0; @@ -25,11 +28,16 @@ public: break; } } + if (_report_eagain_on_end && total_nc == 0) { + errno = EAGAIN; + return -1; + } return total_nc; } private: std::string _str; size_t _offset; + bool _report_eagain_on_end; }; class StringWriter : public butil::IWriter { @@ -159,6 +167,50 @@ TEST(RecordIOTest, write_read_basic) { ASSERT_EQ(sw.str().size(), rr.read_bytes()); } +TEST(RecordIOTest, incomplete_reader) { + StringWriter sw; + butil::RecordWriter rw(&sw); + + butil::Record src; + butil::IOBuf* foo_val = src.MutableMeta("foo"); + foo_val->append("foo_data"); + ASSERT_EQ(0, rw.Write(src)); + + butil::IOBuf* bar_val = src.MutableMeta("bar"); + bar_val->append("bar_data"); + ASSERT_EQ(0, rw.Write(src)); + + ASSERT_EQ(0, rw.Flush()); + std::string data = sw.str(); + std::cout << "len=" << data.size() + << " content=" << butil::PrintedAsBinary(data, 256) << std::endl; + + StringReader sr(data, true); + butil::RecordReader rr(&sr); + + butil::Record r2; + ASSERT_TRUE(rr.ReadNext(&r2)); + ASSERT_EQ(0, rr.last_error()); + ASSERT_EQ((size_t)1, r2.MetaCount()); + ASSERT_EQ("foo", r2.MetaAt(0).name); + ASSERT_EQ("foo_data", *r2.MetaAt(0).data); + ASSERT_TRUE(r2.Payload().empty()); + + butil::Record r3; + ASSERT_TRUE(rr.ReadNext(&r3)); + ASSERT_EQ(0, rr.last_error()); + ASSERT_EQ((size_t)2, r3.MetaCount()); + ASSERT_EQ("foo", r3.MetaAt(0).name); + ASSERT_EQ("foo_data", *r3.MetaAt(0).data); + ASSERT_EQ("bar", r3.MetaAt(1).name); + ASSERT_EQ("bar_data", *r3.MetaAt(1).data); + ASSERT_TRUE(r3.Payload().empty()); + + ASSERT_FALSE(rr.ReadNext(NULL)); + ASSERT_EQ(EAGAIN, rr.last_error()); + ASSERT_EQ(sw.str().size(), rr.read_bytes()); +} + static std::string rand_string(int min_len, int max_len) { const int len = butil::fast_rand_in(min_len, max_len); std::string str; From 0664bb909eb148ac6d4fbf921c1270be14312ea2 Mon Sep 17 00:00:00 2001 From: Gavin Chou Date: Thu, 16 May 2019 13:10:23 +0800 Subject: [PATCH 177/270] Fix compilation errors caused by ssl on MacOS Related issue: #328 #360 #666 #723 #726 --- config_brpc.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config_brpc.sh b/config_brpc.sh index a1934d79..c5970fd1 100755 --- a/config_brpc.sh +++ b/config_brpc.sh @@ -136,6 +136,9 @@ find_dir_of_header_or_die() { $ECHO $dir } +# User specified path of openssl, if not given it's empty +OPENSSL_LIB=$(find_dir_of_lib ssl) + # Inconvenient to check these headers in baidu-internal #PTHREAD_HDR=$(find_dir_of_header_or_die pthread.h) OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h) @@ -233,7 +236,7 @@ PROTOBUF_HDR=$(find_dir_of_header_or_die google/protobuf/message.h) LEVELDB_HDR=$(find_dir_of_header_or_die leveldb/db.h) HDRS=$($ECHO "$GFLAGS_HDR\n$PROTOBUF_HDR\n$LEVELDB_HDR\n$OPENSSL_HDR" | sort | uniq) -LIBS=$($ECHO "$GFLAGS_LIB\n$PROTOBUF_LIB\n$LEVELDB_LIB\n$SNAPPY_LIB" | sort | uniq) +LIBS=$($ECHO "$GFLAGS_LIB\n$PROTOBUF_LIB\n$LEVELDB_LIB\n$OPENSSL_LIB\n$SNAPPY_LIB" | sort | uniq) absent_in_the_list() { TMP=`$ECHO "$1\n$2" | sort | uniq` From 87e6224cfd31484f102e65649728039023ae7c8d Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 17 May 2019 18:56:42 +0800 Subject: [PATCH 178/270] Fix backup req bug in h2 --- src/brpc/policy/http2_rpc_protocol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index d0e1e25e..5ed7b22e 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -1449,10 +1449,10 @@ private: void H2UnsentRequest::DestroyStreamUserData(SocketUniquePtr& sending_sock, Controller* cntl, - int /*error_code*/, + int error_code, bool /*end_of_rpc*/) { RemoveRefOnQuit deref_self(this); - if (sending_sock != NULL && cntl->ErrorCode() != 0) { + if (sending_sock != NULL && (cntl->ErrorCode() != 0 || error_code != 0)) { CHECK_EQ(cntl, _cntl); std::unique_lock mu(_mutex); _cntl = NULL; From d174847b6ceb42552f2893b1736e550e7a49c00b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 20 May 2019 11:26:34 +0800 Subject: [PATCH 179/270] Fix typo --- src/brpc/controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 8f1bcacf..7bbd9863 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -690,7 +690,7 @@ inline bool does_error_affect_main_socket(int error_code) { error_code == EINVAL/*returned by connect "0.0.0.1"*/; } -//Note: A RPC call is probably consisted by serveral individual Calls such as +//Note: A RPC call is probably consisted by several individual Calls such as // retries and backup requests. This method simply cares about the error of // this very Call (specified by |error_code|) rather than the error of the // entire RPC (specified by c->FailedInline()). From e06c67c5dac12d76e2b149621c944c1314d7e8b9 Mon Sep 17 00:00:00 2001 From: gejun Date: Mon, 20 May 2019 12:00:21 +0800 Subject: [PATCH 180/270] Add recordio.cc into CMakeLists.txt and BUILD --- BUILD | 1 + CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/BUILD b/BUILD index 185f44fe..07d8d6bc 100644 --- a/BUILD +++ b/BUILD @@ -217,6 +217,7 @@ BUTIL_SRCS = [ "src/butil/containers/case_ignored_flat_map.cpp", "src/butil/iobuf.cpp", "src/butil/binary_printer.cpp", + "src/butil/recordio.cc", "src/butil/popen.cpp", ] + select({ ":darwin": [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f221dc4..090d3447 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -311,6 +311,7 @@ set(BUTIL_SOURCES ${PROJECT_SOURCE_DIR}/src/butil/containers/case_ignored_flat_map.cpp ${PROJECT_SOURCE_DIR}/src/butil/iobuf.cpp ${PROJECT_SOURCE_DIR}/src/butil/binary_printer.cpp + ${PROJECT_SOURCE_DIR}/src/butil/recordio.cc ${PROJECT_SOURCE_DIR}/src/butil/popen.cpp ) From 751b36969bb8c35c8fa36ba77bb6fa37b424b64e Mon Sep 17 00:00:00 2001 From: gejun Date: Mon, 20 May 2019 15:37:18 +0800 Subject: [PATCH 181/270] Add recordio_unittest.cpp into test/CMakeLists.txt and test/BUILD --- test/BUILD | 1 + test/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/test/BUILD b/test/BUILD index b1f9ae53..0b443e83 100644 --- a/test/BUILD +++ b/test/BUILD @@ -139,6 +139,7 @@ TEST_BUTIL_SOURCES = [ "iobuf_unittest.cpp", "test_switches.cc", "scoped_locale.cc", + "recordio_unittest.cpp", #"popen_unittest.cpp", "butil_unittest_main.cpp", ] + select({ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2c9023a1..cfb29858 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -58,6 +58,7 @@ file(COPY ${PROJECT_SOURCE_DIR}/test/jsonout DESTINATION ${CMAKE_CURRENT_BINARY_ file(COPY ${PROJECT_SOURCE_DIR}/test/run_tests.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) SET(TEST_BUTIL_SOURCES + ${PROJECT_SOURCE_DIR}/test/recordio_unittest.cpp ${PROJECT_SOURCE_DIR}/test/popen_unittest.cpp ${PROJECT_SOURCE_DIR}/test/at_exit_unittest.cc ${PROJECT_SOURCE_DIR}/test/atomicops_unittest.cc From 44c4944758492a63d426b76fe50953a76a575b64 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 20 May 2019 21:39:46 +0800 Subject: [PATCH 182/270] Refine interface of DestroyStreamUserData --- src/brpc/controller.cpp | 2 +- src/brpc/policy/http2_rpc_protocol.cpp | 4 +--- src/brpc/policy/http2_rpc_protocol.h | 1 - src/brpc/rtmp.cpp | 1 - src/brpc/rtmp.h | 1 - src/brpc/stream_creator.h | 4 +--- test/brpc_http_rpc_protocol_unittest.cpp | 2 +- 7 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 7bbd9863..16eaaa88 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -697,7 +697,7 @@ inline bool does_error_affect_main_socket(int error_code) { void Controller::Call::OnComplete( Controller* c, int error_code/*note*/, bool responded, bool end_of_rpc) { if (stream_user_data) { - stream_user_data->DestroyStreamUserData(sending_sock, c, error_code, end_of_rpc); + stream_user_data->DestroyStreamUserData(sending_sock, error_code, end_of_rpc); stream_user_data = NULL; } diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index 5ed7b22e..3d5aa2e5 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -1448,12 +1448,10 @@ private: }; void H2UnsentRequest::DestroyStreamUserData(SocketUniquePtr& sending_sock, - Controller* cntl, int error_code, bool /*end_of_rpc*/) { RemoveRefOnQuit deref_self(this); - if (sending_sock != NULL && (cntl->ErrorCode() != 0 || error_code != 0)) { - CHECK_EQ(cntl, _cntl); + if (sending_sock != NULL && error_code != 0) { std::unique_lock mu(_mutex); _cntl = NULL; if (_stream_id != 0) { diff --git a/src/brpc/policy/http2_rpc_protocol.h b/src/brpc/policy/http2_rpc_protocol.h index 24556111..e93c6b2f 100644 --- a/src/brpc/policy/http2_rpc_protocol.h +++ b/src/brpc/policy/http2_rpc_protocol.h @@ -153,7 +153,6 @@ public: // @StreamUserData void DestroyStreamUserData(SocketUniquePtr& sending_sock, - Controller* cntl, int error_code, bool end_of_rpc) override; diff --git a/src/brpc/rtmp.cpp b/src/brpc/rtmp.cpp index 795f86bc..4362539d 100644 --- a/src/brpc/rtmp.cpp +++ b/src/brpc/rtmp.cpp @@ -1747,7 +1747,6 @@ void RtmpClientStream::OnFailedToCreateStream() { } void RtmpClientStream::DestroyStreamUserData(SocketUniquePtr& sending_sock, - Controller* cntl, int /*error_code*/, bool end_of_rpc) { if (!end_of_rpc) { diff --git a/src/brpc/rtmp.h b/src/brpc/rtmp.h index 12642e16..44455633 100644 --- a/src/brpc/rtmp.h +++ b/src/brpc/rtmp.h @@ -827,7 +827,6 @@ friend class RtmpRetryingClientStream; // @StreamUserData void DestroyStreamUserData(SocketUniquePtr& sending_sock, - Controller* cntl, int error_code, bool end_of_rpc) override; diff --git a/src/brpc/stream_creator.h b/src/brpc/stream_creator.h index 0386392a..ed911197 100644 --- a/src/brpc/stream_creator.h +++ b/src/brpc/stream_creator.h @@ -66,11 +66,9 @@ public: // Params: // sending_sock: The socket chosen by OnCreatingStream(), if an error // happens during choosing, the enclosed socket is NULL. - // cntl: contexts of the RPC - // error_code: Use this instead of cntl->ErrorCode() + // error_code: the error code after the RPC. // end_of_rpc: true if the RPC is about to destroyed. virtual void DestroyStreamUserData(SocketUniquePtr& sending_sock, - Controller* cntl, int error_code, bool end_of_rpc) = 0; }; diff --git a/test/brpc_http_rpc_protocol_unittest.cpp b/test/brpc_http_rpc_protocol_unittest.cpp index 255fd055..08e82a26 100644 --- a/test/brpc_http_rpc_protocol_unittest.cpp +++ b/test/brpc_http_rpc_protocol_unittest.cpp @@ -1113,7 +1113,7 @@ TEST_F(HttpTest, http2_window_used_up) { } else { ASSERT_TRUE(st.ok()); } - h2_req->DestroyStreamUserData(_h2_client_sock, &cntl, 0, false); + h2_req->DestroyStreamUserData(_h2_client_sock, 0, false); } } From 05473176ead75ce63309cdaba8037b519d8fa7df Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 21 May 2019 11:51:51 +0800 Subject: [PATCH 183/270] Fix typo in gflags version --- docs/cn/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index 8b1bca07..fc1edc91 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -364,7 +364,7 @@ Don't use new types in proto3 and start the proto file with `syntax="proto2";` Arena in pb 3.x is not supported yet. -## gflags: 2.0-2.21 +## gflags: 2.0-2.2.1 no known issues. From cd3711f538acea21254ca55a9a60ca4c6cf295f7 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 21 May 2019 18:52:36 +0800 Subject: [PATCH 184/270] transmit discovery metadata into tag field of ServerNode --- src/brpc/policy/discovery_naming_service.cpp | 13 +++++++++++++ test/brpc_naming_service_unittest.cpp | 7 +++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index 7519f83a..5ea1b01e 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -16,6 +16,8 @@ #include #include "butil/third_party/rapidjson/document.h" +#include "butil/third_party/rapidjson/stringbuffer.h" +#include "butil/third_party/rapidjson/writer.h" #include "butil/string_printf.h" #include "butil/fast_rand.h" #include "bthread/bthread.h" @@ -163,6 +165,16 @@ int ParseFetchsResult(const butil::IOBuf& buf, } for (BUTIL_RAPIDJSON_NAMESPACE::SizeType i = 0; i < instances.Size(); ++i) { + std::string metadata; + // convert metadata in object to string + auto itr_metadata = instances[i].FindMember("metadata"); + if (itr_metadata != instances[i].MemberEnd()) { + BUTIL_RAPIDJSON_NAMESPACE::StringBuffer buffer; + BUTIL_RAPIDJSON_NAMESPACE::Writer writer(buffer); + itr_metadata->value.Accept(writer); + metadata = buffer.GetString(); + } + auto itr = instances[i].FindMember("addrs"); if (itr == instances[i].MemberEnd() || !itr->value.IsArray()) { LOG(ERROR) << "Fail to find addrs or addrs is not an array"; @@ -186,6 +198,7 @@ int ParseFetchsResult(const butil::IOBuf& buf, addr.remove_prefix(pos + 3); } ServerNode node; + node.tag = metadata; // Variable addr contains data from addrs[j].GetString(), it is a // null-terminated string, so it is safe to pass addr.data() as the // first parameter to str2endpoint. diff --git a/test/brpc_naming_service_unittest.cpp b/test/brpc_naming_service_unittest.cpp index 478aec45..efbdb660 100644 --- a/test/brpc_naming_service_unittest.cpp +++ b/test/brpc_naming_service_unittest.cpp @@ -448,7 +448,8 @@ static const std::string s_fetchs_result = R"({ "rpc":"", "version":"123", "metadata":{ - + "weight": "10", + "cluster": "" }, "addrs":[ "http://127.0.0.1:8999", @@ -475,7 +476,8 @@ static const std::string s_fetchs_result = R"({ "rpc":"", "version":"123", "metadata":{ - + "weight": "10", + "cluster": "" }, "addrs":[ "http://127.0.0.1:8999", @@ -525,6 +527,7 @@ TEST(NamingServiceTest, discovery_parse_function) { buf.append(s_fetchs_result); ASSERT_EQ(0, brpc::policy::ParseFetchsResult(buf, "admin.test", &servers)); ASSERT_EQ((size_t)1, servers.size()); + ASSERT_EQ(servers[0].tag, "{\"weight\":\"10\",\"cluster\":\"\"}"); buf.clear(); buf.append(s_nodes_result); std::string server; From 760c94738fe1f1cbbc9244747909f09585e708bb Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 21 May 2019 19:53:05 +0800 Subject: [PATCH 185/270] Suppress strict-alias warnings in recordio.cc --- src/butil/recordio.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/butil/recordio.cc b/src/butil/recordio.cc index f4e2b198..447fde33 100755 --- a/src/butil/recordio.cc +++ b/src/butil/recordio.cc @@ -172,7 +172,8 @@ bool RecordReader::CutUntilNextRecordCandidate() { if (_cutter.copy_to(magic, sizeof(magic)) != sizeof(magic)) { return false; } - if (*(const uint32_t*)magic == *(const uint32_t*)BRPC_RECORDIO_MAGIC) { + void* dummy = magic; // suppressing strict-aliasing warning + if (*(const uint32_t*)dummy == *(const uint32_t*)BRPC_RECORDIO_MAGIC) { _cutter.pop_front(sizeof(magic)); _ncut += sizeof(magic); } @@ -184,7 +185,8 @@ bool RecordReader::CutUntilNextRecordCandidate() { } const size_t m = nc + 1 - sizeof(magic); for (size_t i = 0; i < m; ++i) { - if (*(const uint32_t*)(buf + i) == *(const uint32_t*)BRPC_RECORDIO_MAGIC) { + void* dummy = buf + i; // suppressing strict-aliasing warning + if (*(const uint32_t*)dummy == *(const uint32_t*)BRPC_RECORDIO_MAGIC) { _cutter.pop_front(i); _ncut += i; LOG(INFO) << "Found record candidate after " << _ncut - old_ncut << " bytes"; @@ -204,7 +206,8 @@ int RecordReader::CutRecord(Record* rec) { if (_cutter.copy_to(headbuf, sizeof(headbuf)) != sizeof(headbuf)) { return 0; } - if (*(const uint32_t*)headbuf != *(const uint32_t*)BRPC_RECORDIO_MAGIC) { + void* dummy = headbuf; // suppressing strict-aliasing warning + if (*(const uint32_t*)dummy != *(const uint32_t*)BRPC_RECORDIO_MAGIC) { LOG(ERROR) << "Invalid magic_num=" << butil::PrintedAsBinary(std::string((char*)headbuf, 4)) << ", offset=" << read_bytes(); @@ -310,7 +313,8 @@ int RecordWriter::WriteWithoutFlush(const Record& rec) { if (!rec.Payload().empty()) { _buf.append(rec.Payload()); } - *(uint32_t*)headbuf = *(const uint32_t*)BRPC_RECORDIO_MAGIC; + void* dummy = headbuf; // suppressing strict-aliasing warning + *(uint32_t*)dummy = *(const uint32_t*)BRPC_RECORDIO_MAGIC; const size_t data_size = _buf.size() - old_size - sizeof(headbuf); if (data_size > 0x7FFFFFFFULL) { LOG(ERROR) << "data_size=" << data_size << " is too long"; From 50aaa98552cefc0aea7199626323db452dbe2b51 Mon Sep 17 00:00:00 2001 From: gejun Date: Tue, 21 May 2019 19:56:50 +0800 Subject: [PATCH 186/270] fix typos --- src/brpc/policy/baidu_rpc_protocol.cpp | 3 +-- src/brpc/policy/hulu_pbrpc_protocol.cpp | 3 +-- src/brpc/policy/sofa_pbrpc_protocol.cpp | 3 +-- src/brpc/policy/streaming_rpc_protocol.cpp | 3 +-- src/brpc/rpc_dump.cpp | 3 +-- test/bthread_execution_queue_unittest.cpp | 18 +++++++++--------- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/brpc/policy/baidu_rpc_protocol.cpp b/src/brpc/policy/baidu_rpc_protocol.cpp index d7b88674..f6059c60 100644 --- a/src/brpc/policy/baidu_rpc_protocol.cpp +++ b/src/brpc/policy/baidu_rpc_protocol.cpp @@ -59,8 +59,7 @@ DEFINE_bool(baidu_protocol_use_fullname, true, // Pack header into `buf' inline void PackRpcHeader(char* rpc_header, int meta_size, int payload_size) { - // supress strict-aliasing warning. - uint32_t* dummy = (uint32_t*)rpc_header; + uint32_t* dummy = (uint32_t*)rpc_header; // suppress strict-alias warning *dummy = *(uint32_t*)"PRPC"; butil::RawPacker(rpc_header + 4) .pack32(meta_size + payload_size) diff --git a/src/brpc/policy/hulu_pbrpc_protocol.cpp b/src/brpc/policy/hulu_pbrpc_protocol.cpp index 03c611fe..b0fbdb35 100644 --- a/src/brpc/policy/hulu_pbrpc_protocol.cpp +++ b/src/brpc/policy/hulu_pbrpc_protocol.cpp @@ -142,8 +142,7 @@ private: }; inline void PackHuluHeader(char* hulu_header, int meta_size, int body_size) { - // dummy supresses strict-aliasing warning. - uint32_t* dummy = reinterpret_cast(hulu_header); + uint32_t* dummy = reinterpret_cast(hulu_header); // suppress strict-alias warning *dummy = *reinterpret_cast("HULU"); HuluRawPacker rp(hulu_header + 4); rp.pack32(meta_size + body_size).pack32(meta_size); diff --git a/src/brpc/policy/sofa_pbrpc_protocol.cpp b/src/brpc/policy/sofa_pbrpc_protocol.cpp index d00bbf46..34ed83e9 100644 --- a/src/brpc/policy/sofa_pbrpc_protocol.cpp +++ b/src/brpc/policy/sofa_pbrpc_protocol.cpp @@ -128,8 +128,7 @@ private: }; inline void PackSofaHeader(char* sofa_header, int meta_size, int body_size) { - // dummy supresses strict-aliasing warning. - uint32_t* dummy = reinterpret_cast(sofa_header); + uint32_t* dummy = reinterpret_cast(sofa_header); // suppress strict-alias warning *dummy = *reinterpret_cast("SOFA"); SofaRawPacker rp(sofa_header + 4); diff --git a/src/brpc/policy/streaming_rpc_protocol.cpp b/src/brpc/policy/streaming_rpc_protocol.cpp index b3edcf26..541eaaf3 100644 --- a/src/brpc/policy/streaming_rpc_protocol.cpp +++ b/src/brpc/policy/streaming_rpc_protocol.cpp @@ -43,8 +43,7 @@ void PackStreamMessage(butil::IOBuf* out, const uint32_t data_length = data ? data->length() : 0; const uint32_t meta_length = fm.ByteSize(); char head[12]; - // dummy supresses strict-aliasing warning. - uint32_t* dummy = (uint32_t*)head; + uint32_t* dummy = (uint32_t*)head; // suppresses strict-alias warning *(uint32_t*)dummy = *(const uint32_t*)"STRM"; butil::RawPacker(head + 4) .pack32(data_length + meta_length) diff --git a/src/brpc/rpc_dump.cpp b/src/brpc/rpc_dump.cpp index 7be4bf2e..18f61f87 100644 --- a/src/brpc/rpc_dump.cpp +++ b/src/brpc/rpc_dump.cpp @@ -247,8 +247,7 @@ bool RpcDumpContext::Serialize(butil::IOBuf& buf, SampledRequest* sample) { const size_t meta_size = buf.size() - starting_size; buf.append(sample->request); - // dummy supresses strict-aliasing warning. - uint32_t* dummy = (uint32_t*)rpc_header; + uint32_t* dummy = (uint32_t*)rpc_header; // suppress strict-alias warning *dummy = *(uint32_t*)"PRPC"; butil::RawPacker(rpc_header + 4) .pack32(meta_size + sample->request.size()) diff --git a/test/bthread_execution_queue_unittest.cpp b/test/bthread_execution_queue_unittest.cpp index b8c29086..513b9e5e 100644 --- a/test/bthread_execution_queue_unittest.cpp +++ b/test/bthread_execution_queue_unittest.cpp @@ -124,7 +124,7 @@ void* push_thread_which_addresses_execq(void *arg) { TEST_F(ExecutionQueueTest, performance) { pthread_t threads[8]; - bthread::ExecutionQueueId queue_id = { 0 }; // to supress warns + bthread::ExecutionQueueId queue_id = { 0 }; // to suppress warnings bthread::ExecutionQueueOptions options; int64_t result = 0; ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, @@ -220,7 +220,7 @@ int add_with_suspend(void* meta, bthread::TaskIterator& iter) { TEST_F(ExecutionQueueTest, execute_urgent) { g_should_be_urgent = false; pthread_t threads[10]; - bthread::ExecutionQueueId queue_id = { 0 }; // to supress warns + bthread::ExecutionQueueId queue_id = { 0 }; // to suppress warnings bthread::ExecutionQueueOptions options; int64_t result = 0; ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, @@ -262,7 +262,7 @@ TEST_F(ExecutionQueueTest, execute_urgent) { TEST_F(ExecutionQueueTest, urgent_task_is_the_last_task) { g_should_be_urgent = false; g_suspending = false; - bthread::ExecutionQueueId queue_id = { 0 }; // to supress warns + bthread::ExecutionQueueId queue_id = { 0 }; // to suppress warnings bthread::ExecutionQueueOptions options; int64_t result = 0; ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, @@ -319,7 +319,7 @@ int check_order(void* meta, bthread::TaskIterator& iter) { TEST_F(ExecutionQueueTest, multi_threaded_order) { memset(next_task, 0, sizeof(next_task)); long disorder_times = 0; - bthread::ExecutionQueueId queue_id = { 0 }; // to supress warns + bthread::ExecutionQueueId queue_id = { 0 }; // to suppress warnings bthread::ExecutionQueueOptions options; ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, check_order, &disorder_times)); @@ -346,7 +346,7 @@ int check_running_thread(void* arg, bthread::TaskIterator& iter) { TEST_F(ExecutionQueueTest, in_place_task) { pthread_t thread_id = pthread_self(); - bthread::ExecutionQueueId queue_id = { 0 }; // to supress warns + bthread::ExecutionQueueId queue_id = { 0 }; // to suppress warnings bthread::ExecutionQueueOptions options; ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, check_running_thread, @@ -434,7 +434,7 @@ void* inplace_push_thread(void* arg) { TEST_F(ExecutionQueueTest, inplace_and_order) { memset(next_task, 0, sizeof(next_task)); long disorder_times = 0; - bthread::ExecutionQueueId queue_id = { 0 }; // to supress warns + bthread::ExecutionQueueId queue_id = { 0 }; // to suppress warnings bthread::ExecutionQueueOptions options; ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, check_order, &disorder_times)); @@ -476,7 +476,7 @@ int add_with_suspend2(void* meta, bthread::TaskIterator& iter) { } TEST_F(ExecutionQueueTest, cancel) { - bthread::ExecutionQueueId queue_id = { 0 }; // to supress warns + bthread::ExecutionQueueId queue_id = { 0 }; // to suppress warnings bthread::ExecutionQueueOptions options; int64_t result = 0; ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, @@ -517,7 +517,7 @@ int cancel_self(void* /*meta*/, bthread::TaskIterator& iter) { } TEST_F(ExecutionQueueTest, cancel_self) { - bthread::ExecutionQueueId queue_id = { 0 }; // to supress warns + bthread::ExecutionQueueId queue_id = { 0 }; // to suppress warnings bthread::ExecutionQueueOptions options; ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, cancel_self, NULL)); @@ -665,7 +665,7 @@ int add_with_suspend3(void* meta, bthread::TaskIterator& iter) { TEST_F(ExecutionQueueTest, cancel_unexecuted_high_priority_task) { g_should_be_urgent = false; - bthread::ExecutionQueueId queue_id = { 0 }; // to supress warns + bthread::ExecutionQueueId queue_id = { 0 }; // to suppress warnings bthread::ExecutionQueueOptions options; int64_t result = 0; ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, From d7116ea359af87ecf1251017c932d5b4f3d4eb4a Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 22 May 2019 11:04:04 +0800 Subject: [PATCH 187/270] Add length info when serialize stringbuffer to string --- src/brpc/policy/discovery_naming_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index 5ea1b01e..a09389a2 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -172,7 +172,7 @@ int ParseFetchsResult(const butil::IOBuf& buf, BUTIL_RAPIDJSON_NAMESPACE::StringBuffer buffer; BUTIL_RAPIDJSON_NAMESPACE::Writer writer(buffer); itr_metadata->value.Accept(writer); - metadata = buffer.GetString(); + metadata.assign(buffer.GetString(), buffer.GetSize()); } auto itr = instances[i].FindMember("addrs"); From 2b748f82c3447196c8ce372733e5af8f8d76cef5 Mon Sep 17 00:00:00 2001 From: gejun Date: Wed, 22 May 2019 17:41:47 +0800 Subject: [PATCH 188/270] Rename read_bytes() in RecordReader to offset() to avoid misusage and adjust the UT --- src/butil/recordio.cc | 10 +++++----- src/butil/recordio.h | 6 ++++-- test/recordio_unittest.cpp | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/butil/recordio.cc b/src/butil/recordio.cc index 447fde33..12befac8 100755 --- a/src/butil/recordio.cc +++ b/src/butil/recordio.cc @@ -210,7 +210,7 @@ int RecordReader::CutRecord(Record* rec) { if (*(const uint32_t*)dummy != *(const uint32_t*)BRPC_RECORDIO_MAGIC) { LOG(ERROR) << "Invalid magic_num=" << butil::PrintedAsBinary(std::string((char*)headbuf, 4)) - << ", offset=" << read_bytes(); + << ", offset=" << offset(); return -1; } uint32_t tmp = NetToHost32(*(const uint32_t*)(headbuf + 4)); @@ -224,7 +224,7 @@ int RecordReader::CutRecord(Record* rec) { << std::hex << tmp << std::dec << "(metabit=" << has_meta << " size=" << data_size - << " offset=" << read_bytes() + << " offset=" << offset() << "), expected=" << (unsigned)headbuf[8] << " actual=" << (unsigned)checksum; return -1; @@ -233,7 +233,7 @@ int RecordReader::CutRecord(Record* rec) { LOG(ERROR) << "data_size=" << data_size << " is larger than -recordio_max_record_size=" << FLAGS_recordio_max_record_size - << ", offset=" << read_bytes(); + << ", offset=" << offset(); return -1; } if (_cutter.remaining_bytes() < data_size) { @@ -257,13 +257,13 @@ int RecordReader::CutRecord(Record* rec) { if (consumed_bytes + 5 + name_size + meta_size > data_size) { LOG(ERROR) << name << ".meta_size=" << meta_size << " is inconsistent with its data_size=" << data_size - << ", offset=" << read_bytes(); + << ", offset=" << offset(); return -1; } butil::IOBuf* meta = rec->MutableMeta(name, true/*null_on_found*/); if (meta == NULL) { LOG(ERROR) << "Fail to add meta=" << name - << ", offset=" << read_bytes(); + << ", offset=" << offset(); return -1; } _cutter.cutn(meta, meta_size); diff --git a/src/butil/recordio.h b/src/butil/recordio.h index cd50592a..3541bdff 100755 --- a/src/butil/recordio.h +++ b/src/butil/recordio.h @@ -102,8 +102,10 @@ public: // END_OF_READER means all data in the IReader are successfully consumed. int last_error() const { return _last_error; } - // Total bytes of all read records. - size_t read_bytes() const { return _ncut; } + // Total bytes consumed. + // NOTE: this value may not equal to read bytes from the IReader even if + // the reader runs out, due to parsing errors. + size_t offset() const { return _ncut; } private: bool CutUntilNextRecordCandidate(); diff --git a/test/recordio_unittest.cpp b/test/recordio_unittest.cpp index 2fe9a08c..d7e7bd34 100755 --- a/test/recordio_unittest.cpp +++ b/test/recordio_unittest.cpp @@ -164,7 +164,7 @@ TEST(RecordIOTest, write_read_basic) { ASSERT_FALSE(rr.ReadNext(NULL)); ASSERT_EQ((int)butil::RecordReader::END_OF_READER, rr.last_error()); - ASSERT_EQ(sw.str().size(), rr.read_bytes()); + ASSERT_EQ(sw.str().size(), rr.offset()); } TEST(RecordIOTest, incomplete_reader) { @@ -208,7 +208,7 @@ TEST(RecordIOTest, incomplete_reader) { ASSERT_FALSE(rr.ReadNext(NULL)); ASSERT_EQ(EAGAIN, rr.last_error()); - ASSERT_EQ(sw.str().size(), rr.read_bytes()); + ASSERT_EQ(sw.str().size(), rr.offset()); } static std::string rand_string(int min_len, int max_len) { @@ -299,8 +299,8 @@ TEST(RecordIOTest, write_read_random) { ASSERT_EQ(name_value_list[j].second, *r.MetaAt(0).data); } ASSERT_EQ((int)butil::RecordReader::END_OF_READER, rr.last_error()); - ASSERT_EQ(str.size(), rr.read_bytes()); ASSERT_EQ(j, name_value_list.size()); + ASSERT_LE(str.size() - rr.offset(), 3); } } // namespace From b4c943f8f6ffbdd698b7e30e023e3fcc1ac8403d Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 23 May 2019 01:00:49 +0800 Subject: [PATCH 189/270] Change StringBuffer to MemoryBuffer in discovery sdk --- src/brpc/policy/discovery_naming_service.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index a09389a2..aeaa890a 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -16,7 +16,7 @@ #include #include "butil/third_party/rapidjson/document.h" -#include "butil/third_party/rapidjson/stringbuffer.h" +#include "butil/third_party/rapidjson/memorybuffer.h" #include "butil/third_party/rapidjson/writer.h" #include "butil/string_printf.h" #include "butil/fast_rand.h" @@ -169,10 +169,10 @@ int ParseFetchsResult(const butil::IOBuf& buf, // convert metadata in object to string auto itr_metadata = instances[i].FindMember("metadata"); if (itr_metadata != instances[i].MemberEnd()) { - BUTIL_RAPIDJSON_NAMESPACE::StringBuffer buffer; - BUTIL_RAPIDJSON_NAMESPACE::Writer writer(buffer); + BUTIL_RAPIDJSON_NAMESPACE::MemoryBuffer buffer; + BUTIL_RAPIDJSON_NAMESPACE::Writer writer(buffer); itr_metadata->value.Accept(writer); - metadata.assign(buffer.GetString(), buffer.GetSize()); + metadata.assign(buffer.GetBuffer(), buffer.GetSize()); } auto itr = instances[i].FindMember("addrs"); From 0bc3f27ca91e8cae3a65940852f83e0046fb519f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 23 May 2019 19:02:07 +0800 Subject: [PATCH 190/270] Add cntl param back to DestroyStreamUserData --- src/brpc/controller.cpp | 2 +- src/brpc/policy/http2_rpc_protocol.cpp | 2 ++ src/brpc/policy/http2_rpc_protocol.h | 1 + src/brpc/rtmp.cpp | 1 + src/brpc/rtmp.h | 1 + src/brpc/stream_creator.h | 4 +++- test/brpc_http_rpc_protocol_unittest.cpp | 2 +- 7 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 16eaaa88..7bbd9863 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -697,7 +697,7 @@ inline bool does_error_affect_main_socket(int error_code) { void Controller::Call::OnComplete( Controller* c, int error_code/*note*/, bool responded, bool end_of_rpc) { if (stream_user_data) { - stream_user_data->DestroyStreamUserData(sending_sock, error_code, end_of_rpc); + stream_user_data->DestroyStreamUserData(sending_sock, c, error_code, end_of_rpc); stream_user_data = NULL; } diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index 3d5aa2e5..d25c96bc 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -1448,10 +1448,12 @@ private: }; void H2UnsentRequest::DestroyStreamUserData(SocketUniquePtr& sending_sock, + Controller* cntl, int error_code, bool /*end_of_rpc*/) { RemoveRefOnQuit deref_self(this); if (sending_sock != NULL && error_code != 0) { + CHECK_EQ(cntl, _cntl); std::unique_lock mu(_mutex); _cntl = NULL; if (_stream_id != 0) { diff --git a/src/brpc/policy/http2_rpc_protocol.h b/src/brpc/policy/http2_rpc_protocol.h index e93c6b2f..24556111 100644 --- a/src/brpc/policy/http2_rpc_protocol.h +++ b/src/brpc/policy/http2_rpc_protocol.h @@ -153,6 +153,7 @@ public: // @StreamUserData void DestroyStreamUserData(SocketUniquePtr& sending_sock, + Controller* cntl, int error_code, bool end_of_rpc) override; diff --git a/src/brpc/rtmp.cpp b/src/brpc/rtmp.cpp index 4362539d..795f86bc 100644 --- a/src/brpc/rtmp.cpp +++ b/src/brpc/rtmp.cpp @@ -1747,6 +1747,7 @@ void RtmpClientStream::OnFailedToCreateStream() { } void RtmpClientStream::DestroyStreamUserData(SocketUniquePtr& sending_sock, + Controller* cntl, int /*error_code*/, bool end_of_rpc) { if (!end_of_rpc) { diff --git a/src/brpc/rtmp.h b/src/brpc/rtmp.h index 44455633..12642e16 100644 --- a/src/brpc/rtmp.h +++ b/src/brpc/rtmp.h @@ -827,6 +827,7 @@ friend class RtmpRetryingClientStream; // @StreamUserData void DestroyStreamUserData(SocketUniquePtr& sending_sock, + Controller* cntl, int error_code, bool end_of_rpc) override; diff --git a/src/brpc/stream_creator.h b/src/brpc/stream_creator.h index ed911197..8ea1d8ef 100644 --- a/src/brpc/stream_creator.h +++ b/src/brpc/stream_creator.h @@ -66,9 +66,11 @@ public: // Params: // sending_sock: The socket chosen by OnCreatingStream(), if an error // happens during choosing, the enclosed socket is NULL. - // error_code: the error code after the RPC. + // cntl: contexts of the RPC + // error_code: error code after the RPC. // end_of_rpc: true if the RPC is about to destroyed. virtual void DestroyStreamUserData(SocketUniquePtr& sending_sock, + Controller* cntl, int error_code, bool end_of_rpc) = 0; }; diff --git a/test/brpc_http_rpc_protocol_unittest.cpp b/test/brpc_http_rpc_protocol_unittest.cpp index 08e82a26..255fd055 100644 --- a/test/brpc_http_rpc_protocol_unittest.cpp +++ b/test/brpc_http_rpc_protocol_unittest.cpp @@ -1113,7 +1113,7 @@ TEST_F(HttpTest, http2_window_used_up) { } else { ASSERT_TRUE(st.ok()); } - h2_req->DestroyStreamUserData(_h2_client_sock, 0, false); + h2_req->DestroyStreamUserData(_h2_client_sock, &cntl, 0, false); } } From 7384bf7b98c6c8fdb3462d5d69551e864cebd8f3 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 23 May 2019 19:04:14 +0800 Subject: [PATCH 191/270] refine comments in stream_creator.h --- src/brpc/stream_creator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/stream_creator.h b/src/brpc/stream_creator.h index 8ea1d8ef..02ed4dc9 100644 --- a/src/brpc/stream_creator.h +++ b/src/brpc/stream_creator.h @@ -66,8 +66,8 @@ public: // Params: // sending_sock: The socket chosen by OnCreatingStream(), if an error // happens during choosing, the enclosed socket is NULL. - // cntl: contexts of the RPC - // error_code: error code after the RPC. + // cntl: contexts of the RPC. + // error_code: Use this instead of cntl->ErrorCode(). // end_of_rpc: true if the RPC is about to destroyed. virtual void DestroyStreamUserData(SocketUniquePtr& sending_sock, Controller* cntl, From f22f04f8c4d8fde806d4e853a7f5b5f74ab6ad1b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 24 May 2019 12:11:31 +0800 Subject: [PATCH 192/270] separate cmake-compilation into different travis task --- .travis.yml | 2 +- build_in_travis_ci.sh | 32 +++++++++++--------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 82e75cf9..ca1e2c3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ compiler: env: - PURPOSE=compile - PURPOSE=unittest +- PURPOSE=compile-with-cmake - PURPOSE=compile-with-bazel - PURPOSE=compile USE_MESALINK=yes - PURPOSE=unittest USE_MESALINK=yes @@ -28,5 +29,4 @@ install: - if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0.tar.gz && tar -xf v0.8.0.tar.gz && cd mesalink-0.8.0 && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi script: -- if [[ "$PURPOSE" == "compile-with-bazel" ]]; then bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //... ; fi - sh build_in_travis_ci.sh diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index 6e353090..af6ec03b 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -21,39 +21,29 @@ runcmd(){ echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC" +init_make_config() { EXTRA_BUILD_OPTS="" if [ "$USE_MESALINK" = "yes" ]; then EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" fi - # The default env in travis-ci is Ubuntu. if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS; then echo "Fail to configure brpc" exit 1 fi +} + if [ "$PURPOSE" = "compile" ]; then + init_make_config make -j4 && sh tools/make_all_examples elif [ "$PURPOSE" = "unittest" ]; then - # pass the unittest from default Makefile to accelerate build process - : -else - echo "Unknown purpose=\"$PURPOSE\"" -fi - -echo "start building by cmake" -rm -rf bld && mkdir bld && cd bld -if [ "$PURPOSE" = "compile" ]; then - if ! cmake ..; then - echo "Fail to generate Makefile by cmake" - exit 1 - fi - make -j4 -elif [ "$PURPOSE" = "unittest" ]; then - if ! cmake -DBUILD_UNIT_TESTS=ON ..; then - echo "Fail to generate Makefile by cmake" - exit 1 - fi - make -j4 && cd test && sh ./run_tests.sh && cd ../ + init_make_config + cd test + make -j4 && sh ./run_tests.sh +elif [ "$PURPOSE" = "compile-with-bazel" ]; then + bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //... +elif [ "$PURPOSE" = "compile-with-cmake" ]; then + rm -rf bld && mkdir bld && cd bld && cmake .. && make -j4 else echo "Unknown purpose=\"$PURPOSE\"" fi From c916ff616f5bf63db8370bd8010393b42f8cc82d Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 24 May 2019 12:34:59 +0800 Subject: [PATCH 193/270] make compile-with-bazel in .travis.yml --- .travis.yml | 1 + build_in_travis_ci.sh | 2 -- test/recordio_unittest.cpp | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ca1e2c3e..87f05c94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,4 +29,5 @@ install: - if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0.tar.gz && tar -xf v0.8.0.tar.gz && cd mesalink-0.8.0 && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi script: +- if [[ "$PURPOSE" == "compile-with-bazel" ]]; then bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //... ; fi - sh build_in_travis_ci.sh diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index af6ec03b..debbdf9e 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -40,8 +40,6 @@ elif [ "$PURPOSE" = "unittest" ]; then init_make_config cd test make -j4 && sh ./run_tests.sh -elif [ "$PURPOSE" = "compile-with-bazel" ]; then - bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //... elif [ "$PURPOSE" = "compile-with-cmake" ]; then rm -rf bld && mkdir bld && cd bld && cmake .. && make -j4 else diff --git a/test/recordio_unittest.cpp b/test/recordio_unittest.cpp index d7e7bd34..ed0ef05f 100755 --- a/test/recordio_unittest.cpp +++ b/test/recordio_unittest.cpp @@ -1,3 +1,4 @@ +#include #include #include "butil/recordio.h" #include "butil/fast_rand.h" From 7c4b8346dfbd1f2ef8deb7d6ab1139f966bda49e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 24 May 2019 13:59:54 +0800 Subject: [PATCH 194/270] remove -init_make_config --- build_in_travis_ci.sh | 4 ---- src/brpc/cluster_recover_policy.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index debbdf9e..e21b507f 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -21,7 +21,6 @@ runcmd(){ echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC" -init_make_config() { EXTRA_BUILD_OPTS="" if [ "$USE_MESALINK" = "yes" ]; then EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" @@ -31,13 +30,10 @@ if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols - echo "Fail to configure brpc" exit 1 fi -} if [ "$PURPOSE" = "compile" ]; then - init_make_config make -j4 && sh tools/make_all_examples elif [ "$PURPOSE" = "unittest" ]; then - init_make_config cd test make -j4 && sh ./run_tests.sh elif [ "$PURPOSE" = "compile-with-cmake" ]; then diff --git a/src/brpc/cluster_recover_policy.h b/src/brpc/cluster_recover_policy.h index c09933b4..4d4df0d8 100644 --- a/src/brpc/cluster_recover_policy.h +++ b/src/brpc/cluster_recover_policy.h @@ -25,7 +25,7 @@ namespace brpc { -class ServerId; +struct ServerId; // After all servers are down and health check happens, servers are // online one by one. Once one server is up, all the request that should From 7d0c67b8e7c83ac9fab0def2e4a4e8a38f101e15 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 24 May 2019 14:23:16 +0800 Subject: [PATCH 195/270] revert build_in_travis_ci.sh --- build_in_travis_ci.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index e21b507f..6e353090 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -25,19 +25,35 @@ EXTRA_BUILD_OPTS="" if [ "$USE_MESALINK" = "yes" ]; then EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" fi + # The default env in travis-ci is Ubuntu. if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS; then echo "Fail to configure brpc" exit 1 fi - if [ "$PURPOSE" = "compile" ]; then make -j4 && sh tools/make_all_examples elif [ "$PURPOSE" = "unittest" ]; then - cd test - make -j4 && sh ./run_tests.sh -elif [ "$PURPOSE" = "compile-with-cmake" ]; then - rm -rf bld && mkdir bld && cd bld && cmake .. && make -j4 + # pass the unittest from default Makefile to accelerate build process + : +else + echo "Unknown purpose=\"$PURPOSE\"" +fi + +echo "start building by cmake" +rm -rf bld && mkdir bld && cd bld +if [ "$PURPOSE" = "compile" ]; then + if ! cmake ..; then + echo "Fail to generate Makefile by cmake" + exit 1 + fi + make -j4 +elif [ "$PURPOSE" = "unittest" ]; then + if ! cmake -DBUILD_UNIT_TESTS=ON ..; then + echo "Fail to generate Makefile by cmake" + exit 1 + fi + make -j4 && cd test && sh ./run_tests.sh && cd ../ else echo "Unknown purpose=\"$PURPOSE\"" fi From 8dccbb9c1b5ee5b2911b50883159eb9e28d66694 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 24 May 2019 14:35:51 +0800 Subject: [PATCH 196/270] revert travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 87f05c94..82e75cf9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ compiler: env: - PURPOSE=compile - PURPOSE=unittest -- PURPOSE=compile-with-cmake - PURPOSE=compile-with-bazel - PURPOSE=compile USE_MESALINK=yes - PURPOSE=unittest USE_MESALINK=yes From 46df9ddef456dc179aa599868e460a5e2fb0b59f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 24 May 2019 18:29:56 +0800 Subject: [PATCH 197/270] comment mesalink --- .travis.yml | 7 ++++--- build_in_travis_ci.sh | 33 +++++++++------------------------ 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 82e75cf9..f682abaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,10 @@ compiler: env: - PURPOSE=compile - PURPOSE=unittest +- PURPOSE=compile-with-cmake - PURPOSE=compile-with-bazel -- PURPOSE=compile USE_MESALINK=yes -- PURPOSE=unittest USE_MESALINK=yes +#- PURPOSE=compile USE_MESALINK=yes +#- PURPOSE=unittest USE_MESALINK=yes before_script: - ulimit -c unlimited -S # enable core dumps @@ -25,7 +26,7 @@ install: - sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgoogle-perftools-dev libboost-dev libssl-dev libevent-dev libboost-test-dev - sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo env "PATH=$PATH" cmake . && sudo make && sudo mv libgtest* /usr/lib/ && cd - - sudo apt-get install -y gdb # install gdb -- if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0.tar.gz && tar -xf v0.8.0.tar.gz && cd mesalink-0.8.0 && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi +#- if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0.tar.gz && tar -xf v0.8.0.tar.gz && cd mesalink-0.8.0 && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi script: - if [[ "$PURPOSE" == "compile-with-bazel" ]]; then bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //... ; fi diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index 6e353090..bff94dda 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -21,39 +21,24 @@ runcmd(){ echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC" -EXTRA_BUILD_OPTS="" -if [ "$USE_MESALINK" = "yes" ]; then - EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" -fi +#EXTRA_BUILD_OPTS="" +#if [ "$USE_MESALINK" = "yes" ]; then +# EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" +#fi # The default env in travis-ci is Ubuntu. if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS; then echo "Fail to configure brpc" exit 1 fi + if [ "$PURPOSE" = "compile" ]; then make -j4 && sh tools/make_all_examples elif [ "$PURPOSE" = "unittest" ]; then - # pass the unittest from default Makefile to accelerate build process - : -else - echo "Unknown purpose=\"$PURPOSE\"" -fi - -echo "start building by cmake" -rm -rf bld && mkdir bld && cd bld -if [ "$PURPOSE" = "compile" ]; then - if ! cmake ..; then - echo "Fail to generate Makefile by cmake" - exit 1 - fi - make -j4 -elif [ "$PURPOSE" = "unittest" ]; then - if ! cmake -DBUILD_UNIT_TESTS=ON ..; then - echo "Fail to generate Makefile by cmake" - exit 1 - fi - make -j4 && cd test && sh ./run_tests.sh && cd ../ + cd test + make -j4 && sh ./run_tests.sh +elif [ "$PURPOSE" = "compile-with-cmake" ]; then + rm -rf bld && mkdir bld && cd bld && cmake .. && make -j4 else echo "Unknown purpose=\"$PURPOSE\"" fi From 876c45e473a5552b63f07a2aa81d788304416575 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 24 May 2019 18:34:55 +0800 Subject: [PATCH 198/270] 1. add init_make_config in build_in_travis_ci.sh; 2. move compile-with-bazel into script --- .travis.yml | 1 - build_in_travis_ci.sh | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f682abaf..f1f378aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,5 +29,4 @@ install: #- if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0.tar.gz && tar -xf v0.8.0.tar.gz && cd mesalink-0.8.0 && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi script: -- if [[ "$PURPOSE" == "compile-with-bazel" ]]; then bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //... ; fi - sh build_in_travis_ci.sh diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index bff94dda..8f3a1fec 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -21,6 +21,7 @@ runcmd(){ echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC" +init_make_config() { #EXTRA_BUILD_OPTS="" #if [ "$USE_MESALINK" = "yes" ]; then # EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" @@ -31,14 +32,19 @@ if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols - echo "Fail to configure brpc" exit 1 fi +} if [ "$PURPOSE" = "compile" ]; then + init_make_config make -j4 && sh tools/make_all_examples elif [ "$PURPOSE" = "unittest" ]; then + init_make_config cd test make -j4 && sh ./run_tests.sh elif [ "$PURPOSE" = "compile-with-cmake" ]; then rm -rf bld && mkdir bld && cd bld && cmake .. && make -j4 +elif [ "$PURPOSE" = "compile-with-bazel" ]; then + bazel build -j 12 -c opt --copt -DHAVE_ZLIB=1 //... else echo "Unknown purpose=\"$PURPOSE\"" fi From a714422a1aa282fb0dbb9d621a77b08da1e44784 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 24 May 2019 19:19:41 +0800 Subject: [PATCH 199/270] comment compiling example --- build_in_travis_ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index 8f3a1fec..e10c09e7 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -36,7 +36,7 @@ fi if [ "$PURPOSE" = "compile" ]; then init_make_config - make -j4 && sh tools/make_all_examples + make -j4 #&& sh tools/make_all_examples elif [ "$PURPOSE" = "unittest" ]; then init_make_config cd test From da17b65b1ad0a4952c85d92127b9d278be209a98 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 25 May 2019 14:43:51 +0800 Subject: [PATCH 200/270] add thrift dependencies --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f1f378aa..88e7eb58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,8 @@ before_script: before_install: - wget --no-clobber https://github.com/bazelbuild/bazel/releases/download/0.25.1/bazel_0.25.1-linux-x86_64.deb - sudo dpkg -i bazel_0.25.1-linux-x86_64.deb -- wget http://www.us.apache.org/dist/thrift/0.11.0/thrift-0.11.0.tar.gz && tar -xf thrift-0.11.0.tar.gz && cd thrift-0.11.0/ && ./configure --prefix=/usr --with-ruby=no --with-python=no --with-java=no --with-go=no --with-perl=no --with-php=no --with-csharp=no --with-erlang=no --with-lua=no --with-nodejs=no && make CPPFLAGS=-DFORCE_BOOST_SMART_PTR -j 3 -s && sudo make install && cd - +- sudo apt-get install automake bison flex g++ git libboost-all-dev libevent-dev libssl-dev libtool make pkg-config # thrift dependencies +- wget http://www.us.apache.org/dist/thrift/0.11.0/thrift-0.11.0.tar.gz && tar -xf thrift-0.11.0.tar.gz && cd thrift-0.11.0/ && ./configure --prefix=/usr --with-rs=no --with-ruby=no --with-python=no --with-java=no --with-go=no --with-perl=no --with-php=no --with-csharp=no --with-erlang=no --with-lua=no --with-nodejs=no && make CPPFLAGS=-DFORCE_BOOST_SMART_PTR -j 3 -s && sudo make install && cd - install: - sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgoogle-perftools-dev libboost-dev libssl-dev libevent-dev libboost-test-dev From 543be5e18f70bb0a69de78f0f5cd1ff66e7a9c43 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 25 May 2019 14:53:19 +0800 Subject: [PATCH 201/270] compile example in build_in_travis_ci.sh --- build_in_travis_ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index e10c09e7..8f3a1fec 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -36,7 +36,7 @@ fi if [ "$PURPOSE" = "compile" ]; then init_make_config - make -j4 #&& sh tools/make_all_examples + make -j4 && sh tools/make_all_examples elif [ "$PURPOSE" = "unittest" ]; then init_make_config cd test From 016cafa751c2d2b1c4b941e0937d6f26cbc3a521 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 25 May 2019 16:03:44 +0800 Subject: [PATCH 202/270] add --with-thrift to travis --- build_in_travis_ci.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index 8f3a1fec..eae68613 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -22,13 +22,13 @@ runcmd(){ echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC" init_make_config() { -#EXTRA_BUILD_OPTS="" +EXTRA_BUILD_OPTS="" #if [ "$USE_MESALINK" = "yes" ]; then # EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" #fi # The default env in travis-ci is Ubuntu. -if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS; then +if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS --with-thrift ; then echo "Fail to configure brpc" exit 1 fi From 87e4624c32122130c790a13bc9d62c2346aa5d8a Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 25 May 2019 16:35:27 +0800 Subject: [PATCH 203/270] remove FORCE_BOOST_SMART_PTR macro when compiling thrift --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 88e7eb58..893eae62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ before_install: - wget --no-clobber https://github.com/bazelbuild/bazel/releases/download/0.25.1/bazel_0.25.1-linux-x86_64.deb - sudo dpkg -i bazel_0.25.1-linux-x86_64.deb - sudo apt-get install automake bison flex g++ git libboost-all-dev libevent-dev libssl-dev libtool make pkg-config # thrift dependencies -- wget http://www.us.apache.org/dist/thrift/0.11.0/thrift-0.11.0.tar.gz && tar -xf thrift-0.11.0.tar.gz && cd thrift-0.11.0/ && ./configure --prefix=/usr --with-rs=no --with-ruby=no --with-python=no --with-java=no --with-go=no --with-perl=no --with-php=no --with-csharp=no --with-erlang=no --with-lua=no --with-nodejs=no && make CPPFLAGS=-DFORCE_BOOST_SMART_PTR -j 3 -s && sudo make install && cd - +- wget http://www.us.apache.org/dist/thrift/0.11.0/thrift-0.11.0.tar.gz && tar -xf thrift-0.11.0.tar.gz && cd thrift-0.11.0/ && ./configure --prefix=/usr --with-rs=no --with-ruby=no --with-python=no --with-java=no --with-go=no --with-perl=no --with-php=no --with-csharp=no --with-erlang=no --with-lua=no --with-nodejs=no && make -sj4 && sudo make install && cd - install: - sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgoogle-perftools-dev libboost-dev libssl-dev libevent-dev libboost-test-dev From c0d3b6a555fb52b664e5b2077a6b788a0287ab81 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Sat, 25 May 2019 22:45:06 +0800 Subject: [PATCH 204/270] comment out only the purpose part of mesalink in travis --- .travis.yml | 2 +- build_in_travis_ci.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 893eae62..e4da9208 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ install: - sudo apt-get install -qq realpath libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgoogle-perftools-dev libboost-dev libssl-dev libevent-dev libboost-test-dev - sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo env "PATH=$PATH" cmake . && sudo make && sudo mv libgtest* /usr/lib/ && cd - - sudo apt-get install -y gdb # install gdb -#- if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0.tar.gz && tar -xf v0.8.0.tar.gz && cd mesalink-0.8.0 && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi +- if [[ "$USE_MESALINK" == "yes" ]]; then curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && wget https://github.com/mesalock-linux/mesalink/archive/v0.8.0.tar.gz && tar -xf v0.8.0.tar.gz && cd mesalink-0.8.0 && ./autogen.sh --prefix=/usr/ && make && sudo make install && cd - ; fi script: - sh build_in_travis_ci.sh diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index eae68613..def7766d 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -23,9 +23,9 @@ echo "build combination: PURPOSE=$PURPOSE CXX=$CXX CC=$CC" init_make_config() { EXTRA_BUILD_OPTS="" -#if [ "$USE_MESALINK" = "yes" ]; then -# EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" -#fi +if [ "$USE_MESALINK" = "yes" ]; then + EXTRA_BUILD_OPTS="$EXTRA_BUILD_OPTS --with-mesalink" +fi # The default env in travis-ci is Ubuntu. if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS --with-thrift ; then From c62926de5e16b0ed115d91aa877f1ef86e50e5d8 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 27 May 2019 11:43:05 +0800 Subject: [PATCH 205/270] passing --with-thrift as init_make_config argument --- build_in_travis_ci.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index def7766d..4a836bcc 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -28,14 +28,15 @@ if [ "$USE_MESALINK" = "yes" ]; then fi # The default env in travis-ci is Ubuntu. -if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS --with-thrift ; then +if ! sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --nodebugsymbols --cxx=$CXX --cc=$CC $EXTRA_BUILD_OPTS $1 ; then echo "Fail to configure brpc" exit 1 fi } if [ "$PURPOSE" = "compile" ]; then - init_make_config + # In order to run thrift example, we need to add the corresponding flag + init_make_config "--with-thrift" make -j4 && sh tools/make_all_examples elif [ "$PURPOSE" = "unittest" ]; then init_make_config From 322439db4b789880bc6d81197a1e8dd4bb002cf8 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 27 May 2019 12:30:21 +0800 Subject: [PATCH 206/270] Make init_make_config in build_in_travis_ci.sh can be failed too --- build_in_travis_ci.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build_in_travis_ci.sh b/build_in_travis_ci.sh index 4a836bcc..592aa8ce 100644 --- a/build_in_travis_ci.sh +++ b/build_in_travis_ci.sh @@ -36,12 +36,9 @@ fi if [ "$PURPOSE" = "compile" ]; then # In order to run thrift example, we need to add the corresponding flag - init_make_config "--with-thrift" - make -j4 && sh tools/make_all_examples + init_make_config "--with-thrift" && make -j4 && sh tools/make_all_examples elif [ "$PURPOSE" = "unittest" ]; then - init_make_config - cd test - make -j4 && sh ./run_tests.sh + init_make_config && cd test && make -j4 && sh ./run_tests.sh elif [ "$PURPOSE" = "compile-with-cmake" ]; then rm -rf bld && mkdir bld && cd bld && cmake .. && make -j4 elif [ "$PURPOSE" = "compile-with-bazel" ]; then From 93c35ba909c1a52ff59a9c4ad272e27a47162464 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 27 May 2019 19:28:27 +0800 Subject: [PATCH 207/270] fix wrong pointer in processing http response after h2goaway --- src/brpc/policy/http2_rpc_protocol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index d25c96bc..7a88620e 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -967,8 +967,8 @@ H2ParseResult H2Context::OnGoAway( BTHREAD_ATTR_PTHREAD : BTHREAD_ATTR_NORMAL); tmp.keytable_pool = _socket->keytable_pool(); - CHECK_EQ(0, bthread_start_background( - &th, &tmp, ProcessHttpResponseWrapper, goaway_streams[i])); + CHECK_EQ(0, bthread_start_background(&th, &tmp, ProcessHttpResponseWrapper, + static_cast(goaway_streams[i]))); } return MakeH2Message(goaway_streams[0]); } else { From ccb9018820372fa1c9345a61de435f3b61b84f29 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 28 May 2019 13:59:20 +0800 Subject: [PATCH 208/270] add UT: http2_handle_goaway_streams --- test/brpc_http_rpc_protocol_unittest.cpp | 48 +++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/test/brpc_http_rpc_protocol_unittest.cpp b/test/brpc_http_rpc_protocol_unittest.cpp index 255fd055..9354e629 100644 --- a/test/brpc_http_rpc_protocol_unittest.cpp +++ b/test/brpc_http_rpc_protocol_unittest.cpp @@ -12,6 +12,7 @@ #include "butil/time.h" #include "butil/macros.h" #include "butil/files/scoped_file.h" +#include "butil/fd_guard.h" #include "brpc/socket.h" #include "brpc/acceptor.h" #include "brpc/server.h" @@ -1324,7 +1325,7 @@ TEST_F(HttpTest, http2_header_after_data) { ASSERT_EQ(*user_defined2, "b"); } -TEST_F(HttpTest, http2_goaway) { +TEST_F(HttpTest, http2_goaway_sanity) { brpc::Controller cntl; // Prepare request butil::IOBuf req_out; @@ -1363,4 +1364,49 @@ TEST_F(HttpTest, http2_goaway) { ASSERT_TRUE(st.error_data().ends_with("the connection just issued GOAWAY")); } +class AfterRecevingGoAway : public ::google::protobuf::Closure { +public: + void Run() { + ASSERT_EQ(brpc::EHTTP, cntl.ErrorCode()); + delete this; + } + brpc::Controller cntl; +}; + +TEST_F(HttpTest, http2_handle_goaway_streams) { + const butil::EndPoint ep(butil::IP_ANY, 5961); + butil::fd_guard listenfd(butil::tcp_listen(ep)); + ASSERT_GT(listenfd, 0); + + brpc::Channel channel; + brpc::ChannelOptions options; + options.protocol = brpc::PROTOCOL_H2; + ASSERT_EQ(0, channel.Init(ep, &options)); + + int req_size = 10; + std::vector ids(req_size); + for (int i = 0; i < req_size; i++) { + AfterRecevingGoAway* done = new AfterRecevingGoAway; + brpc::Controller& cntl = done->cntl; + ids.push_back(cntl.call_id()); + cntl.set_timeout_ms(-1); + cntl.http_request().uri() = "/it-doesnt-matter"; + channel.CallMethod(NULL, &cntl, NULL, NULL, done); + } + + int servfd = accept(listenfd, NULL, NULL); + ASSERT_GT(servfd, 0); + // Sleep for a while to make sure that server has received all data. + bthread_usleep(2000); + char goawaybuf[brpc::policy::FRAME_HEAD_SIZE + 8]; + SerializeFrameHead(goawaybuf, 8, brpc::policy::H2_FRAME_GOAWAY, 0, 0); + SaveUint32(goawaybuf + brpc::policy::FRAME_HEAD_SIZE, 0); + SaveUint32(goawaybuf + brpc::policy::FRAME_HEAD_SIZE + 4, 0); + ASSERT_EQ(brpc::policy::FRAME_HEAD_SIZE + 8, ::write(servfd, goawaybuf, brpc::policy::FRAME_HEAD_SIZE + 8)); + + // After receving GOAWAY, the callbacks in client should be run correctly. + for (int i = 0; i < req_size; i++) { + brpc::Join(ids[i]); + } +} } //namespace From 255a653c651aeec2f0a4f6b063fea9c5789f209d Mon Sep 17 00:00:00 2001 From: gejun Date: Wed, 29 May 2019 15:29:04 +0800 Subject: [PATCH 209/270] Link shared libbrpc in UTs built by the Makefile --- Makefile | 26 +++++++++++++++----------- test/Makefile | 50 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index cdd1ff51..27a506c8 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,9 @@ COMMA = , SOPATHS = $(addprefix -Wl$(COMMA)-rpath$(COMMA), $(LIBS)) SRCEXTS = .c .cc .cpp .proto -TARGET_LIB_DY = libbrpc.so +SOEXT = so ifeq ($(SYSTEM),Darwin) - TARGET_LIB_DY = libbrpc.dylib + SOEXT = dylib endif #required by butil/crc32.cc to boost performance for 10x @@ -205,19 +205,19 @@ DEBUG_OBJS = $(OBJS:.o=.dbg.o) PROTOS=$(BRPC_PROTOS) src/idl_options.proto .PHONY:all -all: protoc-gen-mcpack libbrpc.a $(TARGET_LIB_DY) output/include output/lib output/bin +all: protoc-gen-mcpack libbrpc.a libbrpc.$(SOEXT) output/include output/lib output/bin .PHONY:debug -debug: test/libbrpc.dbg.a test/libbvar.dbg.a +debug: test/libbrpc.dbg.$(SOEXT) test/libbvar.dbg.a .PHONY:clean clean: @echo "Cleaning" - @rm -rf src/mcpack2pb/generator.o protoc-gen-mcpack libbrpc.a $(TARGET_LIB_DY) $(OBJS) output/include output/lib output/bin $(PROTOS:.proto=.pb.h) $(PROTOS:.proto=.pb.cc) + @rm -rf src/mcpack2pb/generator.o protoc-gen-mcpack libbrpc.a libbrpc.$(SOEXT) $(OBJS) output/include output/lib output/bin $(PROTOS:.proto=.pb.h) $(PROTOS:.proto=.pb.cc) .PHONY:clean_debug clean_debug: - @rm -rf test/libbrpc.dbg.a test/libbvar.dbg.a $(DEBUG_OBJS) + @rm -rf test/libbrpc.dbg.$(SOEXT) test/libbvar.dbg.a $(DEBUG_OBJS) .PRECIOUS: %.o @@ -234,7 +234,7 @@ libbrpc.a:$(BRPC_PROTOS:.proto=.pb.h) $(OBJS) @echo "Packing $@" @ar crs $@ $(filter %.o,$^) -$(TARGET_LIB_DY):$(BRPC_PROTOS:.proto=.pb.h) $(OBJS) +libbrpc.$(SOEXT):$(BRPC_PROTOS:.proto=.pb.h) $(OBJS) @echo "Linking $@" ifeq ($(SYSTEM),Linux) @$(CXX) -shared -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $(filter %.o,$^) -Xlinker "-)" $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) @@ -246,9 +246,13 @@ test/libbvar.dbg.a:$(BVAR_DEBUG_OBJS) @echo "Packing $@" @ar crs $@ $^ -test/libbrpc.dbg.a:$(BRPC_PROTOS:.proto=.pb.h) $(DEBUG_OBJS) - @echo "Packing $@" - @ar crs $@ $(filter %.o,$^) +test/libbrpc.dbg.$(SOEXT):$(BRPC_PROTOS:.proto=.pb.h) $(DEBUG_OBJS) + @echo "Linking $@" +ifeq ($(SYSTEM),Linux) + @$(CXX) -shared -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $(filter %.o,$^) -Xlinker "-)" $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) +else ifeq ($(SYSTEM),Darwin) + @$(CXX) -dynamiclib -Wl,-headerpad_max_install_names -o $@ -install_name @rpath/$@ $(LIBPATHS) $(SOPATHS) $(filter %.o,$^) $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) +endif .PHONY:output/include output/include: @@ -258,7 +262,7 @@ output/include: @cp src/idl_options.proto src/idl_options.pb.h $@ .PHONY:output/lib -output/lib:libbrpc.a $(TARGET_LIB_DY) +output/lib:libbrpc.a libbrpc.$(SOEXT) @echo "Copying to $@" @mkdir -p $@ @cp $^ $@ diff --git a/test/Makefile b/test/Makefile index db4d7d81..b21a3538 100644 --- a/test/Makefile +++ b/test/Makefile @@ -15,9 +15,18 @@ ifeq ($(CC),gcc) endif endif +LIBS += . HDRPATHS=-I. -I../src $(addprefix -I, $(HDRS)) LIBPATHS=$(addprefix -L, $(LIBS)) +COMMA = , +SOPATHS = $(addprefix -Wl$(COMMA)-rpath$(COMMA), $(LIBS)) + +SOEXT = so +ifeq ($(SYSTEM),Darwin) + SOEXT = dylib +endif + TEST_BUTIL_SOURCES = \ at_exit_unittest.cc \ atomicops_unittest.cc \ @@ -129,6 +138,8 @@ ifeq ($(SYSTEM), Darwin) DYNAMIC_LINKINGS+=-Wl,-U,_bthread_key_create endif +UT_DYNAMIC_LINKINGS = $(DYNAMIC_LINKINGS) -lbrpc.dbg + TEST_BUTIL_OBJS = iobuf.pb.o $(addsuffix .o, $(basename $(TEST_BUTIL_SOURCES))) TEST_BVAR_SOURCES = $(wildcard bvar_*_unittest.cpp) @@ -158,62 +169,65 @@ clean:clean_bins clean_bins: @rm -rf $(TEST_BINS) -libbrpc.dbg.a:FORCE - @$(MAKE) -C.. debug +libbrpc.dbg.$(SOEXT):FORCE + @$(MAKE) -C.. test/libbrpc.dbg.$(SOEXT) + +libbvar.dbg.a:FORCE + @$(MAKE) -C.. test/libbvar.dbg.a FORCE: .PRECIOUS: %.o -test_butil:libbrpc.dbg.a $(TEST_BUTIL_OBJS) +test_butil:$(TEST_BUTIL_OBJS) | libbrpc.dbg.$(SOEXT) @echo "Linking $@" ifeq ($(SYSTEM),Linux) - @$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(UT_DYNAMIC_LINKINGS) else ifeq ($(SYSTEM),Darwin) - @$(CXX) -o $@ $(LIBPATHS) $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS) endif -test_bvar:libbrpc.dbg.a $(TEST_BVAR_OBJS) +test_bvar:libbvar.dbg.a $(TEST_BVAR_OBJS) @echo "Linking $@" ifeq ($(SYSTEM),Linux) - @$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $(TEST_BVAR_OBJS) libbvar.dbg.a -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) else ifeq ($(SYSTEM),Darwin) - @$(CXX) -o $@ $(LIBPATHS) $(TEST_BVAR_OBJS) libbvar.dbg.a $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) endif -bthread%unittest:libbrpc.dbg.a bthread%unittest.o +bthread%unittest:bthread%unittest.o | libbrpc.dbg.$(SOEXT) @echo "Linking $@" ifeq ($(SYSTEM),Linux) - @$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(UT_DYNAMIC_LINKINGS) else ifeq ($(SYSTEM),Darwin) - @$(CXX) -o $@ $(LIBPATHS) $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS) endif -brpc_%_unittest:libbrpc.dbg.a $(TEST_PROTO_OBJS) brpc_%_unittest.o +brpc_%_unittest:$(TEST_PROTO_OBJS) brpc_%_unittest.o | libbrpc.dbg.$(SOEXT) @echo "Linking $@" ifeq ($(SYSTEM),Linux) - @$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(UT_DYNAMIC_LINKINGS) else ifeq ($(SYSTEM),Darwin) - @$(CXX) -o $@ $(LIBPATHS) $^ $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS) endif %.pb.cc %.pb.h:%.proto @echo "Generating $@" @$(PROTOC) --cpp_out=. --proto_path=. --proto_path=../src --proto_path=$(PROTOBUF_HDR) $< -baidu_time_unittest.o:baidu_time_unittest.cpp | libbrpc.dbg.a +baidu_time_unittest.o:baidu_time_unittest.cpp | libbrpc.dbg.$(SOEXT) @echo "Compiling $@" @$(CXX) -c $(HDRPATHS) -O2 $(CXXFLAGS) $< -o $@ -brpc_h2_unsent_message_unittest.o:brpc_h2_unsent_message_unittest.cpp | libbrpc.dbg.a +brpc_h2_unsent_message_unittest.o:brpc_h2_unsent_message_unittest.cpp | libbrpc.dbg.$(SOEXT) @echo "Compiling $@" @$(CXX) -c $(HDRPATHS) -O2 $(CXXFLAGS) $< -o $@ -%.o:%.cpp | libbrpc.dbg.a +%.o:%.cpp | libbrpc.dbg.$(SOEXT) @echo "Compiling $@" @$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@ -%.o:%.cc | libbrpc.dbg.a +%.o:%.cc | libbrpc.dbg.$(SOEXT) @echo "Compiling $@" @$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@ From fe11661166a177a366ed800c4561e4cb74ac6c4b Mon Sep 17 00:00:00 2001 From: gejun Date: Thu, 30 May 2019 12:08:10 +0800 Subject: [PATCH 210/270] Fix UT linked with SO --- test/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Makefile b/test/Makefile index b21a3538..7a6306ff 100644 --- a/test/Makefile +++ b/test/Makefile @@ -182,7 +182,7 @@ FORCE: test_butil:$(TEST_BUTIL_OBJS) | libbrpc.dbg.$(SOEXT) @echo "Linking $@" ifeq ($(SYSTEM),Linux) - @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(UT_DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Xlinker "-)" $(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS) else ifeq ($(SYSTEM),Darwin) @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS) endif @@ -198,7 +198,7 @@ endif bthread%unittest:bthread%unittest.o | libbrpc.dbg.$(SOEXT) @echo "Linking $@" ifeq ($(SYSTEM),Linux) - @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(UT_DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Xlinker "-)" $(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS) else ifeq ($(SYSTEM),Darwin) @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS) endif @@ -206,7 +206,7 @@ endif brpc_%_unittest:$(TEST_PROTO_OBJS) brpc_%_unittest.o | libbrpc.dbg.$(SOEXT) @echo "Linking $@" ifeq ($(SYSTEM),Linux) - @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(UT_DYNAMIC_LINKINGS) + @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $^ -Xlinker "-)" $(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS) else ifeq ($(SYSTEM),Darwin) @$(CXX) -o $@ $(LIBPATHS) $(SOPATHS) $^ $(STATIC_LINKINGS) $(UT_DYNAMIC_LINKINGS) endif From cf9f1f8f89669f4edc74890b55697335c369cb85 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 30 May 2019 12:38:58 +0800 Subject: [PATCH 211/270] Fix make issue in mac --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 27a506c8..a31f47a8 100644 --- a/Makefile +++ b/Makefile @@ -251,7 +251,7 @@ test/libbrpc.dbg.$(SOEXT):$(BRPC_PROTOS:.proto=.pb.h) $(DEBUG_OBJS) ifeq ($(SYSTEM),Linux) @$(CXX) -shared -o $@ $(LIBPATHS) $(SOPATHS) -Xlinker "-(" $(filter %.o,$^) -Xlinker "-)" $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) else ifeq ($(SYSTEM),Darwin) - @$(CXX) -dynamiclib -Wl,-headerpad_max_install_names -o $@ -install_name @rpath/$@ $(LIBPATHS) $(SOPATHS) $(filter %.o,$^) $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) + @$(CXX) -dynamiclib -Wl,-headerpad_max_install_names -o $@ -install_name @rpath/libbrpc.dbg.$(SOEXT) $(LIBPATHS) $(SOPATHS) $(filter %.o,$^) $(STATIC_LINKINGS) $(DYNAMIC_LINKINGS) endif .PHONY:output/include From 2a1718e112a48533b2b257c582907a8c61c9f591 Mon Sep 17 00:00:00 2001 From: Jason S Zang Date: Tue, 28 May 2019 15:53:40 +0100 Subject: [PATCH 212/270] Make unit tests link against the brpc shared library so we don't build a world of huge binaries. --- test/CMakeLists.txt | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cfb29858..5a65749b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -174,9 +174,9 @@ endif() # create executable add_executable(test_butil ${TEST_BUTIL_SOURCES} - ${CMAKE_CURRENT_BINARY_DIR}/iobuf.pb.cc - $) -target_link_libraries(test_butil gtest + ${CMAKE_CURRENT_BINARY_DIR}/iobuf.pb.cc) +target_link_libraries(test_butil brpc-shared + gtest ${GPERFTOOLS_LIBRARIES} ${DYNAMIC_LIB}) @@ -185,10 +185,9 @@ list(REMOVE_ITEM BVAR_SOURCES ${PROJECT_SOURCE_DIR}/src/bvar/default_variables.c add_library(BVAR_OBJ OBJECT ${BVAR_SOURCES}) file(GLOB TEST_BVAR_SRCS "bvar_*_unittest.cpp") -add_executable(test_bvar $ - $ - ${TEST_BVAR_SRCS}) -target_link_libraries(test_bvar gtest +add_executable(test_bvar ${TEST_BVAR_SRCS}) +target_link_libraries(test_bvar brpc-shared + gtest ${GPERFTOOLS_LIBRARIES} ${DYNAMIC_LIB}) @@ -197,29 +196,20 @@ add_library(PROTO_OBJ OBJECT ${PROTO_SRCS}) file(GLOB BTHREAD_UNITTESTS "bthread*unittest.cpp") foreach(BTHREAD_UT ${BTHREAD_UNITTESTS}) get_filename_component(BTHREAD_UT_WE ${BTHREAD_UT} NAME_WE) - add_executable(${BTHREAD_UT_WE} ${BTHREAD_UT} - $ - $ - $ - $ - $) - target_link_libraries(${BTHREAD_UT_WE} - gtest_main - ${GPERFTOOLS_LIBRARIES} - ${DYNAMIC_LIB}) + add_executable(${BTHREAD_UT_WE} ${BTHREAD_UT} $) + target_link_libraries(${BTHREAD_UT_WE} brpc-shared + gtest_main + ${GPERFTOOLS_LIBRARIES} + ${DYNAMIC_LIB}) endforeach() file(GLOB BRPC_UNITTESTS "brpc_*_unittest.cpp") foreach(BRPC_UT ${BRPC_UNITTESTS}) get_filename_component(BRPC_UT_WE ${BRPC_UT} NAME_WE) - add_executable(${BRPC_UT_WE} ${BRPC_UT} - $ - $ - $ - $) - target_link_libraries(${BRPC_UT_WE} - gtest_main - ${GPERFTOOLS_LIBRARIES} - ${GTEST_LIB} - ${DYNAMIC_LIB}) + add_executable(${BRPC_UT_WE} ${BRPC_UT} $) + target_link_libraries(${BRPC_UT_WE} brpc-shared + gtest_main + ${GPERFTOOLS_LIBRARIES} + ${GTEST_LIB} + ${DYNAMIC_LIB}) endforeach() From 72f3f4de3469567d9571892bceef725cfd19ed68 Mon Sep 17 00:00:00 2001 From: gejun Date: Thu, 30 May 2019 14:09:08 +0800 Subject: [PATCH 213/270] Fix run_tests.sh --- test/run_tests.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/run_tests.sh b/test/run_tests.sh index be1f4364..8d84856e 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -3,6 +3,7 @@ test_num=0 failed_test="" rc=0 test_bins="test_butil test_bvar bthread*unittest brpc*unittest" +ulimit -c unlimited # turn on coredumps for test_bin in $test_bins; do test_num=$((test_num + 1)) >&2 echo "[runtest] $test_bin" @@ -18,8 +19,9 @@ if [ $test_num -eq 0 ]; then exit 1 fi print_bt () { - COREFILE=$(find . -maxdepth 2 -name "core*" | head -n 1) # find core file - if [[ -f "$COREFILE" ]]; then + # find newest core file + COREFILE=$(find . -name "core*" -type f -printf "%T@ %p\n" | sort -k 1 -n | cut -d' ' -f 2- | tail -n 1) + if [ ! -z "$COREFILE" ]; then gdb -c "$COREFILE" $1 -ex "thread apply all bt" -ex "set pagination 0" -batch; fi } From 8c4554f8c643684ba7810503e868d73a4bb7eeb0 Mon Sep 17 00:00:00 2001 From: Jason S Zang Date: Wed, 29 May 2019 10:17:14 +0100 Subject: [PATCH 214/270] Revert to obj lib for some tests that rely on differtly built non-test objects. Make ctest work right. --- CMakeLists.txt | 1 + test/CMakeLists.txt | 20 ++++++++++++++------ test/brpc_server_unittest.cpp | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 090d3447..a1ecf940 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -391,6 +391,7 @@ set(SOURCES add_subdirectory(src) if(BUILD_UNIT_TESTS) + enable_testing() add_subdirectory(test) endif() add_subdirectory(tools) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5a65749b..30afbda7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -179,28 +179,35 @@ target_link_libraries(test_butil brpc-shared gtest ${GPERFTOOLS_LIBRARIES} ${DYNAMIC_LIB}) +add_test(NAME test_butil COMMAND test_butil) # -DBVAR_NOT_LINK_DEFAULT_VARIABLES not work for gcc >= 5.0, just remove the file to prevent linking into unit tests list(REMOVE_ITEM BVAR_SOURCES ${PROJECT_SOURCE_DIR}/src/bvar/default_variables.cpp) add_library(BVAR_OBJ OBJECT ${BVAR_SOURCES}) file(GLOB TEST_BVAR_SRCS "bvar_*_unittest.cpp") -add_executable(test_bvar ${TEST_BVAR_SRCS}) -target_link_libraries(test_bvar brpc-shared - gtest +add_executable(test_bvar ${TEST_BVAR_SRCS} $ $) +target_link_libraries(test_bvar gtest ${GPERFTOOLS_LIBRARIES} ${DYNAMIC_LIB}) +add_test(NAME test_bvar COMMAND test_bvar) add_library(BTHREAD_OBJ OBJECT ${BTHREAD_SOURCES}) add_library(PROTO_OBJ OBJECT ${PROTO_SRCS}) file(GLOB BTHREAD_UNITTESTS "bthread*unittest.cpp") foreach(BTHREAD_UT ${BTHREAD_UNITTESTS}) get_filename_component(BTHREAD_UT_WE ${BTHREAD_UT} NAME_WE) - add_executable(${BTHREAD_UT_WE} ${BTHREAD_UT} $) - target_link_libraries(${BTHREAD_UT_WE} brpc-shared - gtest_main + add_executable(${BTHREAD_UT_WE} ${BTHREAD_UT} + $ + $ + $ + $ + $ + ) + target_link_libraries(${BTHREAD_UT_WE} gtest_main ${GPERFTOOLS_LIBRARIES} ${DYNAMIC_LIB}) + add_test(NAME ${BTHREAD_UT_WE} COMMAND ${BTHREAD_UT_WE}) endforeach() file(GLOB BRPC_UNITTESTS "brpc_*_unittest.cpp") @@ -212,4 +219,5 @@ foreach(BRPC_UT ${BRPC_UNITTESTS}) ${GPERFTOOLS_LIBRARIES} ${GTEST_LIB} ${DYNAMIC_LIB}) + add_test(NAME ${BRPC_UT_WE} COMMAND ${BRPC_UT_WE}) endforeach() diff --git a/test/brpc_server_unittest.cpp b/test/brpc_server_unittest.cpp index f000bf3c..e2cebac7 100644 --- a/test/brpc_server_unittest.cpp +++ b/test/brpc_server_unittest.cpp @@ -1158,7 +1158,7 @@ TEST_F(ServerTest, serving_requests) { TEST_F(ServerTest, create_pid_file) { { brpc::Server server; - server._options.pid_file = "$PWD//pid_dir/sub_dir/./.server.pid"; + server._options.pid_file = "./pid_dir/sub_dir/./.server.pid"; server.PutPidFileIfNeeded(); pid_t pid = getpid(); std::ifstream fin("./pid_dir/sub_dir/.server.pid"); From 0bc9eaa36383021eb5da73d572600ade881d8817 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 31 May 2019 15:31:36 +0800 Subject: [PATCH 215/270] replace example/partition_echo_c++/server.cpp with that in dynamic_partition_echo_c++ --- example/partition_echo_c++/server.cpp | 139 ++++++++++++++++++++----- example/partition_echo_c++/server_list | 11 +- 2 files changed, 120 insertions(+), 30 deletions(-) diff --git a/example/partition_echo_c++/server.cpp b/example/partition_echo_c++/server.cpp index bd42714f..2e0b7b15 100644 --- a/example/partition_echo_c++/server.cpp +++ b/example/partition_echo_c++/server.cpp @@ -14,9 +14,13 @@ // A server to receive EchoRequest and send back EchoResponse. +#include #include +#include #include #include +#include +#include #include #include "echo.pb.h" @@ -27,57 +31,144 @@ DEFINE_int32(idle_timeout_s, -1, "Connection will be closed if there is no " DEFINE_int32(logoff_ms, 2000, "Maximum duration of server's LOGOFF state " "(waiting for client to close connection before server stops)"); DEFINE_int32(max_concurrency, 0, "Limit of request processing in parallel"); +DEFINE_int32(server_num, 1, "Number of servers"); +DEFINE_string(sleep_us, "", "Sleep so many microseconds before responding"); +DEFINE_bool(spin, false, "spin rather than sleep"); +DEFINE_double(exception_ratio, 0.1, "Percentage of irregular latencies"); +DEFINE_double(min_ratio, 0.2, "min_sleep / sleep_us"); +DEFINE_double(max_ratio, 10, "max_sleep / sleep_us"); // Your implementation of example::EchoService class EchoServiceImpl : public example::EchoService { public: - EchoServiceImpl() {} - ~EchoServiceImpl() {}; - void Echo(google::protobuf::RpcController* cntl_base, - const example::EchoRequest* request, - example::EchoResponse* response, - google::protobuf::Closure* done) { + EchoServiceImpl() : _index(0) {} + virtual ~EchoServiceImpl() {}; + void set_index(size_t index, int64_t sleep_us) { + _index = index; + _sleep_us = sleep_us; + } + virtual void Echo(google::protobuf::RpcController* cntl_base, + const example::EchoRequest* request, + example::EchoResponse* response, + google::protobuf::Closure* done) { brpc::ClosureGuard done_guard(done); brpc::Controller* cntl = static_cast(cntl_base); + if (_sleep_us > 0) { + double delay = _sleep_us; + const double a = FLAGS_exception_ratio * 0.5; + if (a >= 0.0001) { + double x = butil::RandDouble(); + if (x < a) { + const double min_sleep_us = FLAGS_min_ratio * _sleep_us; + delay = min_sleep_us + (_sleep_us - min_sleep_us) * x / a; + } else if (x + a > 1) { + const double max_sleep_us = FLAGS_max_ratio * _sleep_us; + delay = _sleep_us + (max_sleep_us - _sleep_us) * (x + a - 1) / a; + } + } + if (FLAGS_spin) { + int64_t end_time = butil::gettimeofday_us() + (int64_t)delay; + while (butil::gettimeofday_us() < end_time) {} + } else { + bthread_usleep((int64_t)delay); + } + } // Echo request and its attachment response->set_message(request->message()); if (FLAGS_echo_attachment) { cntl->response_attachment().append(cntl->request_attachment()); } + _nreq << 1; } + + size_t num_requests() const { return _nreq.get_value(); } + +private: + size_t _index; + int64_t _sleep_us; + bvar::Adder _nreq; }; int main(int argc, char* argv[]) { // Parse gflags. We recommend you to use gflags as well. GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true); - // Generally you only need one Server. - brpc::Server server; - - // Instance of your service. - EchoServiceImpl echo_service_impl; - - // Add the service into server. Notice the second parameter, because the - // service is put on stack, we don't want server to delete it, otherwise - // use brpc::SERVER_OWNS_SERVICE. - if (server.AddService(&echo_service_impl, - brpc::SERVER_DOESNT_OWN_SERVICE) != 0) { - LOG(ERROR) << "Fail to add service"; + if (FLAGS_server_num <= 0) { + LOG(ERROR) << "server_num must be positive"; return -1; } - // Start the server. + // We need multiple servers in this example. + brpc::Server* servers = new brpc::Server[FLAGS_server_num]; + // For more options see `brpc/server.h'. brpc::ServerOptions options; options.idle_timeout_sec = FLAGS_idle_timeout_s; options.max_concurrency = FLAGS_max_concurrency; - if (server.Start(FLAGS_port, &options) != 0) { - LOG(ERROR) << "Fail to start EchoServer"; - return -1; + + butil::StringSplitter sp(FLAGS_sleep_us.c_str(), ','); + std::vector sleep_list; + for (; sp; ++sp) { + sleep_list.push_back(strtoll(sp.field(), NULL, 10)); + } + if (sleep_list.empty()) { + sleep_list.push_back(0); } - // Wait until Ctrl-C is pressed, then Stop() and Join() the server. - server.RunUntilAskedToQuit(); + // Instance of your services. + EchoServiceImpl* echo_service_impls = new EchoServiceImpl[FLAGS_server_num]; + // Add the service into servers. Notice the second parameter, because the + // service is put on stack, we don't want server to delete it, otherwise + // use brpc::SERVER_OWNS_SERVICE. + for (int i = 0; i < FLAGS_server_num; ++i) { + int64_t sleep_us = sleep_list[(size_t)i < sleep_list.size() ? i : (sleep_list.size() - 1)]; + echo_service_impls[i].set_index(i, sleep_us); + // will be shown on /version page + servers[i].set_version(butil::string_printf( + "example/dynamic_partition_echo_c++[%d]", i)); + if (servers[i].AddService(&echo_service_impls[i], + brpc::SERVER_DOESNT_OWN_SERVICE) != 0) { + LOG(ERROR) << "Fail to add service"; + return -1; + } + // Start the server. + int port = FLAGS_port + i; + if (servers[i].Start(port, &options) != 0) { + LOG(ERROR) << "Fail to start EchoServer"; + return -1; + } + } + + // Service logic are running in separate worker threads, for main thread, + // we don't have much to do, just spinning. + std::vector last_num_requests(FLAGS_server_num); + while (!brpc::IsAskedToQuit()) { + sleep(1); + + size_t cur_total = 0; + for (int i = 0; i < FLAGS_server_num; ++i) { + const size_t current_num_requests = + echo_service_impls[i].num_requests(); + size_t diff = current_num_requests - last_num_requests[i]; + cur_total += diff; + last_num_requests[i] = current_num_requests; + LOG(INFO) << "S[" << i << "]=" << diff << ' ' << noflush; + } + LOG(INFO) << "[total=" << cur_total << ']'; + } + + // Don't forget to stop and join the server otherwise still-running + // worker threads may crash your program. Clients will have/ at most + // `FLAGS_logoff_ms' to close their connections. If some connections + // still remains after `FLAGS_logoff_ms', they will be closed by force. + for (int i = 0; i < FLAGS_server_num; ++i) { + servers[i].Stop(FLAGS_logoff_ms); + } + for (int i = 0; i < FLAGS_server_num; ++i) { + servers[i].Join(); + } + delete [] servers; + delete [] echo_service_impls; return 0; } diff --git a/example/partition_echo_c++/server_list b/example/partition_echo_c++/server_list index 9e2272f0..835f984c 100644 --- a/example/partition_echo_c++/server_list +++ b/example/partition_echo_c++/server_list @@ -1,10 +1,9 @@ # You can change following lines when client is running to see how client # deals with partition changes. - 0.0.0.0:8002 1/4 # unmatched num - 0.0.0.0:8002 -1/3 # invalid index - 0.0.0.0:8002 1/3 - 0.0.0.0:8002 1/3 # repeated + 0.0.0.0:8002 1/4 # ignored: unmatched num + 0.0.0.0:8002 -1/3 # ignored: invalid index + 0.0.0.0:8002 1/3 + 0.0.0.0:8002 1/3 # ignored: repeated 0.0.0.0:8002 2/3 - 0.0.0.0:8002 0/3 - + 0.0.0.0:8002 0/3 From d070457cbe333467ae6c32a617f2d08188f99731 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 3 Jun 2019 18:55:15 +0800 Subject: [PATCH 216/270] separate_cmake_debug_and_release_obj: done --- CMakeLists.txt | 23 +++++++++--------- test/CMakeLists.txt | 58 ++++++++++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1ecf940..b8382a82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,14 @@ cmake_minimum_required(VERSION 2.8.10) project(brpc C CXX) +option(WITH_GLOG "With glog" OFF) +option(DEBUG "Print debug logs" OFF) +option(WITH_DEBUG_SYMBOLS "With debug symbols" ON) +option(WITH_THRIFT "With thrift framed protocol supported" OFF) +option(BUILD_UNIT_TESTS "Whether to build unit tests" OFF) +option(DOWNLOAD_GTEST "Download and build a fresh copy of \ + googletest. Requires Internet access." ON) + # Enable MACOSX_RPATH. Run "cmake --help-policy CMP0042" for policy details. if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) @@ -26,12 +34,6 @@ else() message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.") endif() -option(WITH_GLOG "With glog" OFF) -option(DEBUG "Print debug logs" OFF) -option(WITH_DEBUG_SYMBOLS "With debug symbols" ON) -option(WITH_THRIFT "With thrift framed protocol supported" OFF) -option(BUILD_UNIT_TESTS "Whether to build unit tests" OFF) - set(WITH_GLOG_VAL "0") if(WITH_GLOG) set(WITH_GLOG_VAL "1") @@ -166,8 +168,7 @@ set(DYNAMIC_LIB ${OPENSSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} dl - z - ) + z) set(BRPC_PRIVATE_LIBS "-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz") if(WITH_GLOG) @@ -197,7 +198,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/lib) # for *.a set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/lib) -# list all source files +# the reason why not using file(GLOB_RECURSE...) is that we want to +# include different files on different platforms. set(BUTIL_SOURCES ${PROJECT_SOURCE_DIR}/src/butil/third_party/dmg_fp/g_fmt.cc ${PROJECT_SOURCE_DIR}/src/butil/third_party/dmg_fp/dtoa_wrapper.cc @@ -351,8 +353,7 @@ set(MCPACK2PB_SOURCES ${PROJECT_SOURCE_DIR}/src/mcpack2pb/field_type.cpp ${PROJECT_SOURCE_DIR}/src/mcpack2pb/mcpack2pb.cpp ${PROJECT_SOURCE_DIR}/src/mcpack2pb/parser.cpp - ${PROJECT_SOURCE_DIR}/src/mcpack2pb/serializer.cpp - ) + ${PROJECT_SOURCE_DIR}/src/mcpack2pb/serializer.cpp) include(CompileProto) set(PROTO_FILES idl_options.proto diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 30afbda7..3f17800e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,10 +24,9 @@ compile_proto(PROTO_HDRS PROTO_SRCS ${CMAKE_BINARY_DIR}/test "${TEST_PROTO_FILES}") add_library(TEST_PROTO_LIB OBJECT ${PROTO_SRCS} ${PROTO_HDRS}) -option(BRPC_DOWNLOAD_GTEST "Download and build a fresh copy of googletest. Requires Internet access." ON) set(BRPC_SYSTEM_GTEST_SOURCE_DIR "" CACHE PATH "System googletest source directory.") -if(BRPC_DOWNLOAD_GTEST) +if(DOWNLOAD_GTEST) include(SetupGtest) elseif(BRPC_SYSTEM_GTEST_SOURCE_DIR) add_subdirectory("${BRPC_SYSTEM_GTEST_SOURCE_DIR}" "${PROJECT_BINARY_DIR}/system-googletest-build") @@ -172,52 +171,67 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") "-Wl,-U,_bthread_key_create") endif() -# create executable +add_library(BUTIL_DEBUG_LIB OBJECT ${BUTIL_SOURCES}) +add_library(SOURCES_DEBUG_LIB OBJECT ${SOURCES}) + +# shared library needs POSITION_INDEPENDENT_CODE +set_property(TARGET ${BUTIL_DEBUG_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1) +set_property(TARGET ${SOURCES_DEBUG_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1) + +add_library(brpc-shared-debug SHARED $ + $ + $) +# change the debug lib output dir to be different from the release output +set_target_properties(brpc-shared-debug PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test) + +target_link_libraries(brpc-shared-debug ${DYNAMIC_LIB}) +if(BRPC_WITH_GLOG) + target_link_libraries(brpc-shared-debug ${GLOG_LIB}) +endif() + +# test_butil add_executable(test_butil ${TEST_BUTIL_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/iobuf.pb.cc) -target_link_libraries(test_butil brpc-shared +target_link_libraries(test_butil brpc-shared-debug gtest - ${GPERFTOOLS_LIBRARIES} - ${DYNAMIC_LIB}) + ${GPERFTOOLS_LIBRARIES}) + add_test(NAME test_butil COMMAND test_butil) +# test_bvar # -DBVAR_NOT_LINK_DEFAULT_VARIABLES not work for gcc >= 5.0, just remove the file to prevent linking into unit tests list(REMOVE_ITEM BVAR_SOURCES ${PROJECT_SOURCE_DIR}/src/bvar/default_variables.cpp) -add_library(BVAR_OBJ OBJECT ${BVAR_SOURCES}) +add_library(BVAR_DEBUG_LIB OBJECT ${BVAR_SOURCES}) file(GLOB TEST_BVAR_SRCS "bvar_*_unittest.cpp") -add_executable(test_bvar ${TEST_BVAR_SRCS} $ $) +add_executable(test_bvar ${TEST_BVAR_SRCS} + $ + $) target_link_libraries(test_bvar gtest ${GPERFTOOLS_LIBRARIES} ${DYNAMIC_LIB}) add_test(NAME test_bvar COMMAND test_bvar) -add_library(BTHREAD_OBJ OBJECT ${BTHREAD_SOURCES}) -add_library(PROTO_OBJ OBJECT ${PROTO_SRCS}) +# bthread tests file(GLOB BTHREAD_UNITTESTS "bthread*unittest.cpp") foreach(BTHREAD_UT ${BTHREAD_UNITTESTS}) get_filename_component(BTHREAD_UT_WE ${BTHREAD_UT} NAME_WE) add_executable(${BTHREAD_UT_WE} ${BTHREAD_UT} - $ - $ - $ - $ - $ - ) + $) target_link_libraries(${BTHREAD_UT_WE} gtest_main - ${GPERFTOOLS_LIBRARIES} - ${DYNAMIC_LIB}) + brpc-shared-debug + ${GPERFTOOLS_LIBRARIES}) add_test(NAME ${BTHREAD_UT_WE} COMMAND ${BTHREAD_UT_WE}) endforeach() +# brpc tests file(GLOB BRPC_UNITTESTS "brpc_*_unittest.cpp") foreach(BRPC_UT ${BRPC_UNITTESTS}) get_filename_component(BRPC_UT_WE ${BRPC_UT} NAME_WE) add_executable(${BRPC_UT_WE} ${BRPC_UT} $) - target_link_libraries(${BRPC_UT_WE} brpc-shared + target_link_libraries(${BRPC_UT_WE} brpc-shared-debug gtest_main - ${GPERFTOOLS_LIBRARIES} - ${GTEST_LIB} - ${DYNAMIC_LIB}) + ${GPERFTOOLS_LIBRARIES}) add_test(NAME ${BRPC_UT_WE} COMMAND ${BRPC_UT_WE}) endforeach() From de1269859f430744dd0978754b108d775bdeb431 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 3 Jun 2019 19:04:27 +0800 Subject: [PATCH 217/270] separate_cmake_debug_and_release_obj: remove UT options in src --- src/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index efb9ad5e..9e444170 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,4 @@ -if(BUILD_UNIT_TESTS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNIT_TEST -DBVAR_NOT_LINK_DEFAULT_VARIABLES") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNIT_TEST") -elseif(NOT DEBUG) +if(NOT DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNDEBUG") endif() From e1a6a2abf6f95da5e872d345bef0524b9ca213d9 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 3 Jun 2019 19:30:20 +0800 Subject: [PATCH 218/270] separate_cmake_debug_and_release_obj: make the name of obj in debug and release be consistent --- src/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e444170..28c1be65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,17 +7,17 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${PROJECT_SOURCE_DIR}/src) add_library(BUTIL_LIB OBJECT ${BUTIL_SOURCES}) -add_library(OBJ_LIB OBJECT ${SOURCES}) +add_library(SOURCES_LIB OBJECT ${SOURCES}) # shared library needs POSITION_INDEPENDENT_CODE -set_property(TARGET ${OBJ_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1) +set_property(TARGET ${SOURCES_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1) set_property(TARGET ${BUTIL_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1) add_library(brpc-shared SHARED $ - $ + $ $) add_library(brpc-static STATIC $ - $ + $ $) target_link_libraries(brpc-shared ${DYNAMIC_LIB}) From 2f1595a4077f01d66965538530f433d93e0e91a8 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 4 Jun 2019 12:04:23 +0800 Subject: [PATCH 219/270] improve the way of running ut in cmake --- docs/cn/getting_started.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index fc1edc91..1a2fa192 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -99,9 +99,7 @@ Examples link brpc statically, if you need to link the shared version, use `cmak **Run tests** ```shell -$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make -$ cd test -$ sh run_tests.sh +$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make test ``` ## Fedora/CentOS @@ -191,9 +189,7 @@ Examples link brpc statically, if you need to link the shared version, use `cmak **Run tests** ```shell -$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make -$ cd test -$ sh run_tests.sh +$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make test ``` ## Linux with self-built deps @@ -331,9 +327,7 @@ Examples link brpc statically, if you need to link the shared version, use `cmak **Run tests** ```shell -$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make -$ cd test -$ sh run_tests.sh +$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make test ``` # Supported deps From 30b64f9f563b2c6dde834e5229e48a7c523c574e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 4 Jun 2019 12:08:26 +0800 Subject: [PATCH 220/270] improve the way of running ut in cmake --- docs/cn/getting_started.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index 1a2fa192..dbab05c3 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -99,7 +99,7 @@ Examples link brpc statically, if you need to link the shared version, use `cmak **Run tests** ```shell -$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make test +$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make && make test ``` ## Fedora/CentOS @@ -189,7 +189,7 @@ Examples link brpc statically, if you need to link the shared version, use `cmak **Run tests** ```shell -$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make test +$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make && make test ``` ## Linux with self-built deps @@ -327,7 +327,7 @@ Examples link brpc statically, if you need to link the shared version, use `cmak **Run tests** ```shell -$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make test +$ mkdir bld && cd bld && cmake -DBUILD_UNIT_TESTS=ON .. && make && make test ``` # Supported deps From c32b4de1a1a636f4d607460e90ba6a9a0bc0dfae Mon Sep 17 00:00:00 2001 From: wenweihu86 Date: Fri, 7 Jun 2019 11:56:18 +0800 Subject: [PATCH 221/270] update lib search path to /usr/local for mac os env --- config_brpc.sh | 7 +------ docs/cn/getting_started.md | 18 ++++++------------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/config_brpc.sh b/config_brpc.sh index 659f7cb9..c5970fd1 100755 --- a/config_brpc.sh +++ b/config_brpc.sh @@ -141,12 +141,7 @@ OPENSSL_LIB=$(find_dir_of_lib ssl) # Inconvenient to check these headers in baidu-internal #PTHREAD_HDR=$(find_dir_of_header_or_die pthread.h) -if [ "$SYSTEM" = "Darwin" ]; then - OPENSSL_HDR="/usr/local/Cellar/openssl\@1.1/1.1.1b/include" - OPENSSL_LIB="/usr/local/Cellar/openssl\@1.1/1.1.1b/lib" -else - OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h) -fi +OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h) if [ $WITH_MESALINK != 0 ]; then MESALINK_HDR=$(find_dir_of_header_or_die mesalink/openssl/ssl.h) diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index 8a55f155..9369d831 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -40,7 +40,7 @@ sudo apt-get install libgoogle-perftools-dev If you need to run tests, install and compile libgtest-dev (which is not compiled yet): ```shell -sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv lib/libgtest* /usr/lib/ && cd - +sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv libgtest* /usr/lib/ && cd - ``` The directory of gtest source code may be changed, try `/usr/src/googletest/googletest` if `/usr/src/gtest` is not there. @@ -257,18 +257,12 @@ Note: In the same running environment, the performance of the current Mac versio Install common deps: ```shell -brew install openssl@1.1 git gnu-getopt coreutils +brew install openssl git gnu-getopt coreutils ``` -Install [gflags](https://github.com/gflags/gflags), [leveldb](https://github.com/google/leveldb): +Install [gflags](https://github.com/gflags/gflags), [protobuf](https://github.com/google/protobuf), [leveldb](https://github.com/google/leveldb): ```shell -brew install gflags leveldb -``` - -Install [protobuf](https://github.com/google/protobuf): -```shell -brew install protobuf@3.1 -brew link --force --overwrite protobuf@3.1 +brew install gflags protobuf leveldb ``` If you need to enable cpu/heap profilers in examples: @@ -278,13 +272,13 @@ brew install gperftools If you need to run tests, install and compile googletest (which is not compiled yet): ```shell -git clone https://github.com/google/googletest && cd googletest/googletest && mkdir bld && cd bld && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make && sudo mv lib/libgtest* /usr/lib/ && cd - +git clone https://github.com/google/googletest && cd googletest/googletest && mkdir bld && cd bld && cmake -DCMAKE_CXX_FLAGS="-std=c++11" .. && make && sudo mv libgtest* /usr/lib/ && cd - ``` ### Compile brpc with config_brpc.sh git clone brpc, cd into the repo and run ```shell -$ sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib --cc=clang --cxx=clang++ +$ sh config_brpc.sh --headers=/usr/local --libs=/usr/local --cc=clang --cxx=clang++ $ make ``` To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller. From f85311d536741ad6e2bf2c42a9b411c13557d998 Mon Sep 17 00:00:00 2001 From: wenweihu86 Date: Fri, 7 Jun 2019 15:26:42 +0800 Subject: [PATCH 222/270] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62ab9d1d..b4976a0f 100755 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ You can use it to: * Get [better latency and throughput](docs/en/overview.md#better-latency-and-throughput). * [Extend brpc](docs/en/new_protocol.md) with the protocols used in your organization quickly, or customize components, including [naming services](docs/cn/load_balancing.md#命名服务) (dns, zk, etcd), [load balancers](docs/cn/load_balancing.md#负载均衡) (rr, random, consistent hashing) -# How to Build +# How to build * Read [getting started](docs/cn/getting_started.md) for building steps. From e2c9d6a7802dfc9fad944ef3972ca282f680b8d4 Mon Sep 17 00:00:00 2001 From: gejun Date: Mon, 10 Jun 2019 12:39:07 +0800 Subject: [PATCH 223/270] bvar::Status on integrals supports historical series --- src/bvar/passive_status.h | 5 ++-- src/bvar/status.h | 60 +++++++++++++++++++++++++++++++++++---- src/bvar/window.h | 5 ++-- 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/bvar/passive_status.h b/src/bvar/passive_status.h index 8ada60be..9f5a3beb 100644 --- a/src/bvar/passive_status.h +++ b/src/bvar/passive_status.h @@ -149,7 +149,7 @@ public: detail::AddTo op() const { return detail::AddTo(); } detail::MinusFrom inv_op() const { return detail::MinusFrom(); } - int describe_series(std::ostream& os, const SeriesOptions& options) const { + int describe_series(std::ostream& os, const SeriesOptions& options) const override { if (_series_sampler == NULL) { return 1; } @@ -165,10 +165,9 @@ public: } protected: - // @Variable int expose_impl(const butil::StringPiece& prefix, const butil::StringPiece& name, - DisplayFilter display_filter) { + DisplayFilter display_filter) override { const int rc = Variable::expose_impl(prefix, name, display_filter); if (ADDITIVE && rc == 0 && diff --git a/src/bvar/status.h b/src/bvar/status.h index 48c0ae10..568fa878 100644 --- a/src/bvar/status.h +++ b/src/bvar/status.h @@ -86,16 +86,41 @@ template class Status::value>::type> : public Variable { public: - Status() {} - Status(const T& value) : _value(value) { } - Status(const butil::StringPiece& name, const T& value) : _value(value) { + struct PlaceHolderOp { + void operator()(T&, const T&) const {} + }; + class SeriesSampler : public detail::Sampler { + public: + typedef typename butil::conditional< + true, detail::AddTo, PlaceHolderOp>::type Op; + explicit SeriesSampler(Status* owner) + : _owner(owner), _series(Op()) {} + void take_sample() { _series.append(_owner->get_value()); } + void describe(std::ostream& os) { _series.describe(os, NULL); } + private: + Status* _owner; + detail::Series _series; + }; + +public: + Status() : _series_sampler(NULL) {} + Status(const T& value) : _value(value), _series_sampler(NULL) { } + Status(const butil::StringPiece& name, const T& value) + : _value(value), _series_sampler(NULL) { this->expose(name); } Status(const butil::StringPiece& prefix, - const butil::StringPiece& name, const T& value) : _value(value) { + const butil::StringPiece& name, const T& value) + : _value(value), _series_sampler(NULL) { this->expose_as(prefix, name); } - ~Status() { hide(); } + ~Status() { + hide(); + if (_series_sampler) { + _series_sampler->destroy(); + _series_sampler = NULL; + } + } // Implement Variable::describe() and Variable::get_value(). void describe(std::ostream& os, bool /*quote_string*/) const { @@ -116,8 +141,33 @@ public: _value.store(value, butil::memory_order_relaxed); } + int describe_series(std::ostream& os, const SeriesOptions& options) const override { + if (_series_sampler == NULL) { + return 1; + } + if (!options.test_only) { + _series_sampler->describe(os); + } + return 0; + } + +protected: + int expose_impl(const butil::StringPiece& prefix, + const butil::StringPiece& name, + DisplayFilter display_filter) override { + const int rc = Variable::expose_impl(prefix, name, display_filter); + if (rc == 0 && + _series_sampler == NULL && + FLAGS_save_series) { + _series_sampler = new SeriesSampler(this); + _series_sampler->schedule(); + } + return rc; + } + private: butil::atomic _value; + SeriesSampler* _series_sampler; }; // Specialize for std::string, adding a printf-style set_value(). diff --git a/src/bvar/window.h b/src/bvar/window.h index 984f5c61..f67a8e93 100644 --- a/src/bvar/window.h +++ b/src/bvar/window.h @@ -123,7 +123,7 @@ public: time_t window_size() const { return _window_size; } - int describe_series(std::ostream& os, const SeriesOptions& options) const { + int describe_series(std::ostream& os, const SeriesOptions& options) const override { if (_series_sampler == NULL) { return 1; } @@ -140,10 +140,9 @@ public: } protected: - // @Variable int expose_impl(const butil::StringPiece& prefix, const butil::StringPiece& name, - DisplayFilter display_filter) { + DisplayFilter display_filter) override { const int rc = Variable::expose_impl(prefix, name, display_filter); if (rc == 0 && _series_sampler == NULL && From fe55625086f3b197c3a6d82dce6389324cd7dbcd Mon Sep 17 00:00:00 2001 From: gejun Date: Wed, 12 Jun 2019 16:31:37 +0800 Subject: [PATCH 224/270] add a lot of override --- src/brpc/acceptor.h | 2 +- src/brpc/callback.h | 2 +- src/brpc/cluster_recover_policy.h | 6 +++--- src/brpc/controller.h | 14 +++++++------- src/brpc/describable.h | 2 +- src/brpc/details/method_status.h | 2 +- src/brpc/policy/consul_naming_service.h | 8 ++++---- src/brpc/policy/domain_naming_service.h | 8 ++++---- src/brpc/policy/file_naming_service.h | 8 ++++---- src/brpc/policy/list_naming_service.h | 10 +++++----- src/brpc/policy/remote_file_naming_service.h | 8 ++++---- src/brpc/rpc_dump.h | 6 +++--- src/bthread/mutex.cpp | 6 +++--- src/bthread/task_group.h | 2 +- src/butil/iobuf.h | 10 +++++----- src/butil/logging.cc | 2 +- src/butil/logging.h | 6 +++--- .../third_party/snappy/snappy-sinksource.h | 18 +++++++++--------- src/butil/zero_copy_stream_as_streambuf.h | 6 +++--- src/bvar/detail/sampler.h | 2 +- src/bvar/gflag.h | 5 ++--- src/bvar/latency_recorder.h | 4 ++-- src/bvar/passive_status.h | 8 ++++---- src/bvar/recorder.h | 2 +- src/bvar/reducer.h | 11 +++++------ src/bvar/status.h | 14 ++++++-------- src/bvar/variable.cpp | 8 ++++---- src/bvar/window.h | 9 ++++----- src/mcpack2pb/generator.cpp | 2 +- 29 files changed, 93 insertions(+), 98 deletions(-) diff --git a/src/brpc/acceptor.h b/src/brpc/acceptor.h index 9bfb2e79..c472e88c 100644 --- a/src/brpc/acceptor.h +++ b/src/brpc/acceptor.h @@ -88,7 +88,7 @@ private: int Initialize(); // Remove the accepted socket `sock' from inside - virtual void BeforeRecycle(Socket* sock); + void BeforeRecycle(Socket* sock) override; bthread_keytable_pool_t* _keytable_pool; // owned by Server Status _status; diff --git a/src/brpc/callback.h b/src/brpc/callback.h index eeff5cd5..334bb5c9 100644 --- a/src/brpc/callback.h +++ b/src/brpc/callback.h @@ -86,7 +86,7 @@ class FunctionClosure0 : public ::google::protobuf::Closure { : function_(function), self_deleting_(self_deleting) {} ~FunctionClosure0() {} - void Run() { + void Run() override { bool needs_delete = self_deleting_; // read in case callback deletes function_(); if (needs_delete) delete this; diff --git a/src/brpc/cluster_recover_policy.h b/src/brpc/cluster_recover_policy.h index 4d4df0d8..438ff53c 100644 --- a/src/brpc/cluster_recover_policy.h +++ b/src/brpc/cluster_recover_policy.h @@ -59,9 +59,9 @@ class DefaultClusterRecoverPolicy : public ClusterRecoverPolicy { public: DefaultClusterRecoverPolicy(int64_t min_working_instances, int64_t hold_seconds); - void StartRecover(); - bool DoReject(const std::vector& server_list); - bool StopRecoverIfNecessary(); + void StartRecover() override; + bool DoReject(const std::vector& server_list) override; + bool StopRecoverIfNecessary() override; private: uint64_t GetUsableServerCount(int64_t now_ms, const std::vector& server_list); diff --git a/src/brpc/controller.h b/src/brpc/controller.h index 6e896819..9654ba1b 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -336,7 +336,7 @@ public: // call the final "done" callback. // Note: Reaching deadline of the RPC would not affect this function, which means // even if deadline has been reached, this function may still return false. - bool IsCanceled() const; + bool IsCanceled() const override; // Asks that the given callback be called when the RPC is canceled or the // connection has broken. The callback will always be called exactly once. @@ -345,7 +345,7 @@ public: // when NotifyOnCancel() is called, the callback will be called immediately. // // NotifyOnCancel() must be called no more than once per request. - void NotifyOnCancel(google::protobuf::Closure* callback); + void NotifyOnCancel(google::protobuf::Closure* callback) override; // Returns the authenticated result. NULL if there is no authentication const AuthContext* auth_context() const { return _auth_context; } @@ -437,7 +437,7 @@ public: // Resets the Controller to its initial state so that it may be reused in // a new call. Must NOT be called while an RPC is in progress. - void Reset() { + void Reset() override { ResetNonPods(); ResetPods(); } @@ -448,18 +448,18 @@ public: // as well if the protocol is HTTP. If you want to overwrite the // status_code, call http_response().set_status_code() after SetFailed() // (rather than before SetFailed) - void SetFailed(const std::string& reason); + void SetFailed(const std::string& reason) override; void SetFailed(int error_code, const char* reason_fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); // After a call has finished, returns true if the RPC call failed. // The response to Channel is undefined when Failed() is true. // Calling Failed() before a call has finished is undefined. - bool Failed() const; + bool Failed() const override; // If Failed() is true, return description of the errors. // NOTE: ErrorText() != berror(ErrorCode()). - std::string ErrorText() const; + std::string ErrorText() const override; // Last error code. Equals 0 iff Failed() is false. // If there's retry, latter code overwrites former one. @@ -557,7 +557,7 @@ private: void ResetPods(); void ResetNonPods(); - void StartCancel(); + void StartCancel() override; // Using fixed start_realtime_us (microseconds since the Epoch) gives // more accurate deadline. diff --git a/src/brpc/describable.h b/src/brpc/describable.h index 5dbb397a..07b55146 100644 --- a/src/brpc/describable.h +++ b/src/brpc/describable.h @@ -93,7 +93,7 @@ public: , _indent(indent, ' ') {} protected: - virtual int overflow(int ch) { + int overflow(int ch) override { if (_is_at_start_of_line && ch != '\n' ) { _dest->sputn(_indent.data(), _indent.size()); } diff --git a/src/brpc/details/method_status.h b/src/brpc/details/method_status.h index a00e71ff..8003a61f 100644 --- a/src/brpc/details/method_status.h +++ b/src/brpc/details/method_status.h @@ -51,7 +51,7 @@ public: int Expose(const butil::StringPiece& prefix); // Describe internal vars, used by /status - void Describe(std::ostream &os, const DescribeOptions&) const; + void Describe(std::ostream &os, const DescribeOptions&) const override; // Current max_concurrency of the method. int MaxConcurrency() const { return _cl ? _cl->MaxConcurrency() : 0; } diff --git a/src/brpc/policy/consul_naming_service.h b/src/brpc/policy/consul_naming_service.h index 798ac5bc..067a2668 100644 --- a/src/brpc/policy/consul_naming_service.h +++ b/src/brpc/policy/consul_naming_service.h @@ -28,19 +28,19 @@ namespace policy { class ConsulNamingService : public NamingService { private: int RunNamingService(const char* service_name, - NamingServiceActions* actions); + NamingServiceActions* actions) override; int GetServers(const char* service_name, std::vector* servers); - void Describe(std::ostream& os, const DescribeOptions&) const; + void Describe(std::ostream& os, const DescribeOptions&) const override; - NamingService* New() const; + NamingService* New() const override; int DegradeToOtherServiceIfNeeded(const char* service_name, std::vector* servers); - void Destroy(); + void Destroy() override; private: Channel _channel; diff --git a/src/brpc/policy/domain_naming_service.h b/src/brpc/policy/domain_naming_service.h index 45b3e919..99195f47 100644 --- a/src/brpc/policy/domain_naming_service.h +++ b/src/brpc/policy/domain_naming_service.h @@ -30,13 +30,13 @@ public: private: int GetServers(const char *service_name, - std::vector* servers); + std::vector* servers) override; - void Describe(std::ostream& os, const DescribeOptions&) const; + void Describe(std::ostream& os, const DescribeOptions&) const override; - NamingService* New() const; + NamingService* New() const override; - void Destroy(); + void Destroy() override; private: std::unique_ptr _aux_buf; diff --git a/src/brpc/policy/file_naming_service.h b/src/brpc/policy/file_naming_service.h index 20616b6b..2d2f4e1b 100644 --- a/src/brpc/policy/file_naming_service.h +++ b/src/brpc/policy/file_naming_service.h @@ -27,16 +27,16 @@ class FileNamingService : public NamingService { friend class ConsulNamingService; private: int RunNamingService(const char* service_name, - NamingServiceActions* actions); + NamingServiceActions* actions) override; int GetServers(const char *service_name, std::vector* servers); - void Describe(std::ostream& os, const DescribeOptions&) const; + void Describe(std::ostream& os, const DescribeOptions&) const override; - NamingService* New() const; + NamingService* New() const override; - void Destroy(); + void Destroy() override; }; } // namespace policy diff --git a/src/brpc/policy/list_naming_service.h b/src/brpc/policy/list_naming_service.h index a03ba080..d55196dc 100644 --- a/src/brpc/policy/list_naming_service.h +++ b/src/brpc/policy/list_naming_service.h @@ -26,19 +26,19 @@ namespace policy { class ListNamingService : public NamingService { private: int RunNamingService(const char* service_name, - NamingServiceActions* actions); + NamingServiceActions* actions) override; // We don't need a dedicated bthread to run this static NS. - bool RunNamingServiceReturnsQuickly() { return true; } + bool RunNamingServiceReturnsQuickly() override { return true; } int GetServers(const char *service_name, std::vector* servers); - void Describe(std::ostream& os, const DescribeOptions& options) const; + void Describe(std::ostream& os, const DescribeOptions& options) const override; - NamingService* New() const; + NamingService* New() const override; - void Destroy(); + void Destroy() override; }; } // namespace policy diff --git a/src/brpc/policy/remote_file_naming_service.h b/src/brpc/policy/remote_file_naming_service.h index 03bfdf1a..be391c5e 100644 --- a/src/brpc/policy/remote_file_naming_service.h +++ b/src/brpc/policy/remote_file_naming_service.h @@ -29,13 +29,13 @@ namespace policy { class RemoteFileNamingService : public PeriodicNamingService { private: int GetServers(const char* service_name, - std::vector* servers); + std::vector* servers) override; - void Describe(std::ostream& os, const DescribeOptions&) const; + void Describe(std::ostream& os, const DescribeOptions&) const override; - NamingService* New() const; + NamingService* New() const override; - void Destroy(); + void Destroy() override; private: std::unique_ptr _channel; diff --git a/src/brpc/rpc_dump.h b/src/brpc/rpc_dump.h index c7fd7d8f..e17213bd 100644 --- a/src/brpc/rpc_dump.h +++ b/src/brpc/rpc_dump.h @@ -51,9 +51,9 @@ struct SampledRequest : public bvar::Collected butil::IOBuf request; // Implement methods of Sampled. - void dump_and_destroy(size_t round); - void destroy(); - bvar::CollectorSpeedLimit* speed_limit() { + void dump_and_destroy(size_t round) override; + void destroy() override; + bvar::CollectorSpeedLimit* speed_limit() override { extern bvar::CollectorSpeedLimit g_rpc_dump_sl; return &g_rpc_dump_sl; } diff --git a/src/bthread/mutex.cpp b/src/bthread/mutex.cpp index 0de00b27..e8660ae5 100644 --- a/src/bthread/mutex.cpp +++ b/src/bthread/mutex.cpp @@ -65,9 +65,9 @@ struct SampledContention : public bvar::Collected { void* stack[26]; // backtrace. // Implement bvar::Collected - void dump_and_destroy(size_t round); - void destroy(); - bvar::CollectorSpeedLimit* speed_limit() { return &g_cp_sl; } + void dump_and_destroy(size_t round) override; + void destroy() override; + bvar::CollectorSpeedLimit* speed_limit() override { return &g_cp_sl; } // For combining samples with hashmap. size_t hash_code() const { diff --git a/src/bthread/task_group.h b/src/bthread/task_group.h index 2a068f41..201472d3 100644 --- a/src/bthread/task_group.h +++ b/src/bthread/task_group.h @@ -34,7 +34,7 @@ class ExitException : public std::exception { public: explicit ExitException(void* value) : _value(value) {} ~ExitException() throw() {} - const char* what() const throw() { + const char* what() const throw() override { return "ExitException"; } void* value() const { diff --git a/src/butil/iobuf.h b/src/butil/iobuf.h index 40f015ad..e376f7c3 100644 --- a/src/butil/iobuf.h +++ b/src/butil/iobuf.h @@ -588,14 +588,14 @@ public: virtual ~IOBufAsSnappySource() {} // Return the number of bytes left to read from the source - virtual size_t Available() const; + size_t Available() const override; // Peek at the next flat region of the source. - virtual const char* Peek(size_t* len); + const char* Peek(size_t* len) override; // Skip the next n bytes. Invalidates any buffer returned by // a previous call to Peek(). - virtual void Skip(size_t n); + void Skip(size_t n) override; private: const butil::IOBuf* _buf; @@ -609,10 +609,10 @@ public: virtual ~IOBufAsSnappySink() {} // Append "bytes[0,n-1]" to this. - virtual void Append(const char* bytes, size_t n); + void Append(const char* bytes, size_t n) override; // Returns a writable buffer of the specified length for appending. - virtual char* GetAppendBuffer(size_t length, char* scratch); + char* GetAppendBuffer(size_t length, char* scratch) override; private: char* _cur_buf; diff --git a/src/butil/logging.cc b/src/butil/logging.cc index b9e2b23d..8a9b2698 100644 --- a/src/butil/logging.cc +++ b/src/butil/logging.cc @@ -764,7 +764,7 @@ public: } bool OnLogMessage(int severity, const char* file, int line, - const butil::StringPiece& content) { + const butil::StringPiece& content) override { // There's a copy here to concatenate prefix and content. Since // DefaultLogSink is hardly used right now, the copy is irrelevant. // A LogSink focused on performance should also be able to handle diff --git a/src/butil/logging.h b/src/butil/logging.h index 998ee95f..4f8b71c1 100644 --- a/src/butil/logging.h +++ b/src/butil/logging.h @@ -321,7 +321,7 @@ BUTIL_EXPORT LogSink* SetLogSink(LogSink* sink); class StringSink : public LogSink, public std::string { public: bool OnLogMessage(int severity, const char* file, int line, - const butil::StringPiece& log_content); + const butil::StringPiece& log_content) override; private: butil::Lock _lock; }; @@ -857,8 +857,8 @@ public: explicit CharArrayStreamBuf() : _data(NULL), _size(0) {} ~CharArrayStreamBuf(); - virtual int overflow(int ch); - virtual int sync(); + int overflow(int ch) override; + int sync() override; void reset(); private: diff --git a/src/butil/third_party/snappy/snappy-sinksource.h b/src/butil/third_party/snappy/snappy-sinksource.h index be0e74aa..b34fb4cd 100644 --- a/src/butil/third_party/snappy/snappy-sinksource.h +++ b/src/butil/third_party/snappy/snappy-sinksource.h @@ -148,9 +148,9 @@ class ByteArraySource : public Source { public: ByteArraySource(const char* p, size_t n) : ptr_(p), left_(n) { } virtual ~ByteArraySource(); - virtual size_t Available() const; - virtual const char* Peek(size_t* len); - virtual void Skip(size_t n); + size_t Available() const override; + const char* Peek(size_t* len) override; + void Skip(size_t n) override; private: const char* ptr_; size_t left_; @@ -161,14 +161,14 @@ class UncheckedByteArraySink : public Sink { public: explicit UncheckedByteArraySink(char* dest) : dest_(dest) { } virtual ~UncheckedByteArraySink(); - virtual void Append(const char* data, size_t n); - virtual char* GetAppendBuffer(size_t len, char* scratch); - virtual char* GetAppendBufferVariable( + void Append(const char* data, size_t n) override; + char* GetAppendBuffer(size_t len, char* scratch) override; + char* GetAppendBufferVariable( size_t min_size, size_t desired_size_hint, char* scratch, - size_t scratch_size, size_t* allocated_size); - virtual void AppendAndTakeOwnership( + size_t scratch_size, size_t* allocated_size) override; + void AppendAndTakeOwnership( char* bytes, size_t n, void (*deleter)(void*, const char*, size_t), - void *deleter_arg); + void *deleter_arg) override; // Return the current output pointer so that a caller can see how // many bytes were produced. diff --git a/src/butil/zero_copy_stream_as_streambuf.h b/src/butil/zero_copy_stream_as_streambuf.h index c32f066d..581e3e8f 100644 --- a/src/butil/zero_copy_stream_as_streambuf.h +++ b/src/butil/zero_copy_stream_as_streambuf.h @@ -37,11 +37,11 @@ public: void shrink(); protected: - virtual int overflow(int ch); - virtual int sync(); + int overflow(int ch) override; + int sync() override; std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way, - std::ios_base::openmode which); + std::ios_base::openmode which) override; private: google::protobuf::io::ZeroCopyOutputStream* _zero_copy_stream; diff --git a/src/bvar/detail/sampler.h b/src/bvar/detail/sampler.h index eca55be4..4dd809db 100644 --- a/src/bvar/detail/sampler.h +++ b/src/bvar/detail/sampler.h @@ -97,7 +97,7 @@ public: } ~ReducerSampler() {} - void take_sample() { + void take_sample() override { // Make _q ready. // If _window_size is larger than what _q can hold, e.g. a larger // Window<> is created after running of sampler, make _q larger. diff --git a/src/bvar/gflag.h b/src/bvar/gflag.h index c699226b..bd2fb9d7 100644 --- a/src/bvar/gflag.h +++ b/src/bvar/gflag.h @@ -34,11 +34,10 @@ public: // Calling hide() in dtor manually is a MUST required by Variable. ~GFlag() { hide(); } - // Implement Variable::describe() and Variable::get_value(). - void describe(std::ostream& os, bool quote_string) const; + void describe(std::ostream& os, bool quote_string) const override; #ifdef BAIDU_INTERNAL - void get_value(boost::any* value) const; + void get_value(boost::any* value) const override; #endif // Get value of the gflag. diff --git a/src/bvar/latency_recorder.h b/src/bvar/latency_recorder.h index 75d21acc..09c40c48 100644 --- a/src/bvar/latency_recorder.h +++ b/src/bvar/latency_recorder.h @@ -37,8 +37,8 @@ class CDF : public Variable { public: explicit CDF(PercentileWindow* w); ~CDF(); - void describe(std::ostream& os, bool quote_string) const; - int describe_series(std::ostream& os, const SeriesOptions& options) const; + void describe(std::ostream& os, bool quote_string) const override; + int describe_series(std::ostream& os, const SeriesOptions& options) const override; private: PercentileWindow* _w; }; diff --git a/src/bvar/passive_status.h b/src/bvar/passive_status.h index 9f5a3beb..b37a7139 100644 --- a/src/bvar/passive_status.h +++ b/src/bvar/passive_status.h @@ -57,7 +57,7 @@ public: ~SeriesSampler() { delete _vector_names; } - void take_sample() { _series.append(_owner->get_value()); } + void take_sample() override { _series.append(_owner->get_value()); } void describe(std::ostream& os) { _series.describe(os, _vector_names); } void set_vector_names(const std::string& names) { if (_vector_names == NULL) { @@ -120,12 +120,12 @@ public: return -1; } - void describe(std::ostream& os, bool /*quote_string*/) const { + void describe(std::ostream& os, bool /*quote_string*/) const override { os << get_value(); } #ifdef BAIDU_INTERNAL - void get_value(boost::any* value) const { + void get_value(boost::any* value) const override { if (_getfn) { *value = _getfn(_arg); } else { @@ -217,7 +217,7 @@ public: hide(); } - void describe(std::ostream& os, bool quote_string) const { + void describe(std::ostream& os, bool quote_string) const override { if (quote_string) { if (_print) { os << '"'; diff --git a/src/bvar/recorder.h b/src/bvar/recorder.h index 6ef63c51..2c858a75 100644 --- a/src/bvar/recorder.h +++ b/src/bvar/recorder.h @@ -154,7 +154,7 @@ public: AddStat op() const { return AddStat(); } MinusStat inv_op() const { return MinusStat(); } - void describe(std::ostream& os, bool /*quote_string*/) const { + void describe(std::ostream& os, bool /*quote_string*/) const override { os << get_value(); } diff --git a/src/bvar/reducer.h b/src/bvar/reducer.h index cba83353..07562169 100644 --- a/src/bvar/reducer.h +++ b/src/bvar/reducer.h @@ -74,7 +74,7 @@ public: SeriesSampler(Reducer* owner, const Op& op) : _owner(owner), _series(op) {} ~SeriesSampler() {} - void take_sample() { _series.append(_owner->get_value()); } + void take_sample() override { _series.append(_owner->get_value()); } void describe(std::ostream& os) { _series.describe(os, NULL); } private: Reducer* _owner; @@ -125,8 +125,7 @@ public: // Returns the reduced value before reset. T reset() { return _combiner.reset_all_agents(); } - // Implement Variable::describe() and Variable::get_value(). - void describe(std::ostream& os, bool quote_string) const { + void describe(std::ostream& os, bool quote_string) const override { if (butil::is_same::value && quote_string) { os << '"' << get_value() << '"'; } else { @@ -135,7 +134,7 @@ public: } #ifdef BAIDU_INTERNAL - void get_value(boost::any* value) const { *value = get_value(); } + void get_value(boost::any* value) const override { *value = get_value(); } #endif // True if this reducer is constructed successfully. @@ -153,7 +152,7 @@ public: return _sampler; } - int describe_series(std::ostream& os, const SeriesOptions& options) const { + int describe_series(std::ostream& os, const SeriesOptions& options) const override { if (_series_sampler == NULL) { return 1; } @@ -166,7 +165,7 @@ public: protected: int expose_impl(const butil::StringPiece& prefix, const butil::StringPiece& name, - DisplayFilter display_filter) { + DisplayFilter display_filter) override { const int rc = Variable::expose_impl(prefix, name, display_filter); if (rc == 0 && _series_sampler == NULL && diff --git a/src/bvar/status.h b/src/bvar/status.h index 568fa878..64096b6d 100644 --- a/src/bvar/status.h +++ b/src/bvar/status.h @@ -52,13 +52,12 @@ public: // Calling hide() manually is a MUST required by Variable. ~Status() { hide(); } - // Implement Variable::describe() and Variable::get_value(). - void describe(std::ostream& os, bool /*quote_string*/) const { + void describe(std::ostream& os, bool /*quote_string*/) const override { os << get_value(); } #ifdef BAIDU_INTERNAL - void get_value(boost::any* value) const { + void get_value(boost::any* value) const override { butil::AutoLock guard(_lock); *value = _value; } @@ -122,13 +121,12 @@ public: } } - // Implement Variable::describe() and Variable::get_value(). - void describe(std::ostream& os, bool /*quote_string*/) const { + void describe(std::ostream& os, bool /*quote_string*/) const override { os << get_value(); } #ifdef BAIDU_INTERNAL - void get_value(boost::any* value) const { + void get_value(boost::any* value) const override { *value = get_value(); } #endif @@ -197,7 +195,7 @@ public: ~Status() { hide(); } - void describe(std::ostream& os, bool quote_string) const { + void describe(std::ostream& os, bool quote_string) const override { if (quote_string) { os << '"' << get_value() << '"'; } else { @@ -211,7 +209,7 @@ public: } #ifdef BAIDU_INTERNAL - void get_value(boost::any* value) const { + void get_value(boost::any* value) const override { *value = get_value(); } #endif diff --git a/src/bvar/variable.cpp b/src/bvar/variable.cpp index da53833c..deb62456 100644 --- a/src/bvar/variable.cpp +++ b/src/bvar/variable.cpp @@ -315,8 +315,8 @@ public: explicit CharArrayStreamBuf() : _data(NULL), _size(0) {} ~CharArrayStreamBuf(); - virtual int overflow(int ch); - virtual int sync(); + int overflow(int ch) override; + int sync() override; void reset(); butil::StringPiece data() { return butil::StringPiece(pbase(), pptr() - pbase()); @@ -586,7 +586,7 @@ public: _fp = NULL; } } - bool dump(const std::string& name, const butil::StringPiece& desc) { + bool dump(const std::string& name, const butil::StringPiece& desc) override { if (_fp == NULL) { butil::File::Error error; butil::FilePath dir = butil::FilePath(_filename).DirName(); @@ -647,7 +647,7 @@ public: dumpers.clear(); } - bool dump(const std::string& name, const butil::StringPiece& desc) { + bool dump(const std::string& name, const butil::StringPiece& desc) override { for (size_t i = 0; i < dumpers.size() - 1; ++i) { if (dumpers[i].second->match(name)) { return dumpers[i].first->dump(name, desc); diff --git a/src/bvar/window.h b/src/bvar/window.h index f67a8e93..bf3c001a 100644 --- a/src/bvar/window.h +++ b/src/bvar/window.h @@ -56,7 +56,7 @@ public: SeriesSampler(WindowBase* owner, R* var) : _owner(owner), _series(Op(var)) {} ~SeriesSampler() {} - void take_sample() { + void take_sample() override { if (series_freq == SERIES_IN_SECOND) { // Get one-second window value for PerSecond<>, otherwise the // "smoother" plot may hide peaks. @@ -108,8 +108,7 @@ public: value_type get_value() const { return get_value(_window_size); } - // Implement Variable::describe() and Variable::get_value(). - void describe(std::ostream& os, bool quote_string) const { + void describe(std::ostream& os, bool quote_string) const override { if (butil::is_same::value && quote_string) { os << '"' << get_value() << '"'; } else { @@ -118,7 +117,7 @@ public: } #ifdef BAIDU_INTERNAL - void get_value(boost::any* value) const { *value = get_value(); } + void get_value(boost::any* value) const override { *value = get_value(); } #endif time_t window_size() const { return _window_size; } @@ -219,7 +218,7 @@ public: this->expose_as(prefix, name); } - virtual value_type get_value(time_t window_size) const { + value_type get_value(time_t window_size) const override { detail::Sample s; this->get_span(window_size, &s); // We may test if the multiplication overflows and use integral ops diff --git a/src/mcpack2pb/generator.cpp b/src/mcpack2pb/generator.cpp index 2e6799d4..ce7fbfd3 100644 --- a/src/mcpack2pb/generator.cpp +++ b/src/mcpack2pb/generator.cpp @@ -1345,7 +1345,7 @@ public: bool Generate(const google::protobuf::FileDescriptor* file, const std::string& parameter, google::protobuf::compiler::GeneratorContext*, - std::string* error) const; + std::string* error) const override; }; bool McpackToProtobuf::Generate(const google::protobuf::FileDescriptor* file, From 4233593dae994742da821382413415091a0441d9 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 13 Jun 2019 16:33:16 +0800 Subject: [PATCH 225/270] remove nspr --- BUILD | 1 - CMakeLists.txt | 1 - Makefile | 1 - src/butil/third_party/nspr/LICENSE | 35 - src/butil/third_party/nspr/README.chromium | 3 - src/butil/third_party/nspr/prtime.cc | 1254 -------------------- src/butil/third_party/nspr/prtime.h | 252 ---- src/butil/time/time.cc | 28 +- test/BUILD | 1 - test/CMakeLists.txt | 1 - test/Makefile | 1 - test/file_util_unittest.cc | 14 +- test/pr_time_unittest.cc | 298 ----- test/time_unittest.cc | 393 +++--- 14 files changed, 219 insertions(+), 2064 deletions(-) delete mode 100644 src/butil/third_party/nspr/LICENSE delete mode 100644 src/butil/third_party/nspr/README.chromium delete mode 100644 src/butil/third_party/nspr/prtime.cc delete mode 100644 src/butil/third_party/nspr/prtime.h delete mode 100644 test/pr_time_unittest.cc diff --git a/BUILD b/BUILD index 07d8d6bc..d453452b 100644 --- a/BUILD +++ b/BUILD @@ -111,7 +111,6 @@ BUTIL_SRCS = [ "src/butil/third_party/icu/icu_utf.cc", "src/butil/third_party/superfasthash/superfasthash.c", "src/butil/third_party/modp_b64/modp_b64.cc", - "src/butil/third_party/nspr/prtime.cc", "src/butil/third_party/symbolize/demangle.cc", "src/butil/third_party/symbolize/symbolize.cc", "src/butil/third_party/snappy/snappy-sinksource.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index b8382a82..7ba06491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -207,7 +207,6 @@ set(BUTIL_SOURCES ${PROJECT_SOURCE_DIR}/src/butil/third_party/icu/icu_utf.cc ${PROJECT_SOURCE_DIR}/src/butil/third_party/superfasthash/superfasthash.c ${PROJECT_SOURCE_DIR}/src/butil/third_party/modp_b64/modp_b64.cc - ${PROJECT_SOURCE_DIR}/src/butil/third_party/nspr/prtime.cc ${PROJECT_SOURCE_DIR}/src/butil/third_party/symbolize/demangle.cc ${PROJECT_SOURCE_DIR}/src/butil/third_party/symbolize/symbolize.cc ${PROJECT_SOURCE_DIR}/src/butil/third_party/snappy/snappy-sinksource.cc diff --git a/Makefile b/Makefile index a31f47a8..4c3dd808 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,6 @@ BUTIL_SOURCES = \ src/butil/third_party/icu/icu_utf.cc \ src/butil/third_party/superfasthash/superfasthash.c \ src/butil/third_party/modp_b64/modp_b64.cc \ - src/butil/third_party/nspr/prtime.cc \ src/butil/third_party/symbolize/demangle.cc \ src/butil/third_party/symbolize/symbolize.cc \ src/butil/third_party/snappy/snappy-sinksource.cc \ diff --git a/src/butil/third_party/nspr/LICENSE b/src/butil/third_party/nspr/LICENSE deleted file mode 100644 index eba7b77e..00000000 --- a/src/butil/third_party/nspr/LICENSE +++ /dev/null @@ -1,35 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ diff --git a/src/butil/third_party/nspr/README.chromium b/src/butil/third_party/nspr/README.chromium deleted file mode 100644 index 3659a2c4..00000000 --- a/src/butil/third_party/nspr/README.chromium +++ /dev/null @@ -1,3 +0,0 @@ -Name: Netscape Portable Runtime (NSPR) -URL: http://www.mozilla.org/projects/nspr/ -License: MPL 1.1/GPL 2.0/LGPL 2.1 diff --git a/src/butil/third_party/nspr/prtime.cc b/src/butil/third_party/nspr/prtime.cc deleted file mode 100644 index 87d97c4b..00000000 --- a/src/butil/third_party/nspr/prtime.cc +++ /dev/null @@ -1,1254 +0,0 @@ -/* Portions are Copyright (C) 2011 Google Inc */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * prtime.cc -- - * NOTE: The original nspr file name is prtime.c - * - * NSPR date and time functions - * - * CVS revision 3.37 - */ - -/* - * The following functions were copied from the NSPR prtime.c file. - * PR_ParseTimeString - * We inlined the new PR_ParseTimeStringToExplodedTime function to avoid - * copying PR_ExplodeTime and PR_LocalTimeParameters. (The PR_ExplodeTime - * and PR_ImplodeTime calls cancel each other out.) - * PR_NormalizeTime - * PR_GMTParameters - * PR_ImplodeTime - * This was modified to use the Win32 SYSTEMTIME/FILETIME structures - * and the timezone offsets are applied to the FILETIME structure. - * All types and macros are defined in the butil/third_party/prtime.h file. - * These have been copied from the following nspr files. We have only copied - * over the types we need. - * 1. prtime.h - * 2. prtypes.h - * 3. prlong.h - * - * Unit tests are in butil/time/pr_time_unittest.cc. - */ - -#include "butil/logging.h" -#include "butil/third_party/nspr/prtime.h" -#include "butil/build_config.h" - -#if defined(OS_WIN) -#include -#elif defined(OS_MACOSX) -#include -#elif defined(OS_ANDROID) -#include -#include "butil/os_compat_android.h" // For timegm() -#elif defined(OS_NACL) -#include "butil/os_compat_nacl.h" // For timegm() -#endif -#include /* for EINVAL */ -#include -#include /* INT_MAX */ - -/* Implements the Unix localtime_r() function for windows */ -#if defined(OS_WIN) -static void localtime_r(const time_t* secs, struct tm* time) { - (void) localtime_s(time, secs); -} -#endif - -/* - *------------------------------------------------------------------------ - * - * PR_ImplodeTime -- - * - * Cf. time_t mktime(struct tm *tp) - * Note that 1 year has < 2^25 seconds. So an PRInt32 is large enough. - * - *------------------------------------------------------------------------ - */ -PRTime -PR_ImplodeTime(const PRExplodedTime *exploded) -{ - // This is important, we want to make sure multiplications are - // done with the correct precision. - static const PRTime kSecondsToMicroseconds = static_cast(1000000); -#if defined(OS_WIN) - // Create the system struct representing our exploded time. - SYSTEMTIME st = {0}; - FILETIME ft = {0}; - ULARGE_INTEGER uli = {0}; - - st.wYear = exploded->tm_year; - st.wMonth = exploded->tm_month + 1; - st.wDayOfWeek = exploded->tm_wday; - st.wDay = exploded->tm_mday; - st.wHour = exploded->tm_hour; - st.wMinute = exploded->tm_min; - st.wSecond = exploded->tm_sec; - st.wMilliseconds = exploded->tm_usec/1000; - // Convert to FILETIME. - if (!SystemTimeToFileTime(&st, &ft)) { - NOTREACHED() << "Unable to convert time"; - return 0; - } - // Apply offsets. - uli.LowPart = ft.dwLowDateTime; - uli.HighPart = ft.dwHighDateTime; - // Convert from Windows epoch to NSPR epoch, and 100-nanoseconds units - // to microsecond units. - PRTime result = - static_cast((uli.QuadPart / 10) - 11644473600000000i64); - // Adjust for time zone and dst. Convert from seconds to microseconds. - result -= (exploded->tm_params.tp_gmt_offset + - exploded->tm_params.tp_dst_offset) * kSecondsToMicroseconds; - // Add microseconds that cannot be represented in |st|. - result += exploded->tm_usec % 1000; - return result; -#elif defined(OS_MACOSX) - // Create the system struct representing our exploded time. - CFGregorianDate gregorian_date; - gregorian_date.year = exploded->tm_year; - gregorian_date.month = exploded->tm_month + 1; - gregorian_date.day = exploded->tm_mday; - gregorian_date.hour = exploded->tm_hour; - gregorian_date.minute = exploded->tm_min; - gregorian_date.second = exploded->tm_sec; - - // Compute |absolute_time| in seconds, correct for gmt and dst - // (note the combined offset will be negative when we need to add it), then - // convert to microseconds which is what PRTime expects. - CFAbsoluteTime absolute_time = - CFGregorianDateGetAbsoluteTime(gregorian_date, NULL); - PRTime result = static_cast(absolute_time); - result -= exploded->tm_params.tp_gmt_offset + - exploded->tm_params.tp_dst_offset; - result += kCFAbsoluteTimeIntervalSince1970; // PRTime epoch is 1970 - result *= kSecondsToMicroseconds; - result += exploded->tm_usec; - return result; -#elif defined(OS_POSIX) - struct tm exp_tm; - memset(&exp_tm, 0, sizeof(exp_tm)); - exp_tm.tm_sec = exploded->tm_sec; - exp_tm.tm_min = exploded->tm_min; - exp_tm.tm_hour = exploded->tm_hour; - exp_tm.tm_mday = exploded->tm_mday; - exp_tm.tm_mon = exploded->tm_month; - exp_tm.tm_year = exploded->tm_year - 1900; - - time_t absolute_time = timegm(&exp_tm); - - // If timegm returned -1. Since we don't pass it a time zone, the only - // valid case of returning -1 is 1 second before Epoch (Dec 31, 1969). - if (absolute_time == -1 && - !(exploded->tm_year == 1969 && exploded->tm_month == 11 && - exploded->tm_mday == 31 && exploded->tm_hour == 23 && - exploded->tm_min == 59 && exploded->tm_sec == 59)) { - // If we get here, time_t must be 32 bits. - // Date was possibly too far in the future and would overflow. Return - // the most future date possible (year 2038). - if (exploded->tm_year >= 1970) - return INT_MAX * kSecondsToMicroseconds; - // Date was possibly too far in the past and would underflow. Return - // the most past date possible (year 1901). - return INT_MIN * kSecondsToMicroseconds; - } - - PRTime result = static_cast(absolute_time); - result -= exploded->tm_params.tp_gmt_offset + - exploded->tm_params.tp_dst_offset; - result *= kSecondsToMicroseconds; - result += exploded->tm_usec; - return result; -#else -#error No PR_ImplodeTime implemented on your platform. -#endif -} - -/* - * The COUNT_LEAPS macro counts the number of leap years passed by - * till the start of the given year Y. At the start of the year 4 - * A.D. the number of leap years passed by is 0, while at the start of - * the year 5 A.D. this count is 1. The number of years divisible by - * 100 but not divisible by 400 (the non-leap years) is deducted from - * the count to get the correct number of leap years. - * - * The COUNT_DAYS macro counts the number of days since 01/01/01 till the - * start of the given year Y. The number of days at the start of the year - * 1 is 0 while the number of days at the start of the year 2 is 365 - * (which is ((2)-1) * 365) and so on. The reference point is 01/01/01 - * midnight 00:00:00. - */ - -#define COUNT_LEAPS(Y) ( ((Y)-1)/4 - ((Y)-1)/100 + ((Y)-1)/400 ) -#define COUNT_DAYS(Y) ( ((Y)-1)*365 + COUNT_LEAPS(Y) ) -#define DAYS_BETWEEN_YEARS(A, B) (COUNT_DAYS(B) - COUNT_DAYS(A)) - -/* - * Static variables used by functions in this file - */ - -/* - * The following array contains the day of year for the last day of - * each month, where index 1 is January, and day 0 is January 1. - */ - -static const int lastDayOfMonth[2][13] = { - {-1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364}, - {-1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365} -}; - -/* - * The number of days in a month - */ - -static const PRInt8 nDays[2][12] = { - {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} -}; - -/* - *------------------------------------------------------------------------- - * - * IsLeapYear -- - * - * Returns 1 if the year is a leap year, 0 otherwise. - * - *------------------------------------------------------------------------- - */ - -static int IsLeapYear(PRInt16 year) -{ - if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) - return 1; - else - return 0; -} - -/* - * 'secOffset' should be less than 86400 (i.e., a day). - * 'time' should point to a normalized PRExplodedTime. - */ - -static void -ApplySecOffset(PRExplodedTime *time, PRInt32 secOffset) -{ - time->tm_sec += secOffset; - - /* Note that in this implementation we do not count leap seconds */ - if (time->tm_sec < 0 || time->tm_sec >= 60) { - time->tm_min += time->tm_sec / 60; - time->tm_sec %= 60; - if (time->tm_sec < 0) { - time->tm_sec += 60; - time->tm_min--; - } - } - - if (time->tm_min < 0 || time->tm_min >= 60) { - time->tm_hour += time->tm_min / 60; - time->tm_min %= 60; - if (time->tm_min < 0) { - time->tm_min += 60; - time->tm_hour--; - } - } - - if (time->tm_hour < 0) { - /* Decrement mday, yday, and wday */ - time->tm_hour += 24; - time->tm_mday--; - time->tm_yday--; - if (time->tm_mday < 1) { - time->tm_month--; - if (time->tm_month < 0) { - time->tm_month = 11; - time->tm_year--; - if (IsLeapYear(time->tm_year)) - time->tm_yday = 365; - else - time->tm_yday = 364; - } - time->tm_mday = nDays[IsLeapYear(time->tm_year)][time->tm_month]; - } - time->tm_wday--; - if (time->tm_wday < 0) - time->tm_wday = 6; - } else if (time->tm_hour > 23) { - /* Increment mday, yday, and wday */ - time->tm_hour -= 24; - time->tm_mday++; - time->tm_yday++; - if (time->tm_mday > - nDays[IsLeapYear(time->tm_year)][time->tm_month]) { - time->tm_mday = 1; - time->tm_month++; - if (time->tm_month > 11) { - time->tm_month = 0; - time->tm_year++; - time->tm_yday = 0; - } - } - time->tm_wday++; - if (time->tm_wday > 6) - time->tm_wday = 0; - } -} - -void -PR_NormalizeTime(PRExplodedTime *time, PRTimeParamFn params) -{ - int daysInMonth; - PRInt32 numDays; - - /* Get back to GMT */ - time->tm_sec -= time->tm_params.tp_gmt_offset - + time->tm_params.tp_dst_offset; - time->tm_params.tp_gmt_offset = 0; - time->tm_params.tp_dst_offset = 0; - - /* Now normalize GMT */ - - if (time->tm_usec < 0 || time->tm_usec >= 1000000) { - time->tm_sec += time->tm_usec / 1000000; - time->tm_usec %= 1000000; - if (time->tm_usec < 0) { - time->tm_usec += 1000000; - time->tm_sec--; - } - } - - /* Note that we do not count leap seconds in this implementation */ - if (time->tm_sec < 0 || time->tm_sec >= 60) { - time->tm_min += time->tm_sec / 60; - time->tm_sec %= 60; - if (time->tm_sec < 0) { - time->tm_sec += 60; - time->tm_min--; - } - } - - if (time->tm_min < 0 || time->tm_min >= 60) { - time->tm_hour += time->tm_min / 60; - time->tm_min %= 60; - if (time->tm_min < 0) { - time->tm_min += 60; - time->tm_hour--; - } - } - - if (time->tm_hour < 0 || time->tm_hour >= 24) { - time->tm_mday += time->tm_hour / 24; - time->tm_hour %= 24; - if (time->tm_hour < 0) { - time->tm_hour += 24; - time->tm_mday--; - } - } - - /* Normalize month and year before mday */ - if (time->tm_month < 0 || time->tm_month >= 12) { - time->tm_year += time->tm_month / 12; - time->tm_month %= 12; - if (time->tm_month < 0) { - time->tm_month += 12; - time->tm_year--; - } - } - - /* Now that month and year are in proper range, normalize mday */ - - if (time->tm_mday < 1) { - /* mday too small */ - do { - /* the previous month */ - time->tm_month--; - if (time->tm_month < 0) { - time->tm_month = 11; - time->tm_year--; - } - time->tm_mday += nDays[IsLeapYear(time->tm_year)][time->tm_month]; - } while (time->tm_mday < 1); - } else { - daysInMonth = nDays[IsLeapYear(time->tm_year)][time->tm_month]; - while (time->tm_mday > daysInMonth) { - /* mday too large */ - time->tm_mday -= daysInMonth; - time->tm_month++; - if (time->tm_month > 11) { - time->tm_month = 0; - time->tm_year++; - } - daysInMonth = nDays[IsLeapYear(time->tm_year)][time->tm_month]; - } - } - - /* Recompute yday and wday */ - time->tm_yday = time->tm_mday + - lastDayOfMonth[IsLeapYear(time->tm_year)][time->tm_month]; - - numDays = DAYS_BETWEEN_YEARS(1970, time->tm_year) + time->tm_yday; - time->tm_wday = (numDays + 4) % 7; - if (time->tm_wday < 0) { - time->tm_wday += 7; - } - - /* Recompute time parameters */ - - time->tm_params = params(time); - - ApplySecOffset(time, time->tm_params.tp_gmt_offset - + time->tm_params.tp_dst_offset); -} - -/* - *------------------------------------------------------------------------ - * - * PR_GMTParameters -- - * - * Returns the PRTimeParameters for Greenwich Mean Time. - * Trivially, both the tp_gmt_offset and tp_dst_offset fields are 0. - * - *------------------------------------------------------------------------ - */ - -PRTimeParameters -PR_GMTParameters(const PRExplodedTime *gmt) -{ - PRTimeParameters retVal = { 0, 0 }; - return retVal; -} - -/* - * The following code implements PR_ParseTimeString(). It is based on - * ns/lib/xp/xp_time.c, revision 1.25, by Jamie Zawinski . - */ - -/* - * We only recognize the abbreviations of a small subset of time zones - * in North America, Europe, and Japan. - * - * PST/PDT: Pacific Standard/Daylight Time - * MST/MDT: Mountain Standard/Daylight Time - * CST/CDT: Central Standard/Daylight Time - * EST/EDT: Eastern Standard/Daylight Time - * AST: Atlantic Standard Time - * NST: Newfoundland Standard Time - * GMT: Greenwich Mean Time - * BST: British Summer Time - * MET: Middle Europe Time - * EET: Eastern Europe Time - * JST: Japan Standard Time - */ - -typedef enum -{ - TT_UNKNOWN, - - TT_SUN, TT_MON, TT_TUE, TT_WED, TT_THU, TT_FRI, TT_SAT, - - TT_JAN, TT_FEB, TT_MAR, TT_APR, TT_MAY, TT_JUN, - TT_JUL, TT_AUG, TT_SEP, TT_OCT, TT_NOV, TT_DEC, - - TT_PST, TT_PDT, TT_MST, TT_MDT, TT_CST, TT_CDT, TT_EST, TT_EDT, - TT_AST, TT_NST, TT_GMT, TT_BST, TT_MET, TT_EET, TT_JST -} TIME_TOKEN; - -/* - * This parses a time/date string into a PRTime - * (microseconds after "1-Jan-1970 00:00:00 GMT"). - * It returns PR_SUCCESS on success, and PR_FAILURE - * if the time/date string can't be parsed. - * - * Many formats are handled, including: - * - * 14 Apr 89 03:20:12 - * 14 Apr 89 03:20 GMT - * Fri, 17 Mar 89 4:01:33 - * Fri, 17 Mar 89 4:01 GMT - * Mon Jan 16 16:12 PDT 1989 - * Mon Jan 16 16:12 +0130 1989 - * 6 May 1992 16:41-JST (Wednesday) - * 22-AUG-1993 10:59:12.82 - * 22-AUG-1993 10:59pm - * 22-AUG-1993 12:59am - * 22-AUG-1993 12:59 PM - * Friday, August 04, 1995 3:54 PM - * 06/21/95 04:24:34 PM - * 20/06/95 21:07 - * 95-06-08 19:32:48 EDT - * 1995-06-17T23:11:25.342156Z - * - * If the input string doesn't contain a description of the timezone, - * we consult the `default_to_gmt' to decide whether the string should - * be interpreted relative to the local time zone (PR_FALSE) or GMT (PR_TRUE). - * The correct value for this argument depends on what standard specified - * the time string which you are parsing. - */ - -PRStatus -PR_ParseTimeString( - const char *string, - PRBool default_to_gmt, - PRTime *result_imploded) -{ - PRExplodedTime tm; - PRExplodedTime *result = &tm; - TIME_TOKEN dotw = TT_UNKNOWN; - TIME_TOKEN month = TT_UNKNOWN; - TIME_TOKEN zone = TT_UNKNOWN; - int zone_offset = -1; - int dst_offset = 0; - int date = -1; - PRInt32 year = -1; - int hour = -1; - int min = -1; - int sec = -1; - int usec = -1; - - const char *rest = string; - - int iterations = 0; - - PR_ASSERT(string && result); - if (!string || !result) return PR_FAILURE; - - while (*rest) - { - - if (iterations++ > 1000) - { - return PR_FAILURE; - } - - switch (*rest) - { - case 'a': case 'A': - if (month == TT_UNKNOWN && - (rest[1] == 'p' || rest[1] == 'P') && - (rest[2] == 'r' || rest[2] == 'R')) - month = TT_APR; - else if (zone == TT_UNKNOWN && - (rest[1] == 's' || rest[1] == 'S') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_AST; - else if (month == TT_UNKNOWN && - (rest[1] == 'u' || rest[1] == 'U') && - (rest[2] == 'g' || rest[2] == 'G')) - month = TT_AUG; - break; - case 'b': case 'B': - if (zone == TT_UNKNOWN && - (rest[1] == 's' || rest[1] == 'S') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_BST; - break; - case 'c': case 'C': - if (zone == TT_UNKNOWN && - (rest[1] == 'd' || rest[1] == 'D') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_CDT; - else if (zone == TT_UNKNOWN && - (rest[1] == 's' || rest[1] == 'S') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_CST; - break; - case 'd': case 'D': - if (month == TT_UNKNOWN && - (rest[1] == 'e' || rest[1] == 'E') && - (rest[2] == 'c' || rest[2] == 'C')) - month = TT_DEC; - break; - case 'e': case 'E': - if (zone == TT_UNKNOWN && - (rest[1] == 'd' || rest[1] == 'D') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_EDT; - else if (zone == TT_UNKNOWN && - (rest[1] == 'e' || rest[1] == 'E') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_EET; - else if (zone == TT_UNKNOWN && - (rest[1] == 's' || rest[1] == 'S') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_EST; - break; - case 'f': case 'F': - if (month == TT_UNKNOWN && - (rest[1] == 'e' || rest[1] == 'E') && - (rest[2] == 'b' || rest[2] == 'B')) - month = TT_FEB; - else if (dotw == TT_UNKNOWN && - (rest[1] == 'r' || rest[1] == 'R') && - (rest[2] == 'i' || rest[2] == 'I')) - dotw = TT_FRI; - break; - case 'g': case 'G': - if (zone == TT_UNKNOWN && - (rest[1] == 'm' || rest[1] == 'M') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_GMT; - break; - case 'j': case 'J': - if (month == TT_UNKNOWN && - (rest[1] == 'a' || rest[1] == 'A') && - (rest[2] == 'n' || rest[2] == 'N')) - month = TT_JAN; - else if (zone == TT_UNKNOWN && - (rest[1] == 's' || rest[1] == 'S') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_JST; - else if (month == TT_UNKNOWN && - (rest[1] == 'u' || rest[1] == 'U') && - (rest[2] == 'l' || rest[2] == 'L')) - month = TT_JUL; - else if (month == TT_UNKNOWN && - (rest[1] == 'u' || rest[1] == 'U') && - (rest[2] == 'n' || rest[2] == 'N')) - month = TT_JUN; - break; - case 'm': case 'M': - if (month == TT_UNKNOWN && - (rest[1] == 'a' || rest[1] == 'A') && - (rest[2] == 'r' || rest[2] == 'R')) - month = TT_MAR; - else if (month == TT_UNKNOWN && - (rest[1] == 'a' || rest[1] == 'A') && - (rest[2] == 'y' || rest[2] == 'Y')) - month = TT_MAY; - else if (zone == TT_UNKNOWN && - (rest[1] == 'd' || rest[1] == 'D') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_MDT; - else if (zone == TT_UNKNOWN && - (rest[1] == 'e' || rest[1] == 'E') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_MET; - else if (dotw == TT_UNKNOWN && - (rest[1] == 'o' || rest[1] == 'O') && - (rest[2] == 'n' || rest[2] == 'N')) - dotw = TT_MON; - else if (zone == TT_UNKNOWN && - (rest[1] == 's' || rest[1] == 'S') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_MST; - break; - case 'n': case 'N': - if (month == TT_UNKNOWN && - (rest[1] == 'o' || rest[1] == 'O') && - (rest[2] == 'v' || rest[2] == 'V')) - month = TT_NOV; - else if (zone == TT_UNKNOWN && - (rest[1] == 's' || rest[1] == 'S') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_NST; - break; - case 'o': case 'O': - if (month == TT_UNKNOWN && - (rest[1] == 'c' || rest[1] == 'C') && - (rest[2] == 't' || rest[2] == 'T')) - month = TT_OCT; - break; - case 'p': case 'P': - if (zone == TT_UNKNOWN && - (rest[1] == 'd' || rest[1] == 'D') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_PDT; - else if (zone == TT_UNKNOWN && - (rest[1] == 's' || rest[1] == 'S') && - (rest[2] == 't' || rest[2] == 'T')) - zone = TT_PST; - break; - case 's': case 'S': - if (dotw == TT_UNKNOWN && - (rest[1] == 'a' || rest[1] == 'A') && - (rest[2] == 't' || rest[2] == 'T')) - dotw = TT_SAT; - else if (month == TT_UNKNOWN && - (rest[1] == 'e' || rest[1] == 'E') && - (rest[2] == 'p' || rest[2] == 'P')) - month = TT_SEP; - else if (dotw == TT_UNKNOWN && - (rest[1] == 'u' || rest[1] == 'U') && - (rest[2] == 'n' || rest[2] == 'N')) - dotw = TT_SUN; - break; - case 't': case 'T': - if (dotw == TT_UNKNOWN && - (rest[1] == 'h' || rest[1] == 'H') && - (rest[2] == 'u' || rest[2] == 'U')) - dotw = TT_THU; - else if (dotw == TT_UNKNOWN && - (rest[1] == 'u' || rest[1] == 'U') && - (rest[2] == 'e' || rest[2] == 'E')) - dotw = TT_TUE; - break; - case 'u': case 'U': - if (zone == TT_UNKNOWN && - (rest[1] == 't' || rest[1] == 'T') && - !(rest[2] >= 'A' && rest[2] <= 'Z') && - !(rest[2] >= 'a' && rest[2] <= 'z')) - /* UT is the same as GMT but UTx is not. */ - zone = TT_GMT; - break; - case 'w': case 'W': - if (dotw == TT_UNKNOWN && - (rest[1] == 'e' || rest[1] == 'E') && - (rest[2] == 'd' || rest[2] == 'D')) - dotw = TT_WED; - break; - - case '+': case '-': - { - const char *end; - int sign; - if (zone_offset != -1) - { - /* already got one... */ - rest++; - break; - } - if (zone != TT_UNKNOWN && zone != TT_GMT) - { - /* GMT+0300 is legal, but PST+0300 is not. */ - rest++; - break; - } - - sign = ((*rest == '+') ? 1 : -1); - rest++; /* move over sign */ - end = rest; - while (*end >= '0' && *end <= '9') - end++; - if (rest == end) /* no digits here */ - break; - - if ((end - rest) == 4) - /* offset in HHMM */ - zone_offset = (((((rest[0]-'0')*10) + (rest[1]-'0')) * 60) + - (((rest[2]-'0')*10) + (rest[3]-'0'))); - else if ((end - rest) == 2) - /* offset in hours */ - zone_offset = (((rest[0]-'0')*10) + (rest[1]-'0')) * 60; - else if ((end - rest) == 1) - /* offset in hours */ - zone_offset = (rest[0]-'0') * 60; - else - /* 3 or >4 */ - break; - - zone_offset *= sign; - zone = TT_GMT; - break; - } - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - { - int tmp_hour = -1; - int tmp_min = -1; - int tmp_sec = -1; - int tmp_usec = -1; - const char *end = rest + 1; - while (*end >= '0' && *end <= '9') - end++; - - /* end is now the first character after a range of digits. */ - - if (*end == ':') - { - if (hour >= 0 && min >= 0) /* already got it */ - break; - - /* We have seen "[0-9]+:", so this is probably HH:MM[:SS] */ - if ((end - rest) > 2) - /* it is [0-9][0-9][0-9]+: */ - break; - else if ((end - rest) == 2) - tmp_hour = ((rest[0]-'0')*10 + - (rest[1]-'0')); - else - tmp_hour = (rest[0]-'0'); - - /* move over the colon, and parse minutes */ - - rest = ++end; - while (*end >= '0' && *end <= '9') - end++; - - if (end == rest) - /* no digits after first colon? */ - break; - else if ((end - rest) > 2) - /* it is [0-9][0-9][0-9]+: */ - break; - else if ((end - rest) == 2) - tmp_min = ((rest[0]-'0')*10 + - (rest[1]-'0')); - else - tmp_min = (rest[0]-'0'); - - /* now go for seconds */ - rest = end; - if (*rest == ':') - rest++; - end = rest; - while (*end >= '0' && *end <= '9') - end++; - - if (end == rest) - /* no digits after second colon - that's ok. */ - ; - else if ((end - rest) > 2) - /* it is [0-9][0-9][0-9]+: */ - break; - else if ((end - rest) == 2) - tmp_sec = ((rest[0]-'0')*10 + - (rest[1]-'0')); - else - tmp_sec = (rest[0]-'0'); - - /* fractional second */ - rest = end; - if (*rest == '.') - { - rest++; - end++; - tmp_usec = 0; - /* use up to 6 digits, skip over the rest */ - while (*end >= '0' && *end <= '9') - { - if (end - rest < 6) - tmp_usec = tmp_usec * 10 + *end - '0'; - end++; - } - int ndigits = end - rest; - while (ndigits++ < 6) - tmp_usec *= 10; - rest = end; - } - - if (*rest == 'Z') - { - zone = TT_GMT; - rest++; - } - else if (tmp_hour <= 12) - { - /* If we made it here, we've parsed hour and min, - and possibly sec, so the current token is a time. - Now skip over whitespace and see if there's an AM - or PM directly following the time. - */ - const char *s = end; - while (*s && (*s == ' ' || *s == '\t')) - s++; - if ((s[0] == 'p' || s[0] == 'P') && - (s[1] == 'm' || s[1] == 'M')) - /* 10:05pm == 22:05, and 12:05pm == 12:05 */ - tmp_hour = (tmp_hour == 12 ? 12 : tmp_hour + 12); - else if (tmp_hour == 12 && - (s[0] == 'a' || s[0] == 'A') && - (s[1] == 'm' || s[1] == 'M')) - /* 12:05am == 00:05 */ - tmp_hour = 0; - } - - hour = tmp_hour; - min = tmp_min; - sec = tmp_sec; - usec = tmp_usec; - rest = end; - break; - } - else if ((*end == '/' || *end == '-') && - end[1] >= '0' && end[1] <= '9') - { - /* Perhaps this is 6/16/95, 16/6/95, 6-16-95, or 16-6-95 - or even 95-06-05 or 1995-06-22. - */ - int n1, n2, n3; - const char *s; - - if (month != TT_UNKNOWN) - /* if we saw a month name, this can't be. */ - break; - - s = rest; - - n1 = (*s++ - '0'); /* first 1, 2 or 4 digits */ - if (*s >= '0' && *s <= '9') - { - n1 = n1*10 + (*s++ - '0'); - - if (*s >= '0' && *s <= '9') /* optional digits 3 and 4 */ - { - n1 = n1*10 + (*s++ - '0'); - if (*s < '0' || *s > '9') - break; - n1 = n1*10 + (*s++ - '0'); - } - } - - if (*s != '/' && *s != '-') /* slash */ - break; - s++; - - if (*s < '0' || *s > '9') /* second 1 or 2 digits */ - break; - n2 = (*s++ - '0'); - if (*s >= '0' && *s <= '9') - n2 = n2*10 + (*s++ - '0'); - - if (*s != '/' && *s != '-') /* slash */ - break; - s++; - - if (*s < '0' || *s > '9') /* third 1, 2, 4, or 5 digits */ - break; - n3 = (*s++ - '0'); - if (*s >= '0' && *s <= '9') - n3 = n3*10 + (*s++ - '0'); - - if (*s >= '0' && *s <= '9') /* optional digits 3, 4, and 5 */ - { - n3 = n3*10 + (*s++ - '0'); - if (*s < '0' || *s > '9') - break; - n3 = n3*10 + (*s++ - '0'); - if (*s >= '0' && *s <= '9') - n3 = n3*10 + (*s++ - '0'); - } - - if (*s == 'T' && s[1] >= '0' && s[1] <= '9') - /* followed by ISO 8601 T delimiter and number is ok */ - ; - else if ((*s >= '0' && *s <= '9') || - (*s >= 'A' && *s <= 'Z') || - (*s >= 'a' && *s <= 'z')) - /* but other alphanumerics are not ok */ - break; - - /* Ok, we parsed three multi-digit numbers, with / or - - between them. Now decide what the hell they are - (DD/MM/YY or MM/DD/YY or [YY]YY/MM/DD.) - */ - - if (n1 > 31 || n1 == 0) /* must be [YY]YY/MM/DD */ - { - if (n2 > 12) break; - if (n3 > 31) break; - year = n1; - if (year < 70) - year += 2000; - else if (year < 100) - year += 1900; - month = (TIME_TOKEN)(n2 + ((int)TT_JAN) - 1); - date = n3; - rest = s; - break; - } - - if (n1 > 12 && n2 > 12) /* illegal */ - { - rest = s; - break; - } - - if (n3 < 70) - n3 += 2000; - else if (n3 < 100) - n3 += 1900; - - if (n1 > 12) /* must be DD/MM/YY */ - { - date = n1; - month = (TIME_TOKEN)(n2 + ((int)TT_JAN) - 1); - year = n3; - } - else /* assume MM/DD/YY */ - { - /* #### In the ambiguous case, should we consult the - locale to find out the local default? */ - month = (TIME_TOKEN)(n1 + ((int)TT_JAN) - 1); - date = n2; - year = n3; - } - rest = s; - } - else if ((*end >= 'A' && *end <= 'Z') || - (*end >= 'a' && *end <= 'z')) - /* Digits followed by non-punctuation - what's that? */ - ; - else if ((end - rest) == 5) /* five digits is a year */ - year = (year < 0 - ? ((rest[0]-'0')*10000L + - (rest[1]-'0')*1000L + - (rest[2]-'0')*100L + - (rest[3]-'0')*10L + - (rest[4]-'0')) - : year); - else if ((end - rest) == 4) /* four digits is a year */ - year = (year < 0 - ? ((rest[0]-'0')*1000L + - (rest[1]-'0')*100L + - (rest[2]-'0')*10L + - (rest[3]-'0')) - : year); - else if ((end - rest) == 2) /* two digits - date or year */ - { - int n = ((rest[0]-'0')*10 + - (rest[1]-'0')); - /* If we don't have a date (day of the month) and we see a number - less than 32, then assume that is the date. - - Otherwise, if we have a date and not a year, assume this is the - year. If it is less than 70, then assume it refers to the 21st - century. If it is two digits (>= 70), assume it refers to this - century. Otherwise, assume it refers to an unambiguous year. - - The world will surely end soon. - */ - if (date < 0 && n < 32) - date = n; - else if (year < 0) - { - if (n < 70) - year = 2000 + n; - else if (n < 100) - year = 1900 + n; - else - year = n; - } - /* else what the hell is this. */ - } - else if ((end - rest) == 1) /* one digit - date */ - date = (date < 0 ? (rest[0]-'0') : date); - /* else, three or more than five digits - what's that? */ - - break; - } /* case '0' .. '9' */ - } /* switch */ - - /* Skip to the end of this token, whether we parsed it or not. - Tokens are delimited by whitespace, or ,;-+/()[] but explicitly not .: - 'T' is also treated as delimiter when followed by a digit (ISO 8601). - */ - while (*rest && - *rest != ' ' && *rest != '\t' && - *rest != ',' && *rest != ';' && - *rest != '-' && *rest != '+' && - *rest != '/' && - *rest != '(' && *rest != ')' && *rest != '[' && *rest != ']' && - !(*rest == 'T' && rest[1] >= '0' && rest[1] <= '9') - ) - rest++; - /* skip over uninteresting chars. */ - SKIP_MORE: - while (*rest == ' ' || *rest == '\t' || - *rest == ',' || *rest == ';' || *rest == '/' || - *rest == '(' || *rest == ')' || *rest == '[' || *rest == ']') - rest++; - - /* "-" is ignored at the beginning of a token if we have not yet - parsed a year (e.g., the second "-" in "30-AUG-1966"), or if - the character after the dash is not a digit. */ - if (*rest == '-' && ((rest > string && - isalpha((unsigned char)rest[-1]) && year < 0) || - rest[1] < '0' || rest[1] > '9')) - { - rest++; - goto SKIP_MORE; - } - - /* Skip T that may precede ISO 8601 time. */ - if (*rest == 'T' && rest[1] >= '0' && rest[1] <= '9') - rest++; - } /* while */ - - if (zone != TT_UNKNOWN && zone_offset == -1) - { - switch (zone) - { - case TT_PST: zone_offset = -8 * 60; break; - case TT_PDT: zone_offset = -8 * 60; dst_offset = 1 * 60; break; - case TT_MST: zone_offset = -7 * 60; break; - case TT_MDT: zone_offset = -7 * 60; dst_offset = 1 * 60; break; - case TT_CST: zone_offset = -6 * 60; break; - case TT_CDT: zone_offset = -6 * 60; dst_offset = 1 * 60; break; - case TT_EST: zone_offset = -5 * 60; break; - case TT_EDT: zone_offset = -5 * 60; dst_offset = 1 * 60; break; - case TT_AST: zone_offset = -4 * 60; break; - case TT_NST: zone_offset = -3 * 60 - 30; break; - case TT_GMT: zone_offset = 0 * 60; break; - case TT_BST: zone_offset = 0 * 60; dst_offset = 1 * 60; break; - case TT_MET: zone_offset = 1 * 60; break; - case TT_EET: zone_offset = 2 * 60; break; - case TT_JST: zone_offset = 9 * 60; break; - default: - PR_ASSERT (0); - break; - } - } - - /* If we didn't find a year, month, or day-of-the-month, we can't - possibly parse this, and in fact, mktime() will do something random - (I'm seeing it return "Tue Feb 5 06:28:16 2036", which is no doubt - a numerologically significant date... */ - if (month == TT_UNKNOWN || date == -1 || year == -1 || year > PR_INT16_MAX) - return PR_FAILURE; - - memset(result, 0, sizeof(*result)); - if (usec != -1) - result->tm_usec = usec; - if (sec != -1) - result->tm_sec = sec; - if (min != -1) - result->tm_min = min; - if (hour != -1) - result->tm_hour = hour; - if (date != -1) - result->tm_mday = date; - if (month != TT_UNKNOWN) - result->tm_month = (((int)month) - ((int)TT_JAN)); - if (year != -1) - result->tm_year = year; - if (dotw != TT_UNKNOWN) - result->tm_wday = (((int)dotw) - ((int)TT_SUN)); - /* - * Mainly to compute wday and yday, but normalized time is also required - * by the check below that works around a Visual C++ 2005 mktime problem. - */ - PR_NormalizeTime(result, PR_GMTParameters); - /* The remaining work is to set the gmt and dst offsets in tm_params. */ - - if (zone == TT_UNKNOWN && default_to_gmt) - { - /* No zone was specified, so pretend the zone was GMT. */ - zone = TT_GMT; - zone_offset = 0; - } - - if (zone_offset == -1) - { - /* no zone was specified, and we're to assume that everything - is local. */ - struct tm localTime; - time_t secs; - - PR_ASSERT(result->tm_month > -1 && - result->tm_mday > 0 && - result->tm_hour > -1 && - result->tm_min > -1 && - result->tm_sec > -1); - - /* - * To obtain time_t from a tm structure representing the local - * time, we call mktime(). However, we need to see if we are - * on 1-Jan-1970 or before. If we are, we can't call mktime() - * because mktime() will crash on win16. In that case, we - * calculate zone_offset based on the zone offset at - * 00:00:00, 2 Jan 1970 GMT, and subtract zone_offset from the - * date we are parsing to transform the date to GMT. We also - * do so if mktime() returns (time_t) -1 (time out of range). - */ - - /* month, day, hours, mins and secs are always non-negative - so we dont need to worry about them. */ - if (result->tm_year >= 1970) - { - localTime.tm_sec = result->tm_sec; - localTime.tm_min = result->tm_min; - localTime.tm_hour = result->tm_hour; - localTime.tm_mday = result->tm_mday; - localTime.tm_mon = result->tm_month; - localTime.tm_year = result->tm_year - 1900; - /* Set this to -1 to tell mktime "I don't care". If you set - it to 0 or 1, you are making assertions about whether the - date you are handing it is in daylight savings mode or not; - and if you're wrong, it will "fix" it for you. */ - localTime.tm_isdst = -1; - -#if _MSC_VER == 1400 /* 1400 = Visual C++ 2005 (8.0) */ - /* - * mktime will return (time_t) -1 if the input is a date - * after 23:59:59, December 31, 3000, US Pacific Time (not - * UTC as documented): - * http://msdn.microsoft.com/en-us/library/d1y53h2a(VS.80).aspx - * But if the year is 3001, mktime also invokes the invalid - * parameter handler, causing the application to crash. This - * problem has been reported in - * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=266036. - * We avoid this crash by not calling mktime if the date is - * out of range. To use a simple test that works in any time - * zone, we consider year 3000 out of range as well. (See - * bug 480740.) - */ - if (result->tm_year >= 3000) { - /* Emulate what mktime would have done. */ - errno = EINVAL; - secs = (time_t) -1; - } else { - secs = mktime(&localTime); - } -#else - secs = mktime(&localTime); -#endif - if (secs != (time_t) -1) - { - *result_imploded = (PRInt64)secs * PR_USEC_PER_SEC; - *result_imploded += result->tm_usec; - return PR_SUCCESS; - } - } - - /* So mktime() can't handle this case. We assume the - zone_offset for the date we are parsing is the same as - the zone offset on 00:00:00 2 Jan 1970 GMT. */ - secs = 86400; - localtime_r(&secs, &localTime); - zone_offset = localTime.tm_min - + 60 * localTime.tm_hour - + 1440 * (localTime.tm_mday - 2); - } - - result->tm_params.tp_gmt_offset = zone_offset * 60; - result->tm_params.tp_dst_offset = dst_offset * 60; - - *result_imploded = PR_ImplodeTime(result); - return PR_SUCCESS; -} diff --git a/src/butil/third_party/nspr/prtime.h b/src/butil/third_party/nspr/prtime.h deleted file mode 100644 index b87d45a6..00000000 --- a/src/butil/third_party/nspr/prtime.h +++ /dev/null @@ -1,252 +0,0 @@ -/* Portions are Copyright (C) 2011 Google Inc */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - *--------------------------------------------------------------------------- - * - * prtime.h -- - * - * NSPR date and time functions - * CVS revision 3.10 - * This file contains definitions of NSPR's basic types required by - * prtime.cc. These types have been copied over from the following NSPR - * files prtime.h, prtypes.h(CVS revision 3.35), prlong.h(CVS revision 3.13) - * - *--------------------------------------------------------------------------- - */ - -#ifndef BUTIL_PRTIME_H__ -#define BUTIL_PRTIME_H__ - -#include - -#include "butil/base_export.h" - -typedef int8_t PRInt8; -typedef int16_t PRInt16; -typedef int32_t PRInt32; -typedef int64_t PRInt64; -typedef int PRIntn; - -typedef PRIntn PRBool; -#define PR_TRUE 1 -#define PR_FALSE 0 - -typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus; - -#define PR_ASSERT DCHECK -#define PR_CALLBACK -#define PR_INT16_MAX 32767 -#define NSPR_API(__type) extern __type - -/**********************************************************************/ -/************************* TYPES AND CONSTANTS ************************/ -/**********************************************************************/ - -#define PR_MSEC_PER_SEC 1000UL -#define PR_USEC_PER_SEC 1000000UL -#define PR_NSEC_PER_SEC 1000000000UL -#define PR_USEC_PER_MSEC 1000UL -#define PR_NSEC_PER_MSEC 1000000UL - -/* - * PRTime -- - * - * NSPR represents basic time as 64-bit signed integers relative - * to midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT). - * (GMT is also known as Coordinated Universal Time, UTC.) - * The units of time are in microseconds. Negative times are allowed - * to represent times prior to the January 1970 epoch. Such values are - * intended to be exported to other systems or converted to human - * readable form. - * - * Notes on porting: PRTime corresponds to time_t in ANSI C. NSPR 1.0 - * simply uses PRInt64. - */ - -typedef PRInt64 PRTime; - -/* - * Time zone and daylight saving time corrections applied to GMT to - * obtain the local time of some geographic location - */ - -typedef struct PRTimeParameters { - PRInt32 tp_gmt_offset; /* the offset from GMT in seconds */ - PRInt32 tp_dst_offset; /* contribution of DST in seconds */ -} PRTimeParameters; - -/* - * PRExplodedTime -- - * - * Time broken down into human-readable components such as year, month, - * day, hour, minute, second, and microsecond. Time zone and daylight - * saving time corrections may be applied. If they are applied, the - * offsets from the GMT must be saved in the 'tm_params' field so that - * all the information is available to reconstruct GMT. - * - * Notes on porting: PRExplodedTime corrresponds to struct tm in - * ANSI C, with the following differences: - * - an additional field tm_usec; - * - replacing tm_isdst by tm_params; - * - the month field is spelled tm_month, not tm_mon; - * - we use absolute year, AD, not the year since 1900. - * The corresponding type in NSPR 1.0 is called PRTime. Below is - * a table of date/time type correspondence in the three APIs: - * API time since epoch time in components - * ANSI C time_t struct tm - * NSPR 1.0 PRInt64 PRTime - * NSPR 2.0 PRTime PRExplodedTime - */ - -typedef struct PRExplodedTime { - PRInt32 tm_usec; /* microseconds past tm_sec (0-99999) */ - PRInt32 tm_sec; /* seconds past tm_min (0-61, accomodating - up to two leap seconds) */ - PRInt32 tm_min; /* minutes past tm_hour (0-59) */ - PRInt32 tm_hour; /* hours past tm_day (0-23) */ - PRInt32 tm_mday; /* days past tm_mon (1-31, note that it - starts from 1) */ - PRInt32 tm_month; /* months past tm_year (0-11, Jan = 0) */ - PRInt16 tm_year; /* absolute year, AD (note that we do not - count from 1900) */ - - PRInt8 tm_wday; /* calculated day of the week - (0-6, Sun = 0) */ - PRInt16 tm_yday; /* calculated day of the year - (0-365, Jan 1 = 0) */ - - PRTimeParameters tm_params; /* time parameters used by conversion */ -} PRExplodedTime; - -/* - * PRTimeParamFn -- - * - * A function of PRTimeParamFn type returns the time zone and - * daylight saving time corrections for some geographic location, - * given the current time in GMT. The input argument gmt should - * point to a PRExplodedTime that is in GMT, i.e., whose - * tm_params contains all 0's. - * - * For any time zone other than GMT, the computation is intended to - * consist of two steps: - * - Figure out the time zone correction, tp_gmt_offset. This number - * usually depends on the geographic location only. But it may - * also depend on the current time. For example, all of China - * is one time zone right now. But this situation may change - * in the future. - * - Figure out the daylight saving time correction, tp_dst_offset. - * This number depends on both the geographic location and the - * current time. Most of the DST rules are expressed in local - * current time. If so, one should apply the time zone correction - * to GMT before applying the DST rules. - */ - -typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt); - -/**********************************************************************/ -/****************************** FUNCTIONS *****************************/ -/**********************************************************************/ - -NSPR_API(PRTime) -PR_ImplodeTime(const PRExplodedTime *exploded); - -/* - * Adjust exploded time to normalize field overflows after manipulation. - * Note that the following fields of PRExplodedTime should not be - * manipulated: - * - tm_month and tm_year: because the number of days in a month and - * number of days in a year are not constant, it is ambiguous to - * manipulate the month and year fields, although one may be tempted - * to. For example, what does "a month from January 31st" mean? - * - tm_wday and tm_yday: these fields are calculated by NSPR. Users - * should treat them as "read-only". - */ - -NSPR_API(void) PR_NormalizeTime( - PRExplodedTime *exploded, PRTimeParamFn params); - -/**********************************************************************/ -/*********************** TIME PARAMETER FUNCTIONS *********************/ -/**********************************************************************/ - -/* Time parameters that represent Greenwich Mean Time */ -NSPR_API(PRTimeParameters) PR_GMTParameters(const PRExplodedTime *gmt); - -/* - * This parses a time/date string into a PRTime - * (microseconds after "1-Jan-1970 00:00:00 GMT"). - * It returns PR_SUCCESS on success, and PR_FAILURE - * if the time/date string can't be parsed. - * - * Many formats are handled, including: - * - * 14 Apr 89 03:20:12 - * 14 Apr 89 03:20 GMT - * Fri, 17 Mar 89 4:01:33 - * Fri, 17 Mar 89 4:01 GMT - * Mon Jan 16 16:12 PDT 1989 - * Mon Jan 16 16:12 +0130 1989 - * 6 May 1992 16:41-JST (Wednesday) - * 22-AUG-1993 10:59:12.82 - * 22-AUG-1993 10:59pm - * 22-AUG-1993 12:59am - * 22-AUG-1993 12:59 PM - * Friday, August 04, 1995 3:54 PM - * 06/21/95 04:24:34 PM - * 20/06/95 21:07 - * 95-06-08 19:32:48 EDT - * 1995-06-17T23:11:25.342156Z - * - * If the input string doesn't contain a description of the timezone, - * we consult the `default_to_gmt' to decide whether the string should - * be interpreted relative to the local time zone (PR_FALSE) or GMT (PR_TRUE). - * The correct value for this argument depends on what standard specified - * the time string which you are parsing. - */ - -/* - * This is the only funtion that should be called from outside base, and only - * from the unit test. - */ - -BUTIL_EXPORT PRStatus PR_ParseTimeString ( - const char *string, - PRBool default_to_gmt, - PRTime *result); - -#endif // BUTIL_PRTIME_H__ diff --git a/src/butil/time/time.cc b/src/butil/time/time.cc index 16ed1818..d092ccf9 100644 --- a/src/butil/time/time.cc +++ b/src/butil/time/time.cc @@ -10,7 +10,6 @@ #include "butil/float_util.h" #include "butil/lazy_instance.h" #include "butil/logging.h" -#include "butil/third_party/nspr/prtime.h" namespace butil { @@ -213,21 +212,24 @@ Time Time::LocalMidnight() const { bool Time::FromStringInternal(const char* time_string, bool is_local, Time* parsed_time) { - DCHECK((time_string != NULL) && (parsed_time != NULL)); + // TODO(zhujiashun): after removing nspr, this function + // is left unimplemented. + return false; + // DCHECK((time_string != NULL) && (parsed_time != NULL)); - if (time_string[0] == '\0') - return false; + // if (time_string[0] == '\0') + // return false; - PRTime result_time = 0; - PRStatus result = PR_ParseTimeString(time_string, - is_local ? PR_FALSE : PR_TRUE, - &result_time); - if (PR_SUCCESS != result) - return false; + // PRTime result_time = 0; + // PRStatus result = PR_ParseTimeString(time_string, + // is_local ? PR_FALSE : PR_TRUE, + // &result_time); + // if (PR_SUCCESS != result) + // return false; - result_time += kTimeTToMicrosecondsOffset; - *parsed_time = Time(result_time); - return true; + // result_time += kTimeTToMicrosecondsOffset; + // *parsed_time = Time(result_time); + // return true; } // Local helper class to hold the conversion from Time to TickTime at the diff --git a/test/BUILD b/test/BUILD index 0b443e83..28d34b36 100644 --- a/test/BUILD +++ b/test/BUILD @@ -114,7 +114,6 @@ TEST_BUTIL_SOURCES = [ "thread_local_storage_unittest.cc", "thread_local_unittest.cc", "watchdog_unittest.cc", - "pr_time_unittest.cc", "time_unittest.cc", "version_unittest.cc", "logging_unittest.cc", diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3f17800e..621de98a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -127,7 +127,6 @@ SET(TEST_BUTIL_SOURCES ${PROJECT_SOURCE_DIR}/test/thread_local_storage_unittest.cc ${PROJECT_SOURCE_DIR}/test/thread_local_unittest.cc ${PROJECT_SOURCE_DIR}/test/watchdog_unittest.cc - ${PROJECT_SOURCE_DIR}/test/pr_time_unittest.cc ${PROJECT_SOURCE_DIR}/test/time_unittest.cc ${PROJECT_SOURCE_DIR}/test/version_unittest.cc ${PROJECT_SOURCE_DIR}/test/logging_unittest.cc diff --git a/test/Makefile b/test/Makefile index 7a6306ff..65fdd5d9 100644 --- a/test/Makefile +++ b/test/Makefile @@ -96,7 +96,6 @@ TEST_BUTIL_SOURCES = \ thread_local_storage_unittest.cc \ thread_local_unittest.cc \ watchdog_unittest.cc \ - pr_time_unittest.cc \ time_unittest.cc \ version_unittest.cc \ logging_unittest.cc \ diff --git a/test/file_util_unittest.cc b/test/file_util_unittest.cc index dd106546..9882fae2 100644 --- a/test/file_util_unittest.cc +++ b/test/file_util_unittest.cc @@ -2128,17 +2128,15 @@ TEST_F(FileUtilTest, TouchFile) { std::string data("hello"); ASSERT_TRUE(WriteFile(foobar, data.c_str(), data.length())); - Time access_time; - // This timestamp is divisible by one day (in local timezone), - // to make it work on FAT too. - ASSERT_TRUE(Time::FromString("Wed, 16 Nov 1994, 00:00:00", - &access_time)); + // 784915200000000 represents the timestamp of "Wed, 16 Nov 1994, 00:00:00". + // This timestamp is divisible by one day (in local timezone), to make it work + // on FAT too. + Time access_time(784915200000000); - Time modification_time; + // 784903526000000 represents the timestamp of "Tue, 15 Nov 1994, 12:45:26 GMT". // Note that this timestamp is divisible by two (seconds) - FAT stores // modification times with 2s resolution. - ASSERT_TRUE(Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", - &modification_time)); + Time modification_time(784903526000000); ASSERT_TRUE(TouchFile(foobar, access_time, modification_time)); File::Info file_info; diff --git a/test/pr_time_unittest.cc b/test/pr_time_unittest.cc deleted file mode 100644 index 153ee710..00000000 --- a/test/pr_time_unittest.cc +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include -#include - -#include "butil/compiler_specific.h" -#include "butil/third_party/nspr/prtime.h" -#include "butil/time/time.h" -#include - -using butil::Time; - -namespace { - -// time_t representation of 15th Oct 2007 12:45:00 PDT -PRTime comparison_time_pdt = 1192477500 * Time::kMicrosecondsPerSecond; - -// NOTE(gejun): Missing INT64_C in gcc 3.4 -#if !defined(INT64_C) -#define INT64_C(val) __INT64_C(val) -#endif - -// Time with positive tz offset and fractional seconds: -// 2013-07-08T11:28:12.441381+02:00 -PRTime comparison_time_2 = INT64_C(1373275692441381); // represented as GMT - -// Specialized test fixture allowing time strings without timezones to be -// tested by comparing them to a known time in the local zone. -class PRTimeTest : public testing::Test { - protected: - virtual void SetUp() OVERRIDE { - // Use mktime to get a time_t, and turn it into a PRTime by converting - // seconds to microseconds. Use 15th Oct 2007 12:45:00 local. This - // must be a time guaranteed to be outside of a DST fallback hour in - // any timezone. - struct tm local_comparison_tm = { - 0, // second - 45, // minute - 12, // hour - 15, // day of month - 10 - 1, // month - 2007 - 1900, // year - 0, // day of week (ignored, output only) - 0, // day of year (ignored, output only) - -1, // DST in effect, -1 tells mktime to figure it out - 0, - NULL - }; - comparison_time_local_ = - mktime(&local_comparison_tm) * Time::kMicrosecondsPerSecond; - ASSERT_GT(comparison_time_local_, 0); - - const int microseconds = 441381; - struct tm local_comparison_tm_2 = { - 12, // second - 28, // minute - 11, // hour - 8, // day of month - 7 - 1, // month - 2013 - 1900, // year - 0, // day of week (ignored, output only) - 0, // day of year (ignored, output only) - -1, // DST in effect, -1 tells mktime to figure it out - 0, - NULL - }; - comparison_time_local_2_ = - mktime(&local_comparison_tm_2) * Time::kMicrosecondsPerSecond; - ASSERT_GT(comparison_time_local_2_, 0); - comparison_time_local_2_ += microseconds; - } - - PRTime comparison_time_local_; - PRTime comparison_time_local_2_; -}; - -// Tests the PR_ParseTimeString nspr helper function for -// a variety of time strings. -TEST_F(PRTimeTest, ParseTimeTest1) { - time_t current_time = 0; - time(¤t_time); - - const int BUFFER_SIZE = 64; - struct tm local_time; - memset(&local_time, 0, sizeof(local_time)); - char time_buf[BUFFER_SIZE] = {0}; -#if defined(OS_WIN) - localtime_s(&local_time, ¤t_time); - asctime_s(time_buf, arraysize(time_buf), &local_time); -#elif defined(OS_POSIX) - localtime_r(¤t_time, &local_time); - asctime_r(&local_time, time_buf); -#endif - - PRTime current_time64 = static_cast(current_time) * PR_USEC_PER_SEC; - - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString(time_buf, PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(current_time64, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest2) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("Mon, 15 Oct 2007 19:45:00 GMT", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_pdt, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest3) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("15 Oct 07 12:45:00", PR_FALSE, - &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest4) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("15 Oct 07 19:45 GMT", PR_FALSE, - &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_pdt, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest5) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("Mon Oct 15 12:45 PDT 2007", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_pdt, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest6) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("Monday, Oct 15, 2007 12:45 PM", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest7) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("10/15/07 12:45:00 PM", PR_FALSE, - &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest8) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("10/15/07 12:45:00. PM", PR_FALSE, - &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest9) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("10/15/07 12:45:00.0 PM", PR_FALSE, - &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest10) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("15-OCT-2007 12:45pm", PR_FALSE, - &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTest11) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("16 Oct 2007 4:45-JST (Tuesday)", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_pdt, parsed_time); -} - -// hh:mm timezone offset. -TEST_F(PRTimeTest, ParseTimeTest12) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("2013-07-08T11:28:12.441381+02:00", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_2, parsed_time); -} - -// hhmm timezone offset. -TEST_F(PRTimeTest, ParseTimeTest13) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("2013-07-08T11:28:12.441381+0200", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_2, parsed_time); -} - -// hh timezone offset. -TEST_F(PRTimeTest, ParseTimeTest14) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("2013-07-08T11:28:12.4413819+02", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_2, parsed_time); -} - -// 5 digits fractional second. -TEST_F(PRTimeTest, ParseTimeTest15) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("2013-07-08T09:28:12.44138Z", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_2-1, parsed_time); -} - -// Fractional seconds, local timezone. -TEST_F(PRTimeTest, ParseTimeTest16) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("2013-07-08T11:28:12.441381", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_local_2_, parsed_time); -} - -// "Z" (=GMT) timezone. -TEST_F(PRTimeTest, ParseTimeTest17) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("2013-07-08T09:28:12.441381Z", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_2, parsed_time); -} - -// "T" delimiter replaced by space. -TEST_F(PRTimeTest, ParseTimeTest18) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("2013-07-08 09:28:12.441381Z", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_2, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTestInvalid1) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("201-07-08T09:28:12.441381Z", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_FAILURE, result); -} - -TEST_F(PRTimeTest, ParseTimeTestInvalid2) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("2013-007-08T09:28:12.441381Z", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_FAILURE, result); -} - -TEST_F(PRTimeTest, ParseTimeTestInvalid3) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("2013-07-008T09:28:12.441381Z", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_FAILURE, result); -} - -// This test should not crash when compiled with Visual C++ 2005 (see -// http://crbug.com/4387). -TEST_F(PRTimeTest, ParseTimeTestOutOfRange) { - PRTime parsed_time = 0; - // Note the lack of timezone in the time string. The year has to be 3001. - // The date has to be after 23:59:59, December 31, 3000, US Pacific Time, so - // we use January 2, 3001 to make sure it's after the magic maximum in any - // timezone. - PRStatus result = PR_ParseTimeString("Sun Jan 2 00:00:00 3001", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); -} - -TEST_F(PRTimeTest, ParseTimeTestNotNormalized1) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("Mon Oct 15 12:44:60 PDT 2007", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_pdt, parsed_time); -} - -TEST_F(PRTimeTest, ParseTimeTestNotNormalized2) { - PRTime parsed_time = 0; - PRStatus result = PR_ParseTimeString("Sun Oct 14 36:45 PDT 2007", - PR_FALSE, &parsed_time); - EXPECT_EQ(PR_SUCCESS, result); - EXPECT_EQ(comparison_time_pdt, parsed_time); -} - -} // namespace diff --git a/test/time_unittest.cc b/test/time_unittest.cc index 431ad251..0e784ed3 100644 --- a/test/time_unittest.cc +++ b/test/time_unittest.cc @@ -161,201 +161,204 @@ TEST_F(TimeTest, LocalMidnight) { EXPECT_EQ(0, exploded.millisecond); } -TEST_F(TimeTest, ParseTimeTest1) { - time_t current_time = 0; - time(¤t_time); - - const int BUFFER_SIZE = 64; - struct tm local_time; - memset(&local_time, 0, sizeof(local_time)); - char time_buf[BUFFER_SIZE] = {0}; -#if defined(OS_WIN) - localtime_s(&local_time, ¤t_time); - asctime_s(time_buf, arraysize(time_buf), &local_time); -#elif defined(OS_POSIX) - localtime_r(¤t_time, &local_time); - asctime_r(&local_time, time_buf); -#endif - - Time parsed_time; - EXPECT_TRUE(Time::FromString(time_buf, &parsed_time)); - EXPECT_EQ(current_time, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, DayOfWeekSunday) { - Time time; - EXPECT_TRUE(Time::FromString("Sun, 06 May 2012 12:00:00 GMT", &time)); - Time::Exploded exploded; - time.UTCExplode(&exploded); - EXPECT_EQ(0, exploded.day_of_week); -} - -TEST_F(TimeTest, DayOfWeekWednesday) { - Time time; - EXPECT_TRUE(Time::FromString("Wed, 09 May 2012 12:00:00 GMT", &time)); - Time::Exploded exploded; - time.UTCExplode(&exploded); - EXPECT_EQ(3, exploded.day_of_week); -} - -TEST_F(TimeTest, DayOfWeekSaturday) { - Time time; - EXPECT_TRUE(Time::FromString("Sat, 12 May 2012 12:00:00 GMT", &time)); - Time::Exploded exploded; - time.UTCExplode(&exploded); - EXPECT_EQ(6, exploded.day_of_week); -} - -TEST_F(TimeTest, ParseTimeTest2) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("Mon, 15 Oct 2007 19:45:00 GMT", &parsed_time)); - EXPECT_EQ(comparison_time_pdt_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest3) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("15 Oct 07 12:45:00", &parsed_time)); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest4) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("15 Oct 07 19:45 GMT", &parsed_time)); - EXPECT_EQ(comparison_time_pdt_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest5) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("Mon Oct 15 12:45 PDT 2007", &parsed_time)); - EXPECT_EQ(comparison_time_pdt_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest6) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("Monday, Oct 15, 2007 12:45 PM", &parsed_time)); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest7) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("10/15/07 12:45:00 PM", &parsed_time)); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest8) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("15-OCT-2007 12:45pm", &parsed_time)); - EXPECT_EQ(comparison_time_local_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest9) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("16 Oct 2007 4:45-JST (Tuesday)", &parsed_time)); - EXPECT_EQ(comparison_time_pdt_, parsed_time); -} - -TEST_F(TimeTest, ParseTimeTest10) { - Time parsed_time; - EXPECT_TRUE(Time::FromString("15/10/07 12:45", &parsed_time)); - EXPECT_EQ(parsed_time, comparison_time_local_); -} - -// Test some of edge cases around epoch, etc. -TEST_F(TimeTest, ParseTimeTestEpoch0) { - Time parsed_time; - - // time_t == epoch == 0 - EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:00 +0100 1970", - &parsed_time)); - EXPECT_EQ(0, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:00 GMT 1970", - &parsed_time)); - EXPECT_EQ(0, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpoch1) { - Time parsed_time; - - // time_t == 1 second after epoch == 1 - EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:01 +0100 1970", - &parsed_time)); - EXPECT_EQ(1, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:01 GMT 1970", - &parsed_time)); - EXPECT_EQ(1, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpoch2) { - Time parsed_time; - - // time_t == 2 seconds after epoch == 2 - EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:02 +0100 1970", - &parsed_time)); - EXPECT_EQ(2, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:02 GMT 1970", - &parsed_time)); - EXPECT_EQ(2, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpochNeg1) { - Time parsed_time; - - // time_t == 1 second before epoch == -1 - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:59 +0100 1970", - &parsed_time)); - EXPECT_EQ(-1, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 1969", - &parsed_time)); - EXPECT_EQ(-1, parsed_time.ToTimeT()); -} - -// If time_t is 32 bits, a date after year 2038 will overflow time_t and -// cause timegm() to return -1. The parsed time should not be 1 second -// before epoch. -TEST_F(TimeTest, ParseTimeTestEpochNotNeg1) { - Time parsed_time; - - EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 2100", - &parsed_time)); - EXPECT_NE(-1, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpochNeg2) { - Time parsed_time; - - // time_t == 2 seconds before epoch == -2 - EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:58 +0100 1970", - &parsed_time)); - EXPECT_EQ(-2, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:58 GMT 1969", - &parsed_time)); - EXPECT_EQ(-2, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEpoch1960) { - Time parsed_time; - - // time_t before Epoch, in 1960 - EXPECT_TRUE(Time::FromString("Wed Jun 29 19:40:01 +0100 1960", - &parsed_time)); - EXPECT_EQ(-299999999, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Wed Jun 29 18:40:01 GMT 1960", - &parsed_time)); - EXPECT_EQ(-299999999, parsed_time.ToTimeT()); - EXPECT_TRUE(Time::FromString("Wed Jun 29 17:40:01 GMT 1960", - &parsed_time)); - EXPECT_EQ(-300003599, parsed_time.ToTimeT()); -} - -TEST_F(TimeTest, ParseTimeTestEmpty) { - Time parsed_time; - EXPECT_FALSE(Time::FromString("", &parsed_time)); -} - -TEST_F(TimeTest, ParseTimeTestInvalidString) { - Time parsed_time; - EXPECT_FALSE(Time::FromString("Monday morning 2000", &parsed_time)); -} +// TODO(zhujiashun): Time::FromString is not implemented after removing nspr, +// so all tests related to this function is commented out. Uncomment those +// tests once Time::FromString is implemented. +// TEST_F(TimeTest, ParseTimeTest1) { +// time_t current_time = 0; +// time(¤t_time); +// +// const int BUFFER_SIZE = 64; +// struct tm local_time; +// memset(&local_time, 0, sizeof(local_time)); +// char time_buf[BUFFER_SIZE] = {0}; +// #if defined(OS_WIN) +// localtime_s(&local_time, ¤t_time); +// asctime_s(time_buf, arraysize(time_buf), &local_time); +// #elif defined(OS_POSIX) +// localtime_r(¤t_time, &local_time); +// asctime_r(&local_time, time_buf); +// #endif +// +// Time parsed_time; +// EXPECT_TRUE(Time::FromString(time_buf, &parsed_time)); +// EXPECT_EQ(current_time, parsed_time.ToTimeT()); +// } +// +// TEST_F(TimeTest, DayOfWeekSunday) { +// Time time; +// EXPECT_TRUE(Time::FromString("Sun, 06 May 2012 12:00:00 GMT", &time)); +// Time::Exploded exploded; +// time.UTCExplode(&exploded); +// EXPECT_EQ(0, exploded.day_of_week); +// } +// +// TEST_F(TimeTest, DayOfWeekWednesday) { +// Time time; +// EXPECT_TRUE(Time::FromString("Wed, 09 May 2012 12:00:00 GMT", &time)); +// Time::Exploded exploded; +// time.UTCExplode(&exploded); +// EXPECT_EQ(3, exploded.day_of_week); +// } +// +// TEST_F(TimeTest, DayOfWeekSaturday) { +// Time time; +// EXPECT_TRUE(Time::FromString("Sat, 12 May 2012 12:00:00 GMT", &time)); +// Time::Exploded exploded; +// time.UTCExplode(&exploded); +// EXPECT_EQ(6, exploded.day_of_week); +// } +// +// TEST_F(TimeTest, ParseTimeTest2) { +// Time parsed_time; +// EXPECT_TRUE(Time::FromString("Mon, 15 Oct 2007 19:45:00 GMT", &parsed_time)); +// EXPECT_EQ(comparison_time_pdt_, parsed_time); +// } +// +// TEST_F(TimeTest, ParseTimeTest3) { +// Time parsed_time; +// EXPECT_TRUE(Time::FromString("15 Oct 07 12:45:00", &parsed_time)); +// EXPECT_EQ(comparison_time_local_, parsed_time); +// } +// +// TEST_F(TimeTest, ParseTimeTest4) { +// Time parsed_time; +// EXPECT_TRUE(Time::FromString("15 Oct 07 19:45 GMT", &parsed_time)); +// EXPECT_EQ(comparison_time_pdt_, parsed_time); +// } +// +// TEST_F(TimeTest, ParseTimeTest5) { +// Time parsed_time; +// EXPECT_TRUE(Time::FromString("Mon Oct 15 12:45 PDT 2007", &parsed_time)); +// EXPECT_EQ(comparison_time_pdt_, parsed_time); +// } +// +// TEST_F(TimeTest, ParseTimeTest6) { +// Time parsed_time; +// EXPECT_TRUE(Time::FromString("Monday, Oct 15, 2007 12:45 PM", &parsed_time)); +// EXPECT_EQ(comparison_time_local_, parsed_time); +// } +// +// TEST_F(TimeTest, ParseTimeTest7) { +// Time parsed_time; +// EXPECT_TRUE(Time::FromString("10/15/07 12:45:00 PM", &parsed_time)); +// EXPECT_EQ(comparison_time_local_, parsed_time); +// } +// +// TEST_F(TimeTest, ParseTimeTest8) { +// Time parsed_time; +// EXPECT_TRUE(Time::FromString("15-OCT-2007 12:45pm", &parsed_time)); +// EXPECT_EQ(comparison_time_local_, parsed_time); +// } +// +// TEST_F(TimeTest, ParseTimeTest9) { +// Time parsed_time; +// EXPECT_TRUE(Time::FromString("16 Oct 2007 4:45-JST (Tuesday)", &parsed_time)); +// EXPECT_EQ(comparison_time_pdt_, parsed_time); +// } +// +// TEST_F(TimeTest, ParseTimeTest10) { +// Time parsed_time; +// EXPECT_TRUE(Time::FromString("15/10/07 12:45", &parsed_time)); +// EXPECT_EQ(parsed_time, comparison_time_local_); +// } +// +// // Test some of edge cases around epoch, etc. +// TEST_F(TimeTest, ParseTimeTestEpoch0) { +// Time parsed_time; +// +// // time_t == epoch == 0 +// EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:00 +0100 1970", +// &parsed_time)); +// EXPECT_EQ(0, parsed_time.ToTimeT()); +// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:00 GMT 1970", +// &parsed_time)); +// EXPECT_EQ(0, parsed_time.ToTimeT()); +// } +// +// TEST_F(TimeTest, ParseTimeTestEpoch1) { +// Time parsed_time; +// +// // time_t == 1 second after epoch == 1 +// EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:01 +0100 1970", +// &parsed_time)); +// EXPECT_EQ(1, parsed_time.ToTimeT()); +// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:01 GMT 1970", +// &parsed_time)); +// EXPECT_EQ(1, parsed_time.ToTimeT()); +// } +// +// TEST_F(TimeTest, ParseTimeTestEpoch2) { +// Time parsed_time; +// +// // time_t == 2 seconds after epoch == 2 +// EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:02 +0100 1970", +// &parsed_time)); +// EXPECT_EQ(2, parsed_time.ToTimeT()); +// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:02 GMT 1970", +// &parsed_time)); +// EXPECT_EQ(2, parsed_time.ToTimeT()); +// } +// +// TEST_F(TimeTest, ParseTimeTestEpochNeg1) { +// Time parsed_time; +// +// // time_t == 1 second before epoch == -1 +// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:59 +0100 1970", +// &parsed_time)); +// EXPECT_EQ(-1, parsed_time.ToTimeT()); +// EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 1969", +// &parsed_time)); +// EXPECT_EQ(-1, parsed_time.ToTimeT()); +// } +// +// // If time_t is 32 bits, a date after year 2038 will overflow time_t and +// // cause timegm() to return -1. The parsed time should not be 1 second +// // before epoch. +// TEST_F(TimeTest, ParseTimeTestEpochNotNeg1) { +// Time parsed_time; +// +// EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 2100", +// &parsed_time)); +// EXPECT_NE(-1, parsed_time.ToTimeT()); +// } +// +// TEST_F(TimeTest, ParseTimeTestEpochNeg2) { +// Time parsed_time; +// +// // time_t == 2 seconds before epoch == -2 +// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:58 +0100 1970", +// &parsed_time)); +// EXPECT_EQ(-2, parsed_time.ToTimeT()); +// EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:58 GMT 1969", +// &parsed_time)); +// EXPECT_EQ(-2, parsed_time.ToTimeT()); +// } +// +// TEST_F(TimeTest, ParseTimeTestEpoch1960) { +// Time parsed_time; +// +// // time_t before Epoch, in 1960 +// EXPECT_TRUE(Time::FromString("Wed Jun 29 19:40:01 +0100 1960", +// &parsed_time)); +// EXPECT_EQ(-299999999, parsed_time.ToTimeT()); +// EXPECT_TRUE(Time::FromString("Wed Jun 29 18:40:01 GMT 1960", +// &parsed_time)); +// EXPECT_EQ(-299999999, parsed_time.ToTimeT()); +// EXPECT_TRUE(Time::FromString("Wed Jun 29 17:40:01 GMT 1960", +// &parsed_time)); +// EXPECT_EQ(-300003599, parsed_time.ToTimeT()); +// } +// +// TEST_F(TimeTest, ParseTimeTestEmpty) { +// Time parsed_time; +// EXPECT_FALSE(Time::FromString("", &parsed_time)); +// } +// +// TEST_F(TimeTest, ParseTimeTestInvalidString) { +// Time parsed_time; +// EXPECT_FALSE(Time::FromString("Monday morning 2000", &parsed_time)); +// } TEST_F(TimeTest, ExplodeBeforeUnixEpoch) { static const int kUnixEpochYear = 1970; // In case this changes (ha!). From c5355f4d52b38ddaa9f78b672a43b8309286742e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 13 Jun 2019 18:54:56 +0800 Subject: [PATCH 226/270] update LICENSE --- LICENSE | 285 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 285 insertions(+) diff --git a/LICENSE b/LICENSE index f433b1a5..682475db 100644 --- a/LICENSE +++ b/LICENSE @@ -175,3 +175,288 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS + +-------------------------------------------------------------------------------- + +src/butil/third_party/dmg_fp: licensed under the following terms: + + The author of this software is David M. Gay. + + Copyright (c) 1991, 2000, 2001 by Lucent Technologies. + + Permission to use, copy, modify, and distribute this software for any + purpose without fee is hereby granted, provided that this entire notice + is included in all copies of any software which is or includes a copy + or modification of this software and in all copies of the supporting + documentation for such software. + + THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY + REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + +-------------------------------------------------------------------------------- + +src/butil/third_party/dynamic_annotations: licensed under the following terms: + + Copyright (c) 2008-2009, Google Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + --- + Author: Kostya Serebryany + +-------------------------------------------------------------------------------- + +src/butil/third_party/icu: licensed under the following terms: + + ICU License - ICU 1.8.1 and later + + COPYRIGHT AND PERMISSION NOTICE + + Copyright (c) 1995-2009 International Business Machines Corporation and others + + All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, and/or sell copies of the Software, and to permit persons + to whom the Software is furnished to do so, provided that the above + copyright notice(s) and this permission notice appear in all copies of + the Software and that both the above copyright notice(s) and this + permission notice appear in supporting documentation. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY + SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER + RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + Except as contained in this notice, the name of a copyright holder + shall not be used in advertising or otherwise to promote the sale, use + or other dealings in this Software without prior written authorization + of the copyright holder. + +-------------------------------------------------------------------------------- + +src/butil/third_party/modp_b64: licensed under the following terms: + + MODP_B64 - High performance base64 encoder/decoder + Version 1.3 -- 17-Mar-2006 + http://modp.com/release/base64 + + Copyright (c) 2005, 2006 Nick Galbreath -- nickg [at] modp [dot] com + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + Neither the name of the modp.com nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------------------- + +src/butil/third_party/murmurhash3: MIT license + + MurmurHash3 was written by Austin Appleby, and is placed in the public + domain. The author hereby disclaims copyright to this source code. + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT + OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + +-------------------------------------------------------------------------------- + +src/butil/third_party/rapidjson: MIT license + + Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy of this + software and associated documentation files (the "Software"), to deal in the Software + without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT + OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + +-------------------------------------------------------------------------------- + +src/butil/third_party/superfasthash: licensed under the following terms: + + Paul Hsieh OLD BSD license + + Copyright (c) 2010, Paul Hsieh + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + * Neither my name, Paul Hsieh, nor the names of any other contributors to the + code use may not be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------------------- + +src/butil/third_party/valgrind: licensed under the following terms: + + Notice that the following BSD-style license applies to the Valgrind header + files used by brpc (valgrind.h). However, the rest of Valgrind is + licensed under the terms of the GNU General Public License, version 2, + unless otherwise indicated. + + ---------------------------------------------------------------- + + Copyright (C) 2000-2008 Julian Seward. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 3. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------------------- + +src/butil (some portions): 3-clause BSD + +Some portions of this module are derived from code in the Chromium project, +copyright (c) Google inc and (c) The Chromium Authors and licensed under the +3-clause BSD license: + + Copyright (c) 2000 - 2014 The Chromium Authors. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 568dba34fc472c65589fd2a36a65224a5f703122 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 13 Jun 2019 19:15:27 +0800 Subject: [PATCH 227/270] remove unnecessary comments & using DISABLE_* to disable corresponding UTs --- src/butil/time/time.cc | 15 -- test/time_unittest.cc | 394 ++++++++++++++++++++--------------------- 2 files changed, 197 insertions(+), 212 deletions(-) diff --git a/src/butil/time/time.cc b/src/butil/time/time.cc index d092ccf9..8cb3b97f 100644 --- a/src/butil/time/time.cc +++ b/src/butil/time/time.cc @@ -215,21 +215,6 @@ bool Time::FromStringInternal(const char* time_string, // TODO(zhujiashun): after removing nspr, this function // is left unimplemented. return false; - // DCHECK((time_string != NULL) && (parsed_time != NULL)); - - // if (time_string[0] == '\0') - // return false; - - // PRTime result_time = 0; - // PRStatus result = PR_ParseTimeString(time_string, - // is_local ? PR_FALSE : PR_TRUE, - // &result_time); - // if (PR_SUCCESS != result) - // return false; - - // result_time += kTimeTToMicrosecondsOffset; - // *parsed_time = Time(result_time); - // return true; } // Local helper class to hold the conversion from Time to TickTime at the diff --git a/test/time_unittest.cc b/test/time_unittest.cc index 0e784ed3..2622e20b 100644 --- a/test/time_unittest.cc +++ b/test/time_unittest.cc @@ -162,203 +162,203 @@ TEST_F(TimeTest, LocalMidnight) { } // TODO(zhujiashun): Time::FromString is not implemented after removing nspr, -// so all tests related to this function is commented out. Uncomment those -// tests once Time::FromString is implemented. -// TEST_F(TimeTest, ParseTimeTest1) { -// time_t current_time = 0; -// time(¤t_time); -// -// const int BUFFER_SIZE = 64; -// struct tm local_time; -// memset(&local_time, 0, sizeof(local_time)); -// char time_buf[BUFFER_SIZE] = {0}; -// #if defined(OS_WIN) -// localtime_s(&local_time, ¤t_time); -// asctime_s(time_buf, arraysize(time_buf), &local_time); -// #elif defined(OS_POSIX) -// localtime_r(¤t_time, &local_time); -// asctime_r(&local_time, time_buf); -// #endif -// -// Time parsed_time; -// EXPECT_TRUE(Time::FromString(time_buf, &parsed_time)); -// EXPECT_EQ(current_time, parsed_time.ToTimeT()); -// } -// -// TEST_F(TimeTest, DayOfWeekSunday) { -// Time time; -// EXPECT_TRUE(Time::FromString("Sun, 06 May 2012 12:00:00 GMT", &time)); -// Time::Exploded exploded; -// time.UTCExplode(&exploded); -// EXPECT_EQ(0, exploded.day_of_week); -// } -// -// TEST_F(TimeTest, DayOfWeekWednesday) { -// Time time; -// EXPECT_TRUE(Time::FromString("Wed, 09 May 2012 12:00:00 GMT", &time)); -// Time::Exploded exploded; -// time.UTCExplode(&exploded); -// EXPECT_EQ(3, exploded.day_of_week); -// } -// -// TEST_F(TimeTest, DayOfWeekSaturday) { -// Time time; -// EXPECT_TRUE(Time::FromString("Sat, 12 May 2012 12:00:00 GMT", &time)); -// Time::Exploded exploded; -// time.UTCExplode(&exploded); -// EXPECT_EQ(6, exploded.day_of_week); -// } -// -// TEST_F(TimeTest, ParseTimeTest2) { -// Time parsed_time; -// EXPECT_TRUE(Time::FromString("Mon, 15 Oct 2007 19:45:00 GMT", &parsed_time)); -// EXPECT_EQ(comparison_time_pdt_, parsed_time); -// } -// -// TEST_F(TimeTest, ParseTimeTest3) { -// Time parsed_time; -// EXPECT_TRUE(Time::FromString("15 Oct 07 12:45:00", &parsed_time)); -// EXPECT_EQ(comparison_time_local_, parsed_time); -// } -// -// TEST_F(TimeTest, ParseTimeTest4) { -// Time parsed_time; -// EXPECT_TRUE(Time::FromString("15 Oct 07 19:45 GMT", &parsed_time)); -// EXPECT_EQ(comparison_time_pdt_, parsed_time); -// } -// -// TEST_F(TimeTest, ParseTimeTest5) { -// Time parsed_time; -// EXPECT_TRUE(Time::FromString("Mon Oct 15 12:45 PDT 2007", &parsed_time)); -// EXPECT_EQ(comparison_time_pdt_, parsed_time); -// } -// -// TEST_F(TimeTest, ParseTimeTest6) { -// Time parsed_time; -// EXPECT_TRUE(Time::FromString("Monday, Oct 15, 2007 12:45 PM", &parsed_time)); -// EXPECT_EQ(comparison_time_local_, parsed_time); -// } -// -// TEST_F(TimeTest, ParseTimeTest7) { -// Time parsed_time; -// EXPECT_TRUE(Time::FromString("10/15/07 12:45:00 PM", &parsed_time)); -// EXPECT_EQ(comparison_time_local_, parsed_time); -// } -// -// TEST_F(TimeTest, ParseTimeTest8) { -// Time parsed_time; -// EXPECT_TRUE(Time::FromString("15-OCT-2007 12:45pm", &parsed_time)); -// EXPECT_EQ(comparison_time_local_, parsed_time); -// } -// -// TEST_F(TimeTest, ParseTimeTest9) { -// Time parsed_time; -// EXPECT_TRUE(Time::FromString("16 Oct 2007 4:45-JST (Tuesday)", &parsed_time)); -// EXPECT_EQ(comparison_time_pdt_, parsed_time); -// } -// -// TEST_F(TimeTest, ParseTimeTest10) { -// Time parsed_time; -// EXPECT_TRUE(Time::FromString("15/10/07 12:45", &parsed_time)); -// EXPECT_EQ(parsed_time, comparison_time_local_); -// } -// -// // Test some of edge cases around epoch, etc. -// TEST_F(TimeTest, ParseTimeTestEpoch0) { -// Time parsed_time; -// -// // time_t == epoch == 0 -// EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:00 +0100 1970", -// &parsed_time)); -// EXPECT_EQ(0, parsed_time.ToTimeT()); -// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:00 GMT 1970", -// &parsed_time)); -// EXPECT_EQ(0, parsed_time.ToTimeT()); -// } -// -// TEST_F(TimeTest, ParseTimeTestEpoch1) { -// Time parsed_time; -// -// // time_t == 1 second after epoch == 1 -// EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:01 +0100 1970", -// &parsed_time)); -// EXPECT_EQ(1, parsed_time.ToTimeT()); -// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:01 GMT 1970", -// &parsed_time)); -// EXPECT_EQ(1, parsed_time.ToTimeT()); -// } -// -// TEST_F(TimeTest, ParseTimeTestEpoch2) { -// Time parsed_time; -// -// // time_t == 2 seconds after epoch == 2 -// EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:02 +0100 1970", -// &parsed_time)); -// EXPECT_EQ(2, parsed_time.ToTimeT()); -// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:02 GMT 1970", -// &parsed_time)); -// EXPECT_EQ(2, parsed_time.ToTimeT()); -// } -// -// TEST_F(TimeTest, ParseTimeTestEpochNeg1) { -// Time parsed_time; -// -// // time_t == 1 second before epoch == -1 -// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:59 +0100 1970", -// &parsed_time)); -// EXPECT_EQ(-1, parsed_time.ToTimeT()); -// EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 1969", -// &parsed_time)); -// EXPECT_EQ(-1, parsed_time.ToTimeT()); -// } -// -// // If time_t is 32 bits, a date after year 2038 will overflow time_t and -// // cause timegm() to return -1. The parsed time should not be 1 second -// // before epoch. -// TEST_F(TimeTest, ParseTimeTestEpochNotNeg1) { -// Time parsed_time; -// -// EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 2100", -// &parsed_time)); -// EXPECT_NE(-1, parsed_time.ToTimeT()); -// } -// -// TEST_F(TimeTest, ParseTimeTestEpochNeg2) { -// Time parsed_time; -// -// // time_t == 2 seconds before epoch == -2 -// EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:58 +0100 1970", -// &parsed_time)); -// EXPECT_EQ(-2, parsed_time.ToTimeT()); -// EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:58 GMT 1969", -// &parsed_time)); -// EXPECT_EQ(-2, parsed_time.ToTimeT()); -// } -// -// TEST_F(TimeTest, ParseTimeTestEpoch1960) { -// Time parsed_time; -// -// // time_t before Epoch, in 1960 -// EXPECT_TRUE(Time::FromString("Wed Jun 29 19:40:01 +0100 1960", -// &parsed_time)); -// EXPECT_EQ(-299999999, parsed_time.ToTimeT()); -// EXPECT_TRUE(Time::FromString("Wed Jun 29 18:40:01 GMT 1960", -// &parsed_time)); -// EXPECT_EQ(-299999999, parsed_time.ToTimeT()); -// EXPECT_TRUE(Time::FromString("Wed Jun 29 17:40:01 GMT 1960", -// &parsed_time)); -// EXPECT_EQ(-300003599, parsed_time.ToTimeT()); -// } -// -// TEST_F(TimeTest, ParseTimeTestEmpty) { -// Time parsed_time; -// EXPECT_FALSE(Time::FromString("", &parsed_time)); -// } -// -// TEST_F(TimeTest, ParseTimeTestInvalidString) { -// Time parsed_time; -// EXPECT_FALSE(Time::FromString("Monday morning 2000", &parsed_time)); -// } +// so all tests using this function is disabled. Enable those tests once +// Time::FromString is implemented. +TEST_F(TimeTest, DISABLED_ParseTimeTest1) { + time_t current_time = 0; + time(¤t_time); + + const int BUFFER_SIZE = 64; + struct tm local_time; + memset(&local_time, 0, sizeof(local_time)); + char time_buf[BUFFER_SIZE] = {0}; +#if defined(OS_WIN) + localtime_s(&local_time, ¤t_time); + asctime_s(time_buf, arraysize(time_buf), &local_time); +#elif defined(OS_POSIX) + localtime_r(¤t_time, &local_time); + asctime_r(&local_time, time_buf); +#endif + + Time parsed_time; + EXPECT_TRUE(Time::FromString(time_buf, &parsed_time)); + EXPECT_EQ(current_time, parsed_time.ToTimeT()); +} + +TEST_F(TimeTest, DISABLED_DayOfWeekSunday) { + Time time; + EXPECT_TRUE(Time::FromString("Sun, 06 May 2012 12:00:00 GMT", &time)); + Time::Exploded exploded; + time.UTCExplode(&exploded); + EXPECT_EQ(0, exploded.day_of_week); +} + +TEST_F(TimeTest, DISABLED_DayOfWeekWednesday) { + Time time; + EXPECT_TRUE(Time::FromString("Wed, 09 May 2012 12:00:00 GMT", &time)); + Time::Exploded exploded; + time.UTCExplode(&exploded); + EXPECT_EQ(3, exploded.day_of_week); +} + +TEST_F(TimeTest, DISABLED_DayOfWeekSaturday) { + Time time; + EXPECT_TRUE(Time::FromString("Sat, 12 May 2012 12:00:00 GMT", &time)); + Time::Exploded exploded; + time.UTCExplode(&exploded); + EXPECT_EQ(6, exploded.day_of_week); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTest2) { + Time parsed_time; + EXPECT_TRUE(Time::FromString("Mon, 15 Oct 2007 19:45:00 GMT", &parsed_time)); + EXPECT_EQ(comparison_time_pdt_, parsed_time); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTest3) { + Time parsed_time; + EXPECT_TRUE(Time::FromString("15 Oct 07 12:45:00", &parsed_time)); + EXPECT_EQ(comparison_time_local_, parsed_time); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTest4) { + Time parsed_time; + EXPECT_TRUE(Time::FromString("15 Oct 07 19:45 GMT", &parsed_time)); + EXPECT_EQ(comparison_time_pdt_, parsed_time); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTest5) { + Time parsed_time; + EXPECT_TRUE(Time::FromString("Mon Oct 15 12:45 PDT 2007", &parsed_time)); + EXPECT_EQ(comparison_time_pdt_, parsed_time); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTest6) { + Time parsed_time; + EXPECT_TRUE(Time::FromString("Monday, Oct 15, 2007 12:45 PM", &parsed_time)); + EXPECT_EQ(comparison_time_local_, parsed_time); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTest7) { + Time parsed_time; + EXPECT_TRUE(Time::FromString("10/15/07 12:45:00 PM", &parsed_time)); + EXPECT_EQ(comparison_time_local_, parsed_time); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTest8) { + Time parsed_time; + EXPECT_TRUE(Time::FromString("15-OCT-2007 12:45pm", &parsed_time)); + EXPECT_EQ(comparison_time_local_, parsed_time); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTest9) { + Time parsed_time; + EXPECT_TRUE(Time::FromString("16 Oct 2007 4:45-JST (Tuesday)", &parsed_time)); + EXPECT_EQ(comparison_time_pdt_, parsed_time); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTest10) { + Time parsed_time; + EXPECT_TRUE(Time::FromString("15/10/07 12:45", &parsed_time)); + EXPECT_EQ(parsed_time, comparison_time_local_); +} + +// Test some of edge cases around epoch, etc. +TEST_F(TimeTest, DISABLED_ParseTimeTestEpoch0) { + Time parsed_time; + + // time_t == epoch == 0 + EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:00 +0100 1970", + &parsed_time)); + EXPECT_EQ(0, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:00 GMT 1970", + &parsed_time)); + EXPECT_EQ(0, parsed_time.ToTimeT()); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTestEpoch1) { + Time parsed_time; + + // time_t == 1 second after epoch == 1 + EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:01 +0100 1970", + &parsed_time)); + EXPECT_EQ(1, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:01 GMT 1970", + &parsed_time)); + EXPECT_EQ(1, parsed_time.ToTimeT()); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTestEpoch2) { + Time parsed_time; + + // time_t == 2 seconds after epoch == 2 + EXPECT_TRUE(Time::FromString("Thu Jan 01 01:00:02 +0100 1970", + &parsed_time)); + EXPECT_EQ(2, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString("Thu Jan 01 00:00:02 GMT 1970", + &parsed_time)); + EXPECT_EQ(2, parsed_time.ToTimeT()); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTestEpochNeg1) { + Time parsed_time; + + // time_t == 1 second before epoch == -1 + EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:59 +0100 1970", + &parsed_time)); + EXPECT_EQ(-1, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 1969", + &parsed_time)); + EXPECT_EQ(-1, parsed_time.ToTimeT()); +} + +// If time_t is 32 bits, a date after year 2038 will overflow time_t and +// cause timegm() to return -1. The parsed time should not be 1 second +// before epoch. +TEST_F(TimeTest, DISABLED_ParseTimeTestEpochNotNeg1) { + Time parsed_time; + + EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:59 GMT 2100", + &parsed_time)); + EXPECT_NE(-1, parsed_time.ToTimeT()); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTestEpochNeg2) { + Time parsed_time; + + // time_t == 2 seconds before epoch == -2 + EXPECT_TRUE(Time::FromString("Thu Jan 01 00:59:58 +0100 1970", + &parsed_time)); + EXPECT_EQ(-2, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString("Wed Dec 31 23:59:58 GMT 1969", + &parsed_time)); + EXPECT_EQ(-2, parsed_time.ToTimeT()); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTestEpoch1960) { + Time parsed_time; + + // time_t before Epoch, in 1960 + EXPECT_TRUE(Time::FromString("Wed Jun 29 19:40:01 +0100 1960", + &parsed_time)); + EXPECT_EQ(-299999999, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString("Wed Jun 29 18:40:01 GMT 1960", + &parsed_time)); + EXPECT_EQ(-299999999, parsed_time.ToTimeT()); + EXPECT_TRUE(Time::FromString("Wed Jun 29 17:40:01 GMT 1960", + &parsed_time)); + EXPECT_EQ(-300003599, parsed_time.ToTimeT()); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTestEmpty) { + Time parsed_time; + EXPECT_FALSE(Time::FromString("", &parsed_time)); +} + +TEST_F(TimeTest, DISABLED_ParseTimeTestInvalidString) { + Time parsed_time; + EXPECT_FALSE(Time::FromString("Monday morning 2000", &parsed_time)); +} TEST_F(TimeTest, ExplodeBeforeUnixEpoch) { static const int kUnixEpochYear = 1970; // In case this changes (ha!). From 7100a7ba8394dd6cbaa1213fa48a8f7c70f4dbc1 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 14 Jun 2019 11:59:39 +0800 Subject: [PATCH 228/270] make the path of PrometheusMetricsService be different from default /metrics --- src/brpc/builtin/prometheus_metrics_service.h | 2 +- src/brpc/builtin_service.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.h b/src/brpc/builtin/prometheus_metrics_service.h index a9f47bc6..fc03ba31 100644 --- a/src/brpc/builtin/prometheus_metrics_service.h +++ b/src/brpc/builtin/prometheus_metrics_service.h @@ -22,7 +22,7 @@ namespace brpc { -class PrometheusMetricsService : public metrics { +class PrometheusMetricsService : public brpc_vars_metrics { public: PrometheusMetricsService(Server* server) : _server(server) {} diff --git a/src/brpc/builtin_service.proto b/src/brpc/builtin_service.proto index 558d4b04..e939aaf7 100644 --- a/src/brpc/builtin_service.proto +++ b/src/brpc/builtin_service.proto @@ -97,7 +97,7 @@ service sockets { rpc default_method(SocketsRequest) returns (SocketsResponse); } -service metrics { +service brpc_vars_metrics { rpc default_method(MetricsRequest) returns (MetricsResponse); } From 29de815d71fac5783b0032f76798e0c3bd03128f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 14 Jun 2019 13:43:45 +0800 Subject: [PATCH 229/270] adjust prometheus UT --- test/brpc_prometheus_metrics_unittest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/brpc_prometheus_metrics_unittest.cpp b/test/brpc_prometheus_metrics_unittest.cpp index fe9055d4..e2e4d5f2 100644 --- a/test/brpc_prometheus_metrics_unittest.cpp +++ b/test/brpc_prometheus_metrics_unittest.cpp @@ -45,7 +45,7 @@ TEST(PrometheusMetrics, sanity) { channel_opts.protocol = "http"; ASSERT_EQ(0, channel.Init("127.0.0.1:8614", &channel_opts)); brpc::Controller cntl; - cntl.http_request().uri() = "/metrics"; + cntl.http_request().uri() = "/brpc_vars_metrics"; channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); ASSERT_FALSE(cntl.Failed()); std::string res = cntl.response_attachment().to_string(); From c4ae795ca0a98c7ca3df444caee0f7530b252b8a Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 14 Jun 2019 14:50:36 +0800 Subject: [PATCH 230/270] customize brpc metrics path --- src/brpc/builtin/prometheus_metrics_service.cpp | 11 +++++++---- src/brpc/builtin/prometheus_metrics_service.h | 10 +++++----- src/brpc/builtin_service.proto | 4 ++-- src/brpc/server.cpp | 11 ++++++++++- src/brpc/server.h | 2 ++ test/brpc_prometheus_metrics_unittest.cpp | 6 +++++- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp b/src/brpc/builtin/prometheus_metrics_service.cpp index 4ff38c56..1dd8fdba 100644 --- a/src/brpc/builtin/prometheus_metrics_service.cpp +++ b/src/brpc/builtin/prometheus_metrics_service.cpp @@ -32,6 +32,9 @@ DECLARE_int32(bvar_latency_p3); namespace brpc { +DEFINE_string(prometheus_metrics_path, "/metrics", "The HTTP resource " + "path from which prometheus fetch metrics."); + // This is a class that convert bvar result to prometheus output. // Currently the output only includes gauge and summary for two // reasons: @@ -174,10 +177,10 @@ bool PrometheusMetricsDumper::DumpLatencyRecorderSuffix( return true; } -void PrometheusMetricsService::default_method(::google::protobuf::RpcController* cntl_base, - const ::brpc::MetricsRequest*, - ::brpc::MetricsResponse*, - ::google::protobuf::Closure* done) { +void PrometheusMetricsService::metrics(::google::protobuf::RpcController* cntl_base, + const ::brpc::MetricsRequest*, + ::brpc::MetricsResponse*, + ::google::protobuf::Closure* done) { ClosureGuard done_guard(done); Controller *cntl = static_cast(cntl_base); cntl->http_response().set_content_type("text/plain"); diff --git a/src/brpc/builtin/prometheus_metrics_service.h b/src/brpc/builtin/prometheus_metrics_service.h index fc03ba31..6d58a042 100644 --- a/src/brpc/builtin/prometheus_metrics_service.h +++ b/src/brpc/builtin/prometheus_metrics_service.h @@ -22,15 +22,15 @@ namespace brpc { -class PrometheusMetricsService : public brpc_vars_metrics { +class PrometheusMetricsService : public bvars { public: PrometheusMetricsService(Server* server) : _server(server) {} - void default_method(::google::protobuf::RpcController* cntl_base, - const ::brpc::MetricsRequest* request, - ::brpc::MetricsResponse* response, - ::google::protobuf::Closure* done) override; + void metrics(::google::protobuf::RpcController* cntl_base, + const ::brpc::MetricsRequest* request, + ::brpc::MetricsResponse* response, + ::google::protobuf::Closure* done) override; private: Server* _server; }; diff --git a/src/brpc/builtin_service.proto b/src/brpc/builtin_service.proto index e939aaf7..f3ff06c0 100644 --- a/src/brpc/builtin_service.proto +++ b/src/brpc/builtin_service.proto @@ -97,8 +97,8 @@ service sockets { rpc default_method(SocketsRequest) returns (SocketsResponse); } -service brpc_vars_metrics { - rpc default_method(MetricsRequest) returns (MetricsResponse); +service bvars { + rpc metrics(MetricsRequest) returns (MetricsResponse); } service badmethod { diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 1eefe063..c7cb8af2 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -110,6 +110,7 @@ DEFINE_bool(enable_threads_service, false, "Enable /threads"); DECLARE_int32(usercode_backup_threads); DECLARE_bool(usercode_in_pthread); +DECLARE_string(prometheus_metrics_path); const int INITIAL_SERVICE_CAP = 64; const int INITIAL_CERT_MAP = 64; @@ -484,7 +485,10 @@ int Server::AddBuiltinServices() { LOG(ERROR) << "Fail to add ListService"; return -1; } - if (AddBuiltinService(new (std::nothrow) PrometheusMetricsService(this))) { + ServiceOptions options; + options.ownership = SERVER_OWNS_SERVICE; + options.restful_mappings = FLAGS_prometheus_metrics_path + " => metrics"; + if (AddBuiltinService(new (std::nothrow) PrometheusMetricsService(this), options)) { LOG(ERROR) << "Fail to add MetricsService"; return -1; } @@ -1411,6 +1415,11 @@ int Server::AddService(google::protobuf::Service* service, int Server::AddBuiltinService(google::protobuf::Service* service) { ServiceOptions options; options.ownership = SERVER_OWNS_SERVICE; + return AddBuiltinService(service, options); +} + +int Server::AddBuiltinService(google::protobuf::Service* service, + const ServiceOptions& options) { return AddServiceInternal(service, true, options); } diff --git a/src/brpc/server.h b/src/brpc/server.h index 1c0968ce..21477a8d 100644 --- a/src/brpc/server.h +++ b/src/brpc/server.h @@ -530,6 +530,8 @@ friend class Controller; const ServiceOptions& options); int AddBuiltinService(google::protobuf::Service* service); + int AddBuiltinService(google::protobuf::Service* service, + const ServiceOptions& options); // Remove all methods of `service' from internal structures. void RemoveMethodsOf(google::protobuf::Service* service); diff --git a/test/brpc_prometheus_metrics_unittest.cpp b/test/brpc_prometheus_metrics_unittest.cpp index e2e4d5f2..5ea457be 100644 --- a/test/brpc_prometheus_metrics_unittest.cpp +++ b/test/brpc_prometheus_metrics_unittest.cpp @@ -10,6 +10,10 @@ #include "butil/strings/string_piece.h" #include "echo.pb.h" +namespace brpc { +DECLARE_string(prometheus_metrics_path); +} // brpc + int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); @@ -45,7 +49,7 @@ TEST(PrometheusMetrics, sanity) { channel_opts.protocol = "http"; ASSERT_EQ(0, channel.Init("127.0.0.1:8614", &channel_opts)); brpc::Controller cntl; - cntl.http_request().uri() = "/brpc_vars_metrics"; + cntl.http_request().uri() = brpc::FLAGS_prometheus_metrics_path; channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); ASSERT_FALSE(cntl.Failed()); std::string res = cntl.response_attachment().to_string(); From 4ceba2fe35e694ecb4f26828e45266c68c91e5b5 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 14 Jun 2019 18:03:26 +0800 Subject: [PATCH 231/270] update {cn|en}/bvar.md --- docs/cn/bvar.md | 2 +- docs/en/bvar.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/cn/bvar.md b/docs/cn/bvar.md index c485fb92..73d2ec1e 100644 --- a/docs/cn/bvar.md +++ b/docs/cn/bvar.md @@ -92,4 +92,4 @@ process_username : "gejun" # bvar导出到其它监控系统格式 -bvar已支持的其它监控系统格式有[Prometheus](https://prometheus.io)。将Prometheus的抓取url地址的路径设置为`/metrics`即可,例如brpc server跑在本机的8080端口,则抓取url配置为`127.0.0.1:8080/metrics`。 +bvar已支持的其它监控系统格式有[Prometheus](https://prometheus.io)。通过-prometheus_metrics_path可设置Prometheus的抓取url,默认路径为`/metrics`,例如brpc server跑在本机的8080端口,则在默认配置下抓取url为`127.0.0.1:8080/metrics`。 diff --git a/docs/en/bvar.md b/docs/en/bvar.md index 26f973d7..1ea80db2 100644 --- a/docs/en/bvar.md +++ b/docs/en/bvar.md @@ -92,4 +92,4 @@ The monitoring system should combine data on every single machine periodically a # Dump to the format of other monitoring system -Currently monitoring system supported by bvar is [Prometheus](https://prometheus.io). All you need to do is to set the path in scraping target url to `/metrics`. For example, if brpc server is running in localhost on port 8080, the scraping target should be `127.0.0.1:8080/metrics`. +Currently monitoring system supported by bvar is [Prometheus](https://prometheus.io). Flag -prometheus_metrics_path can be used to set the path of scraping target, and its default value is `/metrics`. For example, if brpc server is running on localhost:8080, the scraping target should be `127.0.0.1:8080/metrics` under default configuration. From aff4da230b8e7ecdc7d8c1d99e31b166d8d2b9dd Mon Sep 17 00:00:00 2001 From: helei Date: Mon, 17 Jun 2019 10:50:20 +0800 Subject: [PATCH 232/270] revert last_revived_time of circuit_breaker --- src/brpc/circuit_breaker.cpp | 12 ++---- src/brpc/circuit_breaker.h | 2 +- test/brpc_circuit_breaker_unittest.cpp | 56 +++++++++++++------------- 3 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/brpc/circuit_breaker.cpp b/src/brpc/circuit_breaker.cpp index 7380b1bd..87be0c05 100644 --- a/src/brpc/circuit_breaker.cpp +++ b/src/brpc/circuit_breaker.cpp @@ -164,10 +164,9 @@ CircuitBreaker::CircuitBreaker() FLAGS_circuit_breaker_long_window_error_percent) , _short_window(FLAGS_circuit_breaker_short_window_size, FLAGS_circuit_breaker_short_window_error_percent) - , _last_revived_time_ms(butil::cpuwide_time_ms()) + , _last_reset_time_ms(0) , _isolation_duration_ms(FLAGS_circuit_breaker_min_isolation_duration_ms) , _isolated_times(0) - , _is_first_call_after_revived(true) , _broken(false) { } @@ -175,10 +174,6 @@ bool CircuitBreaker::OnCallEnd(int error_code, int64_t latency) { if (_broken.load(butil::memory_order_relaxed)) { return false; } - if (_is_first_call_after_revived.load(butil::memory_order_relaxed) && - _is_first_call_after_revived.exchange(false, butil::memory_order_relaxed)) { - _last_revived_time_ms.store(butil::cpuwide_time_ms(), butil::memory_order_relaxed); - } if (_long_window.OnCallEnd(error_code, latency) && _short_window.OnCallEnd(error_code, latency)) { return true; @@ -190,8 +185,7 @@ bool CircuitBreaker::OnCallEnd(int error_code, int64_t latency) { void CircuitBreaker::Reset() { _long_window.Reset(); _short_window.Reset(); - _last_revived_time_ms.store(butil::cpuwide_time_ms(), butil::memory_order_relaxed); - _is_first_call_after_revived.store(true, butil::memory_order_relaxed); + _last_reset_time_ms = butil::cpuwide_time_ms(); _broken.store(false, butil::memory_order_release); } @@ -209,7 +203,7 @@ void CircuitBreaker::UpdateIsolationDuration() { FLAGS_circuit_breaker_max_isolation_duration_ms; const int min_isolation_duration_ms = FLAGS_circuit_breaker_min_isolation_duration_ms; - if (now_time_ms - _last_revived_time_ms < max_isolation_duration_ms) { + if (now_time_ms - _last_reset_time_ms < max_isolation_duration_ms) { isolation_duration_ms = std::min(isolation_duration_ms * 2, max_isolation_duration_ms); } else { diff --git a/src/brpc/circuit_breaker.h b/src/brpc/circuit_breaker.h index 3b2cd756..aa3531a4 100644 --- a/src/brpc/circuit_breaker.h +++ b/src/brpc/circuit_breaker.h @@ -82,7 +82,7 @@ private: EmaErrorRecorder _long_window; EmaErrorRecorder _short_window; - butil::atomic _last_revived_time_ms; + int64_t _last_reset_time_ms; butil::atomic _isolation_duration_ms; butil::atomic _isolated_times; butil::atomic _is_first_call_after_revived; diff --git a/test/brpc_circuit_breaker_unittest.cpp b/test/brpc_circuit_breaker_unittest.cpp index c7e8a177..207c9b58 100644 --- a/test/brpc_circuit_breaker_unittest.cpp +++ b/test/brpc_circuit_breaker_unittest.cpp @@ -124,7 +124,7 @@ TEST_F(CircuitBreakerTest, should_not_isolate) { StartFeedbackThread(&thread_list, &fc_list, 3); for (int i = 0; i < kThreadNum; ++i) { void* ret_data = nullptr; - EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); + ASSERT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_EQ(fc->_unhealthy_cnt, 0); EXPECT_TRUE(fc->_healthy); @@ -137,21 +137,32 @@ TEST_F(CircuitBreakerTest, should_isolate) { StartFeedbackThread(&thread_list, &fc_list, 50); for (int i = 0; i < kThreadNum; ++i) { void* ret_data = nullptr; - EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); + ASSERT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_GT(fc->_unhealthy_cnt, 0); EXPECT_FALSE(fc->_healthy); } } -TEST_F(CircuitBreakerTest, isolation_duration_grow) { - _circuit_breaker.Reset(); +TEST_F(CircuitBreakerTest, isolation_duration_grow_and_reset) { std::vector thread_list; std::vector> fc_list; StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { void* ret_data = nullptr; - EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); + ASSERT_EQ(pthread_join(thread_list[i], &ret_data), 0); + FeedbackControl* fc = static_cast(ret_data); + EXPECT_FALSE(fc->_healthy); + EXPECT_LE(fc->_healthy_cnt, kShortWindowSize); + EXPECT_GT(fc->_unhealthy_cnt, 0); + } + EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), kMinIsolationDurationMs); + + _circuit_breaker.Reset(); + StartFeedbackThread(&thread_list, &fc_list, 100); + for (int i = 0; i < kThreadNum; ++i) { + void* ret_data = nullptr; + ASSERT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_FALSE(fc->_healthy); EXPECT_LE(fc->_healthy_cnt, kShortWindowSize); @@ -163,7 +174,7 @@ TEST_F(CircuitBreakerTest, isolation_duration_grow) { StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { void* ret_data = nullptr; - EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); + ASSERT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_FALSE(fc->_healthy); EXPECT_LE(fc->_healthy_cnt, kShortWindowSize); @@ -172,49 +183,38 @@ TEST_F(CircuitBreakerTest, isolation_duration_grow) { EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), kMinIsolationDurationMs * 4); _circuit_breaker.Reset(); - StartFeedbackThread(&thread_list, &fc_list, 100); - for (int i = 0; i < kThreadNum; ++i) { - void* ret_data = nullptr; - EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); - FeedbackControl* fc = static_cast(ret_data); - EXPECT_FALSE(fc->_healthy); - EXPECT_LE(fc->_healthy_cnt, kShortWindowSize); - EXPECT_GT(fc->_unhealthy_cnt, 0); - } - EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), kMinIsolationDurationMs * 8); -} - -TEST_F(CircuitBreakerTest, isolation_duration_reset) { - std::vector thread_list; - std::vector> fc_list; - _circuit_breaker.Reset(); - _circuit_breaker.OnCallEnd(kErrorCodeForFailed, kLatency); ::usleep((kMaxIsolationDurationMs + kMinIsolationDurationMs) * 1000); StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { void* ret_data = nullptr; - EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); + ASSERT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_FALSE(fc->_healthy); EXPECT_LE(fc->_healthy_cnt, kShortWindowSize); EXPECT_GT(fc->_unhealthy_cnt, 0); } EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), kMinIsolationDurationMs); + } -TEST_F(CircuitBreakerTest, isolation_duration_compute) { +TEST_F(CircuitBreakerTest, maximum_isolation_duration) { + brpc::FLAGS_circuit_breaker_max_isolation_duration_ms = + brpc::FLAGS_circuit_breaker_min_isolation_duration_ms + 1; + ASSERT_LT(brpc::FLAGS_circuit_breaker_max_isolation_duration_ms, + 2 * brpc::FLAGS_circuit_breaker_min_isolation_duration_ms); std::vector thread_list; std::vector> fc_list; + _circuit_breaker.Reset(); - ::usleep((kMaxIsolationDurationMs + kMinIsolationDurationMs) * 1000); StartFeedbackThread(&thread_list, &fc_list, 100); for (int i = 0; i < kThreadNum; ++i) { void* ret_data = nullptr; - EXPECT_EQ(pthread_join(thread_list[i], &ret_data), 0); + ASSERT_EQ(pthread_join(thread_list[i], &ret_data), 0); FeedbackControl* fc = static_cast(ret_data); EXPECT_FALSE(fc->_healthy); EXPECT_LE(fc->_healthy_cnt, kShortWindowSize); EXPECT_GT(fc->_unhealthy_cnt, 0); } - EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), 2 * kMinIsolationDurationMs); + EXPECT_EQ(_circuit_breaker.isolation_duration_ms(), + brpc::FLAGS_circuit_breaker_max_isolation_duration_ms); } From f4f4791a5688fee7f611ef79b6c6d9f8aaeabb63 Mon Sep 17 00:00:00 2001 From: helei Date: Mon, 17 Jun 2019 10:54:31 +0800 Subject: [PATCH 233/270] delete useless member of circuit breaker --- src/brpc/circuit_breaker.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/brpc/circuit_breaker.h b/src/brpc/circuit_breaker.h index aa3531a4..f9eaa66f 100644 --- a/src/brpc/circuit_breaker.h +++ b/src/brpc/circuit_breaker.h @@ -85,7 +85,6 @@ private: int64_t _last_reset_time_ms; butil::atomic _isolation_duration_ms; butil::atomic _isolated_times; - butil::atomic _is_first_call_after_revived; butil::atomic _broken; }; From 981310aa5dbf368f9a09bf2222a050532ecbbee3 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 17 Jun 2019 14:24:17 +0800 Subject: [PATCH 234/270] Fix bug in inserting RestfulMap service --- src/brpc/server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index c7cb8af2..eb9436b2 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -1351,7 +1351,7 @@ int Server::AddServiceInternal(google::protobuf::Service* service, } if (sp == NULL) { ServiceProperty ss = - { false, SERVER_DOESNT_OWN_SERVICE, NULL, m }; + { is_builtin_service, SERVER_DOESNT_OWN_SERVICE, NULL, m }; _fullname_service_map[svc_name] = ss; _service_map[svc_name] = ss; ++_virtual_service_count; From 963f7ea122a165f641de49a9925022b7f75ed1bd Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 17 Jun 2019 16:40:04 +0800 Subject: [PATCH 235/270] make brpc prometheus metrics path fixed --- src/brpc/builtin/prometheus_metrics_service.cpp | 11 ++++------- src/brpc/builtin/prometheus_metrics_service.h | 10 +++++----- src/brpc/builtin_service.proto | 4 ++-- src/brpc/server.cpp | 12 ++---------- src/brpc/server.h | 2 -- test/brpc_prometheus_metrics_unittest.cpp | 6 +----- 6 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp b/src/brpc/builtin/prometheus_metrics_service.cpp index 1dd8fdba..4ff38c56 100644 --- a/src/brpc/builtin/prometheus_metrics_service.cpp +++ b/src/brpc/builtin/prometheus_metrics_service.cpp @@ -32,9 +32,6 @@ DECLARE_int32(bvar_latency_p3); namespace brpc { -DEFINE_string(prometheus_metrics_path, "/metrics", "The HTTP resource " - "path from which prometheus fetch metrics."); - // This is a class that convert bvar result to prometheus output. // Currently the output only includes gauge and summary for two // reasons: @@ -177,10 +174,10 @@ bool PrometheusMetricsDumper::DumpLatencyRecorderSuffix( return true; } -void PrometheusMetricsService::metrics(::google::protobuf::RpcController* cntl_base, - const ::brpc::MetricsRequest*, - ::brpc::MetricsResponse*, - ::google::protobuf::Closure* done) { +void PrometheusMetricsService::default_method(::google::protobuf::RpcController* cntl_base, + const ::brpc::MetricsRequest*, + ::brpc::MetricsResponse*, + ::google::protobuf::Closure* done) { ClosureGuard done_guard(done); Controller *cntl = static_cast(cntl_base); cntl->http_response().set_content_type("text/plain"); diff --git a/src/brpc/builtin/prometheus_metrics_service.h b/src/brpc/builtin/prometheus_metrics_service.h index 6d58a042..6100aa0d 100644 --- a/src/brpc/builtin/prometheus_metrics_service.h +++ b/src/brpc/builtin/prometheus_metrics_service.h @@ -22,15 +22,15 @@ namespace brpc { -class PrometheusMetricsService : public bvars { +class PrometheusMetricsService : public brpc_prometheus_metrics { public: PrometheusMetricsService(Server* server) : _server(server) {} - void metrics(::google::protobuf::RpcController* cntl_base, - const ::brpc::MetricsRequest* request, - ::brpc::MetricsResponse* response, - ::google::protobuf::Closure* done) override; + void default_method(::google::protobuf::RpcController* cntl_base, + const ::brpc::MetricsRequest* request, + ::brpc::MetricsResponse* response, + ::google::protobuf::Closure* done) override; private: Server* _server; }; diff --git a/src/brpc/builtin_service.proto b/src/brpc/builtin_service.proto index f3ff06c0..9430ba8f 100644 --- a/src/brpc/builtin_service.proto +++ b/src/brpc/builtin_service.proto @@ -97,8 +97,8 @@ service sockets { rpc default_method(SocketsRequest) returns (SocketsResponse); } -service bvars { - rpc metrics(MetricsRequest) returns (MetricsResponse); +service brpc_prometheus_metrics { + rpc default_method(MetricsRequest) returns (MetricsResponse); } service badmethod { diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index eb9436b2..79a70faf 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -485,10 +485,7 @@ int Server::AddBuiltinServices() { LOG(ERROR) << "Fail to add ListService"; return -1; } - ServiceOptions options; - options.ownership = SERVER_OWNS_SERVICE; - options.restful_mappings = FLAGS_prometheus_metrics_path + " => metrics"; - if (AddBuiltinService(new (std::nothrow) PrometheusMetricsService(this), options)) { + if (AddBuiltinService(new (std::nothrow) PrometheusMetricsService(this))) { LOG(ERROR) << "Fail to add MetricsService"; return -1; } @@ -1351,7 +1348,7 @@ int Server::AddServiceInternal(google::protobuf::Service* service, } if (sp == NULL) { ServiceProperty ss = - { is_builtin_service, SERVER_DOESNT_OWN_SERVICE, NULL, m }; + { false , SERVER_DOESNT_OWN_SERVICE, NULL, m }; _fullname_service_map[svc_name] = ss; _service_map[svc_name] = ss; ++_virtual_service_count; @@ -1415,11 +1412,6 @@ int Server::AddService(google::protobuf::Service* service, int Server::AddBuiltinService(google::protobuf::Service* service) { ServiceOptions options; options.ownership = SERVER_OWNS_SERVICE; - return AddBuiltinService(service, options); -} - -int Server::AddBuiltinService(google::protobuf::Service* service, - const ServiceOptions& options) { return AddServiceInternal(service, true, options); } diff --git a/src/brpc/server.h b/src/brpc/server.h index 21477a8d..1c0968ce 100644 --- a/src/brpc/server.h +++ b/src/brpc/server.h @@ -530,8 +530,6 @@ friend class Controller; const ServiceOptions& options); int AddBuiltinService(google::protobuf::Service* service); - int AddBuiltinService(google::protobuf::Service* service, - const ServiceOptions& options); // Remove all methods of `service' from internal structures. void RemoveMethodsOf(google::protobuf::Service* service); diff --git a/test/brpc_prometheus_metrics_unittest.cpp b/test/brpc_prometheus_metrics_unittest.cpp index 5ea457be..56715ccc 100644 --- a/test/brpc_prometheus_metrics_unittest.cpp +++ b/test/brpc_prometheus_metrics_unittest.cpp @@ -10,10 +10,6 @@ #include "butil/strings/string_piece.h" #include "echo.pb.h" -namespace brpc { -DECLARE_string(prometheus_metrics_path); -} // brpc - int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); @@ -49,7 +45,7 @@ TEST(PrometheusMetrics, sanity) { channel_opts.protocol = "http"; ASSERT_EQ(0, channel.Init("127.0.0.1:8614", &channel_opts)); brpc::Controller cntl; - cntl.http_request().uri() = brpc::FLAGS_prometheus_metrics_path; + cntl.http_request().uri() = "/brpc_prometheus_metrics"; channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); ASSERT_FALSE(cntl.Failed()); std::string res = cntl.response_attachment().to_string(); From 6aa2d593936c20716ec497b2e6454a1ef08aac83 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 17 Jun 2019 16:45:29 +0800 Subject: [PATCH 236/270] revert docs --- docs/cn/bvar.md | 2 +- docs/en/bvar.md | 2 +- src/brpc/server.cpp | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/cn/bvar.md b/docs/cn/bvar.md index 73d2ec1e..f1a379b5 100644 --- a/docs/cn/bvar.md +++ b/docs/cn/bvar.md @@ -92,4 +92,4 @@ process_username : "gejun" # bvar导出到其它监控系统格式 -bvar已支持的其它监控系统格式有[Prometheus](https://prometheus.io)。通过-prometheus_metrics_path可设置Prometheus的抓取url,默认路径为`/metrics`,例如brpc server跑在本机的8080端口,则在默认配置下抓取url为`127.0.0.1:8080/metrics`。 +bvar已支持的其它监控系统格式有[Prometheus](https://prometheus.io)。将Prometheus的抓取url地址的路径设置为`/brpc_prometheus_metrics`即可,例如brpc server跑在本机的8080端口,则抓取url配置为`127.0.0.1:8080/brpc_prometheus_metrics`。 diff --git a/docs/en/bvar.md b/docs/en/bvar.md index 1ea80db2..018d3189 100644 --- a/docs/en/bvar.md +++ b/docs/en/bvar.md @@ -92,4 +92,4 @@ The monitoring system should combine data on every single machine periodically a # Dump to the format of other monitoring system -Currently monitoring system supported by bvar is [Prometheus](https://prometheus.io). Flag -prometheus_metrics_path can be used to set the path of scraping target, and its default value is `/metrics`. For example, if brpc server is running on localhost:8080, the scraping target should be `127.0.0.1:8080/metrics` under default configuration. +Currently monitoring system supported by bvar is [Prometheus](https://prometheus.io). All you need to do is to set the path in scraping target url to `/brpc_prometheus_metrics`. For example, if brpc server is running on localhost:8080, the scraping target should be `127.0.0.1:8080/brpc_prometheus_metrics`. diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 79a70faf..1eefe063 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -110,7 +110,6 @@ DEFINE_bool(enable_threads_service, false, "Enable /threads"); DECLARE_int32(usercode_backup_threads); DECLARE_bool(usercode_in_pthread); -DECLARE_string(prometheus_metrics_path); const int INITIAL_SERVICE_CAP = 64; const int INITIAL_CERT_MAP = 64; @@ -1348,7 +1347,7 @@ int Server::AddServiceInternal(google::protobuf::Service* service, } if (sp == NULL) { ServiceProperty ss = - { false , SERVER_DOESNT_OWN_SERVICE, NULL, m }; + { false, SERVER_DOESNT_OWN_SERVICE, NULL, m }; _fullname_service_map[svc_name] = ss; _service_map[svc_name] = ss; ++_virtual_service_count; From ad1596aaef47dd73204ea31b24f3733dd1a24e91 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 17 Jun 2019 17:16:05 +0800 Subject: [PATCH 237/270] add DumpPrometheusMetricsToIOBuf --- .../builtin/prometheus_metrics_service.cpp | 18 +++++++++++++----- src/brpc/builtin/prometheus_metrics_service.h | 3 +++ src/brpc/details/server_private_accessor.h | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp b/src/brpc/builtin/prometheus_metrics_service.cpp index 4ff38c56..1f078850 100644 --- a/src/brpc/builtin/prometheus_metrics_service.cpp +++ b/src/brpc/builtin/prometheus_metrics_service.cpp @@ -22,6 +22,7 @@ #include "brpc/closure_guard.h" // ClosureGuard #include "brpc/builtin/prometheus_metrics_service.h" #include "brpc/builtin/common.h" +#include "brpc/details/server_private_accessor.h" #include "bvar/bvar.h" namespace bvar { @@ -181,14 +182,21 @@ void PrometheusMetricsService::default_method(::google::protobuf::RpcController* ClosureGuard done_guard(done); Controller *cntl = static_cast(cntl_base); cntl->http_response().set_content_type("text/plain"); - butil::IOBufBuilder os; - PrometheusMetricsDumper dumper(&os, _server->ServerPrefix()); - const int ndump = bvar::Variable::dump_exposed(&dumper, NULL); - if (ndump < 0) { + if (DumpPrometheusMetricsToIOBuf(_server, &cntl->response_attachment()) != 0) { cntl->SetFailed("Fail to dump metrics"); return; } - os.move_to(cntl->response_attachment()); +} + +int DumpPrometheusMetricsToIOBuf(const Server* server, butil::IOBuf* output) { + butil::IOBufBuilder os; + PrometheusMetricsDumper dumper(&os, brpc::ServerPrivateAccessor(server).ServerPrefix()); + const int ndump = bvar::Variable::dump_exposed(&dumper, NULL); + if (ndump < 0) { + return -1; + } + os.move_to(*output); + return 0; } } // namespace brpc diff --git a/src/brpc/builtin/prometheus_metrics_service.h b/src/brpc/builtin/prometheus_metrics_service.h index 6100aa0d..fe31bfbb 100644 --- a/src/brpc/builtin/prometheus_metrics_service.h +++ b/src/brpc/builtin/prometheus_metrics_service.h @@ -31,10 +31,13 @@ public: const ::brpc::MetricsRequest* request, ::brpc::MetricsResponse* response, ::google::protobuf::Closure* done) override; + private: Server* _server; }; +int DumpPrometheusMetricsToIOBuf(const Server* server, butil::IOBuf* output); + } // namepace brpc #endif // BRPC_PROMETHEUS_METRICS_SERVICE_H diff --git a/src/brpc/details/server_private_accessor.h b/src/brpc/details/server_private_accessor.h index d9f9ef37..c2c4a965 100644 --- a/src/brpc/details/server_private_accessor.h +++ b/src/brpc/details/server_private_accessor.h @@ -97,6 +97,8 @@ public: RestfulMap* global_restful_map() const { return _server->_global_restful_map; } + + std::string ServerPrefix() const { return _server->ServerPrefix(); } private: const Server* _server; From 6955aabd4ad2d09d11cf6381387e105fa1a9453f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 17 Jun 2019 17:51:34 +0800 Subject: [PATCH 238/270] change /brpc_prometheus_metrics to /brpc_metrics --- src/brpc/builtin/prometheus_metrics_service.h | 2 +- src/brpc/builtin_service.proto | 2 +- test/brpc_prometheus_metrics_unittest.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.h b/src/brpc/builtin/prometheus_metrics_service.h index fe31bfbb..2cdc8e47 100644 --- a/src/brpc/builtin/prometheus_metrics_service.h +++ b/src/brpc/builtin/prometheus_metrics_service.h @@ -22,7 +22,7 @@ namespace brpc { -class PrometheusMetricsService : public brpc_prometheus_metrics { +class PrometheusMetricsService : public brpc_metrics { public: PrometheusMetricsService(Server* server) : _server(server) {} diff --git a/src/brpc/builtin_service.proto b/src/brpc/builtin_service.proto index 9430ba8f..8701e53e 100644 --- a/src/brpc/builtin_service.proto +++ b/src/brpc/builtin_service.proto @@ -97,7 +97,7 @@ service sockets { rpc default_method(SocketsRequest) returns (SocketsResponse); } -service brpc_prometheus_metrics { +service brpc_metrics { rpc default_method(MetricsRequest) returns (MetricsResponse); } diff --git a/test/brpc_prometheus_metrics_unittest.cpp b/test/brpc_prometheus_metrics_unittest.cpp index 56715ccc..0d7eeca9 100644 --- a/test/brpc_prometheus_metrics_unittest.cpp +++ b/test/brpc_prometheus_metrics_unittest.cpp @@ -45,7 +45,7 @@ TEST(PrometheusMetrics, sanity) { channel_opts.protocol = "http"; ASSERT_EQ(0, channel.Init("127.0.0.1:8614", &channel_opts)); brpc::Controller cntl; - cntl.http_request().uri() = "/brpc_prometheus_metrics"; + cntl.http_request().uri() = "/brpc_metrics"; channel.CallMethod(NULL, &cntl, NULL, NULL, NULL); ASSERT_FALSE(cntl.Failed()); std::string res = cntl.response_attachment().to_string(); From 328772dc61a1277826d640bb2e17c7529af94b4f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 17 Jun 2019 17:54:31 +0800 Subject: [PATCH 239/270] update docs --- docs/cn/bvar.md | 2 +- docs/en/bvar.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/cn/bvar.md b/docs/cn/bvar.md index f1a379b5..cdf91d74 100644 --- a/docs/cn/bvar.md +++ b/docs/cn/bvar.md @@ -92,4 +92,4 @@ process_username : "gejun" # bvar导出到其它监控系统格式 -bvar已支持的其它监控系统格式有[Prometheus](https://prometheus.io)。将Prometheus的抓取url地址的路径设置为`/brpc_prometheus_metrics`即可,例如brpc server跑在本机的8080端口,则抓取url配置为`127.0.0.1:8080/brpc_prometheus_metrics`。 +bvar已支持的其它监控系统格式有[Prometheus](https://prometheus.io)。将Prometheus的抓取url地址的路径设置为`/brpc_metrics`即可,例如brpc server跑在本机的8080端口,则抓取url配置为`127.0.0.1:8080/brpc_metrics`。 diff --git a/docs/en/bvar.md b/docs/en/bvar.md index 018d3189..c0497b6a 100644 --- a/docs/en/bvar.md +++ b/docs/en/bvar.md @@ -92,4 +92,4 @@ The monitoring system should combine data on every single machine periodically a # Dump to the format of other monitoring system -Currently monitoring system supported by bvar is [Prometheus](https://prometheus.io). All you need to do is to set the path in scraping target url to `/brpc_prometheus_metrics`. For example, if brpc server is running on localhost:8080, the scraping target should be `127.0.0.1:8080/brpc_prometheus_metrics`. +Currently monitoring system supported by bvar is [Prometheus](https://prometheus.io). All you need to do is to set the path in scraping target url to `/brpc_metrics`. For example, if brpc server is running on localhost:8080, the scraping target should be `127.0.0.1:8080/brpc_metrics`. From 81c8e7f26fc0cb8590833779ea94d64a923d5f5e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 17 Jun 2019 19:12:20 +0800 Subject: [PATCH 240/270] Make PrometheusMetricsService be global --- src/brpc/builtin/prometheus_metrics_service.cpp | 6 +++--- src/brpc/builtin/prometheus_metrics_service.h | 8 +------- src/brpc/details/server_private_accessor.h | 5 ++--- src/brpc/server.cpp | 6 ++++-- src/brpc/server.h | 1 + test/brpc_prometheus_metrics_unittest.cpp | 5 +++++ 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp b/src/brpc/builtin/prometheus_metrics_service.cpp index 1f078850..dade6808 100644 --- a/src/brpc/builtin/prometheus_metrics_service.cpp +++ b/src/brpc/builtin/prometheus_metrics_service.cpp @@ -182,15 +182,15 @@ void PrometheusMetricsService::default_method(::google::protobuf::RpcController* ClosureGuard done_guard(done); Controller *cntl = static_cast(cntl_base); cntl->http_response().set_content_type("text/plain"); - if (DumpPrometheusMetricsToIOBuf(_server, &cntl->response_attachment()) != 0) { + if (DumpPrometheusMetricsToIOBuf(&cntl->response_attachment()) != 0) { cntl->SetFailed("Fail to dump metrics"); return; } } -int DumpPrometheusMetricsToIOBuf(const Server* server, butil::IOBuf* output) { +int DumpPrometheusMetricsToIOBuf(butil::IOBuf* output) { butil::IOBufBuilder os; - PrometheusMetricsDumper dumper(&os, brpc::ServerPrivateAccessor(server).ServerPrefix()); + PrometheusMetricsDumper dumper(&os, brpc::ServerPrivateAccessor(NULL).Prefix()); const int ndump = bvar::Variable::dump_exposed(&dumper, NULL); if (ndump < 0) { return -1; diff --git a/src/brpc/builtin/prometheus_metrics_service.h b/src/brpc/builtin/prometheus_metrics_service.h index 2cdc8e47..b53907ce 100644 --- a/src/brpc/builtin/prometheus_metrics_service.h +++ b/src/brpc/builtin/prometheus_metrics_service.h @@ -24,19 +24,13 @@ namespace brpc { class PrometheusMetricsService : public brpc_metrics { public: - PrometheusMetricsService(Server* server) - : _server(server) {} - void default_method(::google::protobuf::RpcController* cntl_base, const ::brpc::MetricsRequest* request, ::brpc::MetricsResponse* response, ::google::protobuf::Closure* done) override; - -private: - Server* _server; }; -int DumpPrometheusMetricsToIOBuf(const Server* server, butil::IOBuf* output); +int DumpPrometheusMetricsToIOBuf(butil::IOBuf* output); } // namepace brpc diff --git a/src/brpc/details/server_private_accessor.h b/src/brpc/details/server_private_accessor.h index c2c4a965..a64f429e 100644 --- a/src/brpc/details/server_private_accessor.h +++ b/src/brpc/details/server_private_accessor.h @@ -30,7 +30,6 @@ namespace brpc { class ServerPrivateAccessor { public: explicit ServerPrivateAccessor(const Server* svr) { - CHECK(svr); _server = svr; } @@ -98,8 +97,8 @@ public: RestfulMap* global_restful_map() const { return _server->_global_restful_map; } - std::string ServerPrefix() const { return _server->ServerPrefix(); } - + std::string Prefix() const { return Server::Prefix(); } + private: const Server* _server; }; diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 1eefe063..5905fbf4 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -265,8 +265,10 @@ static bvar::Vector GetSessionLocalDataCount(void* arg) { return v; } +std::string Server::Prefix() { return "rpc_server"; } + std::string Server::ServerPrefix() const { - return butil::string_printf("rpc_server_%d", listen_address().port); + return butil::string_printf("%s_%d", Prefix().c_str(), listen_address().port); } void* Server::UpdateDerivedVars(void* arg) { @@ -484,7 +486,7 @@ int Server::AddBuiltinServices() { LOG(ERROR) << "Fail to add ListService"; return -1; } - if (AddBuiltinService(new (std::nothrow) PrometheusMetricsService(this))) { + if (AddBuiltinService(new (std::nothrow) PrometheusMetricsService)) { LOG(ERROR) << "Fail to add MetricsService"; return -1; } diff --git a/src/brpc/server.h b/src/brpc/server.h index 1c0968ce..6f4198a9 100644 --- a/src/brpc/server.h +++ b/src/brpc/server.h @@ -579,6 +579,7 @@ friend class Controller; const ServiceProperty* FindServicePropertyByName(const butil::StringPiece& name) const; + static std::string Prefix(); std::string ServerPrefix() const; // Mapping from hostname to corresponding SSL_CTX diff --git a/test/brpc_prometheus_metrics_unittest.cpp b/test/brpc_prometheus_metrics_unittest.cpp index 0d7eeca9..c094a6ec 100644 --- a/test/brpc_prometheus_metrics_unittest.cpp +++ b/test/brpc_prometheus_metrics_unittest.cpp @@ -40,6 +40,11 @@ TEST(PrometheusMetrics, sanity) { ASSERT_EQ(0, server.AddService(&echo_svc, brpc::SERVER_DOESNT_OWN_SERVICE)); ASSERT_EQ(0, server.Start("127.0.0.1:8614", NULL)); + brpc::Server server2; + DummyEchoServiceImpl echo_svc2; + ASSERT_EQ(0, server2.AddService(&echo_svc2, brpc::SERVER_DOESNT_OWN_SERVICE)); + ASSERT_EQ(0, server2.Start("127.0.0.1:8615", NULL)); + brpc::Channel channel; brpc::ChannelOptions channel_opts; channel_opts.protocol = "http"; From 16b9bc789982bf9246d32a90ed6d714398c004df Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 17 Jun 2019 19:16:16 +0800 Subject: [PATCH 241/270] Make ServerPrivateAccessor::Prefix static --- src/brpc/builtin/prometheus_metrics_service.cpp | 2 +- src/brpc/details/server_private_accessor.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp b/src/brpc/builtin/prometheus_metrics_service.cpp index dade6808..175d1c7c 100644 --- a/src/brpc/builtin/prometheus_metrics_service.cpp +++ b/src/brpc/builtin/prometheus_metrics_service.cpp @@ -190,7 +190,7 @@ void PrometheusMetricsService::default_method(::google::protobuf::RpcController* int DumpPrometheusMetricsToIOBuf(butil::IOBuf* output) { butil::IOBufBuilder os; - PrometheusMetricsDumper dumper(&os, brpc::ServerPrivateAccessor(NULL).Prefix()); + PrometheusMetricsDumper dumper(&os, brpc::ServerPrivateAccessor::Prefix()); const int ndump = bvar::Variable::dump_exposed(&dumper, NULL); if (ndump < 0) { return -1; diff --git a/src/brpc/details/server_private_accessor.h b/src/brpc/details/server_private_accessor.h index a64f429e..5a536b4c 100644 --- a/src/brpc/details/server_private_accessor.h +++ b/src/brpc/details/server_private_accessor.h @@ -30,6 +30,7 @@ namespace brpc { class ServerPrivateAccessor { public: explicit ServerPrivateAccessor(const Server* svr) { + CHECK(svr); _server = svr; } @@ -97,7 +98,7 @@ public: RestfulMap* global_restful_map() const { return _server->_global_restful_map; } - std::string Prefix() const { return Server::Prefix(); } + static std::string Prefix() { return Server::Prefix(); } private: const Server* _server; From efdba88fdfeb213393f31fb9ad2cb9eec2642f0d Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Mon, 17 Jun 2019 19:27:59 +0800 Subject: [PATCH 242/270] update valgrind --- LICENSE | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/LICENSE b/LICENSE index 682475db..8624a231 100644 --- a/LICENSE +++ b/LICENSE @@ -383,14 +383,10 @@ src/butil/third_party/superfasthash: licensed under the following terms: -------------------------------------------------------------------------------- -src/butil/third_party/valgrind: licensed under the following terms: +src/butil/third_party/valgrind/valgrind.h: licensed under the following terms: - Notice that the following BSD-style license applies to the Valgrind header - files used by brpc (valgrind.h). However, the rest of Valgrind is - licensed under the terms of the GNU General Public License, version 2, - unless otherwise indicated. - - ---------------------------------------------------------------- + This file is part of Valgrind, a dynamic binary instrumentation + framework. Copyright (C) 2000-2008 Julian Seward. All rights reserved. From e8226c481dd7dc71e292484e5623b9b60fc50d8b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 18 Jun 2019 13:42:35 +0800 Subject: [PATCH 243/270] Make SummaryItem::{latency_avg, count} be int64_t --- src/brpc/builtin/prometheus_metrics_service.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp b/src/brpc/builtin/prometheus_metrics_service.cpp index 175d1c7c..fa91b324 100644 --- a/src/brpc/builtin/prometheus_metrics_service.cpp +++ b/src/brpc/builtin/prometheus_metrics_service.cpp @@ -62,8 +62,8 @@ private: struct SummaryItems { std::string latency_percentiles[NPERCENTILES]; - std::string latency_avg; - std::string count; + int64_t latency_avg; + int64_t count; std::string metric_name; bool IsComplete() const { return !metric_name.empty(); } @@ -103,6 +103,7 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece& butil::string_printf("_latency_%d", (int)bvar::FLAGS_bvar_latency_p3), "_latency_999", "_latency_9999", "_max_latency" }; + std::string desc_str = desc.as_string(); CHECK(NPERCENTILES == arraysize(latency_names)); butil::StringPiece metric_name(name); for (int i = 0; i < NPERCENTILES; ++i) { @@ -111,7 +112,7 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece& } metric_name.remove_suffix(latency_names[i].size()); SummaryItems* si = &_m[metric_name.as_string()]; - si->latency_percentiles[i] = desc.as_string(); + si->latency_percentiles[i] = desc_str; if (i == NPERCENTILES - 1) { // '_max_latency' is the last suffix name that appear in the sorted bvar // list, which means all related percentiles have been gathered and we are @@ -124,13 +125,13 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece& if (metric_name.ends_with("_latency")) { metric_name.remove_suffix(8); SummaryItems* si = &_m[metric_name.as_string()]; - si->latency_avg = desc.as_string(); + si->latency_avg = strtoll(desc_str.data(), NULL, 10); return si; } if (metric_name.ends_with("_count")) { metric_name.remove_suffix(6); SummaryItems* si = &_m[metric_name.as_string()]; - si->count = desc.as_string(); + si->count = strtoll(desc_str.data(), NULL, 10); return si; } return NULL; @@ -169,8 +170,7 @@ bool PrometheusMetricsDumper::DumpLatencyRecorderSuffix( << si->metric_name << "_sum " // There is no sum of latency in bvar output, just use // average * count as approximation - << strtoll(si->latency_avg.data(), NULL, 10) * - strtoll(si->count.data(), NULL, 10) << '\n' + << si->latency_avg * si->count << '\n' << si->metric_name << "_count " << si->count << '\n'; return true; } From 8b4ac5a4f7d038eee6e91bf176ff608d2840563b Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 18 Jun 2019 13:46:25 +0800 Subject: [PATCH 244/270] minor change --- src/brpc/builtin/prometheus_metrics_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp b/src/brpc/builtin/prometheus_metrics_service.cpp index fa91b324..814ec260 100644 --- a/src/brpc/builtin/prometheus_metrics_service.cpp +++ b/src/brpc/builtin/prometheus_metrics_service.cpp @@ -103,8 +103,8 @@ PrometheusMetricsDumper::ProcessLatencyRecorderSuffix(const butil::StringPiece& butil::string_printf("_latency_%d", (int)bvar::FLAGS_bvar_latency_p3), "_latency_999", "_latency_9999", "_max_latency" }; - std::string desc_str = desc.as_string(); CHECK(NPERCENTILES == arraysize(latency_names)); + const std::string desc_str = desc.as_string(); butil::StringPiece metric_name(name); for (int i = 0; i < NPERCENTILES; ++i) { if (!metric_name.ends_with(latency_names[i])) { From 3f46212e7dcf73013c66e6826dbe7bff571df1d6 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Tue, 18 Jun 2019 18:53:28 +0800 Subject: [PATCH 245/270] Add g_server_info_prefix --- src/brpc/builtin/prometheus_metrics_service.cpp | 6 ++++-- src/brpc/builtin/prometheus_metrics_service.h | 1 - src/brpc/details/server_private_accessor.h | 3 --- src/brpc/server.cpp | 6 +++--- src/brpc/server.h | 1 - 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp b/src/brpc/builtin/prometheus_metrics_service.cpp index 814ec260..3ec3f980 100644 --- a/src/brpc/builtin/prometheus_metrics_service.cpp +++ b/src/brpc/builtin/prometheus_metrics_service.cpp @@ -22,7 +22,6 @@ #include "brpc/closure_guard.h" // ClosureGuard #include "brpc/builtin/prometheus_metrics_service.h" #include "brpc/builtin/common.h" -#include "brpc/details/server_private_accessor.h" #include "bvar/bvar.h" namespace bvar { @@ -33,6 +32,9 @@ DECLARE_int32(bvar_latency_p3); namespace brpc { +// Defined in server.cpp +extern const char* const g_server_info_prefix; + // This is a class that convert bvar result to prometheus output. // Currently the output only includes gauge and summary for two // reasons: @@ -190,7 +192,7 @@ void PrometheusMetricsService::default_method(::google::protobuf::RpcController* int DumpPrometheusMetricsToIOBuf(butil::IOBuf* output) { butil::IOBufBuilder os; - PrometheusMetricsDumper dumper(&os, brpc::ServerPrivateAccessor::Prefix()); + PrometheusMetricsDumper dumper(&os, g_server_info_prefix); const int ndump = bvar::Variable::dump_exposed(&dumper, NULL); if (ndump < 0) { return -1; diff --git a/src/brpc/builtin/prometheus_metrics_service.h b/src/brpc/builtin/prometheus_metrics_service.h index b53907ce..46935536 100644 --- a/src/brpc/builtin/prometheus_metrics_service.h +++ b/src/brpc/builtin/prometheus_metrics_service.h @@ -18,7 +18,6 @@ #define BRPC_PROMETHEUS_METRICS_SERVICE_H #include "brpc/builtin_service.pb.h" -#include "brpc/server.h" namespace brpc { diff --git a/src/brpc/details/server_private_accessor.h b/src/brpc/details/server_private_accessor.h index 5a536b4c..4b4992b2 100644 --- a/src/brpc/details/server_private_accessor.h +++ b/src/brpc/details/server_private_accessor.h @@ -22,7 +22,6 @@ #include "brpc/builtin/bad_method_service.h" #include "brpc/restful.h" - namespace brpc { // A wrapper to access some private methods/fields of `Server' @@ -98,8 +97,6 @@ public: RestfulMap* global_restful_map() const { return _server->_global_restful_map; } - static std::string Prefix() { return Server::Prefix(); } - private: const Server* _server; }; diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 5905fbf4..36a49d7e 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -92,6 +92,8 @@ namespace brpc { BAIDU_CASSERT(sizeof(int32_t) == sizeof(butil::subtle::Atomic32), Atomic32_must_be_int32); +extern const char* const g_server_info_prefix = "rpc_server"; + const char* status_str(Server::Status s) { switch (s) { case Server::UNINITIALIZED: return "UNINITIALIZED"; @@ -265,10 +267,8 @@ static bvar::Vector GetSessionLocalDataCount(void* arg) { return v; } -std::string Server::Prefix() { return "rpc_server"; } - std::string Server::ServerPrefix() const { - return butil::string_printf("%s_%d", Prefix().c_str(), listen_address().port); + return butil::string_printf("%s_%d", g_server_info_prefix, listen_address().port); } void* Server::UpdateDerivedVars(void* arg) { diff --git a/src/brpc/server.h b/src/brpc/server.h index 6f4198a9..1c0968ce 100644 --- a/src/brpc/server.h +++ b/src/brpc/server.h @@ -579,7 +579,6 @@ friend class Controller; const ServiceProperty* FindServicePropertyByName(const butil::StringPiece& name) const; - static std::string Prefix(); std::string ServerPrefix() const; // Mapping from hostname to corresponding SSL_CTX From 423b51caeef142b82e67df9d5141af09ed4a4114 Mon Sep 17 00:00:00 2001 From: Ge Jun Date: Wed, 19 Jun 2019 05:09:08 +0100 Subject: [PATCH 246/270] minor change to http_client.md --- docs/cn/http_client.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/cn/http_client.md b/docs/cn/http_client.md index 9a892b69..d6695780 100644 --- a/docs/cn/http_client.md +++ b/docs/cn/http_client.md @@ -158,14 +158,15 @@ std::string str = cntl->request_attachment().to_string(); // 有拷贝 设置body ```c++ cntl->request_attachment().append("...."); -butil::IOBufBuilder os; os << "...."; +butil::IOBufBuilder os; +os << "...."; os.move_to(cntl->request_attachment()); ``` Notes on http header: -- 根据[rfc2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2),header的field_name部分不区分大小写。brpc支持大小写不敏感,同时还能在打印时保持field_name大小写与用户设定的相同。 -- 如果HTTP头中出现了相同的field_name, 根据[rfc2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2),value应合并到一起,用逗号(,)分隔,用户自己确定如何理解和处理此类value. +- 根据[rfc2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2),http header的field_name不区分大小写。brpc支持大小写不敏感,同时会在打印时保持用户传入的大小写。 +- 若http header中出现了相同的field_name, 根据[rfc2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2),value应合并到一起,用逗号(,)分隔,用户自行处理. - query之间用"&"分隔, key和value之间用"="分隔, value可以省略,比如key1=value1&key2&key3=value3中key2是合理的query,值为空字符串。 # 查看HTTP消息 @@ -251,4 +252,4 @@ brpc client支持在读取完body前就结束RPC,让用户在RPC结束后再 根据Server的认证方式生成对应的auth_data,并设置为http header "Authorization"的值。比如用的是curl,那就加上选项`-H "Authorization : "。` # 发送https请求 -https是http over SSL的简称,SSL并不是http特有的,而是对所有协议都有效。开启客户端SSL的一般性方法见[这里](client.md#开启ssl)。为方便使用,brpc会对https://开头的uri自动开启SSL。 +https是http over SSL的简称,SSL并不是http特有的,而是对所有协议都有效。开启客户端SSL的一般性方法见[这里](client.md#开启ssl)。为方便使用,brpc会对https开头的uri自动开启SSL。 From e5279adaa94bcfb44ded18ac057287d764b62462 Mon Sep 17 00:00:00 2001 From: Ge Jun Date: Wed, 19 Jun 2019 05:20:15 +0100 Subject: [PATCH 247/270] Unify callings of http protocols --- docs/cn/client.md | 6 +++--- docs/cn/http_client.md | 4 ++-- docs/en/client.md | 6 +++--- docs/en/http_client.md | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/cn/client.md b/docs/cn/client.md index 8e0961ad..616e8e1a 100755 --- a/docs/cn/client.md +++ b/docs/cn/client.md @@ -599,7 +599,7 @@ Channel的默认协议是baidu_std,可通过设置ChannelOptions.protocol换 - PROTOCOL_HTTP 或 ”http", http/1.0或http/1.1协议,默认为连接池(Keep-Alive)。 - 访问普通http服务的方法见[访问http/h2服务](http_client.md) - 通过http:json或http:proto访问pb服务的方法见[http/h2衍生协议](http_derivatives.md) -- PROTOCOL_H2 或 ”h2", http/2.0协议,默认是单连接。 +- PROTOCOL_H2 或 ”h2", http/2协议,默认是单连接。 - 访问普通h2服务的方法见[访问http/h2服务](http_client.md)。 - 通过h2:json或h2:proto访问pb服务的方法见[http/h2衍生协议](http_derivatives.md) - "h2:grpc", [gRPC](https://grpc.io)的协议,也是h2的衍生协议,默认为单连接,具体见[h2:grpc](http_derivatives.md#h2grpc)。 @@ -620,8 +620,8 @@ Channel的默认协议是baidu_std,可通过设置ChannelOptions.protocol换 brpc支持以下连接方式: -- 短连接:每次RPC前建立连接,结束后关闭连接。由于每次调用得有建立连接的开销,这种方式一般用于偶尔发起的操作,而不是持续发起请求的场景。没有协议默认使用这种连接方式,http 1.0对连接的处理效果类似短链接。 -- 连接池:每次RPC前取用空闲连接,结束后归还,一个连接上最多只有一个请求,一个client对一台server可能有多条连接。http 1.1和各类使用nshead的协议都是这个方式。 +- 短连接:每次RPC前建立连接,结束后关闭连接。由于每次调用得有建立连接的开销,这种方式一般用于偶尔发起的操作,而不是持续发起请求的场景。没有协议默认使用这种连接方式,http/1.0对连接的处理效果类似短链接。 +- 连接池:每次RPC前取用空闲连接,结束后归还,一个连接上最多只有一个请求,一个client对一台server可能有多条连接。http/1.1和各类使用nshead的协议都是这个方式。 - 单连接:进程内所有client与一台server最多只有一个连接,一个连接上可能同时有多个请求,回复返回顺序和请求顺序不需要一致,这是baidu_std,hulu_pbrpc,sofa_pbrpc协议的默认选项。 | | 短连接 | 连接池 | 单连接 | diff --git a/docs/cn/http_client.md b/docs/cn/http_client.md index d6695780..f551ebc5 100644 --- a/docs/cn/http_client.md +++ b/docs/cn/http_client.md @@ -64,9 +64,9 @@ channel.CallMethod(NULL, &cntl, NULL, NULL, NULL/*done*/); ``` # 控制HTTP版本 -brpc的http行为默认是http 1.1。 +brpc的http行为默认是http/1.1。 -http 1.0相比1.1缺少长连接功能,brpc client与一些古老的http server通信时可能需要按如下方法设置为1.0。 +http/1.0相比http/1.1缺少长连接功能,brpc client与一些古老的http server通信时可能需要按如下方法设置为1.0。 ```c++ cntl.http_request().set_version(1, 0); ``` diff --git a/docs/en/client.md b/docs/en/client.md index eaf136e6..8bd7fec5 100644 --- a/docs/en/client.md +++ b/docs/en/client.md @@ -602,7 +602,7 @@ The default protocol used by Channel is baidu_std, which is changeable by settin - PROTOCOL_HTTP or "http", which is http/1.0 or http/1.1, using pooled connection by default (Keep-Alive). - Methods for accessing ordinary http services are listed in [Access http/h2](http_client.md). - Methods for accessing pb services by using http:json or http:proto are listed in [http/h2 derivatives](http_derivatives.md) -- PROTOCOL_H2 or ”h2", which is http/2.0, using single connection by default. +- PROTOCOL_H2 or ”h2", which is http/2, using single connection by default. - Methods for accessing ordinary h2 services are listed in [Access http/h2](http_client.md). - Methods for accessing pb services by using h2:json or h2:proto are listed in [http/h2 derivatives](http_derivatives.md) - "h2:grpc", which is the protocol of [gRPC](https://grpc.io) and based on h2, using single connection by default, check out [h2:grpc](http_derivatives.md#h2grpc) for details. @@ -623,8 +623,8 @@ The default protocol used by Channel is baidu_std, which is changeable by settin brpc supports following connection types: -- short connection: Established before each RPC, closed after completion. Since each RPC has to pay the overhead of establishing connection, this type is used for occasionally launched RPC, not frequently launched ones. No protocol use this type by default. Connections in http 1.0 are handled similarly as short connections. -- pooled connection: Pick an unused connection from a pool before each RPC, return after completion. One connection carries at most one request at the same time. One client may have multiple connections to one server. http 1.1 and the protocols using nshead use this type by default. +- short connection: Established before each RPC, closed after completion. Since each RPC has to pay the overhead of establishing connection, this type is used for occasionally launched RPC, not frequently launched ones. No protocol use this type by default. Connections in http/1.0 are handled similarly as short connections. +- pooled connection: Pick an unused connection from a pool before each RPC, return after completion. One connection carries at most one request at the same time. One client may have multiple connections to one server. http/1.1 and the protocols using nshead use this type by default. - single connection: all clients in one process has at most one connection to one server, one connection may carry multiple requests at the same time. The sequence of received responses does not need to be same as sending requests. This type is used by baidu_std, hulu_pbrpc, sofa_pbrpc by default. | | short connection | pooled connection | single connection | diff --git a/docs/en/http_client.md b/docs/en/http_client.md index 78c0bc31..a350aa29 100644 --- a/docs/en/http_client.md +++ b/docs/en/http_client.md @@ -65,9 +65,9 @@ channel.CallMethod(NULL, &cntl, NULL, NULL, NULL/*done*/); # Change HTTP version -brpc behaves as http 1.1 by default. +brpc behaves as http/1.1 by default. -Comparing to 1.1, http 1.0 lacks of long connections(KeepAlive). To communicate brpc client with some legacy http servers, the client may be configured as follows: +Comparing to http/1.1, http/1.0 lacks of long connections(KeepAlive). To communicate brpc client with some legacy http servers, the client may be configured as follows: ```c++ cntl.http_request().set_version(1, 0); ``` From 3c1a726fffaa9fca6faa5894d3fcd941863559de Mon Sep 17 00:00:00 2001 From: wenweihu86 Date: Wed, 19 Jun 2019 16:37:09 +0800 Subject: [PATCH 248/270] update openssl path --- config_brpc.sh | 16 ++++++++++------ docs/cn/getting_started.md | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config_brpc.sh b/config_brpc.sh index c5970fd1..c236c050 100755 --- a/config_brpc.sh +++ b/config_brpc.sh @@ -136,12 +136,16 @@ find_dir_of_header_or_die() { $ECHO $dir } -# User specified path of openssl, if not given it's empty -OPENSSL_LIB=$(find_dir_of_lib ssl) - -# Inconvenient to check these headers in baidu-internal -#PTHREAD_HDR=$(find_dir_of_header_or_die pthread.h) -OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h) +if [ "$SYSTEM" = "Darwin" ]; then + OPENSSL_LIB="/usr/local/opt/openssl/lib" + OPENSSL_HDR="/usr/local/opt/openssl/include" +else + # User specified path of openssl, if not given it's empty + OPENSSL_LIB=$(find_dir_of_lib ssl) + # Inconvenient to check these headers in baidu-internal + #PTHREAD_HDR=$(find_dir_of_header_or_die pthread.h) + OPENSSL_HDR=$(find_dir_of_header_or_die openssl/ssl.h) +fi if [ $WITH_MESALINK != 0 ]; then MESALINK_HDR=$(find_dir_of_header_or_die mesalink/openssl/ssl.h) diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index 9369d831..dbab05c3 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -278,7 +278,7 @@ git clone https://github.com/google/googletest && cd googletest/googletest && mk ### Compile brpc with config_brpc.sh git clone brpc, cd into the repo and run ```shell -$ sh config_brpc.sh --headers=/usr/local --libs=/usr/local --cc=clang --cxx=clang++ +$ sh config_brpc.sh --headers=/usr/local/include --libs=/usr/local/lib --cc=clang --cxx=clang++ $ make ``` To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller. From 508d85ce54f0b1130d52647b568a890e95306271 Mon Sep 17 00:00:00 2001 From: wenweihu86 Date: Wed, 19 Jun 2019 21:42:34 +0800 Subject: [PATCH 249/270] revert README --- README.md | 6 +----- README_cn.md | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b4976a0f..21009d1a 100755 --- a/README.md +++ b/README.md @@ -22,14 +22,10 @@ You can use it to: * Get [better latency and throughput](docs/en/overview.md#better-latency-and-throughput). * [Extend brpc](docs/en/new_protocol.md) with the protocols used in your organization quickly, or customize components, including [naming services](docs/cn/load_balancing.md#命名服务) (dns, zk, etcd), [load balancers](docs/cn/load_balancing.md#负载均衡) (rr, random, consistent hashing) -# How to build - -* Read [getting started](docs/cn/getting_started.md) for building steps. - # Try it! * Read [overview](docs/en/overview.md) to know where brpc can be used and its advantages. -* Play with [examples](https://github.com/brpc/brpc/tree/master/example/). +* Read [getting started](docs/cn/getting_started.md) for building steps and play with [examples](https://github.com/brpc/brpc/tree/master/example/). * Docs: * [Performance benchmark](docs/cn/benchmark.md) * [bvar](docs/en/bvar.md) diff --git a/README_cn.md b/README_cn.md index a9ada550..819b25f1 100755 --- a/README_cn.md +++ b/README_cn.md @@ -23,14 +23,10 @@ * 获得[更好的延时和吞吐](docs/cn/overview.md#更好的延时和吞吐). * 把你组织中使用的协议快速地[加入brpc](docs/cn/new_protocol.md),或定制各类组件, 包括[命名服务](docs/cn/load_balancing.md#命名服务) (dns, zk, etcd), [负载均衡](docs/cn/load_balancing.md#负载均衡) (rr, random, consistent hashing) -# 如何编译 - -* 请阅读[编译步骤](docs/cn/getting_started.md)了解如何开始使用. - # 试一下! * 通过[概述](docs/cn/overview.md)了解哪里可以用brpc及其优势。 -* 可以运行一下[示例程序](https://github.com/brpc/brpc/tree/master/example/). +* 阅读[编译步骤](docs/cn/getting_started.md)了解如何开始使用, 之后可以运行一下[示例程序](https://github.com/brpc/brpc/tree/master/example/). * 文档: * [性能测试](docs/cn/benchmark.md) * [bvar](docs/cn/bvar.md) From 078051f9bfd3f0519900234f14c3459fa3bb6888 Mon Sep 17 00:00:00 2001 From: Weibing Wang Date: Thu, 20 Jun 2019 14:10:07 +0800 Subject: [PATCH 250/270] Update license header to Apache --- example/asynchronous_echo_c++/client.cpp | 29 ++++++++-------- example/asynchronous_echo_c++/server.cpp | 29 ++++++++-------- example/auto_concurrency_limiter/client.cpp | 29 ++++++++-------- example/auto_concurrency_limiter/server.cpp | 29 ++++++++-------- example/backup_request_c++/client.cpp | 29 ++++++++-------- example/backup_request_c++/server.cpp | 29 ++++++++-------- example/cancel_c++/client.cpp | 29 ++++++++-------- example/cancel_c++/server.cpp | 29 ++++++++-------- example/cascade_echo_c++/client.cpp | 29 ++++++++-------- example/cascade_echo_c++/server.cpp | 29 ++++++++-------- example/dynamic_partition_echo_c++/client.cpp | 29 ++++++++-------- example/dynamic_partition_echo_c++/server.cpp | 29 ++++++++-------- example/echo_c++/client.cpp | 29 ++++++++-------- example/echo_c++/server.cpp | 29 ++++++++-------- example/echo_c++_hulu_pbrpc/client.cpp | 29 ++++++++-------- example/echo_c++_hulu_pbrpc/server.cpp | 29 ++++++++-------- example/echo_c++_sofa_pbrpc/client.cpp | 29 ++++++++-------- example/echo_c++_sofa_pbrpc/server.cpp | 29 ++++++++-------- example/echo_c++_ubrpc_compack/client.cpp | 29 ++++++++-------- .../echo_c++_ubrpc_compack/idl_options.proto | 3 -- example/echo_c++_ubrpc_compack/server.cpp | 29 ++++++++-------- example/grpc_c++/client.cpp | 29 ++++++++-------- example/grpc_c++/server.cpp | 25 +++++++------- example/http_c++/benchmark_http.cpp | 29 ++++++++-------- example/http_c++/http_client.cpp | 29 ++++++++-------- example/http_c++/http_server.cpp | 29 ++++++++-------- example/memcache_c++/client.cpp | 29 ++++++++-------- example/multi_threaded_echo_c++/client.cpp | 29 ++++++++-------- example/multi_threaded_echo_c++/server.cpp | 29 ++++++++-------- .../multi_threaded_echo_fns_c++/client.cpp | 29 ++++++++-------- .../multi_threaded_echo_fns_c++/server.cpp | 29 ++++++++-------- example/multi_threaded_mcpack_c++/client.cpp | 29 ++++++++-------- .../idl_options.proto | 3 -- example/multi_threaded_mcpack_c++/server.cpp | 29 ++++++++-------- example/nshead_extension_c++/client.cpp | 29 ++++++++-------- example/nshead_extension_c++/server.cpp | 29 ++++++++-------- example/nshead_pb_extension_c++/client.cpp | 29 ++++++++-------- example/nshead_pb_extension_c++/server.cpp | 29 ++++++++-------- example/parallel_echo_c++/client.cpp | 29 ++++++++-------- example/parallel_echo_c++/server.cpp | 29 ++++++++-------- example/partition_echo_c++/client.cpp | 29 ++++++++-------- example/partition_echo_c++/server.cpp | 29 ++++++++-------- example/redis_c++/redis_cli.cpp | 29 ++++++++-------- example/redis_c++/redis_press.cpp | 29 ++++++++-------- example/selective_echo_c++/client.cpp | 29 ++++++++-------- example/selective_echo_c++/server.cpp | 29 ++++++++-------- .../session_data_and_thread_local/client.cpp | 29 ++++++++-------- .../session_data_and_thread_local/server.cpp | 29 ++++++++-------- example/streaming_echo_c++/client.cpp | 29 ++++++++-------- example/streaming_echo_c++/server.cpp | 29 ++++++++-------- example/thrift_extension_c++/client.cpp | 29 ++++++++-------- example/thrift_extension_c++/client2.cpp | 29 ++++++++-------- .../thrift_extension_c++/native_client.cpp | 25 +++++++------- .../thrift_extension_c++/native_server.cpp | 25 +++++++------- example/thrift_extension_c++/server.cpp | 29 ++++++++-------- example/thrift_extension_c++/server2.cpp | 29 ++++++++-------- src/brpc/acceptor.cpp | 29 ++++++++-------- src/brpc/acceptor.h | 29 ++++++++-------- src/brpc/adaptive_connection_type.cpp | 29 ++++++++-------- src/brpc/adaptive_connection_type.h | 25 +++++++------- src/brpc/adaptive_max_concurrency.cpp | 27 +++++++-------- src/brpc/adaptive_max_concurrency.h | 27 +++++++-------- src/brpc/adaptive_protocol_type.h | 25 +++++++------- src/brpc/amf.cpp | 29 ++++++++-------- src/brpc/amf.h | 29 ++++++++-------- src/brpc/amf_inl.h | 29 ++++++++-------- src/brpc/authenticator.h | 29 ++++++++-------- src/brpc/builtin/bad_method_service.cpp | 29 ++++++++-------- src/brpc/builtin/bad_method_service.h | 29 ++++++++-------- src/brpc/builtin/bthreads_service.cpp | 29 ++++++++-------- src/brpc/builtin/bthreads_service.h | 29 ++++++++-------- src/brpc/builtin/common.cpp | 29 ++++++++-------- src/brpc/builtin/common.h | 29 ++++++++-------- src/brpc/builtin/connections_service.cpp | 29 ++++++++-------- src/brpc/builtin/connections_service.h | 29 ++++++++-------- src/brpc/builtin/dir_service.cpp | 29 ++++++++-------- src/brpc/builtin/dir_service.h | 29 ++++++++-------- src/brpc/builtin/flags_service.cpp | 25 +++++++------- src/brpc/builtin/flags_service.h | 29 ++++++++-------- src/brpc/builtin/flot_min_js.cpp | 29 ++++++++-------- src/brpc/builtin/flot_min_js.h | 29 ++++++++-------- src/brpc/builtin/get_favicon_service.cpp | 29 ++++++++-------- src/brpc/builtin/get_favicon_service.h | 29 ++++++++-------- src/brpc/builtin/get_js_service.cpp | 29 ++++++++-------- src/brpc/builtin/get_js_service.h | 29 ++++++++-------- src/brpc/builtin/health_service.cpp | 29 ++++++++-------- src/brpc/builtin/health_service.h | 29 ++++++++-------- src/brpc/builtin/hotspots_service.cpp | 29 ++++++++-------- src/brpc/builtin/hotspots_service.h | 29 ++++++++-------- src/brpc/builtin/ids_service.cpp | 29 ++++++++-------- src/brpc/builtin/ids_service.h | 29 ++++++++-------- src/brpc/builtin/index_service.cpp | 29 ++++++++-------- src/brpc/builtin/index_service.h | 29 ++++++++-------- src/brpc/builtin/jquery_min_js.cpp | 29 ++++++++-------- src/brpc/builtin/jquery_min_js.h | 29 ++++++++-------- src/brpc/builtin/list_service.cpp | 29 ++++++++-------- src/brpc/builtin/list_service.h | 29 ++++++++-------- src/brpc/builtin/pprof_perl.h | 29 ++++++++-------- src/brpc/builtin/pprof_service.cpp | 29 ++++++++-------- src/brpc/builtin/pprof_service.h | 29 ++++++++-------- .../builtin/prometheus_metrics_service.cpp | 25 +++++++------- src/brpc/builtin/prometheus_metrics_service.h | 25 +++++++------- src/brpc/builtin/protobufs_service.cpp | 29 ++++++++-------- src/brpc/builtin/protobufs_service.h | 29 ++++++++-------- src/brpc/builtin/rpcz_service.cpp | 29 ++++++++-------- src/brpc/builtin/rpcz_service.h | 29 ++++++++-------- src/brpc/builtin/sockets_service.cpp | 29 ++++++++-------- src/brpc/builtin/sockets_service.h | 29 ++++++++-------- src/brpc/builtin/sorttable_js.cpp | 29 ++++++++-------- src/brpc/builtin/sorttable_js.h | 29 ++++++++-------- src/brpc/builtin/status_service.cpp | 29 ++++++++-------- src/brpc/builtin/status_service.h | 29 ++++++++-------- src/brpc/builtin/tabbed.h | 29 ++++++++-------- src/brpc/builtin/threads_service.cpp | 29 ++++++++-------- src/brpc/builtin/threads_service.h | 29 ++++++++-------- src/brpc/builtin/vars_service.cpp | 29 ++++++++-------- src/brpc/builtin/vars_service.h | 29 ++++++++-------- src/brpc/builtin/version_service.cpp | 29 ++++++++-------- src/brpc/builtin/version_service.h | 29 ++++++++-------- src/brpc/builtin/viz_min_js.cpp | 29 ++++++++-------- src/brpc/builtin/viz_min_js.h | 29 ++++++++-------- src/brpc/builtin/vlog_service.cpp | 29 ++++++++-------- src/brpc/builtin/vlog_service.h | 29 ++++++++-------- src/brpc/channel.cpp | 29 ++++++++-------- src/brpc/channel.h | 29 ++++++++-------- src/brpc/channel_base.h | 29 ++++++++-------- src/brpc/circuit_breaker.cpp | 27 +++++++-------- src/brpc/circuit_breaker.h | 27 +++++++-------- src/brpc/closure_guard.h | 29 ++++++++-------- src/brpc/cluster_recover_policy.cpp | 29 ++++++++-------- src/brpc/cluster_recover_policy.h | 29 ++++++++-------- src/brpc/compress.cpp | 29 ++++++++-------- src/brpc/compress.h | 29 ++++++++-------- src/brpc/concurrency_limiter.h | 27 +++++++-------- src/brpc/controller.cpp | 29 ++++++++-------- src/brpc/controller.h | 29 ++++++++-------- src/brpc/data_factory.h | 29 ++++++++-------- src/brpc/describable.h | 29 ++++++++-------- src/brpc/destroyable.h | 29 ++++++++-------- .../details/controller_private_accessor.h | 29 ++++++++-------- src/brpc/details/has_epollrdhup.cpp | 29 ++++++++-------- src/brpc/details/has_epollrdhup.h | 29 ++++++++-------- src/brpc/details/health_check.cpp | 29 ++++++++-------- src/brpc/details/health_check.h | 29 ++++++++-------- src/brpc/details/hpack-static-table.h | 29 ++++++++-------- src/brpc/details/hpack.cpp | 29 ++++++++-------- src/brpc/details/hpack.h | 29 ++++++++-------- src/brpc/details/http_message.cpp | 29 ++++++++-------- src/brpc/details/http_message.h | 29 ++++++++-------- .../details/load_balancer_with_naming.cpp | 29 ++++++++-------- src/brpc/details/load_balancer_with_naming.h | 29 ++++++++-------- src/brpc/details/mesalink_ssl_helper.cpp | 29 ++++++++-------- src/brpc/details/method_status.cpp | 29 ++++++++-------- src/brpc/details/method_status.h | 29 ++++++++-------- src/brpc/details/naming_service_thread.cpp | 29 ++++++++-------- src/brpc/details/naming_service_thread.h | 29 ++++++++-------- src/brpc/details/profiler_linker.h | 29 ++++++++-------- src/brpc/details/rtmp_utils.cpp | 29 ++++++++-------- src/brpc/details/rtmp_utils.h | 29 ++++++++-------- src/brpc/details/server_private_accessor.h | 29 ++++++++-------- src/brpc/details/sparse_minute_counter.h | 29 ++++++++-------- src/brpc/details/ssl_helper.cpp | 29 ++++++++-------- src/brpc/details/ssl_helper.h | 29 ++++++++-------- src/brpc/details/usercode_backup_pool.cpp | 29 ++++++++-------- src/brpc/details/usercode_backup_pool.h | 29 ++++++++-------- src/brpc/esp_head.h | 29 ++++++++-------- src/brpc/esp_message.cpp | 29 ++++++++-------- src/brpc/esp_message.h | 29 ++++++++-------- src/brpc/event_dispatcher.cpp | 29 ++++++++-------- src/brpc/event_dispatcher.h | 29 ++++++++-------- src/brpc/excluded_servers.h | 29 ++++++++-------- src/brpc/extension.h | 29 ++++++++-------- src/brpc/extension_inl.h | 29 ++++++++-------- src/brpc/global.cpp | 25 +++++++------- src/brpc/global.h | 29 ++++++++-------- src/brpc/grpc.cpp | 29 ++++++++-------- src/brpc/grpc.h | 29 ++++++++-------- src/brpc/health_reporter.h | 29 ++++++++-------- src/brpc/http2.cpp | 29 ++++++++-------- src/brpc/http2.h | 29 ++++++++-------- src/brpc/http_header.cpp | 29 ++++++++-------- src/brpc/http_header.h | 29 ++++++++-------- src/brpc/http_method.cpp | 29 ++++++++-------- src/brpc/http_method.h | 29 ++++++++-------- src/brpc/http_status_code.cpp | 29 ++++++++-------- src/brpc/http_status_code.h | 29 ++++++++-------- src/brpc/input_message_base.h | 29 ++++++++-------- src/brpc/input_messenger.cpp | 29 ++++++++-------- src/brpc/input_messenger.h | 29 ++++++++-------- src/brpc/load_balancer.cpp | 29 ++++++++-------- src/brpc/load_balancer.h | 29 ++++++++-------- src/brpc/log.h | 29 ++++++++-------- src/brpc/memcache.cpp | 29 ++++++++-------- src/brpc/memcache.h | 29 ++++++++-------- src/brpc/mongo_head.h | 29 ++++++++-------- src/brpc/mongo_service_adaptor.h | 29 ++++++++-------- src/brpc/naming_service.h | 29 ++++++++-------- src/brpc/naming_service_filter.h | 29 ++++++++-------- src/brpc/nshead.h | 29 ++++++++-------- src/brpc/nshead_message.cpp | 29 ++++++++-------- src/brpc/nshead_message.h | 29 ++++++++-------- src/brpc/nshead_pb_service_adaptor.cpp | 29 ++++++++-------- src/brpc/nshead_pb_service_adaptor.h | 29 ++++++++-------- src/brpc/nshead_service.cpp | 29 ++++++++-------- src/brpc/nshead_service.h | 29 ++++++++-------- src/brpc/parallel_channel.cpp | 29 ++++++++-------- src/brpc/parallel_channel.h | 29 ++++++++-------- src/brpc/parse_result.h | 29 ++++++++-------- src/brpc/partition_channel.cpp | 29 ++++++++-------- src/brpc/partition_channel.h | 29 ++++++++-------- src/brpc/periodic_naming_service.cpp | 29 ++++++++-------- src/brpc/periodic_naming_service.h | 29 ++++++++-------- src/brpc/periodic_task.cpp | 29 ++++++++-------- src/brpc/periodic_task.h | 29 ++++++++-------- src/brpc/policy/auto_concurrency_limiter.cpp | 27 +++++++-------- src/brpc/policy/auto_concurrency_limiter.h | 27 +++++++-------- src/brpc/policy/baidu_naming_service.cpp | 29 ++++++++-------- src/brpc/policy/baidu_naming_service.h | 29 ++++++++-------- src/brpc/policy/baidu_rpc_protocol.cpp | 29 ++++++++-------- src/brpc/policy/baidu_rpc_protocol.h | 29 ++++++++-------- .../consistent_hashing_load_balancer.cpp | 29 ++++++++-------- .../policy/consistent_hashing_load_balancer.h | 29 ++++++++-------- .../policy/constant_concurrency_limiter.cpp | 27 +++++++-------- .../policy/constant_concurrency_limiter.h | 27 +++++++-------- src/brpc/policy/consul_naming_service.cpp | 25 +++++++------- src/brpc/policy/consul_naming_service.h | 25 +++++++------- src/brpc/policy/couchbase_authenticator.cpp | 27 +++++++-------- src/brpc/policy/couchbase_authenticator.h | 27 +++++++-------- src/brpc/policy/discovery_naming_service.cpp | 25 +++++++------- src/brpc/policy/discovery_naming_service.h | 25 +++++++------- src/brpc/policy/domain_naming_service.cpp | 29 ++++++++-------- src/brpc/policy/domain_naming_service.h | 29 ++++++++-------- src/brpc/policy/dynpart_load_balancer.cpp | 29 ++++++++-------- src/brpc/policy/dynpart_load_balancer.h | 29 ++++++++-------- src/brpc/policy/esp_authenticator.cpp | 29 ++++++++-------- src/brpc/policy/esp_authenticator.h | 29 ++++++++-------- src/brpc/policy/esp_protocol.cpp | 29 ++++++++-------- src/brpc/policy/esp_protocol.h | 29 ++++++++-------- src/brpc/policy/file_naming_service.cpp | 29 ++++++++-------- src/brpc/policy/file_naming_service.h | 25 +++++++------- src/brpc/policy/giano_authenticator.cpp | 29 ++++++++-------- src/brpc/policy/giano_authenticator.h | 29 ++++++++-------- src/brpc/policy/gzip_compress.cpp | 29 ++++++++-------- src/brpc/policy/gzip_compress.h | 29 ++++++++-------- src/brpc/policy/hasher.cpp | 29 ++++++++-------- src/brpc/policy/hasher.h | 29 ++++++++-------- src/brpc/policy/http2_rpc_protocol.cpp | 29 ++++++++-------- src/brpc/policy/http2_rpc_protocol.h | 29 ++++++++-------- src/brpc/policy/http_rpc_protocol.cpp | 29 ++++++++-------- src/brpc/policy/http_rpc_protocol.h | 29 ++++++++-------- src/brpc/policy/hulu_pbrpc_controller.h | 29 ++++++++-------- src/brpc/policy/hulu_pbrpc_protocol.cpp | 29 ++++++++-------- src/brpc/policy/hulu_pbrpc_protocol.h | 29 ++++++++-------- src/brpc/policy/list_naming_service.cpp | 29 ++++++++-------- src/brpc/policy/list_naming_service.h | 29 ++++++++-------- .../policy/locality_aware_load_balancer.cpp | 29 ++++++++-------- .../policy/locality_aware_load_balancer.h | 29 ++++++++-------- src/brpc/policy/memcache_binary_header.h | 29 ++++++++-------- src/brpc/policy/memcache_binary_protocol.cpp | 29 ++++++++-------- src/brpc/policy/memcache_binary_protocol.h | 29 ++++++++-------- src/brpc/policy/mongo_protocol.cpp | 29 ++++++++-------- src/brpc/policy/mongo_protocol.h | 29 ++++++++-------- src/brpc/policy/most_common_message.h | 29 ++++++++-------- src/brpc/policy/nova_pbrpc_protocol.cpp | 29 ++++++++-------- src/brpc/policy/nova_pbrpc_protocol.h | 29 ++++++++-------- src/brpc/policy/nshead_mcpack_protocol.cpp | 29 ++++++++-------- src/brpc/policy/nshead_mcpack_protocol.h | 29 ++++++++-------- src/brpc/policy/nshead_protocol.cpp | 29 ++++++++-------- src/brpc/policy/nshead_protocol.h | 29 ++++++++-------- src/brpc/policy/public_pbrpc_protocol.cpp | 29 ++++++++-------- src/brpc/policy/public_pbrpc_protocol.h | 29 ++++++++-------- src/brpc/policy/randomized_load_balancer.cpp | 29 ++++++++-------- src/brpc/policy/randomized_load_balancer.h | 29 ++++++++-------- src/brpc/policy/redis_authenticator.cpp | 27 +++++++-------- src/brpc/policy/redis_authenticator.h | 27 +++++++-------- src/brpc/policy/redis_protocol.cpp | 25 +++++++------- src/brpc/policy/redis_protocol.h | 29 ++++++++-------- .../policy/remote_file_naming_service.cpp | 29 ++++++++-------- src/brpc/policy/remote_file_naming_service.h | 29 ++++++++-------- src/brpc/policy/round_robin_load_balancer.cpp | 29 ++++++++-------- src/brpc/policy/round_robin_load_balancer.h | 29 ++++++++-------- src/brpc/policy/rtmp_protocol.cpp | 29 ++++++++-------- src/brpc/policy/rtmp_protocol.h | 29 ++++++++-------- src/brpc/policy/snappy_compress.cpp | 29 ++++++++-------- src/brpc/policy/snappy_compress.h | 29 ++++++++-------- src/brpc/policy/sofa_pbrpc_protocol.cpp | 29 ++++++++-------- src/brpc/policy/sofa_pbrpc_protocol.h | 29 ++++++++-------- src/brpc/policy/streaming_rpc_protocol.cpp | 29 ++++++++-------- src/brpc/policy/streaming_rpc_protocol.h | 29 ++++++++-------- src/brpc/policy/thrift_protocol.cpp | 29 ++++++++-------- src/brpc/policy/thrift_protocol.h | 29 ++++++++-------- src/brpc/policy/ubrpc2pb_protocol.cpp | 29 ++++++++-------- src/brpc/policy/ubrpc2pb_protocol.h | 29 ++++++++-------- .../weighted_round_robin_load_balancer.cpp | 31 +++++++++-------- .../weighted_round_robin_load_balancer.h | 29 ++++++++-------- src/brpc/progressive_attachment.cpp | 29 ++++++++-------- src/brpc/progressive_attachment.h | 29 ++++++++-------- src/brpc/progressive_reader.h | 29 ++++++++-------- src/brpc/protocol.cpp | 29 ++++++++-------- src/brpc/protocol.h | 29 ++++++++-------- src/brpc/redis.cpp | 29 ++++++++-------- src/brpc/redis.h | 29 ++++++++-------- src/brpc/redis_command.cpp | 29 ++++++++-------- src/brpc/redis_command.h | 29 ++++++++-------- src/brpc/redis_reply.cpp | 29 ++++++++-------- src/brpc/redis_reply.h | 29 ++++++++-------- src/brpc/reloadable_flags.cpp | 29 ++++++++-------- src/brpc/reloadable_flags.h | 29 ++++++++-------- src/brpc/restful.cpp | 29 ++++++++-------- src/brpc/restful.h | 29 ++++++++-------- src/brpc/retry_policy.cpp | 29 ++++++++-------- src/brpc/retry_policy.h | 29 ++++++++-------- src/brpc/rpc_dump.cpp | 29 ++++++++-------- src/brpc/rpc_dump.h | 29 ++++++++-------- src/brpc/rtmp.cpp | 29 ++++++++-------- src/brpc/rtmp.h | 29 ++++++++-------- src/brpc/selective_channel.cpp | 29 ++++++++-------- src/brpc/selective_channel.h | 29 ++++++++-------- src/brpc/serialized_request.cpp | 29 ++++++++-------- src/brpc/serialized_request.h | 29 ++++++++-------- src/brpc/server.cpp | 25 +++++++------- src/brpc/server.h | 29 ++++++++-------- src/brpc/server_id.cpp | 29 ++++++++-------- src/brpc/server_id.h | 29 ++++++++-------- src/brpc/server_node.h | 29 ++++++++-------- src/brpc/shared_object.h | 29 ++++++++-------- src/brpc/simple_data_pool.h | 29 ++++++++-------- src/brpc/socket.cpp | 29 ++++++++-------- src/brpc/socket.h | 29 ++++++++-------- src/brpc/socket_id.h | 29 ++++++++-------- src/brpc/socket_inl.h | 29 ++++++++-------- src/brpc/socket_map.cpp | 29 ++++++++-------- src/brpc/socket_map.h | 29 ++++++++-------- src/brpc/socket_message.h | 29 ++++++++-------- src/brpc/span.cpp | 29 ++++++++-------- src/brpc/span.h | 29 ++++++++-------- src/brpc/ssl_options.cpp | 25 +++++++------- src/brpc/ssl_options.h | 25 +++++++------- src/brpc/stream.cpp | 29 ++++++++-------- src/brpc/stream.h | 29 ++++++++-------- src/brpc/stream_creator.h | 29 ++++++++-------- src/brpc/stream_impl.h | 29 ++++++++-------- src/brpc/thrift_message.cpp | 29 ++++++++-------- src/brpc/thrift_message.h | 29 ++++++++-------- src/brpc/thrift_service.cpp | 29 ++++++++-------- src/brpc/thrift_service.h | 29 ++++++++-------- src/brpc/traceprintf.h | 29 ++++++++-------- src/brpc/trackme.cpp | 29 ++++++++-------- src/brpc/trackme.h | 29 ++++++++-------- src/brpc/ts.cpp | 29 ++++++++-------- src/brpc/ts.h | 29 ++++++++-------- src/brpc/uri.cpp | 29 ++++++++-------- src/brpc/uri.h | 29 ++++++++-------- src/bthread/bthread.cpp | 30 +++++++++-------- src/bthread/bthread.h | 30 +++++++++-------- src/bthread/butex.cpp | 30 +++++++++-------- src/bthread/butex.h | 30 +++++++++-------- src/bthread/comlog_initializer.h | 30 +++++++++-------- src/bthread/condition_variable.cpp | 30 +++++++++-------- src/bthread/condition_variable.h | 30 +++++++++-------- src/bthread/countdown_event.cpp | 30 +++++++++-------- src/bthread/countdown_event.h | 30 +++++++++-------- src/bthread/errno.cpp | 30 +++++++++-------- src/bthread/errno.h | 30 +++++++++-------- src/bthread/execution_queue.cpp | 30 +++++++++-------- src/bthread/execution_queue.h | 30 +++++++++-------- src/bthread/execution_queue_inl.h | 30 +++++++++-------- src/bthread/fd.cpp | 30 +++++++++-------- src/bthread/id.cpp | 30 +++++++++-------- src/bthread/id.h | 30 +++++++++-------- src/bthread/interrupt_pthread.cpp | 30 +++++++++-------- src/bthread/interrupt_pthread.h | 30 +++++++++-------- src/bthread/key.cpp | 30 +++++++++-------- src/bthread/list_of_abafree_id.h | 30 +++++++++-------- src/bthread/log.h | 30 +++++++++-------- src/bthread/mutex.cpp | 30 +++++++++-------- src/bthread/mutex.h | 30 +++++++++-------- src/bthread/parking_lot.h | 30 +++++++++-------- src/bthread/processor.h | 30 +++++++++-------- src/bthread/remote_task_queue.h | 30 +++++++++-------- src/bthread/stack.cpp | 30 +++++++++-------- src/bthread/stack.h | 30 +++++++++-------- src/bthread/stack_inl.h | 30 +++++++++-------- src/bthread/sys_futex.cpp | 30 +++++++++-------- src/bthread/sys_futex.h | 30 +++++++++-------- src/bthread/task_control.cpp | 30 +++++++++-------- src/bthread/task_control.h | 30 +++++++++-------- src/bthread/task_group.cpp | 30 +++++++++-------- src/bthread/task_group.h | 30 +++++++++-------- src/bthread/task_group_inl.h | 30 +++++++++-------- src/bthread/task_meta.h | 30 +++++++++-------- src/bthread/timer_thread.cpp | 30 +++++++++-------- src/bthread/timer_thread.h | 30 +++++++++-------- src/bthread/types.h | 30 +++++++++-------- src/bthread/unstable.h | 30 +++++++++-------- src/bthread/work_stealing_queue.h | 30 +++++++++-------- src/butil/arena.cpp | 29 ++++++++-------- src/butil/arena.h | 29 ++++++++-------- src/butil/binary_printer.cpp | 29 ++++++++-------- src/butil/binary_printer.h | 29 ++++++++-------- src/butil/bit_array.h | 29 ++++++++-------- src/butil/class_name.cpp | 29 ++++++++-------- src/butil/class_name.h | 29 ++++++++-------- src/butil/comlog_sink.cc | 29 ++++++++-------- src/butil/comlog_sink.h | 29 ++++++++-------- src/butil/compat.h | 25 +++++++------- src/butil/containers/bounded_queue.h | 29 ++++++++-------- .../containers/case_ignored_flat_map.cpp | 29 ++++++++-------- src/butil/containers/case_ignored_flat_map.h | 29 ++++++++-------- src/butil/containers/doubly_buffered_data.h | 29 ++++++++-------- src/butil/containers/flat_map.h | 29 ++++++++-------- src/butil/containers/flat_map_inl.h | 29 ++++++++-------- src/butil/containers/pooled_map.h | 29 ++++++++-------- src/butil/endpoint.cpp | 25 +++++++------- src/butil/endpoint.h | 29 ++++++++-------- src/butil/errno.cpp | 29 ++++++++-------- src/butil/errno.h | 29 ++++++++-------- src/butil/fast_rand.cpp | 29 ++++++++-------- src/butil/fast_rand.h | 29 ++++++++-------- src/butil/fd_guard.h | 29 ++++++++-------- src/butil/fd_utility.cpp | 29 ++++++++-------- src/butil/fd_utility.h | 29 ++++++++-------- src/butil/files/dir_reader_unix.h | 25 +++++++------- src/butil/files/fd_guard.h | 29 ++++++++-------- src/butil/files/file_watcher.cpp | 29 ++++++++-------- src/butil/files/file_watcher.h | 29 ++++++++-------- src/butil/files/temp_file.cpp | 29 ++++++++-------- src/butil/files/temp_file.h | 29 ++++++++-------- src/butil/find_cstr.cpp | 29 ++++++++-------- src/butil/find_cstr.h | 29 ++++++++-------- src/butil/iobuf.cpp | 30 +++++++++-------- src/butil/iobuf.h | 30 +++++++++-------- src/butil/iobuf_inl.h | 30 +++++++++-------- src/butil/logging.cc | 29 ++++++++-------- src/butil/logging.h | 29 ++++++++-------- src/butil/memory/singleton_on_pthread_once.h | 29 ++++++++-------- src/butil/object_pool.h | 30 +++++++++-------- src/butil/object_pool_inl.h | 30 +++++++++-------- src/butil/popen.cpp | 29 ++++++++-------- src/butil/popen.h | 29 ++++++++-------- src/butil/process_util.cc | 30 +++++++++-------- src/butil/process_util.h | 30 +++++++++-------- src/butil/ptr_container.h | 29 ++++++++-------- src/butil/raw_pack.h | 29 ++++++++-------- src/butil/reader_writer.h | 29 ++++++++-------- src/butil/resource_pool.h | 30 +++++++++-------- src/butil/resource_pool_inl.h | 30 +++++++++-------- src/butil/scoped_lock.h | 27 +++++++-------- src/butil/single_threaded_pool.h | 29 ++++++++-------- src/butil/ssl_compat.h | 33 +++++++++---------- src/butil/status.cpp | 29 ++++++++-------- src/butil/status.h | 17 +++++++++- src/butil/string_printf.cpp | 21 ++++++++---- src/butil/string_printf.h | 18 ++++++++-- src/butil/string_splitter.h | 29 ++++++++-------- src/butil/string_splitter_inl.h | 29 ++++++++-------- src/butil/synchronization/lock.h | 18 ++++++++-- src/butil/synchronous_event.h | 29 ++++++++-------- .../third_party/murmurhash3/murmurhash3.cpp | 20 +++++++++-- .../third_party/murmurhash3/murmurhash3.h | 20 +++++++++-- .../third_party/rapidjson/optimized_writer.h | 21 +++++++++--- src/butil/thread_local.cpp | 29 ++++++++-------- src/butil/thread_local.h | 29 ++++++++-------- src/butil/thread_local_inl.h | 29 ++++++++-------- src/butil/time.cpp | 29 ++++++++-------- src/butil/time.h | 29 ++++++++-------- src/butil/unix_socket.cpp | 29 ++++++++-------- src/butil/unix_socket.h | 29 ++++++++-------- src/butil/zero_copy_stream_as_streambuf.cpp | 29 ++++++++-------- src/butil/zero_copy_stream_as_streambuf.h | 29 ++++++++-------- src/bvar/bvar.h | 29 ++++++++-------- src/bvar/collector.cpp | 29 ++++++++-------- src/bvar/collector.h | 29 ++++++++-------- src/bvar/default_variables.cpp | 29 ++++++++-------- src/bvar/detail/agent_group.h | 29 ++++++++-------- src/bvar/detail/call_op_returning_void.h | 29 ++++++++-------- src/bvar/detail/combiner.h | 29 ++++++++-------- src/bvar/detail/is_atomical.h | 29 ++++++++-------- src/bvar/detail/percentile.cpp | 29 ++++++++-------- src/bvar/detail/percentile.h | 29 ++++++++-------- src/bvar/detail/sampler.cpp | 29 ++++++++-------- src/bvar/detail/sampler.h | 29 ++++++++-------- src/bvar/detail/series.h | 29 ++++++++-------- src/bvar/gflag.cpp | 29 ++++++++-------- src/bvar/gflag.h | 29 ++++++++-------- src/bvar/latency_recorder.cpp | 29 ++++++++-------- src/bvar/latency_recorder.h | 29 ++++++++-------- src/bvar/passive_status.h | 29 ++++++++-------- src/bvar/recorder.h | 29 ++++++++-------- src/bvar/reducer.h | 29 ++++++++-------- src/bvar/scoped_timer.h | 29 ++++++++-------- src/bvar/status.h | 29 ++++++++-------- src/bvar/utils/lock_timer.h | 29 ++++++++-------- src/bvar/variable.cpp | 29 ++++++++-------- src/bvar/variable.h | 29 ++++++++-------- src/bvar/vector.h | 29 ++++++++-------- src/bvar/window.h | 29 ++++++++-------- src/idl_options.proto | 3 -- src/json2pb/encode_decode.cpp | 19 +++++++++-- src/json2pb/encode_decode.h | 19 +++++++++-- src/json2pb/json_to_pb.cpp | 17 +++++++++- src/json2pb/json_to_pb.h | 19 +++++++++-- src/json2pb/pb_to_json.cpp | 17 +++++++++- src/json2pb/pb_to_json.h | 19 +++++++++-- src/json2pb/protobuf_map.cpp | 17 +++++++++- src/json2pb/protobuf_map.h | 18 ++++++++-- src/json2pb/rapidjson.h | 19 +++++++++-- src/json2pb/zero_copy_stream_reader.h | 20 ++++++++--- src/json2pb/zero_copy_stream_writer.h | 19 +++++++++-- src/mcpack2pb/field_type.cpp | 30 +++++++++-------- src/mcpack2pb/field_type.h | 30 +++++++++-------- src/mcpack2pb/generator.cpp | 30 +++++++++-------- src/mcpack2pb/mcpack2pb.cpp | 30 +++++++++-------- src/mcpack2pb/mcpack2pb.h | 30 +++++++++-------- src/mcpack2pb/parser-inl.h | 30 +++++++++-------- src/mcpack2pb/parser.cpp | 30 +++++++++-------- src/mcpack2pb/parser.h | 30 +++++++++-------- src/mcpack2pb/serializer-inl.h | 30 +++++++++-------- src/mcpack2pb/serializer.cpp | 30 +++++++++-------- src/mcpack2pb/serializer.h | 30 +++++++++-------- test/baidu_thread_local_unittest.cpp | 19 +++++++++-- test/baidu_time_unittest.cpp | 19 +++++++++-- test/brpc_adaptive_class_unittest.cpp | 18 +++++++++- test/brpc_builtin_service_unittest.cpp | 18 +++++++++- test/brpc_channel_unittest.cpp | 18 +++++++++- test/brpc_circuit_breaker_unittest.cpp | 18 +++++++++- test/brpc_controller_unittest.cpp | 18 +++++++++- test/brpc_esp_protocol_unittest.cpp | 18 +++++++++- test/brpc_event_dispatcher_unittest.cpp | 18 +++++++++- test/brpc_extension_unittest.cpp | 18 +++++++++- test/brpc_grpc_protocol_unittest.cpp | 29 ++++++++-------- test/brpc_h2_unsent_message_unittest.cpp | 18 +++++++++- test/brpc_hpack_unittest.cpp | 18 +++++++++- test/brpc_http_parser_unittest.cpp | 19 +++++++++-- test/brpc_http_rpc_protocol_unittest.cpp | 18 +++++++++- test/brpc_http_status_code_unittest.cpp | 18 +++++++++- test/brpc_hulu_pbrpc_protocol_unittest.cpp | 18 +++++++++- test/brpc_input_messenger_unittest.cpp | 18 +++++++++- test/brpc_load_balancer_unittest.cpp | 18 +++++++++- test/brpc_memcache_unittest.cpp | 18 ++++++++-- test/brpc_mongo_protocol_unittest.cpp | 18 +++++++++- test/brpc_naming_service_filter_unittest.cpp | 19 +++++++++-- test/brpc_naming_service_unittest.cpp | 18 ++++++++-- test/brpc_nova_pbrpc_protocol_unittest.cpp | 18 +++++++++- test/brpc_prometheus_metrics_unittest.cpp | 20 +++++++++-- test/brpc_proto_unittest.cpp | 17 +++++++++- test/brpc_protobuf_json_unittest.cpp | 17 +++++++++- test/brpc_public_pbrpc_protocol_unittest.cpp | 18 +++++++++- test/brpc_redis_unittest.cpp | 18 ++++++++-- test/brpc_repeated_field_unittest.cpp | 19 +++++++++-- test/brpc_rtmp_unittest.cpp | 18 +++++++++- test/brpc_server_unittest.cpp | 18 +++++++++- test/brpc_snappy_compress_unittest.cpp | 18 +++++++++- test/brpc_socket_map_unittest.cpp | 18 +++++++++- test/brpc_socket_unittest.cpp | 18 +++++++++- test/brpc_sofa_pbrpc_protocol_unittest.cpp | 18 +++++++++- test/brpc_ssl_unittest.cpp | 18 +++++++++- test/brpc_streaming_rpc_unittest.cpp | 18 +++++++++- test/brpc_uri_unittest.cpp | 19 +++++++++-- test/bthread_butex_unittest.cpp | 19 +++++++++-- test/bthread_cond_unittest.cpp | 19 +++++++++-- test/bthread_countdown_event_unittest.cpp | 17 +++++++++- test/bthread_dispatcher_unittest.cpp | 19 +++++++++-- test/bthread_execution_queue_unittest.cpp | 19 +++++++++-- test/bthread_fd_unittest.cpp | 19 +++++++++-- test/bthread_futex_unittest.cpp | 18 ++++++++-- test/bthread_id_unittest.cpp | 19 +++++++++-- test/bthread_key_unittest.cpp | 19 +++++++++-- test/bthread_list_unittest.cpp | 19 +++++++++-- test/bthread_mutex_unittest.cpp | 19 +++++++++-- test/bthread_ping_pong_unittest.cpp | 18 ++++++++-- test/bthread_rwlock_unittest.cpp | 18 ++++++++-- test/bthread_setconcurrency_unittest.cpp | 19 +++++++++-- test/bthread_timer_thread_unittest.cpp | 18 ++++++++-- test/bthread_unittest.cpp | 19 +++++++++-- test/bthread_work_stealing_queue_unittest.cpp | 18 ++++++++-- test/butil_unittest_main.cpp | 17 +++++++++- test/bvar_agent_group_unittest.cpp | 19 +++++++++-- test/bvar_file_dumper_unittest.cpp | 17 +++++++++- test/bvar_lock_timer_unittest.cpp | 17 +++++++++- test/bvar_percentile_unittest.cpp | 17 +++++++++- test/bvar_recorder_unittest.cpp | 17 +++++++++- test/bvar_reducer_unittest.cpp | 19 +++++++++-- test/bvar_sampler_unittest.cpp | 17 +++++++++- test/bvar_status_unittest.cpp | 17 +++++++++- test/bvar_variable_unittest.cpp | 17 +++++++++- test/cacheline_unittest.cpp | 18 ++++++++-- test/class_name_unittest.cpp | 18 ++++++++-- test/endpoint_unittest.cpp | 18 ++++++++-- test/errno_unittest.cpp | 19 +++++++++-- test/fd_guard_unittest.cpp | 19 +++++++++-- test/find_cstr_unittest.cpp | 18 ++++++++-- test/flat_map_unittest.cpp | 18 ++++++++-- test/iobuf_unittest.cpp | 19 +++++++++-- test/object_pool_unittest.cpp | 19 +++++++++-- test/popen_unittest.cpp | 17 +++++++++- test/resource_pool_unittest.cpp | 19 +++++++++-- test/scoped_lock_unittest.cpp | 19 +++++++++-- test/sstream_workaround.h | 18 ++++++++-- test/status_unittest.cpp | 18 ++++++++-- test/string_printf_unittest.cpp | 19 +++++++++-- test/synchronous_event_unittest.cpp | 18 ++++++++-- test/temp_file_unittest.cpp | 18 ++++++++-- test/unique_ptr_unittest.cpp | 18 ++++++++-- tools/idl2proto | 2 -- tools/parallel_http/parallel_http.cpp | 29 ++++++++-------- tools/rpc_press/info_thread.cpp | 29 ++++++++-------- tools/rpc_press/info_thread.h | 29 ++++++++-------- tools/rpc_press/json_loader.cpp | 29 ++++++++-------- tools/rpc_press/json_loader.h | 29 ++++++++-------- tools/rpc_press/pb_util.cpp | 29 ++++++++-------- tools/rpc_press/pb_util.h | 29 ++++++++-------- tools/rpc_press/rpc_press.cpp | 29 ++++++++-------- tools/rpc_press/rpc_press_impl.cpp | 29 ++++++++-------- tools/rpc_press/rpc_press_impl.h | 29 ++++++++-------- tools/rpc_replay/info_thread.cpp | 29 ++++++++-------- tools/rpc_replay/info_thread.h | 29 ++++++++-------- tools/rpc_replay/rpc_replay.cpp | 29 ++++++++-------- tools/rpc_view/rpc_view.cpp | 29 ++++++++-------- tools/trackme_server/trackme_server.cpp | 29 ++++++++-------- 620 files changed, 9870 insertions(+), 6881 deletions(-) diff --git a/example/asynchronous_echo_c++/client.cpp b/example/asynchronous_echo_c++/client.cpp index 446cd16a..e77918cb 100644 --- a/example/asynchronous_echo_c++/client.cpp +++ b/example/asynchronous_echo_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server asynchronously every 1 second. diff --git a/example/asynchronous_echo_c++/server.cpp b/example/asynchronous_echo_c++/server.cpp index 2f80910d..b91654b8 100644 --- a/example/asynchronous_echo_c++/server.cpp +++ b/example/asynchronous_echo_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/auto_concurrency_limiter/client.cpp b/example/auto_concurrency_limiter/client.cpp index 69025917..13377f04 100644 --- a/example/auto_concurrency_limiter/client.cpp +++ b/example/auto_concurrency_limiter/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server asynchronously every 1 second. diff --git a/example/auto_concurrency_limiter/server.cpp b/example/auto_concurrency_limiter/server.cpp index c52e11e5..45580920 100644 --- a/example/auto_concurrency_limiter/server.cpp +++ b/example/auto_concurrency_limiter/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/backup_request_c++/client.cpp b/example/backup_request_c++/client.cpp index 396955de..dfbb5856 100644 --- a/example/backup_request_c++/client.cpp +++ b/example/backup_request_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server every 1 second. If the response does // not come back within FLAGS_backup_request_ms, it sends another request diff --git a/example/backup_request_c++/server.cpp b/example/backup_request_c++/server.cpp index c512562d..6ecfa91b 100644 --- a/example/backup_request_c++/server.cpp +++ b/example/backup_request_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server sleeping for even-th requests to trigger backup request of client. diff --git a/example/cancel_c++/client.cpp b/example/cancel_c++/client.cpp index 0472484d..b1ba1aeb 100644 --- a/example/cancel_c++/client.cpp +++ b/example/cancel_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client to send 2 requests to server and accept the first returned response. diff --git a/example/cancel_c++/server.cpp b/example/cancel_c++/server.cpp index 6c5c3978..df07b16b 100644 --- a/example/cancel_c++/server.cpp +++ b/example/cancel_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/cascade_echo_c++/client.cpp b/example/cascade_echo_c++/client.cpp index baa2178c..1bb7005b 100644 --- a/example/cascade_echo_c++/client.cpp +++ b/example/cascade_echo_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server which will send the request to itself // again according to the field `depth' diff --git a/example/cascade_echo_c++/server.cpp b/example/cascade_echo_c++/server.cpp index 99671ac1..b8f1c047 100644 --- a/example/cascade_echo_c++/server.cpp +++ b/example/cascade_echo_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/example/dynamic_partition_echo_c++/client.cpp b/example/dynamic_partition_echo_c++/client.cpp index e4064a44..6c83b086 100644 --- a/example/dynamic_partition_echo_c++/client.cpp +++ b/example/dynamic_partition_echo_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server in parallel by multiple threads. diff --git a/example/dynamic_partition_echo_c++/server.cpp b/example/dynamic_partition_echo_c++/server.cpp index 8159445f..2437c9cb 100644 --- a/example/dynamic_partition_echo_c++/server.cpp +++ b/example/dynamic_partition_echo_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/echo_c++/client.cpp b/example/echo_c++/client.cpp index 3f61ee5e..337aa6e9 100644 --- a/example/echo_c++/client.cpp +++ b/example/echo_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server every 1 second. diff --git a/example/echo_c++/server.cpp b/example/echo_c++/server.cpp index 6c5c3978..df07b16b 100644 --- a/example/echo_c++/server.cpp +++ b/example/echo_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/echo_c++_hulu_pbrpc/client.cpp b/example/echo_c++_hulu_pbrpc/client.cpp index c51b37be..eeb9995d 100644 --- a/example/echo_c++_hulu_pbrpc/client.cpp +++ b/example/echo_c++_hulu_pbrpc/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server every 1 second. diff --git a/example/echo_c++_hulu_pbrpc/server.cpp b/example/echo_c++_hulu_pbrpc/server.cpp index b74af1bc..70a7951d 100644 --- a/example/echo_c++_hulu_pbrpc/server.cpp +++ b/example/echo_c++_hulu_pbrpc/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/echo_c++_sofa_pbrpc/client.cpp b/example/echo_c++_sofa_pbrpc/client.cpp index f1ec99cf..fef815eb 100644 --- a/example/echo_c++_sofa_pbrpc/client.cpp +++ b/example/echo_c++_sofa_pbrpc/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server every 1 second. diff --git a/example/echo_c++_sofa_pbrpc/server.cpp b/example/echo_c++_sofa_pbrpc/server.cpp index 5e89ec28..ef3c0f1a 100644 --- a/example/echo_c++_sofa_pbrpc/server.cpp +++ b/example/echo_c++_sofa_pbrpc/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/echo_c++_ubrpc_compack/client.cpp b/example/echo_c++_ubrpc_compack/client.cpp index 094c1062..6785a23f 100644 --- a/example/echo_c++_ubrpc_compack/client.cpp +++ b/example/echo_c++_ubrpc_compack/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to ubrpc server every 1 second. // This client can access the server in public/baidu-rpc-ub/example/echo_c++_compack_ubrpc as well. diff --git a/example/echo_c++_ubrpc_compack/idl_options.proto b/example/echo_c++_ubrpc_compack/idl_options.proto index 7e22e92c..6929355d 100644 --- a/example/echo_c++_ubrpc_compack/idl_options.proto +++ b/example/echo_c++_ubrpc_compack/idl_options.proto @@ -1,8 +1,5 @@ syntax="proto2"; // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Mon Oct 19 17:17:36 CST 2015 import "google/protobuf/descriptor.proto"; diff --git a/example/echo_c++_ubrpc_compack/server.cpp b/example/echo_c++_ubrpc_compack/server.cpp index 68cccdc3..23be57f9 100644 --- a/example/echo_c++_ubrpc_compack/server.cpp +++ b/example/echo_c++_ubrpc_compack/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive requests from ubrpc clients. // This server can be accessed by the client in public/baidu-rpc-ub/example/echo_c++_compack_ubrpc as well. diff --git a/example/grpc_c++/client.cpp b/example/grpc_c++/client.cpp index 0668e837..3690b9ae 100644 --- a/example/grpc_c++/client.cpp +++ b/example/grpc_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2018 brpc authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server every 1 second using grpc. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/example/grpc_c++/server.cpp b/example/grpc_c++/server.cpp index f48e5b6c..a02b83b8 100644 --- a/example/grpc_c++/server.cpp +++ b/example/grpc_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2018 brpc authors. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive HelloRequest and send back HelloReply // diff --git a/example/http_c++/benchmark_http.cpp b/example/http_c++/benchmark_http.cpp index d513580e..3ddcfe14 100644 --- a/example/http_c++/benchmark_http.cpp +++ b/example/http_c++/benchmark_http.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Benchmark http-server by multiple threads. diff --git a/example/http_c++/http_client.cpp b/example/http_c++/http_client.cpp index 50177c48..6d5e0e90 100644 --- a/example/http_c++/http_client.cpp +++ b/example/http_c++/http_client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // - Access pb services via HTTP // ./http_client http://www.foo.com:8765/EchoService/Echo -d '{"message":"hello"}' diff --git a/example/http_c++/http_server.cpp b/example/http_c++/http_server.cpp index db9a4540..c52800ef 100644 --- a/example/http_c++/http_server.cpp +++ b/example/http_c++/http_server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive HttpRequest and send back HttpResponse. diff --git a/example/memcache_c++/client.cpp b/example/memcache_c++/client.cpp index 80a6d3fb..01b03651 100644 --- a/example/memcache_c++/client.cpp +++ b/example/memcache_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A multi-threaded client getting keys from a memcache server constantly. diff --git a/example/multi_threaded_echo_c++/client.cpp b/example/multi_threaded_echo_c++/client.cpp index effc612a..0b7ea28c 100644 --- a/example/multi_threaded_echo_c++/client.cpp +++ b/example/multi_threaded_echo_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server by multiple threads. diff --git a/example/multi_threaded_echo_c++/server.cpp b/example/multi_threaded_echo_c++/server.cpp index 622f003c..b3c65e21 100644 --- a/example/multi_threaded_echo_c++/server.cpp +++ b/example/multi_threaded_echo_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/multi_threaded_echo_fns_c++/client.cpp b/example/multi_threaded_echo_fns_c++/client.cpp index 75091d4d..cec7f0d4 100644 --- a/example/multi_threaded_echo_fns_c++/client.cpp +++ b/example/multi_threaded_echo_fns_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to servers(discovered by naming service) by multiple threads. diff --git a/example/multi_threaded_echo_fns_c++/server.cpp b/example/multi_threaded_echo_fns_c++/server.cpp index 5d7f2305..45ac381d 100644 --- a/example/multi_threaded_echo_fns_c++/server.cpp +++ b/example/multi_threaded_echo_fns_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/multi_threaded_mcpack_c++/client.cpp b/example/multi_threaded_mcpack_c++/client.cpp index db585bf6..7f0dc543 100644 --- a/example/multi_threaded_mcpack_c++/client.cpp +++ b/example/multi_threaded_mcpack_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server by multiple threads. diff --git a/example/multi_threaded_mcpack_c++/idl_options.proto b/example/multi_threaded_mcpack_c++/idl_options.proto index 7e22e92c..6929355d 100644 --- a/example/multi_threaded_mcpack_c++/idl_options.proto +++ b/example/multi_threaded_mcpack_c++/idl_options.proto @@ -1,8 +1,5 @@ syntax="proto2"; // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Mon Oct 19 17:17:36 CST 2015 import "google/protobuf/descriptor.proto"; diff --git a/example/multi_threaded_mcpack_c++/server.cpp b/example/multi_threaded_mcpack_c++/server.cpp index abcb7c8b..43d2ba96 100644 --- a/example/multi_threaded_mcpack_c++/server.cpp +++ b/example/multi_threaded_mcpack_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/nshead_extension_c++/client.cpp b/example/nshead_extension_c++/client.cpp index 6e1a1dde..b5263d52 100644 --- a/example/nshead_extension_c++/client.cpp +++ b/example/nshead_extension_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server every 1 second. diff --git a/example/nshead_extension_c++/server.cpp b/example/nshead_extension_c++/server.cpp index 8818148e..b59c2c04 100644 --- a/example/nshead_extension_c++/server.cpp +++ b/example/nshead_extension_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/nshead_pb_extension_c++/client.cpp b/example/nshead_pb_extension_c++/client.cpp index 6e1a1dde..b5263d52 100644 --- a/example/nshead_pb_extension_c++/client.cpp +++ b/example/nshead_pb_extension_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server every 1 second. diff --git a/example/nshead_pb_extension_c++/server.cpp b/example/nshead_pb_extension_c++/server.cpp index ad3725e4..3980a911 100644 --- a/example/nshead_pb_extension_c++/server.cpp +++ b/example/nshead_pb_extension_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/parallel_echo_c++/client.cpp b/example/parallel_echo_c++/client.cpp index 1d97191e..933e2b65 100644 --- a/example/parallel_echo_c++/client.cpp +++ b/example/parallel_echo_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server in parallel by multiple threads. diff --git a/example/parallel_echo_c++/server.cpp b/example/parallel_echo_c++/server.cpp index c509ff05..e7b77150 100644 --- a/example/parallel_echo_c++/server.cpp +++ b/example/parallel_echo_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/partition_echo_c++/client.cpp b/example/partition_echo_c++/client.cpp index 3cda4ace..83fa001e 100644 --- a/example/partition_echo_c++/client.cpp +++ b/example/partition_echo_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server in parallel by multiple threads. diff --git a/example/partition_echo_c++/server.cpp b/example/partition_echo_c++/server.cpp index 2e0b7b15..657b4677 100644 --- a/example/partition_echo_c++/server.cpp +++ b/example/partition_echo_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/redis_c++/redis_cli.cpp b/example/redis_c++/redis_cli.cpp index 1007a8d6..d4cbf63a 100644 --- a/example/redis_c++/redis_cli.cpp +++ b/example/redis_c++/redis_cli.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A brpc based command-line interface to talk with redis-server diff --git a/example/redis_c++/redis_press.cpp b/example/redis_c++/redis_press.cpp index d171abfe..7c4e5a5c 100644 --- a/example/redis_c++/redis_press.cpp +++ b/example/redis_c++/redis_press.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A multi-threaded client getting keys from a redis-server constantly. diff --git a/example/selective_echo_c++/client.cpp b/example/selective_echo_c++/client.cpp index e4c62ea8..99f9f0fd 100644 --- a/example/selective_echo_c++/client.cpp +++ b/example/selective_echo_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server in parallel by multiple threads. diff --git a/example/selective_echo_c++/server.cpp b/example/selective_echo_c++/server.cpp index bc890d15..63fd183e 100644 --- a/example/selective_echo_c++/server.cpp +++ b/example/selective_echo_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/session_data_and_thread_local/client.cpp b/example/session_data_and_thread_local/client.cpp index ccacb41d..f0cc9892 100644 --- a/example/session_data_and_thread_local/client.cpp +++ b/example/session_data_and_thread_local/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server by multiple threads. diff --git a/example/session_data_and_thread_local/server.cpp b/example/session_data_and_thread_local/server.cpp index 7ae506ee..ae585cc7 100644 --- a/example/session_data_and_thread_local/server.cpp +++ b/example/session_data_and_thread_local/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse asynchronously. diff --git a/example/streaming_echo_c++/client.cpp b/example/streaming_echo_c++/client.cpp index 2629ee9b..d5936251 100644 --- a/example/streaming_echo_c++/client.cpp +++ b/example/streaming_echo_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server in batch every 1 second. diff --git a/example/streaming_echo_c++/server.cpp b/example/streaming_echo_c++/server.cpp index 687e7fef..26837f64 100644 --- a/example/streaming_echo_c++/server.cpp +++ b/example/streaming_echo_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/thrift_extension_c++/client.cpp b/example/thrift_extension_c++/client.cpp index fbcc920f..b3587924 100755 --- a/example/thrift_extension_c++/client.cpp +++ b/example/thrift_extension_c++/client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending thrift requests to server every 1 second. diff --git a/example/thrift_extension_c++/client2.cpp b/example/thrift_extension_c++/client2.cpp index 18b0dcb8..276dbac0 100644 --- a/example/thrift_extension_c++/client2.cpp +++ b/example/thrift_extension_c++/client2.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A client sending requests to server by multiple threads. diff --git a/example/thrift_extension_c++/native_client.cpp b/example/thrift_extension_c++/native_client.cpp index 87ec3a4c..f157a12e 100644 --- a/example/thrift_extension_c++/native_client.cpp +++ b/example/thrift_extension_c++/native_client.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A thrift client sending requests to server every 1 second. diff --git a/example/thrift_extension_c++/native_server.cpp b/example/thrift_extension_c++/native_server.cpp index 30e7e29d..c501a493 100755 --- a/example/thrift_extension_c++/native_server.cpp +++ b/example/thrift_extension_c++/native_server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A thrift server to receive EchoRequest and send back EchoResponse. diff --git a/example/thrift_extension_c++/server.cpp b/example/thrift_extension_c++/server.cpp index 57cb0631..ef2ff2ba 100755 --- a/example/thrift_extension_c++/server.cpp +++ b/example/thrift_extension_c++/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/example/thrift_extension_c++/server2.cpp b/example/thrift_extension_c++/server2.cpp index 36d3c9e4..92060533 100755 --- a/example/thrift_extension_c++/server2.cpp +++ b/example/thrift_extension_c++/server2.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // A server to receive EchoRequest and send back EchoResponse. diff --git a/src/brpc/acceptor.cpp b/src/brpc/acceptor.cpp index e72bcb87..1b8d83e4 100644 --- a/src/brpc/acceptor.cpp +++ b/src/brpc/acceptor.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang(jiangrujie@baidu.com) // Ge,Jun(gejun@baidu.com) diff --git a/src/brpc/acceptor.h b/src/brpc/acceptor.h index c472e88c..2b0e13c6 100644 --- a/src/brpc/acceptor.h +++ b/src/brpc/acceptor.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang(jiangrujie@baidu.com) // Ge,Jun(gejun@baidu.com) diff --git a/src/brpc/adaptive_connection_type.cpp b/src/brpc/adaptive_connection_type.cpp index 42709b41..6ae8a5e6 100644 --- a/src/brpc/adaptive_connection_type.cpp +++ b/src/brpc/adaptive_connection_type.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/adaptive_connection_type.h b/src/brpc/adaptive_connection_type.h index 65bd44c8..8587f947 100644 --- a/src/brpc/adaptive_connection_type.h +++ b/src/brpc/adaptive_connection_type.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/adaptive_max_concurrency.cpp b/src/brpc/adaptive_max_concurrency.cpp index 1765e316..2e90c530 100644 --- a/src/brpc/adaptive_max_concurrency.cpp +++ b/src/brpc/adaptive_max_concurrency.cpp @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Authors: Lei He (helei@qiyi.com) +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/src/brpc/adaptive_max_concurrency.h b/src/brpc/adaptive_max_concurrency.h index b4e45294..46af4141 100644 --- a/src/brpc/adaptive_max_concurrency.h +++ b/src/brpc/adaptive_max_concurrency.h @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Authors: Lei He (helei@qiyi.com) +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_ADAPTIVE_MAX_CONCURRENCY_H #define BRPC_ADAPTIVE_MAX_CONCURRENCY_H diff --git a/src/brpc/adaptive_protocol_type.h b/src/brpc/adaptive_protocol_type.h index 0ebff3b0..666654ea 100644 --- a/src/brpc/adaptive_protocol_type.h +++ b/src/brpc/adaptive_protocol_type.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_ADAPTIVE_PROTOCOL_TYPE_H #define BRPC_ADAPTIVE_PROTOCOL_TYPE_H diff --git a/src/brpc/amf.cpp b/src/brpc/amf.cpp index 448f4667..902c839c 100644 --- a/src/brpc/amf.cpp +++ b/src/brpc/amf.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/amf.h b/src/brpc/amf.h index 9630a2d6..748adee9 100644 --- a/src/brpc/amf.h +++ b/src/brpc/amf.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/amf_inl.h b/src/brpc/amf_inl.h index 83ff53c3..881c3081 100644 --- a/src/brpc/amf_inl.h +++ b/src/brpc/amf_inl.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/authenticator.h b/src/brpc/authenticator.h index 42d74ca5..3b2fe418 100644 --- a/src/brpc/authenticator.h +++ b/src/brpc/authenticator.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/builtin/bad_method_service.cpp b/src/brpc/builtin/bad_method_service.cpp index 41fcb657..07da5003 100644 --- a/src/brpc/builtin/bad_method_service.cpp +++ b/src/brpc/builtin/bad_method_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/builtin/bad_method_service.h b/src/brpc/builtin/bad_method_service.h index cf3ab4a3..5156aab2 100644 --- a/src/brpc/builtin/bad_method_service.h +++ b/src/brpc/builtin/bad_method_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/builtin/bthreads_service.cpp b/src/brpc/builtin/bthreads_service.cpp index 017d3b35..7c6fba3e 100644 --- a/src/brpc/builtin/bthreads_service.cpp +++ b/src/brpc/builtin/bthreads_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/bthreads_service.h b/src/brpc/builtin/bthreads_service.h index 7fd13003..7a596049 100644 --- a/src/brpc/builtin/bthreads_service.h +++ b/src/brpc/builtin/bthreads_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/common.cpp b/src/brpc/builtin/common.cpp index 2ccac4d0..c6b219e8 100644 --- a/src/brpc/builtin/common.cpp +++ b/src/brpc/builtin/common.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/common.h b/src/brpc/builtin/common.h index 535dbed9..71b52326 100644 --- a/src/brpc/builtin/common.h +++ b/src/brpc/builtin/common.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/connections_service.cpp b/src/brpc/builtin/connections_service.cpp index a81c81f1..21860c16 100644 --- a/src/brpc/builtin/connections_service.cpp +++ b/src/brpc/builtin/connections_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/connections_service.h b/src/brpc/builtin/connections_service.h index 834690ea..96cdb4fd 100644 --- a/src/brpc/builtin/connections_service.h +++ b/src/brpc/builtin/connections_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/dir_service.cpp b/src/brpc/builtin/dir_service.cpp index 0c12172f..da55ed76 100644 --- a/src/brpc/builtin/dir_service.cpp +++ b/src/brpc/builtin/dir_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/dir_service.h b/src/brpc/builtin/dir_service.h index 767767c5..20c47941 100644 --- a/src/brpc/builtin/dir_service.h +++ b/src/brpc/builtin/dir_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/flags_service.cpp b/src/brpc/builtin/flags_service.cpp index 723450b4..b8201526 100644 --- a/src/brpc/builtin/flags_service.cpp +++ b/src/brpc/builtin/flags_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/flags_service.h b/src/brpc/builtin/flags_service.h index d0445809..ec8df221 100644 --- a/src/brpc/builtin/flags_service.h +++ b/src/brpc/builtin/flags_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/flot_min_js.cpp b/src/brpc/builtin/flot_min_js.cpp index 3f8882f7..bfcb1f58 100644 --- a/src/brpc/builtin/flot_min_js.cpp +++ b/src/brpc/builtin/flot_min_js.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/flot_min_js.h b/src/brpc/builtin/flot_min_js.h index 39f910dc..10145549 100644 --- a/src/brpc/builtin/flot_min_js.h +++ b/src/brpc/builtin/flot_min_js.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/get_favicon_service.cpp b/src/brpc/builtin/get_favicon_service.cpp index e6688df1..f8ab437a 100644 --- a/src/brpc/builtin/get_favicon_service.cpp +++ b/src/brpc/builtin/get_favicon_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/builtin/get_favicon_service.h b/src/brpc/builtin/get_favicon_service.h index 64325e5f..4205bb55 100644 --- a/src/brpc/builtin/get_favicon_service.h +++ b/src/brpc/builtin/get_favicon_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/builtin/get_js_service.cpp b/src/brpc/builtin/get_js_service.cpp index 38f7cc43..4b3477de 100644 --- a/src/brpc/builtin/get_js_service.cpp +++ b/src/brpc/builtin/get_js_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "butil/macros.h" // ARRAY_SIZE #include "butil/iobuf.h" // butil::IOBuf diff --git a/src/brpc/builtin/get_js_service.h b/src/brpc/builtin/get_js_service.h index 977d602a..89f7bf0e 100644 --- a/src/brpc/builtin/get_js_service.h +++ b/src/brpc/builtin/get_js_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_GET_JAVASCRIPT_SERVICE_H #define BRPC_GET_JAVASCRIPT_SERVICE_H diff --git a/src/brpc/builtin/health_service.cpp b/src/brpc/builtin/health_service.cpp index eba30a84..503a38eb 100644 --- a/src/brpc/builtin/health_service.cpp +++ b/src/brpc/builtin/health_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/health_service.h b/src/brpc/builtin/health_service.h index 06cb53fa..9c26d67d 100644 --- a/src/brpc/builtin/health_service.h +++ b/src/brpc/builtin/health_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/hotspots_service.cpp b/src/brpc/builtin/hotspots_service.cpp index 048ceb8a..3764f939 100644 --- a/src/brpc/builtin/hotspots_service.cpp +++ b/src/brpc/builtin/hotspots_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/hotspots_service.h b/src/brpc/builtin/hotspots_service.h index 366c8a05..56fe4ea3 100644 --- a/src/brpc/builtin/hotspots_service.h +++ b/src/brpc/builtin/hotspots_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/ids_service.cpp b/src/brpc/builtin/ids_service.cpp index 4683d068..6646b05f 100644 --- a/src/brpc/builtin/ids_service.cpp +++ b/src/brpc/builtin/ids_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/ids_service.h b/src/brpc/builtin/ids_service.h index a152db7b..0e3b172e 100644 --- a/src/brpc/builtin/ids_service.h +++ b/src/brpc/builtin/ids_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/index_service.cpp b/src/brpc/builtin/index_service.cpp index c588bfe9..feccfdb3 100644 --- a/src/brpc/builtin/index_service.cpp +++ b/src/brpc/builtin/index_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/index_service.h b/src/brpc/builtin/index_service.h index 4f35781e..d5e4af5b 100644 --- a/src/brpc/builtin/index_service.h +++ b/src/brpc/builtin/index_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/jquery_min_js.cpp b/src/brpc/builtin/jquery_min_js.cpp index 689095ce..a795acd7 100644 --- a/src/brpc/builtin/jquery_min_js.cpp +++ b/src/brpc/builtin/jquery_min_js.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/jquery_min_js.h b/src/brpc/builtin/jquery_min_js.h index 1f7dc8f0..ed4893d3 100644 --- a/src/brpc/builtin/jquery_min_js.h +++ b/src/brpc/builtin/jquery_min_js.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/list_service.cpp b/src/brpc/builtin/list_service.cpp index e5469084..bbd694dd 100644 --- a/src/brpc/builtin/list_service.cpp +++ b/src/brpc/builtin/list_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/list_service.h b/src/brpc/builtin/list_service.h index c97db19c..192addb3 100644 --- a/src/brpc/builtin/list_service.h +++ b/src/brpc/builtin/list_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/pprof_perl.h b/src/brpc/builtin/pprof_perl.h index 15655854..e86c78dc 100644 --- a/src/brpc/builtin/pprof_perl.h +++ b/src/brpc/builtin/pprof_perl.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/pprof_service.cpp b/src/brpc/builtin/pprof_service.cpp index e2309114..abc2b8e3 100644 --- a/src/brpc/builtin/pprof_service.cpp +++ b/src/brpc/builtin/pprof_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include // strftime #include diff --git a/src/brpc/builtin/pprof_service.h b/src/brpc/builtin/pprof_service.h index 9553bd35..b61bb039 100644 --- a/src/brpc/builtin/pprof_service.h +++ b/src/brpc/builtin/pprof_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_PPROF_SERVICE_H #define BRPC_PPROF_SERVICE_H diff --git a/src/brpc/builtin/prometheus_metrics_service.cpp b/src/brpc/builtin/prometheus_metrics_service.cpp index 3ec3f980..b050c822 100644 --- a/src/brpc/builtin/prometheus_metrics_service.cpp +++ b/src/brpc/builtin/prometheus_metrics_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2018 Bilibili, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/src/brpc/builtin/prometheus_metrics_service.h b/src/brpc/builtin/prometheus_metrics_service.h index 46935536..809da24f 100644 --- a/src/brpc/builtin/prometheus_metrics_service.h +++ b/src/brpc/builtin/prometheus_metrics_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2018 BiliBili, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/src/brpc/builtin/protobufs_service.cpp b/src/brpc/builtin/protobufs_service.cpp index 0ba98a85..e4679e25 100644 --- a/src/brpc/builtin/protobufs_service.cpp +++ b/src/brpc/builtin/protobufs_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/protobufs_service.h b/src/brpc/builtin/protobufs_service.h index 1a2ea8dc..05ea13a6 100644 --- a/src/brpc/builtin/protobufs_service.h +++ b/src/brpc/builtin/protobufs_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/rpcz_service.cpp b/src/brpc/builtin/rpcz_service.cpp index 6a0ca6b2..6a21a471 100644 --- a/src/brpc/builtin/rpcz_service.cpp +++ b/src/brpc/builtin/rpcz_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/rpcz_service.h b/src/brpc/builtin/rpcz_service.h index d94a9425..94b3f326 100644 --- a/src/brpc/builtin/rpcz_service.h +++ b/src/brpc/builtin/rpcz_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/sockets_service.cpp b/src/brpc/builtin/sockets_service.cpp index a70e56c4..53b9a4b7 100644 --- a/src/brpc/builtin/sockets_service.cpp +++ b/src/brpc/builtin/sockets_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/sockets_service.h b/src/brpc/builtin/sockets_service.h index 8721743f..5d329e44 100644 --- a/src/brpc/builtin/sockets_service.h +++ b/src/brpc/builtin/sockets_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/sorttable_js.cpp b/src/brpc/builtin/sorttable_js.cpp index 17ad9708..ef705c0a 100644 --- a/src/brpc/builtin/sorttable_js.cpp +++ b/src/brpc/builtin/sorttable_js.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/sorttable_js.h b/src/brpc/builtin/sorttable_js.h index 926533ff..ef9b2dc8 100644 --- a/src/brpc/builtin/sorttable_js.h +++ b/src/brpc/builtin/sorttable_js.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/status_service.cpp b/src/brpc/builtin/status_service.cpp index 4b4e44b9..fc0f5ee8 100644 --- a/src/brpc/builtin/status_service.cpp +++ b/src/brpc/builtin/status_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/status_service.h b/src/brpc/builtin/status_service.h index fda21755..ffb19aa0 100644 --- a/src/brpc/builtin/status_service.h +++ b/src/brpc/builtin/status_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/tabbed.h b/src/brpc/builtin/tabbed.h index 6ba7e3b6..0b1ebd7f 100644 --- a/src/brpc/builtin/tabbed.h +++ b/src/brpc/builtin/tabbed.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/threads_service.cpp b/src/brpc/builtin/threads_service.cpp index c9327dd9..ad49e9db 100644 --- a/src/brpc/builtin/threads_service.cpp +++ b/src/brpc/builtin/threads_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/threads_service.h b/src/brpc/builtin/threads_service.h index be1f8d2c..dedd8b74 100644 --- a/src/brpc/builtin/threads_service.h +++ b/src/brpc/builtin/threads_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/vars_service.cpp b/src/brpc/builtin/vars_service.cpp index 9b69be35..bfbf720b 100644 --- a/src/brpc/builtin/vars_service.cpp +++ b/src/brpc/builtin/vars_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/vars_service.h b/src/brpc/builtin/vars_service.h index 0c46b6ad..457622cc 100644 --- a/src/brpc/builtin/vars_service.h +++ b/src/brpc/builtin/vars_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/version_service.cpp b/src/brpc/builtin/version_service.cpp index 92fc17b8..b4681bfe 100644 --- a/src/brpc/builtin/version_service.cpp +++ b/src/brpc/builtin/version_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/version_service.h b/src/brpc/builtin/version_service.h index da3b32d4..c0ce8c31 100644 --- a/src/brpc/builtin/version_service.h +++ b/src/brpc/builtin/version_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/viz_min_js.cpp b/src/brpc/builtin/viz_min_js.cpp index b1c1210e..987f8d2a 100644 --- a/src/brpc/builtin/viz_min_js.cpp +++ b/src/brpc/builtin/viz_min_js.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/viz_min_js.h b/src/brpc/builtin/viz_min_js.h index 5b51752c..ad0fe8ed 100644 --- a/src/brpc/builtin/viz_min_js.h +++ b/src/brpc/builtin/viz_min_js.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/vlog_service.cpp b/src/brpc/builtin/vlog_service.cpp index 0708cf44..1b605607 100644 --- a/src/brpc/builtin/vlog_service.cpp +++ b/src/brpc/builtin/vlog_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/builtin/vlog_service.h b/src/brpc/builtin/vlog_service.h index ece83f08..73981443 100644 --- a/src/brpc/builtin/vlog_service.h +++ b/src/brpc/builtin/vlog_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/channel.cpp b/src/brpc/channel.cpp index e5d4a45d..d9604365 100755 --- a/src/brpc/channel.cpp +++ b/src/brpc/channel.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang(jiangrujie@baidu.com) diff --git a/src/brpc/channel.h b/src/brpc/channel.h index be631cff..9b87869a 100644 --- a/src/brpc/channel.h +++ b/src/brpc/channel.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/channel_base.h b/src/brpc/channel_base.h index 584aa873..3a46c870 100644 --- a/src/brpc/channel_base.h +++ b/src/brpc/channel_base.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/circuit_breaker.cpp b/src/brpc/circuit_breaker.cpp index 87be0c05..ba7ef79a 100644 --- a/src/brpc/circuit_breaker.cpp +++ b/src/brpc/circuit_breaker.cpp @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Authors: Lei He (helei@qiyi.com) +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/src/brpc/circuit_breaker.h b/src/brpc/circuit_breaker.h index f9eaa66f..826e6914 100644 --- a/src/brpc/circuit_breaker.h +++ b/src/brpc/circuit_breaker.h @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Authors: Lei He (helei@qiyi.com) +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_CIRCUIT_BREAKER_H #define BRPC_CIRCUIT_BREAKER_H diff --git a/src/brpc/closure_guard.h b/src/brpc/closure_guard.h index c7ed73df..9e31800e 100644 --- a/src/brpc/closure_guard.h +++ b/src/brpc/closure_guard.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/cluster_recover_policy.cpp b/src/brpc/cluster_recover_policy.cpp index ff8ed79a..aef47540 100644 --- a/src/brpc/cluster_recover_policy.cpp +++ b/src/brpc/cluster_recover_policy.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/src/brpc/cluster_recover_policy.h b/src/brpc/cluster_recover_policy.h index 438ff53c..616feb73 100644 --- a/src/brpc/cluster_recover_policy.h +++ b/src/brpc/cluster_recover_policy.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/src/brpc/compress.cpp b/src/brpc/compress.cpp index f808e348..18bd1a4d 100644 --- a/src/brpc/compress.cpp +++ b/src/brpc/compress.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/compress.h b/src/brpc/compress.h index f21d29ad..20324b66 100644 --- a/src/brpc/compress.h +++ b/src/brpc/compress.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/concurrency_limiter.h b/src/brpc/concurrency_limiter.h index 7b6754c2..99ca13a1 100644 --- a/src/brpc/concurrency_limiter.h +++ b/src/brpc/concurrency_limiter.h @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Authors: Lei He (helei@qiyi.com) +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_CONCURRENCY_LIMITER_H #define BRPC_CONCURRENCY_LIMITER_H diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 7bbd9863..c1c07e4b 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang(jiangrujie@baidu.com) diff --git a/src/brpc/controller.h b/src/brpc/controller.h index 9654ba1b..1d907308 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/data_factory.h b/src/brpc/data_factory.h index 3f04a5da..e825d36d 100644 --- a/src/brpc/data_factory.h +++ b/src/brpc/data_factory.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/describable.h b/src/brpc/describable.h index 07b55146..9acd9a0c 100644 --- a/src/brpc/describable.h +++ b/src/brpc/describable.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/destroyable.h b/src/brpc/destroyable.h index c8bfc1b3..26744be9 100644 --- a/src/brpc/destroyable.h +++ b/src/brpc/destroyable.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/controller_private_accessor.h b/src/brpc/details/controller_private_accessor.h index 3ea8c76a..1aa567e3 100644 --- a/src/brpc/details/controller_private_accessor.h +++ b/src/brpc/details/controller_private_accessor.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_CONTROLLER_PRIVATE_ACCESSOR_H #define BRPC_CONTROLLER_PRIVATE_ACCESSOR_H diff --git a/src/brpc/details/has_epollrdhup.cpp b/src/brpc/details/has_epollrdhup.cpp index 9d0f3c4f..0180545a 100644 --- a/src/brpc/details/has_epollrdhup.cpp +++ b/src/brpc/details/has_epollrdhup.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/has_epollrdhup.h b/src/brpc/details/has_epollrdhup.h index f809f005..18f2f4d9 100644 --- a/src/brpc/details/has_epollrdhup.h +++ b/src/brpc/details/has_epollrdhup.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/health_check.cpp b/src/brpc/details/health_check.cpp index 7a33a807..1a7fce83 100644 --- a/src/brpc/details/health_check.cpp +++ b/src/brpc/details/health_check.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Jiashun Zhu(zhujiashun@baidu.com) diff --git a/src/brpc/details/health_check.h b/src/brpc/details/health_check.h index 9ada5a34..933b633d 100644 --- a/src/brpc/details/health_check.h +++ b/src/brpc/details/health_check.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Jiashun Zhu(zhujiashun@baidu.com) diff --git a/src/brpc/details/hpack-static-table.h b/src/brpc/details/hpack-static-table.h index 2182c0e3..768d2650 100644 --- a/src/brpc/details/hpack-static-table.h +++ b/src/brpc/details/hpack-static-table.h @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Intentionally no header guard diff --git a/src/brpc/details/hpack.cpp b/src/brpc/details/hpack.cpp index 16f330ac..fa2c736c 100644 --- a/src/brpc/details/hpack.cpp +++ b/src/brpc/details/hpack.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/details/hpack.h b/src/brpc/details/hpack.h index 17ba5699..98934c20 100644 --- a/src/brpc/details/hpack.h +++ b/src/brpc/details/hpack.h @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/details/http_message.cpp b/src/brpc/details/http_message.cpp index 134abfdf..a0538086 100644 --- a/src/brpc/details/http_message.cpp +++ b/src/brpc/details/http_message.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/http_message.h b/src/brpc/details/http_message.h index 5d8db12d..26684f88 100644 --- a/src/brpc/details/http_message.h +++ b/src/brpc/details/http_message.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/load_balancer_with_naming.cpp b/src/brpc/details/load_balancer_with_naming.cpp index eeeb8a90..b8147ea4 100644 --- a/src/brpc/details/load_balancer_with_naming.cpp +++ b/src/brpc/details/load_balancer_with_naming.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/load_balancer_with_naming.h b/src/brpc/details/load_balancer_with_naming.h index 01e9a364..e79de4fe 100644 --- a/src/brpc/details/load_balancer_with_naming.h +++ b/src/brpc/details/load_balancer_with_naming.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/mesalink_ssl_helper.cpp b/src/brpc/details/mesalink_ssl_helper.cpp index 3c12fce6..a06a23bb 100644 --- a/src/brpc/details/mesalink_ssl_helper.cpp +++ b/src/brpc/details/mesalink_ssl_helper.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2019 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Yiming Jing (jingyijming@baidu.com) diff --git a/src/brpc/details/method_status.cpp b/src/brpc/details/method_status.cpp index 7e9dded2..7609aed5 100644 --- a/src/brpc/details/method_status.cpp +++ b/src/brpc/details/method_status.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/method_status.h b/src/brpc/details/method_status.h index 8003a61f..05ffc53c 100644 --- a/src/brpc/details/method_status.h +++ b/src/brpc/details/method_status.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/naming_service_thread.cpp b/src/brpc/details/naming_service_thread.cpp index 785ae5fc..abe9b4cb 100644 --- a/src/brpc/details/naming_service_thread.cpp +++ b/src/brpc/details/naming_service_thread.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/naming_service_thread.h b/src/brpc/details/naming_service_thread.h index 01c5c85c..57ef7c91 100644 --- a/src/brpc/details/naming_service_thread.h +++ b/src/brpc/details/naming_service_thread.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/profiler_linker.h b/src/brpc/details/profiler_linker.h index c5eaa865..3a33b37d 100644 --- a/src/brpc/details/profiler_linker.h +++ b/src/brpc/details/profiler_linker.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/rtmp_utils.cpp b/src/brpc/details/rtmp_utils.cpp index 6de0f0eb..47736cb1 100644 --- a/src/brpc/details/rtmp_utils.cpp +++ b/src/brpc/details/rtmp_utils.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/rtmp_utils.h b/src/brpc/details/rtmp_utils.h index eedf08ec..20dbf4e3 100644 --- a/src/brpc/details/rtmp_utils.h +++ b/src/brpc/details/rtmp_utils.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/server_private_accessor.h b/src/brpc/details/server_private_accessor.h index 4b4992b2..aacf2835 100644 --- a/src/brpc/details/server_private_accessor.h +++ b/src/brpc/details/server_private_accessor.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_SERVER_PRIVATE_ACCESSOR_H #define BRPC_SERVER_PRIVATE_ACCESSOR_H diff --git a/src/brpc/details/sparse_minute_counter.h b/src/brpc/details/sparse_minute_counter.h index 60224905..ffc97d65 100644 --- a/src/brpc/details/sparse_minute_counter.h +++ b/src/brpc/details/sparse_minute_counter.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/ssl_helper.cpp b/src/brpc/details/ssl_helper.cpp index 5032258d..07263fb5 100644 --- a/src/brpc/details/ssl_helper.cpp +++ b/src/brpc/details/ssl_helper.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/details/ssl_helper.h b/src/brpc/details/ssl_helper.h index 793be7d2..e946de58 100644 --- a/src/brpc/details/ssl_helper.h +++ b/src/brpc/details/ssl_helper.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/details/usercode_backup_pool.cpp b/src/brpc/details/usercode_backup_pool.cpp index 1c25569e..4b1e71ae 100644 --- a/src/brpc/details/usercode_backup_pool.cpp +++ b/src/brpc/details/usercode_backup_pool.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/details/usercode_backup_pool.h b/src/brpc/details/usercode_backup_pool.h index 2f0d6e8d..1dfde9c2 100644 --- a/src/brpc/details/usercode_backup_pool.h +++ b/src/brpc/details/usercode_backup_pool.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/esp_head.h b/src/brpc/esp_head.h index 6e84218b..b882ff90 100644 --- a/src/brpc/esp_head.h +++ b/src/brpc/esp_head.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_ESP_HEAD_H #define BRPC_ESP_HEAD_H diff --git a/src/brpc/esp_message.cpp b/src/brpc/esp_message.cpp index 26eff2c7..996fb5ee 100644 --- a/src/brpc/esp_message.cpp +++ b/src/brpc/esp_message.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Generated by the protocol buffer compiler. DO NOT EDIT! diff --git a/src/brpc/esp_message.h b/src/brpc/esp_message.h index 8dc708d4..e1ea7580 100644 --- a/src/brpc/esp_message.h +++ b/src/brpc/esp_message.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_ESP_MESSAGE_H #define BRPC_ESP_MESSAGE_H diff --git a/src/brpc/event_dispatcher.cpp b/src/brpc/event_dispatcher.cpp index ad411e18..fb0c29d2 100644 --- a/src/brpc/event_dispatcher.cpp +++ b/src/brpc/event_dispatcher.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/event_dispatcher.h b/src/brpc/event_dispatcher.h index 863ce857..bda4d813 100644 --- a/src/brpc/event_dispatcher.h +++ b/src/brpc/event_dispatcher.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/excluded_servers.h b/src/brpc/excluded_servers.h index fe486734..04f347ef 100644 --- a/src/brpc/excluded_servers.h +++ b/src/brpc/excluded_servers.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/extension.h b/src/brpc/extension.h index 76dda7cd..becaa345 100644 --- a/src/brpc/extension.h +++ b/src/brpc/extension.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/extension_inl.h b/src/brpc/extension_inl.h index cbfbb7bf..5072e1d8 100644 --- a/src/brpc/extension_inl.h +++ b/src/brpc/extension_inl.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/global.cpp b/src/brpc/global.cpp index 88f0bae7..802be318 100755 --- a/src/brpc/global.cpp +++ b/src/brpc/global.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/global.h b/src/brpc/global.h index 6e72fb7a..bbd7fef9 100644 --- a/src/brpc/global.h +++ b/src/brpc/global.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/grpc.cpp b/src/brpc/grpc.cpp index 2e3ded67..b1ebdd6f 100644 --- a/src/brpc/grpc.cpp +++ b/src/brpc/grpc.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2018 brpc authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/src/brpc/grpc.h b/src/brpc/grpc.h index a17b559f..4643cfbd 100644 --- a/src/brpc/grpc.h +++ b/src/brpc/grpc.h @@ -1,16 +1,19 @@ -// Copyright (c) 2018 brpc authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/src/brpc/health_reporter.h b/src/brpc/health_reporter.h index 37c5230e..048956f8 100644 --- a/src/brpc/health_reporter.h +++ b/src/brpc/health_reporter.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/http2.cpp b/src/brpc/http2.cpp index 46760625..59099c2d 100644 --- a/src/brpc/http2.cpp +++ b/src/brpc/http2.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/logging.h" diff --git a/src/brpc/http2.h b/src/brpc/http2.h index 329c935f..9a40d40d 100644 --- a/src/brpc/http2.h +++ b/src/brpc/http2.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BAIDU_RPC_HTTP2_H #define BAIDU_RPC_HTTP2_H diff --git a/src/brpc/http_header.cpp b/src/brpc/http_header.cpp index da27afbe..ccfa309f 100644 --- a/src/brpc/http_header.cpp +++ b/src/brpc/http_header.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen(chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/http_header.h b/src/brpc/http_header.h index bbe08afc..7e0fe988 100644 --- a/src/brpc/http_header.h +++ b/src/brpc/http_header.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen(chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/http_method.cpp b/src/brpc/http_method.cpp index fa2ab5a2..43457f89 100644 --- a/src/brpc/http_method.cpp +++ b/src/brpc/http_method.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen(chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/http_method.h b/src/brpc/http_method.h index ad97740a..41811b77 100644 --- a/src/brpc/http_method.h +++ b/src/brpc/http_method.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen(chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/http_status_code.cpp b/src/brpc/http_status_code.cpp index 0f3a67d1..afb58419 100644 --- a/src/brpc/http_status_code.cpp +++ b/src/brpc/http_status_code.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen(chenzhangyi01@baidu.com) diff --git a/src/brpc/http_status_code.h b/src/brpc/http_status_code.h index a4ba5346..8b75f7ad 100644 --- a/src/brpc/http_status_code.h +++ b/src/brpc/http_status_code.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen(chenzhangyi01@baidu.com) diff --git a/src/brpc/input_message_base.h b/src/brpc/input_message_base.h index 2ec404ef..fa457447 100644 --- a/src/brpc/input_message_base.h +++ b/src/brpc/input_message_base.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/input_messenger.cpp b/src/brpc/input_messenger.cpp index d953322d..de0b9528 100644 --- a/src/brpc/input_messenger.cpp +++ b/src/brpc/input_messenger.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/input_messenger.h b/src/brpc/input_messenger.h index 0801d504..27aa67ea 100644 --- a/src/brpc/input_messenger.h +++ b/src/brpc/input_messenger.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/load_balancer.cpp b/src/brpc/load_balancer.cpp index 16af3c56..372e7b1b 100644 --- a/src/brpc/load_balancer.cpp +++ b/src/brpc/load_balancer.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/load_balancer.h b/src/brpc/load_balancer.h index b6020dc6..94d1b56b 100644 --- a/src/brpc/load_balancer.h +++ b/src/brpc/load_balancer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/log.h b/src/brpc/log.h index 168ff42d..9cd180d9 100644 --- a/src/brpc/log.h +++ b/src/brpc/log.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_LOG_H #define BRPC_LOG_H diff --git a/src/brpc/memcache.cpp b/src/brpc/memcache.cpp index b069a195..c6b5edce 100644 --- a/src/brpc/memcache.cpp +++ b/src/brpc/memcache.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/memcache.h b/src/brpc/memcache.h index 9ef168d0..46c9c10c 100644 --- a/src/brpc/memcache.h +++ b/src/brpc/memcache.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/mongo_head.h b/src/brpc/mongo_head.h index 853e20a7..b9da0171 100644 --- a/src/brpc/mongo_head.h +++ b/src/brpc/mongo_head.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_MONGO_HEAD_H #define BRPC_MONGO_HEAD_H diff --git a/src/brpc/mongo_service_adaptor.h b/src/brpc/mongo_service_adaptor.h index 8314c956..318e902e 100644 --- a/src/brpc/mongo_service_adaptor.h +++ b/src/brpc/mongo_service_adaptor.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_MONGO_SERVICE_ADAPTOR_H #define BRPC_MONGO_SERVICE_ADAPTOR_H diff --git a/src/brpc/naming_service.h b/src/brpc/naming_service.h index 12fecdc2..d0713297 100644 --- a/src/brpc/naming_service.h +++ b/src/brpc/naming_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/naming_service_filter.h b/src/brpc/naming_service_filter.h index d9786585..24bd3969 100644 --- a/src/brpc/naming_service_filter.h +++ b/src/brpc/naming_service_filter.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/nshead.h b/src/brpc/nshead.h index 7d970992..4ea7268a 100644 --- a/src/brpc/nshead.h +++ b/src/brpc/nshead.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_NSHEAD_H #define BRPC_NSHEAD_H diff --git a/src/brpc/nshead_message.cpp b/src/brpc/nshead_message.cpp index dc197f99..0ac1cad6 100644 --- a/src/brpc/nshead_message.cpp +++ b/src/brpc/nshead_message.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/nshead_message.h b/src/brpc/nshead_message.h index 368c0828..9a61b083 100644 --- a/src/brpc/nshead_message.h +++ b/src/brpc/nshead_message.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/nshead_pb_service_adaptor.cpp b/src/brpc/nshead_pb_service_adaptor.cpp index 107aaaf4..0981d93f 100644 --- a/src/brpc/nshead_pb_service_adaptor.cpp +++ b/src/brpc/nshead_pb_service_adaptor.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/nshead_pb_service_adaptor.h b/src/brpc/nshead_pb_service_adaptor.h index cb9b71bd..bd511c50 100644 --- a/src/brpc/nshead_pb_service_adaptor.h +++ b/src/brpc/nshead_pb_service_adaptor.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/nshead_service.cpp b/src/brpc/nshead_service.cpp index d1f3bfdd..65a83a0b 100644 --- a/src/brpc/nshead_service.cpp +++ b/src/brpc/nshead_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/nshead_service.h b/src/brpc/nshead_service.h index 796e194f..da98047c 100644 --- a/src/brpc/nshead_service.h +++ b/src/brpc/nshead_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/parallel_channel.cpp b/src/brpc/parallel_channel.cpp index 5403d17f..38cd5f39 100644 --- a/src/brpc/parallel_channel.cpp +++ b/src/brpc/parallel_channel.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/parallel_channel.h b/src/brpc/parallel_channel.h index 71c15ba6..681536d1 100644 --- a/src/brpc/parallel_channel.h +++ b/src/brpc/parallel_channel.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/parse_result.h b/src/brpc/parse_result.h index ec50779f..a153f6b9 100644 --- a/src/brpc/parse_result.h +++ b/src/brpc/parse_result.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/partition_channel.cpp b/src/brpc/partition_channel.cpp index 9dc7daca..738d2fc6 100644 --- a/src/brpc/partition_channel.cpp +++ b/src/brpc/partition_channel.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/partition_channel.h b/src/brpc/partition_channel.h index 2b959c10..6353e5ed 100644 --- a/src/brpc/partition_channel.h +++ b/src/brpc/partition_channel.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/periodic_naming_service.cpp b/src/brpc/periodic_naming_service.cpp index 845d7ac5..fc625651 100644 --- a/src/brpc/periodic_naming_service.cpp +++ b/src/brpc/periodic_naming_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/periodic_naming_service.h b/src/brpc/periodic_naming_service.h index 0f99ee6d..4c4c68ae 100644 --- a/src/brpc/periodic_naming_service.h +++ b/src/brpc/periodic_naming_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/periodic_task.cpp b/src/brpc/periodic_task.cpp index e4cfd8f4..3d761ff6 100644 --- a/src/brpc/periodic_task.cpp +++ b/src/brpc/periodic_task.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2018 brpc authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/periodic_task.h b/src/brpc/periodic_task.h index 806201bc..a1807303 100644 --- a/src/brpc/periodic_task.h +++ b/src/brpc/periodic_task.h @@ -1,16 +1,19 @@ -// Copyright (c) 2018 brpc authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/auto_concurrency_limiter.cpp b/src/brpc/policy/auto_concurrency_limiter.cpp index 547b793a..628fe16c 100644 --- a/src/brpc/policy/auto_concurrency_limiter.cpp +++ b/src/brpc/policy/auto_concurrency_limiter.cpp @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Authors: Lei He (helei@qiyi.com) +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/src/brpc/policy/auto_concurrency_limiter.h b/src/brpc/policy/auto_concurrency_limiter.h index cd3b3dd4..84d677a7 100644 --- a/src/brpc/policy/auto_concurrency_limiter.h +++ b/src/brpc/policy/auto_concurrency_limiter.h @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Authors: Lei He (helei@qiyi.com) +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_POLICY_AUTO_CONCURRENCY_LIMITER_H #define BRPC_POLICY_AUTO_CONCURRENCY_LIMITER_H diff --git a/src/brpc/policy/baidu_naming_service.cpp b/src/brpc/policy/baidu_naming_service.cpp index 831f6fdc..1dc68653 100644 --- a/src/brpc/policy/baidu_naming_service.cpp +++ b/src/brpc/policy/baidu_naming_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifdef BAIDU_INTERNAL diff --git a/src/brpc/policy/baidu_naming_service.h b/src/brpc/policy/baidu_naming_service.h index cc8f0687..6992425e 100644 --- a/src/brpc/policy/baidu_naming_service.h +++ b/src/brpc/policy/baidu_naming_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifdef BAIDU_INTERNAL diff --git a/src/brpc/policy/baidu_rpc_protocol.cpp b/src/brpc/policy/baidu_rpc_protocol.cpp index f6059c60..eae2134d 100644 --- a/src/brpc/policy/baidu_rpc_protocol.cpp +++ b/src/brpc/policy/baidu_rpc_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/policy/baidu_rpc_protocol.h b/src/brpc/policy/baidu_rpc_protocol.h index 159f7309..d245cf26 100644 --- a/src/brpc/policy/baidu_rpc_protocol.h +++ b/src/brpc/policy/baidu_rpc_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.cpp b/src/brpc/policy/consistent_hashing_load_balancer.cpp index 56a2096d..db48ca8c 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.cpp +++ b/src/brpc/policy/consistent_hashing_load_balancer.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/policy/consistent_hashing_load_balancer.h b/src/brpc/policy/consistent_hashing_load_balancer.h index 1786ad16..05b659fd 100644 --- a/src/brpc/policy/consistent_hashing_load_balancer.h +++ b/src/brpc/policy/consistent_hashing_load_balancer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/policy/constant_concurrency_limiter.cpp b/src/brpc/policy/constant_concurrency_limiter.cpp index 6c93825d..91ab7a88 100644 --- a/src/brpc/policy/constant_concurrency_limiter.cpp +++ b/src/brpc/policy/constant_concurrency_limiter.cpp @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Authors: Lei He (helei@qiyi.com) +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "brpc/policy/constant_concurrency_limiter.h" diff --git a/src/brpc/policy/constant_concurrency_limiter.h b/src/brpc/policy/constant_concurrency_limiter.h index 5597d110..755714b8 100644 --- a/src/brpc/policy/constant_concurrency_limiter.h +++ b/src/brpc/policy/constant_concurrency_limiter.h @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Authors: Lei He (helei@qiyi.com) +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_POLICY_CONSTANT_CONCURRENCY_LIMITER_H #define BRPC_POLICY_CONSTANT_CONCURRENCY_LIMITER_H diff --git a/src/brpc/policy/consul_naming_service.cpp b/src/brpc/policy/consul_naming_service.cpp index 80bc6065..f170ce61 100644 --- a/src/brpc/policy/consul_naming_service.cpp +++ b/src/brpc/policy/consul_naming_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Yaofu Zhang (zhangyaofu@qiyi.com) diff --git a/src/brpc/policy/consul_naming_service.h b/src/brpc/policy/consul_naming_service.h index 067a2668..776b8c39 100644 --- a/src/brpc/policy/consul_naming_service.h +++ b/src/brpc/policy/consul_naming_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc.G +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Yaofu Zhang (zhangyaofu@qiyi.com) diff --git a/src/brpc/policy/couchbase_authenticator.cpp b/src/brpc/policy/couchbase_authenticator.cpp index 803deea2..40670f02 100644 --- a/src/brpc/policy/couchbase_authenticator.cpp +++ b/src/brpc/policy/couchbase_authenticator.cpp @@ -1,18 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Author(s): Chengcheng Wu +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "brpc/policy/couchbase_authenticator.h" diff --git a/src/brpc/policy/couchbase_authenticator.h b/src/brpc/policy/couchbase_authenticator.h index 446da936..f9742374 100644 --- a/src/brpc/policy/couchbase_authenticator.h +++ b/src/brpc/policy/couchbase_authenticator.h @@ -1,18 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Author(s): Chengcheng Wu +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_POLICY_COUCHBASE_AUTHENTICATOR_H #define BRPC_POLICY_COUCHBASE_AUTHENTICATOR_H diff --git a/src/brpc/policy/discovery_naming_service.cpp b/src/brpc/policy/discovery_naming_service.cpp index aeaa890a..643b0fa1 100644 --- a/src/brpc/policy/discovery_naming_service.cpp +++ b/src/brpc/policy/discovery_naming_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2018 BiliBili, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/src/brpc/policy/discovery_naming_service.h b/src/brpc/policy/discovery_naming_service.h index f529262f..3ad31fe1 100644 --- a/src/brpc/policy/discovery_naming_service.h +++ b/src/brpc/policy/discovery_naming_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2018 BiliBili, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/src/brpc/policy/domain_naming_service.cpp b/src/brpc/policy/domain_naming_service.cpp index d6f8c543..ee5e3b92 100644 --- a/src/brpc/policy/domain_naming_service.cpp +++ b/src/brpc/policy/domain_naming_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/policy/domain_naming_service.h b/src/brpc/policy/domain_naming_service.h index 99195f47..c555b8e9 100644 --- a/src/brpc/policy/domain_naming_service.h +++ b/src/brpc/policy/domain_naming_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/policy/dynpart_load_balancer.cpp b/src/brpc/policy/dynpart_load_balancer.cpp index 8b0079d3..bfb192ad 100644 --- a/src/brpc/policy/dynpart_load_balancer.cpp +++ b/src/brpc/policy/dynpart_load_balancer.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/dynpart_load_balancer.h b/src/brpc/policy/dynpart_load_balancer.h index ce481b32..02cf92b0 100644 --- a/src/brpc/policy/dynpart_load_balancer.h +++ b/src/brpc/policy/dynpart_load_balancer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/esp_authenticator.cpp b/src/brpc/policy/esp_authenticator.cpp index 69f944da..737ff18e 100644 --- a/src/brpc/policy/esp_authenticator.cpp +++ b/src/brpc/policy/esp_authenticator.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "butil/logging.h" #include "butil/memory/singleton_on_pthread_once.h" diff --git a/src/brpc/policy/esp_authenticator.h b/src/brpc/policy/esp_authenticator.h index 6f55b84a..a0f83b98 100644 --- a/src/brpc/policy/esp_authenticator.h +++ b/src/brpc/policy/esp_authenticator.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_POLICY_ESP_AUTHENTICATOR_H #define BRPC_POLICY_ESP_AUTHENTICATOR_H diff --git a/src/brpc/policy/esp_protocol.cpp b/src/brpc/policy/esp_protocol.cpp index 1d026313..6665a1a9 100644 --- a/src/brpc/policy/esp_protocol.cpp +++ b/src/brpc/policy/esp_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include // MethodDescriptor #include // Message diff --git a/src/brpc/policy/esp_protocol.h b/src/brpc/policy/esp_protocol.h index b86cfa37..7fb58c35 100644 --- a/src/brpc/policy/esp_protocol.h +++ b/src/brpc/policy/esp_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_POLICY_ESP_PROTOCOL_H #define BRPC_POLICY_ESP_PROTOCOL_H diff --git a/src/brpc/policy/file_naming_service.cpp b/src/brpc/policy/file_naming_service.cpp index df699277..0da98058 100644 --- a/src/brpc/policy/file_naming_service.cpp +++ b/src/brpc/policy/file_naming_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/file_naming_service.h b/src/brpc/policy/file_naming_service.h index 2d2f4e1b..a5c4484f 100644 --- a/src/brpc/policy/file_naming_service.h +++ b/src/brpc/policy/file_naming_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/giano_authenticator.cpp b/src/brpc/policy/giano_authenticator.cpp index 1e7556e6..dca3b988 100644 --- a/src/brpc/policy/giano_authenticator.cpp +++ b/src/brpc/policy/giano_authenticator.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifdef BAIDU_INTERNAL diff --git a/src/brpc/policy/giano_authenticator.h b/src/brpc/policy/giano_authenticator.h index 964efcd4..a008f6da 100644 --- a/src/brpc/policy/giano_authenticator.h +++ b/src/brpc/policy/giano_authenticator.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifdef BAIDU_INTERNAL diff --git a/src/brpc/policy/gzip_compress.cpp b/src/brpc/policy/gzip_compress.cpp index b2bca6ca..edba16d1 100644 --- a/src/brpc/policy/gzip_compress.cpp +++ b/src/brpc/policy/gzip_compress.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/gzip_compress.h b/src/brpc/policy/gzip_compress.h index 87cbdc8f..f45edd43 100644 --- a/src/brpc/policy/gzip_compress.h +++ b/src/brpc/policy/gzip_compress.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/hasher.cpp b/src/brpc/policy/hasher.cpp index e53df2b0..7cb0bc9c 100644 --- a/src/brpc/policy/hasher.cpp +++ b/src/brpc/policy/hasher.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/policy/hasher.h b/src/brpc/policy/hasher.h index a0a23000..fd70e517 100644 --- a/src/brpc/policy/hasher.h +++ b/src/brpc/policy/hasher.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/policy/http2_rpc_protocol.cpp b/src/brpc/policy/http2_rpc_protocol.cpp index 7a88620e..bd0ef9ae 100644 --- a/src/brpc/policy/http2_rpc_protocol.cpp +++ b/src/brpc/policy/http2_rpc_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Jiashun Zhu(zhujiashun@baidu.com) diff --git a/src/brpc/policy/http2_rpc_protocol.h b/src/brpc/policy/http2_rpc_protocol.h index 24556111..dded7d26 100644 --- a/src/brpc/policy/http2_rpc_protocol.h +++ b/src/brpc/policy/http2_rpc_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Jiashun Zhu(zhujiashun@baidu.com) diff --git a/src/brpc/policy/http_rpc_protocol.cpp b/src/brpc/policy/http_rpc_protocol.cpp index e0177aa7..012e3035 100644 --- a/src/brpc/policy/http_rpc_protocol.cpp +++ b/src/brpc/policy/http_rpc_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/http_rpc_protocol.h b/src/brpc/policy/http_rpc_protocol.h index bd6540cc..46993cd7 100644 --- a/src/brpc/policy/http_rpc_protocol.h +++ b/src/brpc/policy/http_rpc_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/hulu_pbrpc_controller.h b/src/brpc/policy/hulu_pbrpc_controller.h index 47a13b2a..c2e72663 100644 --- a/src/brpc/policy/hulu_pbrpc_controller.h +++ b/src/brpc/policy/hulu_pbrpc_controller.h @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/policy/hulu_pbrpc_protocol.cpp b/src/brpc/policy/hulu_pbrpc_protocol.cpp index b0fbdb35..9766e2ed 100644 --- a/src/brpc/policy/hulu_pbrpc_protocol.cpp +++ b/src/brpc/policy/hulu_pbrpc_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/hulu_pbrpc_protocol.h b/src/brpc/policy/hulu_pbrpc_protocol.h index 000479c6..b3413416 100644 --- a/src/brpc/policy/hulu_pbrpc_protocol.h +++ b/src/brpc/policy/hulu_pbrpc_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/list_naming_service.cpp b/src/brpc/policy/list_naming_service.cpp index 592e6aeb..b9c4e4fb 100644 --- a/src/brpc/policy/list_naming_service.cpp +++ b/src/brpc/policy/list_naming_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/list_naming_service.h b/src/brpc/policy/list_naming_service.h index d55196dc..3a574345 100644 --- a/src/brpc/policy/list_naming_service.h +++ b/src/brpc/policy/list_naming_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/locality_aware_load_balancer.cpp b/src/brpc/policy/locality_aware_load_balancer.cpp index f28941c5..7a3cb3e6 100644 --- a/src/brpc/policy/locality_aware_load_balancer.cpp +++ b/src/brpc/policy/locality_aware_load_balancer.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/locality_aware_load_balancer.h b/src/brpc/policy/locality_aware_load_balancer.h index 0ff00971..3c269d8f 100644 --- a/src/brpc/policy/locality_aware_load_balancer.h +++ b/src/brpc/policy/locality_aware_load_balancer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/memcache_binary_header.h b/src/brpc/policy/memcache_binary_header.h index 37136999..854bdfc2 100644 --- a/src/brpc/policy/memcache_binary_header.h +++ b/src/brpc/policy/memcache_binary_header.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/memcache_binary_protocol.cpp b/src/brpc/policy/memcache_binary_protocol.cpp index c9c6a012..1fa8903e 100644 --- a/src/brpc/policy/memcache_binary_protocol.cpp +++ b/src/brpc/policy/memcache_binary_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/memcache_binary_protocol.h b/src/brpc/policy/memcache_binary_protocol.h index 29974144..f180dd8f 100644 --- a/src/brpc/policy/memcache_binary_protocol.h +++ b/src/brpc/policy/memcache_binary_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/mongo_protocol.cpp b/src/brpc/policy/mongo_protocol.cpp index 41e91e2c..82bb3e0b 100644 --- a/src/brpc/policy/mongo_protocol.cpp +++ b/src/brpc/policy/mongo_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include // MethodDescriptor #include // Message diff --git a/src/brpc/policy/mongo_protocol.h b/src/brpc/policy/mongo_protocol.h index 782cc798..3b8e6c44 100644 --- a/src/brpc/policy/mongo_protocol.h +++ b/src/brpc/policy/mongo_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_POLICY_MONGO_PROTOCOL_H #define BRPC_POLICY_MONGO_PROTOCOL_H diff --git a/src/brpc/policy/most_common_message.h b/src/brpc/policy/most_common_message.h index 422f238b..83e3cf2d 100644 --- a/src/brpc/policy/most_common_message.h +++ b/src/brpc/policy/most_common_message.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/nova_pbrpc_protocol.cpp b/src/brpc/policy/nova_pbrpc_protocol.cpp index 344c9dc9..412c9eaa 100644 --- a/src/brpc/policy/nova_pbrpc_protocol.cpp +++ b/src/brpc/policy/nova_pbrpc_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/nova_pbrpc_protocol.h b/src/brpc/policy/nova_pbrpc_protocol.h index f583e9cd..9a16994b 100644 --- a/src/brpc/policy/nova_pbrpc_protocol.h +++ b/src/brpc/policy/nova_pbrpc_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/nshead_mcpack_protocol.cpp b/src/brpc/policy/nshead_mcpack_protocol.cpp index f51985d4..b4daadb4 100644 --- a/src/brpc/policy/nshead_mcpack_protocol.cpp +++ b/src/brpc/policy/nshead_mcpack_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/nshead_mcpack_protocol.h b/src/brpc/policy/nshead_mcpack_protocol.h index 32f6f89f..9e42fb8d 100644 --- a/src/brpc/policy/nshead_mcpack_protocol.h +++ b/src/brpc/policy/nshead_mcpack_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/nshead_protocol.cpp b/src/brpc/policy/nshead_protocol.cpp index 3ebcf7fd..98b18b80 100644 --- a/src/brpc/policy/nshead_protocol.cpp +++ b/src/brpc/policy/nshead_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/nshead_protocol.h b/src/brpc/policy/nshead_protocol.h index 30ee8347..9e06b470 100644 --- a/src/brpc/policy/nshead_protocol.h +++ b/src/brpc/policy/nshead_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/public_pbrpc_protocol.cpp b/src/brpc/policy/public_pbrpc_protocol.cpp index c15733af..784ed2f9 100644 --- a/src/brpc/policy/public_pbrpc_protocol.cpp +++ b/src/brpc/policy/public_pbrpc_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/policy/public_pbrpc_protocol.h b/src/brpc/policy/public_pbrpc_protocol.h index 1f39f638..ecc43ae5 100644 --- a/src/brpc/policy/public_pbrpc_protocol.h +++ b/src/brpc/policy/public_pbrpc_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/policy/randomized_load_balancer.cpp b/src/brpc/policy/randomized_load_balancer.cpp index 97bc9146..3600fa63 100644 --- a/src/brpc/policy/randomized_load_balancer.cpp +++ b/src/brpc/policy/randomized_load_balancer.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/randomized_load_balancer.h b/src/brpc/policy/randomized_load_balancer.h index e242d93d..0816dcb3 100644 --- a/src/brpc/policy/randomized_load_balancer.h +++ b/src/brpc/policy/randomized_load_balancer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/redis_authenticator.cpp b/src/brpc/policy/redis_authenticator.cpp index 221b9203..b6921f78 100644 --- a/src/brpc/policy/redis_authenticator.cpp +++ b/src/brpc/policy/redis_authenticator.cpp @@ -1,18 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Author(s): Feng Yan +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "brpc/policy/redis_authenticator.h" diff --git a/src/brpc/policy/redis_authenticator.h b/src/brpc/policy/redis_authenticator.h index 95fa54a1..739f9346 100644 --- a/src/brpc/policy/redis_authenticator.h +++ b/src/brpc/policy/redis_authenticator.h @@ -1,18 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Author(s): Feng Yan +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_POLICY_REDIS_AUTHENTICATOR_H #define BRPC_POLICY_REDIS_AUTHENTICATOR_H diff --git a/src/brpc/policy/redis_protocol.cpp b/src/brpc/policy/redis_protocol.cpp index 0df56fee..14717336 100644 --- a/src/brpc/policy/redis_protocol.cpp +++ b/src/brpc/policy/redis_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/redis_protocol.h b/src/brpc/policy/redis_protocol.h index 319ef5d6..6e1e061b 100644 --- a/src/brpc/policy/redis_protocol.h +++ b/src/brpc/policy/redis_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/remote_file_naming_service.cpp b/src/brpc/policy/remote_file_naming_service.cpp index ac81eb94..ee1d3bc0 100644 --- a/src/brpc/policy/remote_file_naming_service.cpp +++ b/src/brpc/policy/remote_file_naming_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/remote_file_naming_service.h b/src/brpc/policy/remote_file_naming_service.h index be391c5e..c5acb93f 100644 --- a/src/brpc/policy/remote_file_naming_service.h +++ b/src/brpc/policy/remote_file_naming_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/round_robin_load_balancer.cpp b/src/brpc/policy/round_robin_load_balancer.cpp index d0cbd8b6..171f4e60 100644 --- a/src/brpc/policy/round_robin_load_balancer.cpp +++ b/src/brpc/policy/round_robin_load_balancer.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/round_robin_load_balancer.h b/src/brpc/policy/round_robin_load_balancer.h index 9a5d779b..2f117d88 100644 --- a/src/brpc/policy/round_robin_load_balancer.h +++ b/src/brpc/policy/round_robin_load_balancer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/rtmp_protocol.cpp b/src/brpc/policy/rtmp_protocol.cpp index 825f01bd..a6e7bae8 100644 --- a/src/brpc/policy/rtmp_protocol.cpp +++ b/src/brpc/policy/rtmp_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Jiashun Zhu (zhujiashun@baidu.com) diff --git a/src/brpc/policy/rtmp_protocol.h b/src/brpc/policy/rtmp_protocol.h index 9d5b296d..e538d556 100644 --- a/src/brpc/policy/rtmp_protocol.h +++ b/src/brpc/policy/rtmp_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Jiashun Zhu (zhujiashun@baidu.com) diff --git a/src/brpc/policy/snappy_compress.cpp b/src/brpc/policy/snappy_compress.cpp index d9c0967a..c270d239 100644 --- a/src/brpc/policy/snappy_compress.cpp +++ b/src/brpc/policy/snappy_compress.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiang,Lin (jianglin05@baidu.com) diff --git a/src/brpc/policy/snappy_compress.h b/src/brpc/policy/snappy_compress.h index 992de333..19af34da 100644 --- a/src/brpc/policy/snappy_compress.h +++ b/src/brpc/policy/snappy_compress.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiang,Lin (jianglin05@baidu.com) diff --git a/src/brpc/policy/sofa_pbrpc_protocol.cpp b/src/brpc/policy/sofa_pbrpc_protocol.cpp index 34ed83e9..0a0552bf 100644 --- a/src/brpc/policy/sofa_pbrpc_protocol.cpp +++ b/src/brpc/policy/sofa_pbrpc_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/sofa_pbrpc_protocol.h b/src/brpc/policy/sofa_pbrpc_protocol.h index 047eb401..523bd627 100644 --- a/src/brpc/policy/sofa_pbrpc_protocol.h +++ b/src/brpc/policy/sofa_pbrpc_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/streaming_rpc_protocol.cpp b/src/brpc/policy/streaming_rpc_protocol.cpp index 541eaaf3..fb6f3e92 100644 --- a/src/brpc/policy/streaming_rpc_protocol.cpp +++ b/src/brpc/policy/streaming_rpc_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/policy/streaming_rpc_protocol.h b/src/brpc/policy/streaming_rpc_protocol.h index 7a5689c8..4b12fe4c 100644 --- a/src/brpc/policy/streaming_rpc_protocol.h +++ b/src/brpc/policy/streaming_rpc_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/policy/thrift_protocol.cpp b/src/brpc/policy/thrift_protocol.cpp index 32abe3ab..a2558514 100755 --- a/src/brpc/policy/thrift_protocol.cpp +++ b/src/brpc/policy/thrift_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: wangxuefeng (wangxuefeng@didichuxing.com) diff --git a/src/brpc/policy/thrift_protocol.h b/src/brpc/policy/thrift_protocol.h index 44c00b9d..7007acdb 100755 --- a/src/brpc/policy/thrift_protocol.h +++ b/src/brpc/policy/thrift_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: wangxuefeng (wangxuefeng@didichuxing.com) diff --git a/src/brpc/policy/ubrpc2pb_protocol.cpp b/src/brpc/policy/ubrpc2pb_protocol.cpp index 93e080f6..7f83db0b 100644 --- a/src/brpc/policy/ubrpc2pb_protocol.cpp +++ b/src/brpc/policy/ubrpc2pb_protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/ubrpc2pb_protocol.h b/src/brpc/policy/ubrpc2pb_protocol.h index 692f8cce..09b65006 100644 --- a/src/brpc/policy/ubrpc2pb_protocol.h +++ b/src/brpc/policy/ubrpc2pb_protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp index 5b977820..c66ae588 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp +++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp @@ -1,17 +1,20 @@ -// Copyright (c) 2018 Iqiyi, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Authors: Daojin Cai (caidaojin@qiyi.com) #include diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.h b/src/brpc/policy/weighted_round_robin_load_balancer.h index dab98fd2..35d534ce 100644 --- a/src/brpc/policy/weighted_round_robin_load_balancer.h +++ b/src/brpc/policy/weighted_round_robin_load_balancer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2018 Iqiyi, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Daojin Cai (caidaojin@qiyi.com) diff --git a/src/brpc/progressive_attachment.cpp b/src/brpc/progressive_attachment.cpp index 412c29f6..d61feee7 100644 --- a/src/brpc/progressive_attachment.cpp +++ b/src/brpc/progressive_attachment.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/progressive_attachment.h b/src/brpc/progressive_attachment.h index 3af93681..36c68629 100644 --- a/src/brpc/progressive_attachment.h +++ b/src/brpc/progressive_attachment.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/progressive_reader.h b/src/brpc/progressive_reader.h index 0fc6dc64..d76335cb 100644 --- a/src/brpc/progressive_reader.h +++ b/src/brpc/progressive_reader.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/protocol.cpp b/src/brpc/protocol.cpp index fddc6355..e20c88e7 100644 --- a/src/brpc/protocol.cpp +++ b/src/brpc/protocol.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/protocol.h b/src/brpc/protocol.h index 5c972c44..aa782078 100755 --- a/src/brpc/protocol.h +++ b/src/brpc/protocol.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp index c4ff4c5a..60378dad 100644 --- a/src/brpc/redis.cpp +++ b/src/brpc/redis.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/redis.h b/src/brpc/redis.h index d70af0a8..3e591424 100644 --- a/src/brpc/redis.h +++ b/src/brpc/redis.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/redis_command.cpp b/src/brpc/redis_command.cpp index 7beb482d..e8e586a3 100644 --- a/src/brpc/redis_command.cpp +++ b/src/brpc/redis_command.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/redis_command.h b/src/brpc/redis_command.h index 7a91011f..6e57990e 100644 --- a/src/brpc/redis_command.h +++ b/src/brpc/redis_command.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/redis_reply.cpp b/src/brpc/redis_reply.cpp index 504e3033..2e3aec51 100644 --- a/src/brpc/redis_reply.cpp +++ b/src/brpc/redis_reply.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/redis_reply.h b/src/brpc/redis_reply.h index 308b2258..9234b903 100644 --- a/src/brpc/redis_reply.h +++ b/src/brpc/redis_reply.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/reloadable_flags.cpp b/src/brpc/reloadable_flags.cpp index bc45684e..d21c3428 100644 --- a/src/brpc/reloadable_flags.cpp +++ b/src/brpc/reloadable_flags.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/reloadable_flags.h b/src/brpc/reloadable_flags.h index 9f6f2e9a..8cf03604 100644 --- a/src/brpc/reloadable_flags.h +++ b/src/brpc/reloadable_flags.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/restful.cpp b/src/brpc/restful.cpp index aa77dc6f..3fc92191 100644 --- a/src/brpc/restful.cpp +++ b/src/brpc/restful.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/restful.h b/src/brpc/restful.h index bc4044a2..3f52a9b5 100644 --- a/src/brpc/restful.h +++ b/src/brpc/restful.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/retry_policy.cpp b/src/brpc/retry_policy.cpp index 8a64bc14..fbfb4182 100644 --- a/src/brpc/retry_policy.cpp +++ b/src/brpc/retry_policy.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/retry_policy.h b/src/brpc/retry_policy.h index f7e45e52..3db55b76 100644 --- a/src/brpc/retry_policy.h +++ b/src/brpc/retry_policy.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/rpc_dump.cpp b/src/brpc/rpc_dump.cpp index 18f61f87..7c27d5de 100644 --- a/src/brpc/rpc_dump.cpp +++ b/src/brpc/rpc_dump.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/rpc_dump.h b/src/brpc/rpc_dump.h index e17213bd..83b97b3d 100644 --- a/src/brpc/rpc_dump.h +++ b/src/brpc/rpc_dump.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/rtmp.cpp b/src/brpc/rtmp.cpp index 795f86bc..cea0f746 100644 --- a/src/brpc/rtmp.cpp +++ b/src/brpc/rtmp.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Jiashun Zhu (zhujiashun@baidu.com) diff --git a/src/brpc/rtmp.h b/src/brpc/rtmp.h index 12642e16..778baffa 100644 --- a/src/brpc/rtmp.h +++ b/src/brpc/rtmp.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Jiashun Zhu (zhujiashun@baidu.com) diff --git a/src/brpc/selective_channel.cpp b/src/brpc/selective_channel.cpp index 2c495eb7..c2fb4923 100644 --- a/src/brpc/selective_channel.cpp +++ b/src/brpc/selective_channel.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/selective_channel.h b/src/brpc/selective_channel.h index 3f63f3a9..47e739da 100644 --- a/src/brpc/selective_channel.h +++ b/src/brpc/selective_channel.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/serialized_request.cpp b/src/brpc/serialized_request.cpp index c6e73c25..23771772 100644 --- a/src/brpc/serialized_request.cpp +++ b/src/brpc/serialized_request.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/serialized_request.h b/src/brpc/serialized_request.h index 83952225..95999e1c 100644 --- a/src/brpc/serialized_request.h +++ b/src/brpc/serialized_request.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 36a49d7e..3da7f586 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang(jiangrujie@baidu.com) diff --git a/src/brpc/server.h b/src/brpc/server.h index 1c0968ce..dd88957f 100644 --- a/src/brpc/server.h +++ b/src/brpc/server.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/server_id.cpp b/src/brpc/server_id.cpp index d3f8172c..98e13d00 100644 --- a/src/brpc/server_id.cpp +++ b/src/brpc/server_id.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/server_id.h b/src/brpc/server_id.h index d202c09e..f0cb72b0 100644 --- a/src/brpc/server_id.h +++ b/src/brpc/server_id.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/server_node.h b/src/brpc/server_node.h index 19b4a239..81c4b1cd 100644 --- a/src/brpc/server_node.h +++ b/src/brpc/server_node.h @@ -1,18 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Authors: Ge,Jun (gejun@baidu.com) +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_SERVER_NODE_H #define BRPC_SERVER_NODE_H diff --git a/src/brpc/shared_object.h b/src/brpc/shared_object.h index 35ad69fe..380fba5a 100644 --- a/src/brpc/shared_object.h +++ b/src/brpc/shared_object.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/simple_data_pool.h b/src/brpc/simple_data_pool.h index 0368659c..c738e341 100644 --- a/src/brpc/simple_data_pool.h +++ b/src/brpc/simple_data_pool.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 92f56925..cb2d241c 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/socket.h b/src/brpc/socket.h index ade9dc14..9739af4b 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/socket_id.h b/src/brpc/socket_id.h index df1eb282..1ae85ce7 100644 --- a/src/brpc/socket_id.h +++ b/src/brpc/socket_id.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/socket_inl.h b/src/brpc/socket_inl.h index 5b51913e..31ce6a90 100644 --- a/src/brpc/socket_inl.h +++ b/src/brpc/socket_inl.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // This file contains inlined implementation of socket.h diff --git a/src/brpc/socket_map.cpp b/src/brpc/socket_map.cpp index 470d8ee5..bca0f8b6 100644 --- a/src/brpc/socket_map.cpp +++ b/src/brpc/socket_map.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/socket_map.h b/src/brpc/socket_map.h index 33874bc2..fd6a6cb1 100644 --- a/src/brpc/socket_map.h +++ b/src/brpc/socket_map.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/socket_message.h b/src/brpc/socket_message.h index 47a8fa24..c0aa6a74 100644 --- a/src/brpc/socket_message.h +++ b/src/brpc/socket_message.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/span.cpp b/src/brpc/span.cpp index ceedcd03..9381b266 100644 --- a/src/brpc/span.cpp +++ b/src/brpc/span.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/span.h b/src/brpc/span.h index 4a77feac..c29e69a3 100644 --- a/src/brpc/span.h +++ b/src/brpc/span.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/ssl_options.cpp b/src/brpc/ssl_options.cpp index 73b4168d..a601778a 100644 --- a/src/brpc/ssl_options.cpp +++ b/src/brpc/ssl_options.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 baidu-rpc authors. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/ssl_options.h b/src/brpc/ssl_options.h index 95f28a24..9ba01958 100644 --- a/src/brpc/ssl_options.h +++ b/src/brpc/ssl_options.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 baidu-rpc authors. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Rujie Jiang (jiangrujie@baidu.com) diff --git a/src/brpc/stream.cpp b/src/brpc/stream.cpp index 5a41165a..920c2f52 100644 --- a/src/brpc/stream.cpp +++ b/src/brpc/stream.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/stream.h b/src/brpc/stream.h index 540421a7..a193dd03 100644 --- a/src/brpc/stream.h +++ b/src/brpc/stream.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/stream_creator.h b/src/brpc/stream_creator.h index 02ed4dc9..394eb37e 100644 --- a/src/brpc/stream_creator.h +++ b/src/brpc/stream_creator.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/stream_impl.h b/src/brpc/stream_impl.h index ddcc99eb..97b7d96c 100644 --- a/src/brpc/stream_impl.h +++ b/src/brpc/stream_impl.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) diff --git a/src/brpc/thrift_message.cpp b/src/brpc/thrift_message.cpp index 0c0f87c5..c73fccd8 100644 --- a/src/brpc/thrift_message.cpp +++ b/src/brpc/thrift_message.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: wangxuefeng (wangxuefeng@didichuxing.com) diff --git a/src/brpc/thrift_message.h b/src/brpc/thrift_message.h index 82290868..3dbc44a0 100644 --- a/src/brpc/thrift_message.h +++ b/src/brpc/thrift_message.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: wangxuefeng (wangxuefeng@didichuxing.com) diff --git a/src/brpc/thrift_service.cpp b/src/brpc/thrift_service.cpp index aec8cb54..2a501f1b 100644 --- a/src/brpc/thrift_service.cpp +++ b/src/brpc/thrift_service.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: wangxuefeng (wangxuefeng@didichuxing.com) diff --git a/src/brpc/thrift_service.h b/src/brpc/thrift_service.h index 6db0fabe..ef5e905c 100644 --- a/src/brpc/thrift_service.h +++ b/src/brpc/thrift_service.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: wangxuefeng (wangxuefeng@didichuxing.com) diff --git a/src/brpc/traceprintf.h b/src/brpc/traceprintf.h index 3e2b2418..5f07c0e5 100644 --- a/src/brpc/traceprintf.h +++ b/src/brpc/traceprintf.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/trackme.cpp b/src/brpc/trackme.cpp index 9283d4d6..d47a4ff4 100644 --- a/src/brpc/trackme.cpp +++ b/src/brpc/trackme.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/trackme.h b/src/brpc/trackme.h index 7d2def41..f7618cb7 100644 --- a/src/brpc/trackme.h +++ b/src/brpc/trackme.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/ts.cpp b/src/brpc/ts.cpp index 89524aec..70ce320b 100644 --- a/src/brpc/ts.cpp +++ b/src/brpc/ts.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/ts.h b/src/brpc/ts.h index 7f71ba75..12f3cca8 100644 --- a/src/brpc/ts.h +++ b/src/brpc/ts.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/uri.cpp b/src/brpc/uri.cpp index 6fe0e4d0..1f5ffaac 100644 --- a/src/brpc/uri.cpp +++ b/src/brpc/uri.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/brpc/uri.h b/src/brpc/uri.h index 706f5470..70f10899 100644 --- a/src/brpc/uri.h +++ b/src/brpc/uri.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Zhangyi Chen (chenzhangyi01@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/bthread/bthread.cpp b/src/bthread/bthread.cpp index 2de93dc2..4f12e3a2 100644 --- a/src/bthread/bthread.cpp +++ b/src/bthread/bthread.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/bthread.h b/src/bthread/bthread.h index e4c9476f..d93daea8 100644 --- a/src/bthread/bthread.h +++ b/src/bthread/bthread.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/butex.cpp b/src/bthread/butex.cpp index acfa79af..84540b90 100644 --- a/src/bthread/butex.cpp +++ b/src/bthread/butex.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 22 17:30:12 CST 2014 diff --git a/src/bthread/butex.h b/src/bthread/butex.h index 890cd4cf..bc55fa1b 100644 --- a/src/bthread/butex.h +++ b/src/bthread/butex.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 22 17:30:12 CST 2014 diff --git a/src/bthread/comlog_initializer.h b/src/bthread/comlog_initializer.h index 2fc90401..1a5b0fb0 100644 --- a/src/bthread/comlog_initializer.h +++ b/src/bthread/comlog_initializer.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Sep 15 10:51:15 CST 2014 diff --git a/src/bthread/condition_variable.cpp b/src/bthread/condition_variable.cpp index 56e273b7..e1411c20 100644 --- a/src/bthread/condition_variable.cpp +++ b/src/bthread/condition_variable.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Aug 3 12:46:15 CST 2014 diff --git a/src/bthread/condition_variable.h b/src/bthread/condition_variable.h index 012a85a3..08f2b3ba 100644 --- a/src/bthread/condition_variable.h +++ b/src/bthread/condition_variable.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/12/14 21:26:26 diff --git a/src/bthread/countdown_event.cpp b/src/bthread/countdown_event.cpp index 6e0a3730..033774a2 100644 --- a/src/bthread/countdown_event.cpp +++ b/src/bthread/countdown_event.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2016/06/03 13:15:24 diff --git a/src/bthread/countdown_event.h b/src/bthread/countdown_event.h index 62ca9b1f..bb6b4159 100644 --- a/src/bthread/countdown_event.h +++ b/src/bthread/countdown_event.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2016/06/03 13:06:40 diff --git a/src/bthread/errno.cpp b/src/bthread/errno.cpp index 1fb9c022..56b6f22f 100644 --- a/src/bthread/errno.cpp +++ b/src/bthread/errno.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Wed Jul 30 11:47:19 CST 2014 diff --git a/src/bthread/errno.h b/src/bthread/errno.h index 47d15856..f3dcdef1 100644 --- a/src/bthread/errno.h +++ b/src/bthread/errno.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Wed Jul 30 11:47:19 CST 2014 diff --git a/src/bthread/execution_queue.cpp b/src/bthread/execution_queue.cpp index a87362c3..73cfc23d 100644 --- a/src/bthread/execution_queue.cpp +++ b/src/bthread/execution_queue.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2016/04/16 18:43:24 diff --git a/src/bthread/execution_queue.h b/src/bthread/execution_queue.h index a9515f20..caa0cf10 100644 --- a/src/bthread/execution_queue.h +++ b/src/bthread/execution_queue.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/10/23 18:16:16 diff --git a/src/bthread/execution_queue_inl.h b/src/bthread/execution_queue_inl.h index 429ad25e..561525a3 100644 --- a/src/bthread/execution_queue_inl.h +++ b/src/bthread/execution_queue_inl.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/10/27 17:39:48 diff --git a/src/bthread/fd.cpp b/src/bthread/fd.cpp index 364647de..17ab6dbc 100644 --- a/src/bthread/fd.cpp +++ b/src/bthread/fd.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Aug 7 18:56:27 CST 2014 diff --git a/src/bthread/id.cpp b/src/bthread/id.cpp index a3484a26..3e3fcda2 100644 --- a/src/bthread/id.cpp +++ b/src/bthread/id.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Aug 3 12:46:15 CST 2014 diff --git a/src/bthread/id.h b/src/bthread/id.h index 92783301..502086f3 100644 --- a/src/bthread/id.h +++ b/src/bthread/id.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/interrupt_pthread.cpp b/src/bthread/interrupt_pthread.cpp index 0e67ac87..19ad4df2 100644 --- a/src/bthread/interrupt_pthread.cpp +++ b/src/bthread/interrupt_pthread.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/interrupt_pthread.h b/src/bthread/interrupt_pthread.h index f55a74c1..b7f3c294 100644 --- a/src/bthread/interrupt_pthread.h +++ b/src/bthread/interrupt_pthread.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/key.cpp b/src/bthread/key.cpp index 7a0d60a1..438e01ea 100644 --- a/src/bthread/key.cpp +++ b/src/bthread/key.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Aug 3 12:46:15 CST 2014 diff --git a/src/bthread/list_of_abafree_id.h b/src/bthread/list_of_abafree_id.h index 3bfdd82d..362980a8 100644 --- a/src/bthread/list_of_abafree_id.h +++ b/src/bthread/list_of_abafree_id.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Jun 20 11:57:23 CST 2016 diff --git a/src/bthread/log.h b/src/bthread/log.h index 3bba66b7..5d244072 100644 --- a/src/bthread/log.h +++ b/src/bthread/log.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Sep 15 10:51:15 CST 2014 diff --git a/src/bthread/mutex.cpp b/src/bthread/mutex.cpp index e8660ae5..7d5ed641 100644 --- a/src/bthread/mutex.cpp +++ b/src/bthread/mutex.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Aug 3 12:46:15 CST 2014 diff --git a/src/bthread/mutex.h b/src/bthread/mutex.h index a1c8ec00..e47958ea 100644 --- a/src/bthread/mutex.h +++ b/src/bthread/mutex.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/12/14 18:17:04 diff --git a/src/bthread/parking_lot.h b/src/bthread/parking_lot.h index 66485574..13bb92b7 100644 --- a/src/bthread/parking_lot.h +++ b/src/bthread/parking_lot.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2017 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: chenzhangyi01@baidu.com, gejun@baidu.com // Date: 2017/07/27 23:07:06 diff --git a/src/bthread/processor.h b/src/bthread/processor.h index 001e95c9..7513c6af 100644 --- a/src/bthread/processor.h +++ b/src/bthread/processor.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Fri Dec 5 13:40:57 CST 2014 diff --git a/src/bthread/remote_task_queue.h b/src/bthread/remote_task_queue.h index 37e71e8c..3f9bb24e 100644 --- a/src/bthread/remote_task_queue.h +++ b/src/bthread/remote_task_queue.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2017 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun, 22 Jan 2017 diff --git a/src/bthread/stack.cpp b/src/bthread/stack.cpp index 69fd7bf6..05560dad 100644 --- a/src/bthread/stack.cpp +++ b/src/bthread/stack.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Sep 7 22:37:39 CST 2014 diff --git a/src/bthread/stack.h b/src/bthread/stack.h index 73eab53f..9a9de592 100644 --- a/src/bthread/stack.h +++ b/src/bthread/stack.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Sep 7 22:37:39 CST 2014 diff --git a/src/bthread/stack_inl.h b/src/bthread/stack_inl.h index f7acdd73..62df8bcb 100644 --- a/src/bthread/stack_inl.h +++ b/src/bthread/stack_inl.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Sep 7 22:37:39 CST 2014 diff --git a/src/bthread/sys_futex.cpp b/src/bthread/sys_futex.cpp index 4fb0692a..16e35168 100644 --- a/src/bthread/sys_futex.cpp +++ b/src/bthread/sys_futex.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhu,Jiashun (zhujiashun@baidu.com) // Date: Wed Mar 14 17:44:58 CST 2018 diff --git a/src/bthread/sys_futex.h b/src/bthread/sys_futex.h index 516afa28..f57dfcbd 100644 --- a/src/bthread/sys_futex.h +++ b/src/bthread/sys_futex.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/task_control.cpp b/src/bthread/task_control.cpp index 2527c722..068d9c73 100644 --- a/src/bthread/task_control.cpp +++ b/src/bthread/task_control.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/task_control.h b/src/bthread/task_control.h index 83c0c995..afe0d813 100644 --- a/src/bthread/task_control.h +++ b/src/bthread/task_control.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/task_group.cpp b/src/bthread/task_group.cpp index 45e2b859..a0878933 100644 --- a/src/bthread/task_group.cpp +++ b/src/bthread/task_group.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/task_group.h b/src/bthread/task_group.h index 201472d3..4c5d8cde 100644 --- a/src/bthread/task_group.h +++ b/src/bthread/task_group.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/task_group_inl.h b/src/bthread/task_group_inl.h index 76575874..60c95497 100644 --- a/src/bthread/task_group_inl.h +++ b/src/bthread/task_group_inl.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/task_meta.h b/src/bthread/task_meta.h index 92cb4318..f33593e1 100644 --- a/src/bthread/task_meta.h +++ b/src/bthread/task_meta.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/timer_thread.cpp b/src/bthread/timer_thread.cpp index 1a5ff35f..1cc5cd84 100644 --- a/src/bthread/timer_thread.cpp +++ b/src/bthread/timer_thread.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) diff --git a/src/bthread/timer_thread.h b/src/bthread/timer_thread.h index ab39ec60..27f3f4b7 100644 --- a/src/bthread/timer_thread.h +++ b/src/bthread/timer_thread.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) diff --git a/src/bthread/types.h b/src/bthread/types.h index f81ff0cf..d43b6cd0 100644 --- a/src/bthread/types.h +++ b/src/bthread/types.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/unstable.h b/src/bthread/unstable.h index 78e0bf19..0d165377 100644 --- a/src/bthread/unstable.h +++ b/src/bthread/unstable.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/bthread/work_stealing_queue.h b/src/bthread/work_stealing_queue.h index b4a18229..6fd88e19 100644 --- a/src/bthread/work_stealing_queue.h +++ b/src/bthread/work_stealing_queue.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 10 17:40:58 CST 2012 diff --git a/src/butil/arena.cpp b/src/butil/arena.cpp index 5194f696..2bdc573a 100644 --- a/src/butil/arena.cpp +++ b/src/butil/arena.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Fri Jun 5 18:25:40 CST 2015 diff --git a/src/butil/arena.h b/src/butil/arena.h index b8ca9d7b..06c4d1ba 100644 --- a/src/butil/arena.h +++ b/src/butil/arena.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Fri Jun 5 18:25:40 CST 2015 diff --git a/src/butil/binary_printer.cpp b/src/butil/binary_printer.cpp index 58fa11e3..6cca5fb6 100644 --- a/src/butil/binary_printer.cpp +++ b/src/butil/binary_printer.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Nov 22 13:57:56 CST 2012 diff --git a/src/butil/binary_printer.h b/src/butil/binary_printer.h index 8f53627f..79890f78 100644 --- a/src/butil/binary_printer.h +++ b/src/butil/binary_printer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Nov 22 13:57:56 CST 2012 diff --git a/src/butil/bit_array.h b/src/butil/bit_array.h index 99af8151..cb4f90ee 100644 --- a/src/butil/bit_array.h +++ b/src/butil/bit_array.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Feb 25 23:43:39 CST 2014 diff --git a/src/butil/class_name.cpp b/src/butil/class_name.cpp index aea4d9a9..f80d48e2 100644 --- a/src/butil/class_name.cpp +++ b/src/butil/class_name.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/class_name.h b/src/butil/class_name.h index 723c118a..e0b80742 100644 --- a/src/butil/class_name.h +++ b/src/butil/class_name.h @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/comlog_sink.cc b/src/butil/comlog_sink.cc index 4a19db7b..493da15e 100644 --- a/src/butil/comlog_sink.cc +++ b/src/butil/comlog_sink.cc @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Jul 20 12:39:39 CST 2015 diff --git a/src/butil/comlog_sink.h b/src/butil/comlog_sink.h index 247336c4..37b527d2 100644 --- a/src/butil/comlog_sink.h +++ b/src/butil/comlog_sink.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Jul 20 12:39:39 CST 2015 diff --git a/src/butil/compat.h b/src/butil/compat.h index 596059d3..0254c524 100644 --- a/src/butil/compat.h +++ b/src/butil/compat.h @@ -1,16 +1,19 @@ -// Copyright (c) 2018 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) // Jiashun Zhu(zhujiashun@baidu.com) diff --git a/src/butil/containers/bounded_queue.h b/src/butil/containers/bounded_queue.h index 63ad3195..556d70bf 100644 --- a/src/butil/containers/bounded_queue.h +++ b/src/butil/containers/bounded_queue.h @@ -1,16 +1,19 @@ -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sat Aug 18 12:42:16 CST 2012 diff --git a/src/butil/containers/case_ignored_flat_map.cpp b/src/butil/containers/case_ignored_flat_map.cpp index b4c14699..835d5559 100644 --- a/src/butil/containers/case_ignored_flat_map.cpp +++ b/src/butil/containers/case_ignored_flat_map.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Dec 4 14:57:27 CST 2016 diff --git a/src/butil/containers/case_ignored_flat_map.h b/src/butil/containers/case_ignored_flat_map.h index 0a8f264c..fe19ac89 100644 --- a/src/butil/containers/case_ignored_flat_map.h +++ b/src/butil/containers/case_ignored_flat_map.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Dec 4 14:57:27 CST 2016 diff --git a/src/butil/containers/doubly_buffered_data.h b/src/butil/containers/doubly_buffered_data.h index bb39bd2e..076bc711 100644 --- a/src/butil/containers/doubly_buffered_data.h +++ b/src/butil/containers/doubly_buffered_data.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Sep 22 22:23:13 CST 2014 diff --git a/src/butil/containers/flat_map.h b/src/butil/containers/flat_map.h index cfbe96df..eda71724 100644 --- a/src/butil/containers/flat_map.h +++ b/src/butil/containers/flat_map.h @@ -1,16 +1,19 @@ -// Copyright (c) 2013 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Wed Nov 27 12:59:20 CST 2013 diff --git a/src/butil/containers/flat_map_inl.h b/src/butil/containers/flat_map_inl.h index 2184c190..8610b34d 100644 --- a/src/butil/containers/flat_map_inl.h +++ b/src/butil/containers/flat_map_inl.h @@ -1,16 +1,19 @@ -// Copyright (c) 2013 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Wed Nov 27 12:59:20 CST 2013 diff --git a/src/butil/containers/pooled_map.h b/src/butil/containers/pooled_map.h index ecb93034..ce2673d7 100644 --- a/src/butil/containers/pooled_map.h +++ b/src/butil/containers/pooled_map.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sat Dec 3 13:11:32 CST 2016 diff --git a/src/butil/endpoint.cpp b/src/butil/endpoint.cpp index a0ecb35f..82809310 100644 --- a/src/butil/endpoint.cpp +++ b/src/butil/endpoint.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/endpoint.h b/src/butil/endpoint.h index bec4dc5f..81074996 100644 --- a/src/butil/endpoint.h +++ b/src/butil/endpoint.h @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/errno.cpp b/src/butil/errno.cpp index 8da55aeb..9cd10f31 100644 --- a/src/butil/errno.cpp +++ b/src/butil/errno.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2010 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Fri Sep 10 13:34:25 CST 2010 diff --git a/src/butil/errno.h b/src/butil/errno.h index e1157e3d..7aa44295 100644 --- a/src/butil/errno.h +++ b/src/butil/errno.h @@ -1,16 +1,19 @@ -// Copyright (c) 2010 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Fri Sep 10 13:34:25 CST 2010 diff --git a/src/butil/fast_rand.cpp b/src/butil/fast_rand.cpp index fc91135b..34ae06b3 100644 --- a/src/butil/fast_rand.cpp +++ b/src/butil/fast_rand.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Dec 31 13:35:39 CST 2015 diff --git a/src/butil/fast_rand.h b/src/butil/fast_rand.h index c17a130e..6f0ed1b3 100644 --- a/src/butil/fast_rand.h +++ b/src/butil/fast_rand.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Dec 31 13:35:39 CST 2015 diff --git a/src/butil/fd_guard.h b/src/butil/fd_guard.h index c7834e6c..439f5098 100644 --- a/src/butil/fd_guard.h +++ b/src/butil/fd_guard.h @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/fd_utility.cpp b/src/butil/fd_utility.cpp index e49d16bf..3dc54fd6 100644 --- a/src/butil/fd_utility.cpp +++ b/src/butil/fd_utility.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/fd_utility.h b/src/butil/fd_utility.h index 284a1bc2..72fa26e3 100644 --- a/src/butil/fd_utility.h +++ b/src/butil/fd_utility.h @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/files/dir_reader_unix.h b/src/butil/files/dir_reader_unix.h index 5032022d..6ca4ff29 100644 --- a/src/butil/files/dir_reader_unix.h +++ b/src/butil/files/dir_reader_unix.h @@ -1,16 +1,19 @@ -// Copyright (c) 2018 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: yinqiwen (yinqiwen@gmail.com) diff --git a/src/butil/files/fd_guard.h b/src/butil/files/fd_guard.h index 33e97110..82da6d6e 100644 --- a/src/butil/files/fd_guard.h +++ b/src/butil/files/fd_guard.h @@ -1,20 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// RAII file descriptor. +// http://www.apache.org/licenses/LICENSE-2.0 // -// Example: -// fd_guard fd1(open(...)); -// if (fd1 < 0) { -// printf("Fail to open\n"); -// return -1; -// } -// if (another-error-happened) { -// printf("Fail to do sth\n"); -// return -1; // *** closing fd1 automatically *** -// } -// -// Author: Ge,Jun (gejun@baidu.com) -// Date: Mon. Nov 7 14:47:36 CST 2011 +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BUTIL_FD_GUARD_H #define BUTIL_FD_GUARD_H diff --git a/src/butil/files/file_watcher.cpp b/src/butil/files/file_watcher.cpp index 0c5fdbb4..7a1d6fc0 100644 --- a/src/butil/files/file_watcher.cpp +++ b/src/butil/files/file_watcher.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2010 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: 2010/05/29 diff --git a/src/butil/files/file_watcher.h b/src/butil/files/file_watcher.h index ca367d0e..b3e9cfd3 100644 --- a/src/butil/files/file_watcher.h +++ b/src/butil/files/file_watcher.h @@ -1,16 +1,19 @@ -// Copyright (c) 2010 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: 2010/05/29 diff --git a/src/butil/files/temp_file.cpp b/src/butil/files/temp_file.cpp index 3fe3cb4f..1c11eef7 100644 --- a/src/butil/files/temp_file.cpp +++ b/src/butil/files/temp_file.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2010 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Yan,Lin (yanlin@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/butil/files/temp_file.h b/src/butil/files/temp_file.h index 54aa854f..8ad7615a 100644 --- a/src/butil/files/temp_file.h +++ b/src/butil/files/temp_file.h @@ -1,16 +1,19 @@ -// Copyright (c) 2010 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Yan,Lin (yanlin@baidu.com) // Ge,Jun (gejun@baidu.com) diff --git a/src/butil/find_cstr.cpp b/src/butil/find_cstr.cpp index 7f955856..ef8dd513 100644 --- a/src/butil/find_cstr.cpp +++ b/src/butil/find_cstr.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jun 23 15:03:24 CST 2015 diff --git a/src/butil/find_cstr.h b/src/butil/find_cstr.h index 56d43818..122f9986 100644 --- a/src/butil/find_cstr.h +++ b/src/butil/find_cstr.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jun 23 15:03:24 CST 2015 diff --git a/src/butil/iobuf.cpp b/src/butil/iobuf.cpp index daeaa391..83c80863 100644 --- a/src/butil/iobuf.cpp +++ b/src/butil/iobuf.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // iobuf - A non-continuous zero-copied buffer -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Nov 22 13:57:56 CST 2012 diff --git a/src/butil/iobuf.h b/src/butil/iobuf.h index e376f7c3..f4d5e341 100644 --- a/src/butil/iobuf.h +++ b/src/butil/iobuf.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // iobuf - A non-continuous zero-copied buffer -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Nov 22 13:57:56 CST 2012 diff --git a/src/butil/iobuf_inl.h b/src/butil/iobuf_inl.h index 2538f4d2..6818452b 100644 --- a/src/butil/iobuf_inl.h +++ b/src/butil/iobuf_inl.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // iobuf - A non-continuous zero-copied buffer -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Nov 22 13:57:56 CST 2012 diff --git a/src/butil/logging.cc b/src/butil/logging.cc index 8a9b2698..bc5bbaf2 100644 --- a/src/butil/logging.cc +++ b/src/butil/logging.cc @@ -1,16 +1,19 @@ -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: 2012-10-08 23:53:50 diff --git a/src/butil/logging.h b/src/butil/logging.h index 4f8b71c1..99ade10f 100644 --- a/src/butil/logging.h +++ b/src/butil/logging.h @@ -1,16 +1,19 @@ -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: 2012-10-08 23:53:50 diff --git a/src/butil/memory/singleton_on_pthread_once.h b/src/butil/memory/singleton_on_pthread_once.h index 8f66a038..75b4b714 100644 --- a/src/butil/memory/singleton_on_pthread_once.h +++ b/src/butil/memory/singleton_on_pthread_once.h @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Dec 15 14:37:39 CST 2016 diff --git a/src/butil/object_pool.h b/src/butil/object_pool.h index 1890a3ec..3381d562 100644 --- a/src/butil/object_pool.h +++ b/src/butil/object_pool.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/src/butil/object_pool_inl.h b/src/butil/object_pool_inl.h index c8b323d5..3c3b8ea3 100644 --- a/src/butil/object_pool_inl.h +++ b/src/butil/object_pool_inl.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/src/butil/popen.cpp b/src/butil/popen.cpp index c427b1ce..47813c7c 100644 --- a/src/butil/popen.cpp +++ b/src/butil/popen.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2017/11/04 17:37:43 diff --git a/src/butil/popen.h b/src/butil/popen.h index c59685e9..082ba45c 100644 --- a/src/butil/popen.h +++ b/src/butil/popen.h @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2017/11/04 17:13:18 diff --git a/src/butil/process_util.cc b/src/butil/process_util.cc index a2dbfa19..e3481714 100644 --- a/src/butil/process_util.cc +++ b/src/butil/process_util.cc @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Process-related Info -// Copyright (c) 2018 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhu,Jiashun (zhujiashun@baidu.com) // Date: Wed Apr 11 14:35:56 CST 2018 diff --git a/src/butil/process_util.h b/src/butil/process_util.h index 513a085b..f4401fca 100644 --- a/src/butil/process_util.h +++ b/src/butil/process_util.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Process-related Info -// Copyright (c) 2018 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Zhu,Jiashun (zhujiashun@baidu.com) // Date: Wed Apr 11 14:35:56 CST 2018 diff --git a/src/butil/ptr_container.h b/src/butil/ptr_container.h index d33aa8c9..16c3b5f9 100644 --- a/src/butil/ptr_container.h +++ b/src/butil/ptr_container.h @@ -1,16 +1,19 @@ -// Copyright (c) 2018 brpc authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (jge666@gmail.com) // Date: Fri Sep 7 12:15:23 CST 2018 diff --git a/src/butil/raw_pack.h b/src/butil/raw_pack.h index 72becd2e..d4f8167f 100644 --- a/src/butil/raw_pack.h +++ b/src/butil/raw_pack.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BUTIL_RAW_PACK_H #define BUTIL_RAW_PACK_H diff --git a/src/butil/reader_writer.h b/src/butil/reader_writer.h index a028ce03..e830965c 100644 --- a/src/butil/reader_writer.h +++ b/src/butil/reader_writer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2018 brpc authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (jge666@gmail.com) // Date: Wed Aug 8 05:51:33 PDT 2018 diff --git a/src/butil/resource_pool.h b/src/butil/resource_pool.h index 5b51c150..1667a5d6 100644 --- a/src/butil/resource_pool.h +++ b/src/butil/resource_pool.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/src/butil/resource_pool_inl.h b/src/butil/resource_pool_inl.h index 5e69dc68..9625c251 100644 --- a/src/butil/resource_pool_inl.h +++ b/src/butil/resource_pool_inl.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // bthread - A M:N threading library to make applications more concurrent. -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/src/butil/scoped_lock.h b/src/butil/scoped_lock.h index 79e35cc2..45f52301 100644 --- a/src/butil/scoped_lock.h +++ b/src/butil/scoped_lock.h @@ -1,18 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Lock a mutex, a spinlock, or mutex types in C++11 in a way that the lock -// will be unlocked automatically when go out of declaring scope. -// Example: -// pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -// ... -// if (...) { -// BAIDU_SCOPED_LOCK(mutex); -// // got the lock. -// } -// // unlocked when out of declaring scope. +// http://www.apache.org/licenses/LICENSE-2.0 // -// Author: Ge,Jun (gejun@baidu.com) -// Date: Mon. Nov 7 14:47:36 CST 2011 +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BUTIL_BAIDU_SCOPED_LOCK_H #define BUTIL_BAIDU_SCOPED_LOCK_H diff --git a/src/butil/single_threaded_pool.h b/src/butil/single_threaded_pool.h index 1c1bad8d..fd91a287 100644 --- a/src/butil/single_threaded_pool.h +++ b/src/butil/single_threaded_pool.h @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/ssl_compat.h b/src/butil/ssl_compat.h index 1dceabc0..28335a51 100644 --- a/src/butil/ssl_compat.h +++ b/src/butil/ssl_compat.h @@ -1,20 +1,19 @@ -/* Copyright (c) 2017 Baidu, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Author: Ge,Jun (gejun@baidu.com) - Date: Sun Aug 20 11:39:01 CST 2017 -*/ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BUTIL_SSL_COMPAT_H #define BUTIL_SSL_COMPAT_H diff --git a/src/butil/status.cpp b/src/butil/status.cpp index ef35e04e..56982c42 100644 --- a/src/butil/status.cpp +++ b/src/butil/status.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Feb 9 15:04:03 CST 2015 diff --git a/src/butil/status.h b/src/butil/status.h index 35f0b183..ce781697 100644 --- a/src/butil/status.h +++ b/src/butil/status.h @@ -1,4 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BUTIL_STATUS_H #define BUTIL_STATUS_H diff --git a/src/butil/string_printf.cpp b/src/butil/string_printf.cpp index 69c9a3fb..1bcb8757 100644 --- a/src/butil/string_printf.cpp +++ b/src/butil/string_printf.cpp @@ -1,10 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// string_printf_impl, string_printf, string_appendf were taken from -// https://github.com/facebook/folly/blob/master/folly/String.cpp -// with minor changes: -// - coding style -// - replace exceptions with return code +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include // vsnprintf #include // strlen diff --git a/src/butil/string_printf.h b/src/butil/string_printf.h index 17c44dc5..b2cd7a2d 100644 --- a/src/butil/string_printf.h +++ b/src/butil/string_printf.h @@ -1,5 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// Date: Mon. Nov 7 14:47:36 CST 2011 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BUTIL_STRING_PRINTF_H #define BUTIL_STRING_PRINTF_H diff --git a/src/butil/string_splitter.h b/src/butil/string_splitter.h index aeb9e13e..1da1eb4e 100644 --- a/src/butil/string_splitter.h +++ b/src/butil/string_splitter.h @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Apr. 18 19:52:34 CST 2011 diff --git a/src/butil/string_splitter_inl.h b/src/butil/string_splitter_inl.h index a0b9fe5c..76e4d5e8 100644 --- a/src/butil/string_splitter_inl.h +++ b/src/butil/string_splitter_inl.h @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Apr. 18 19:52:34 CST 2011 diff --git a/src/butil/synchronization/lock.h b/src/butil/synchronization/lock.h index bd92ef38..b6f5215c 100644 --- a/src/butil/synchronization/lock.h +++ b/src/butil/synchronization/lock.h @@ -1,5 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc -// Date: Thu Jan 19 16:19:30 CST 2017 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BUTIL_SYNCHRONIZATION_LOCK_H_ #define BUTIL_SYNCHRONIZATION_LOCK_H_ diff --git a/src/butil/synchronous_event.h b/src/butil/synchronous_event.h index 34d79a14..70086bf6 100644 --- a/src/butil/synchronous_event.h +++ b/src/butil/synchronous_event.h @@ -1,16 +1,19 @@ -// Copyright (c) 2010 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Nov 7 21:43:34 CST 2010 diff --git a/src/butil/third_party/murmurhash3/murmurhash3.cpp b/src/butil/third_party/murmurhash3/murmurhash3.cpp index f590c92b..b41c09d1 100644 --- a/src/butil/third_party/murmurhash3/murmurhash3.cpp +++ b/src/butil/third_party/murmurhash3/murmurhash3.cpp @@ -1,9 +1,23 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // MurmurHash3 was written by Austin Appleby, and is placed in the public // domain. The author hereby disclaims copyright to this source code. -// Copyright (c) 2013 Baidu, Inc. -// Compute murmurhash3 iteratively so that you don't have to buffer -// everything in memory before computation. The APIs are similar with MD5 // Note - The x86 and x64 versions do _not_ produce the same results, as the // algorithms are optimized for their respective platforms. You can still diff --git a/src/butil/third_party/murmurhash3/murmurhash3.h b/src/butil/third_party/murmurhash3/murmurhash3.h index 5f5ed50d..c4021b19 100644 --- a/src/butil/third_party/murmurhash3/murmurhash3.h +++ b/src/butil/third_party/murmurhash3/murmurhash3.h @@ -1,9 +1,23 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // MurmurHash3 was written by Austin Appleby, and is placed in the public // domain. The author hereby disclaims copyright to this source code. -// Copyright (c) 2013 Baidu, Inc. -// Compute murmurhash3 iteratively so that you don't have to buffer -// everything in memory before computation. The APIs are similar with MD5 #ifndef BUTIL_THIRD_PARTY_MURMURHASH3_MURMURHASH3_H #define BUTIL_THIRD_PARTY_MURMURHASH3_MURMURHASH3_H diff --git a/src/butil/third_party/rapidjson/optimized_writer.h b/src/butil/third_party/rapidjson/optimized_writer.h index 111a3b02..b038fcbf 100644 --- a/src/butil/third_party/rapidjson/optimized_writer.h +++ b/src/butil/third_party/rapidjson/optimized_writer.h @@ -1,7 +1,20 @@ -// Copyright (c) 2015 Baidu, Inc. -// Author: Lin Jiang (jianglin05@baidu.com) -// Date: 2015/7/21 16:44:42 - +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + #ifndef RAPIDJSON_OPTIMIZED_WRITER_H #define RAPIDJSON_OPTIMIZED_WRITER_H diff --git a/src/butil/thread_local.cpp b/src/butil/thread_local.cpp index 5cd71de6..83eaf337 100644 --- a/src/butil/thread_local.cpp +++ b/src/butil/thread_local.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/thread_local.h b/src/butil/thread_local.h index fc8bdf2c..2baf62c9 100644 --- a/src/butil/thread_local.h +++ b/src/butil/thread_local.h @@ -1,16 +1,19 @@ -// Copyright (c) 2011 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon. Nov 7 14:47:36 CST 2011 diff --git a/src/butil/thread_local_inl.h b/src/butil/thread_local_inl.h index 5e9e43c5..ab378835 100644 --- a/src/butil/thread_local_inl.h +++ b/src/butil/thread_local_inl.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Sep 16 12:39:12 CST 2014 diff --git a/src/butil/time.cpp b/src/butil/time.cpp index 8bb3a567..864d11ff 100644 --- a/src/butil/time.cpp +++ b/src/butil/time.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2010 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Fri Aug 29 15:01:15 CST 2014 diff --git a/src/butil/time.h b/src/butil/time.h index 2ec65e1f..0b22cb45 100644 --- a/src/butil/time.h +++ b/src/butil/time.h @@ -1,16 +1,19 @@ -// Copyright (c) 2010 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Wed Aug 11 10:38:17 2010 diff --git a/src/butil/unix_socket.cpp b/src/butil/unix_socket.cpp index db91969a..9a4291b1 100644 --- a/src/butil/unix_socket.cpp +++ b/src/butil/unix_socket.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Jiang,Rujie(jiangrujie@baidu.com) // Date: Mon. Jan 27 23:08:35 CST 2014 diff --git a/src/butil/unix_socket.h b/src/butil/unix_socket.h index 93cfe2d8..d405ee51 100644 --- a/src/butil/unix_socket.h +++ b/src/butil/unix_socket.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Jiang,Rujie(jiangrujie@baidu.com) // Date: Mon. Jan 27 23:08:35 CST 2014 diff --git a/src/butil/zero_copy_stream_as_streambuf.cpp b/src/butil/zero_copy_stream_as_streambuf.cpp index dd237afb..0f873cbe 100644 --- a/src/butil/zero_copy_stream_as_streambuf.cpp +++ b/src/butil/zero_copy_stream_as_streambuf.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Nov 22 13:57:56 CST 2012 diff --git a/src/butil/zero_copy_stream_as_streambuf.h b/src/butil/zero_copy_stream_as_streambuf.h index 581e3e8f..884ab265 100644 --- a/src/butil/zero_copy_stream_as_streambuf.h +++ b/src/butil/zero_copy_stream_as_streambuf.h @@ -1,16 +1,19 @@ -// Copyright (c) 2012 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Nov 22 13:57:56 CST 2012 diff --git a/src/bvar/bvar.h b/src/bvar/bvar.h index 365312e1..d3a25e61 100644 --- a/src/bvar/bvar.h +++ b/src/bvar/bvar.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2014/12/29 14:54:11 diff --git a/src/bvar/collector.cpp b/src/bvar/collector.cpp index 26ab4c9a..f0725566 100644 --- a/src/bvar/collector.cpp +++ b/src/bvar/collector.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Dec 14 19:12:30 CST 2015 diff --git a/src/bvar/collector.h b/src/bvar/collector.h index 230b76dd..2d7ac35c 100644 --- a/src/bvar/collector.h +++ b/src/bvar/collector.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Dec 14 19:12:30 CST 2015 diff --git a/src/bvar/default_variables.cpp b/src/bvar/default_variables.cpp index 32d91ad5..ce80f97a 100644 --- a/src/bvar/default_variables.cpp +++ b/src/bvar/default_variables.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Thu Jul 30 17:44:54 CST 2015 diff --git a/src/bvar/detail/agent_group.h b/src/bvar/detail/agent_group.h index 3443a663..4ba88664 100644 --- a/src/bvar/detail/agent_group.h +++ b/src/bvar/detail/agent_group.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author Zhangyi Chen (chenzhangyi01@baidu.com) // Date 2014/09/24 19:34:24 diff --git a/src/bvar/detail/call_op_returning_void.h b/src/bvar/detail/call_op_returning_void.h index 25e36371..a4853842 100644 --- a/src/bvar/detail/call_op_returning_void.h +++ b/src/bvar/detail/call_op_returning_void.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author Zhangyi Chen (chenzhangyi01@baidu.com) // Date 2014/09/22 11:57:43 diff --git a/src/bvar/detail/combiner.h b/src/bvar/detail/combiner.h index e0cd2c67..bdf99078 100644 --- a/src/bvar/detail/combiner.h +++ b/src/bvar/detail/combiner.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author Zhangyi Chen (chenzhangyi01@baidu.com) // Date 2014/09/22 11:57:43 diff --git a/src/bvar/detail/is_atomical.h b/src/bvar/detail/is_atomical.h index 47d3b90a..3b841288 100644 --- a/src/bvar/detail/is_atomical.h +++ b/src/bvar/detail/is_atomical.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BVAR_DETAIL_IS_ATOMICAL_H #define BVAR_DETAIL_IS_ATOMICAL_H diff --git a/src/bvar/detail/percentile.cpp b/src/bvar/detail/percentile.cpp index 7d43a4e6..23a68818 100644 --- a/src/bvar/detail/percentile.cpp +++ b/src/bvar/detail/percentile.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/09/15 15:14:32 diff --git a/src/bvar/detail/percentile.h b/src/bvar/detail/percentile.h index 524001c1..c7124f27 100644 --- a/src/bvar/detail/percentile.h +++ b/src/bvar/detail/percentile.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/09/15 10:44:17 diff --git a/src/bvar/detail/sampler.cpp b/src/bvar/detail/sampler.cpp index 90b4f800..7866e76a 100644 --- a/src/bvar/detail/sampler.cpp +++ b/src/bvar/detail/sampler.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 28 18:14:40 CST 2015 diff --git a/src/bvar/detail/sampler.h b/src/bvar/detail/sampler.h index 4dd809db..1e429872 100644 --- a/src/bvar/detail/sampler.h +++ b/src/bvar/detail/sampler.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 28 18:15:57 CST 2015 diff --git a/src/bvar/detail/series.h b/src/bvar/detail/series.h index 347c5516..cc517a40 100644 --- a/src/bvar/detail/series.h +++ b/src/bvar/detail/series.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Tue Jul 28 18:15:57 CST 2015 diff --git a/src/bvar/gflag.cpp b/src/bvar/gflag.cpp index 9ab2ad51..3dd4d989 100644 --- a/src/bvar/gflag.cpp +++ b/src/bvar/gflag.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Aug 9 12:26:03 CST 2015 diff --git a/src/bvar/gflag.h b/src/bvar/gflag.h index bd2fb9d7..8550763a 100644 --- a/src/bvar/gflag.h +++ b/src/bvar/gflag.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Aug 9 12:26:03 CST 2015 diff --git a/src/bvar/latency_recorder.cpp b/src/bvar/latency_recorder.cpp index 7a27e170..52da5e6f 100644 --- a/src/bvar/latency_recorder.cpp +++ b/src/bvar/latency_recorder.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: 2014/09/22 11:57:43 diff --git a/src/bvar/latency_recorder.h b/src/bvar/latency_recorder.h index 09c40c48..6e4359d9 100644 --- a/src/bvar/latency_recorder.h +++ b/src/bvar/latency_recorder.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: 2014/09/22 11:57:43 diff --git a/src/bvar/passive_status.h b/src/bvar/passive_status.h index b37a7139..ab2cbf30 100644 --- a/src/bvar/passive_status.h +++ b/src/bvar/passive_status.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date 2014/09/22 11:57:43 diff --git a/src/bvar/recorder.h b/src/bvar/recorder.h index 2c858a75..f09ab0f2 100644 --- a/src/bvar/recorder.h +++ b/src/bvar/recorder.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: chenzhangyi01@baidu.com gejun@baidu.com // Date 2014/09/25 17:50:21 diff --git a/src/bvar/reducer.h b/src/bvar/reducer.h index 07562169..19adf46d 100644 --- a/src/bvar/reducer.h +++ b/src/bvar/reducer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: chenzhangyi01@baidu.com, gejun@baidu.com // Date 2014/09/24 16:01:08 diff --git a/src/bvar/scoped_timer.h b/src/bvar/scoped_timer.h index 34de59fb..b3f1c5c9 100644 --- a/src/bvar/scoped_timer.h +++ b/src/bvar/scoped_timer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Fri Jul 14 11:29:21 CST 2017 diff --git a/src/bvar/status.h b/src/bvar/status.h index 64096b6d..f9af7ed7 100644 --- a/src/bvar/status.h +++ b/src/bvar/status.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author Zhangyi Chen (chenzhangyi01@baidu.com) // Date 2014/09/22 11:57:43 diff --git a/src/bvar/utils/lock_timer.h b/src/bvar/utils/lock_timer.h index 0c23d506..3dbf3126 100644 --- a/src/bvar/utils/lock_timer.h +++ b/src/bvar/utils/lock_timer.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/03/06 17:13:17 diff --git a/src/bvar/variable.cpp b/src/bvar/variable.cpp index deb62456..e1bb8b83 100644 --- a/src/bvar/variable.cpp +++ b/src/bvar/variable.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: 2014/09/22 19:04:47 diff --git a/src/bvar/variable.h b/src/bvar/variable.h index 23d032d1..57b9443b 100644 --- a/src/bvar/variable.h +++ b/src/bvar/variable.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: 2014/09/22 11:57:43 diff --git a/src/bvar/vector.h b/src/bvar/vector.h index 7b477127..323a0004 100644 --- a/src/bvar/vector.h +++ b/src/bvar/vector.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Sun Sep 20 12:25:11 CST 2015 diff --git a/src/bvar/window.h b/src/bvar/window.h index bf3c001a..6d3af5ba 100644 --- a/src/bvar/window.h +++ b/src/bvar/window.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Wed Jul 29 23:25:43 CST 2015 diff --git a/src/idl_options.proto b/src/idl_options.proto index 7e22e92c..6929355d 100644 --- a/src/idl_options.proto +++ b/src/idl_options.proto @@ -1,8 +1,5 @@ syntax="proto2"; // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Mon Oct 19 17:17:36 CST 2015 import "google/protobuf/descriptor.proto"; diff --git a/src/json2pb/encode_decode.cpp b/src/json2pb/encode_decode.cpp index 0d99d619..95b7819c 100644 --- a/src/json2pb/encode_decode.cpp +++ b/src/json2pb/encode_decode.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// Author: Jiang,Lin (jianglin05@baidu.com) -// Date: 2015/05/26 16:17:28 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/src/json2pb/encode_decode.h b/src/json2pb/encode_decode.h index c07f05d2..7a2ba3aa 100644 --- a/src/json2pb/encode_decode.h +++ b/src/json2pb/encode_decode.h @@ -1,6 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// Author: Jiang,Lin (jianglin05@baidu.com) -// Date: 2015/05/26 16:59:16 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_JSON2PB_ENCODE_DECODE_H #define BRPC_JSON2PB_ENCODE_DECODE_H diff --git a/src/json2pb/json_to_pb.cpp b/src/json2pb/json_to_pb.cpp index 96127555..41da40dc 100644 --- a/src/json2pb/json_to_pb.cpp +++ b/src/json2pb/json_to_pb.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/src/json2pb/json_to_pb.h b/src/json2pb/json_to_pb.h index 9878f8ae..eb400124 100644 --- a/src/json2pb/json_to_pb.h +++ b/src/json2pb/json_to_pb.h @@ -1,6 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // protobuf-json: Conversions between protobuf and json. -// Copyright (c) 2014 Baidu, Inc. -// Date: 2014-10-29 18:30:33 #ifndef BRPC_JSON2PB_JSON_TO_PB_H #define BRPC_JSON2PB_JSON_TO_PB_H diff --git a/src/json2pb/pb_to_json.cpp b/src/json2pb/pb_to_json.cpp index d19f3d0f..704f963f 100644 --- a/src/json2pb/pb_to_json.cpp +++ b/src/json2pb/pb_to_json.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/src/json2pb/pb_to_json.h b/src/json2pb/pb_to_json.h index 4f35664f..3fbc6c4d 100644 --- a/src/json2pb/pb_to_json.h +++ b/src/json2pb/pb_to_json.h @@ -1,6 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // protobuf-json: Conversions between protobuf and json. -// Copyright (c) 2014 Baidu, Inc. -// Date: 2014-10-29 18:30:33 #ifndef BRPC_JSON2PB_PB_TO_JSON_H #define BRPC_JSON2PB_PB_TO_JSON_H diff --git a/src/json2pb/protobuf_map.cpp b/src/json2pb/protobuf_map.cpp index 992941f2..f552bf62 100644 --- a/src/json2pb/protobuf_map.cpp +++ b/src/json2pb/protobuf_map.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "protobuf_map.h" #include diff --git a/src/json2pb/protobuf_map.h b/src/json2pb/protobuf_map.h index 598b8611..244fb5ea 100644 --- a/src/json2pb/protobuf_map.h +++ b/src/json2pb/protobuf_map.h @@ -1,7 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Author: Rujie,Jiang jiangrujie@baidu.com -// Date: Tue Feb 23 13:56:02 2016 +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_JSON2PB_JSON_PROTOBUF_MAP_H #define BRPC_JSON2PB_JSON_PROTOBUF_MAP_H diff --git a/src/json2pb/rapidjson.h b/src/json2pb/rapidjson.h index 3213e86c..d2cf3b68 100644 --- a/src/json2pb/rapidjson.h +++ b/src/json2pb/rapidjson.h @@ -1,6 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// Author: Zhangyi Chen (chenzhangyi01@baidu.com) -// Date: 2015/03/17 15:34:52 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_JSON2PB_RAPIDJSON_H #define BRPC_JSON2PB_RAPIDJSON_H diff --git a/src/json2pb/zero_copy_stream_reader.h b/src/json2pb/zero_copy_stream_reader.h index 394e07ce..6c19d330 100644 --- a/src/json2pb/zero_copy_stream_reader.h +++ b/src/json2pb/zero_copy_stream_reader.h @@ -1,7 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// File: iobuf_read_stream.h -// Author: Zhangyi Chen (chenzhangyi01@baidu.com) -// Date: 2014/10/29 15:01:09 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_JSON2PB_ZERO_COPY_STREAM_READER_H #define BRPC_JSON2PB_ZERO_COPY_STREAM_READER_H diff --git a/src/json2pb/zero_copy_stream_writer.h b/src/json2pb/zero_copy_stream_writer.h index 619ce68b..53455cc8 100644 --- a/src/json2pb/zero_copy_stream_writer.h +++ b/src/json2pb/zero_copy_stream_writer.h @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Zhangyi Chen (chenzhangyi01@baidu.com) -// Date: 2014/10/29 16:44:42 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_JSON2PB_ZERO_COPY_STREAM_WRITER_H #define BRPC_JSON2PB_ZERO_COPY_STREAM_WRITER_H diff --git a/src/mcpack2pb/field_type.cpp b/src/mcpack2pb/field_type.cpp index 3a8b1121..e7190829 100644 --- a/src/mcpack2pb/field_type.cpp +++ b/src/mcpack2pb/field_type.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/field_type.h b/src/mcpack2pb/field_type.h index 259a8f31..f35b9c18 100644 --- a/src/mcpack2pb/field_type.h +++ b/src/mcpack2pb/field_type.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/generator.cpp b/src/mcpack2pb/generator.cpp index ce7fbfd3..0586cb02 100644 --- a/src/mcpack2pb/generator.cpp +++ b/src/mcpack2pb/generator.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/mcpack2pb.cpp b/src/mcpack2pb/mcpack2pb.cpp index 867d3d11..c16066fb 100644 --- a/src/mcpack2pb/mcpack2pb.cpp +++ b/src/mcpack2pb/mcpack2pb.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/mcpack2pb.h b/src/mcpack2pb/mcpack2pb.h index 0b775844..37d4bc0e 100644 --- a/src/mcpack2pb/mcpack2pb.h +++ b/src/mcpack2pb/mcpack2pb.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/parser-inl.h b/src/mcpack2pb/parser-inl.h index 36c8b8c9..09c46b45 100644 --- a/src/mcpack2pb/parser-inl.h +++ b/src/mcpack2pb/parser-inl.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/parser.cpp b/src/mcpack2pb/parser.cpp index 2ffca6e1..f076bf1c 100644 --- a/src/mcpack2pb/parser.cpp +++ b/src/mcpack2pb/parser.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/parser.h b/src/mcpack2pb/parser.h index 672aec10..f5a606f8 100644 --- a/src/mcpack2pb/parser.h +++ b/src/mcpack2pb/parser.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/serializer-inl.h b/src/mcpack2pb/serializer-inl.h index 796dad79..098416db 100644 --- a/src/mcpack2pb/serializer-inl.h +++ b/src/mcpack2pb/serializer-inl.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/serializer.cpp b/src/mcpack2pb/serializer.cpp index 3e964b02..43ce5de9 100644 --- a/src/mcpack2pb/serializer.cpp +++ b/src/mcpack2pb/serializer.cpp @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/src/mcpack2pb/serializer.h b/src/mcpack2pb/serializer.h index f6056ab3..c75f1513 100644 --- a/src/mcpack2pb/serializer.h +++ b/src/mcpack2pb/serializer.h @@ -1,17 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // mcpack2pb - Make protobuf be front-end of mcpack/compack -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Mon Oct 19 17:17:36 CST 2015 diff --git a/test/baidu_thread_local_unittest.cpp b/test/baidu_thread_local_unittest.cpp index 90fb9ee4..a77abda3 100644 --- a/test/baidu_thread_local_unittest.cpp +++ b/test/baidu_thread_local_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/baidu_time_unittest.cpp b/test/baidu_time_unittest.cpp index dd73591d..4af509a3 100644 --- a/test/baidu_time_unittest.cpp +++ b/test/baidu_time_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/build_config.h" diff --git a/test/brpc_adaptive_class_unittest.cpp b/test/brpc_adaptive_class_unittest.cpp index c426cb51..18128f2a 100755 --- a/test/brpc_adaptive_class_unittest.cpp +++ b/test/brpc_adaptive_class_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: 2019/04/16 23:41:04 diff --git a/test/brpc_builtin_service_unittest.cpp b/test/brpc_builtin_service_unittest.cpp index 2b883413..d9a24a8f 100644 --- a/test/brpc_builtin_service_unittest.cpp +++ b/test/brpc_builtin_service_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_channel_unittest.cpp b/test/brpc_channel_unittest.cpp index cf7b1e26..b64e1982 100644 --- a/test/brpc_channel_unittest.cpp +++ b/test/brpc_channel_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_circuit_breaker_unittest.cpp b/test/brpc_circuit_breaker_unittest.cpp index 207c9b58..ef09cd94 100644 --- a/test/brpc_circuit_breaker_unittest.cpp +++ b/test/brpc_circuit_breaker_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: 2018/09/19 14:51:06 diff --git a/test/brpc_controller_unittest.cpp b/test/brpc_controller_unittest.cpp index d659516a..ea628efc 100644 --- a/test/brpc_controller_unittest.cpp +++ b/test/brpc_controller_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_esp_protocol_unittest.cpp b/test/brpc_esp_protocol_unittest.cpp index 027c0e64..4db1943c 100644 --- a/test/brpc_esp_protocol_unittest.cpp +++ b/test/brpc_esp_protocol_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_event_dispatcher_unittest.cpp b/test/brpc_event_dispatcher_unittest.cpp index 91023f5f..d8f69842 100644 --- a/test/brpc_event_dispatcher_unittest.cpp +++ b/test/brpc_event_dispatcher_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_extension_unittest.cpp b/test/brpc_extension_unittest.cpp index 5b14c468..7c01e5b1 100644 --- a/test/brpc_extension_unittest.cpp +++ b/test/brpc_extension_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_grpc_protocol_unittest.cpp b/test/brpc_grpc_protocol_unittest.cpp index f37dcaf7..c835b6ab 100644 --- a/test/brpc_grpc_protocol_unittest.cpp +++ b/test/brpc_grpc_protocol_unittest.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2018 brpc authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Jiashun Zhu(zhujiashun@bilibili.com) diff --git a/test/brpc_h2_unsent_message_unittest.cpp b/test/brpc_h2_unsent_message_unittest.cpp index 1af64c82..79b56f55 100644 --- a/test/brpc_h2_unsent_message_unittest.cpp +++ b/test/brpc_h2_unsent_message_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2018 BiliBili, Inc. // Date: Tue Oct 9 20:27:18 CST 2018 diff --git a/test/brpc_hpack_unittest.cpp b/test/brpc_hpack_unittest.cpp index f03c737f..f30a7128 100644 --- a/test/brpc_hpack_unittest.cpp +++ b/test/brpc_hpack_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: 2017/04/25 00:23:12 diff --git a/test/brpc_http_parser_unittest.cpp b/test/brpc_http_parser_unittest.cpp index e36b1fc8..49ee06ec 100644 --- a/test/brpc_http_parser_unittest.cpp +++ b/test/brpc_http_parser_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// File test_http_parser.cpp -// Date 2014/10/22 09:58:14 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/brpc_http_rpc_protocol_unittest.cpp b/test/brpc_http_rpc_protocol_unittest.cpp index 9354e629..bd329834 100644 --- a/test/brpc_http_rpc_protocol_unittest.cpp +++ b/test/brpc_http_rpc_protocol_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_http_status_code_unittest.cpp b/test/brpc_http_status_code_unittest.cpp index e5c336c6..013b2955 100644 --- a/test/brpc_http_status_code_unittest.cpp +++ b/test/brpc_http_status_code_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // File: test_http_status_code.cpp // Date: 2014/11/04 18:33:39 diff --git a/test/brpc_hulu_pbrpc_protocol_unittest.cpp b/test/brpc_hulu_pbrpc_protocol_unittest.cpp index 51147d75..7830b303 100644 --- a/test/brpc_hulu_pbrpc_protocol_unittest.cpp +++ b/test/brpc_hulu_pbrpc_protocol_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_input_messenger_unittest.cpp b/test/brpc_input_messenger_unittest.cpp index 5fe4680e..7682b83b 100644 --- a/test/brpc_input_messenger_unittest.cpp +++ b/test/brpc_input_messenger_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp index c00f17e6..cfe13add 100644 --- a/test/brpc_load_balancer_unittest.cpp +++ b/test/brpc_load_balancer_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_memcache_unittest.cpp b/test/brpc_memcache_unittest.cpp index 27cb9e42..4acd06f8 100644 --- a/test/brpc_memcache_unittest.cpp +++ b/test/brpc_memcache_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Date: Thu Jun 11 14:30:07 CST 2015 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/time.h" diff --git a/test/brpc_mongo_protocol_unittest.cpp b/test/brpc_mongo_protocol_unittest.cpp index e0a714c4..17c3dee4 100644 --- a/test/brpc_mongo_protocol_unittest.cpp +++ b/test/brpc_mongo_protocol_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Thu Oct 15 21:08:31 CST 2015 diff --git a/test/brpc_naming_service_filter_unittest.cpp b/test/brpc_naming_service_filter_unittest.cpp index b25470df..117e5b72 100644 --- a/test/brpc_naming_service_filter_unittest.cpp +++ b/test/brpc_naming_service_filter_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// File test_baidu_naming_service.cpp -// Date 2014/10/20 13:50:10 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/brpc_naming_service_unittest.cpp b/test/brpc_naming_service_unittest.cpp index efbdb660..f5a40751 100644 --- a/test/brpc_naming_service_unittest.cpp +++ b/test/brpc_naming_service_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Date 2014/10/20 13:50:10 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/brpc_nova_pbrpc_protocol_unittest.cpp b/test/brpc_nova_pbrpc_protocol_unittest.cpp index 8f8207d4..cfc41bd6 100644 --- a/test/brpc_nova_pbrpc_protocol_unittest.cpp +++ b/test/brpc_nova_pbrpc_protocol_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_prometheus_metrics_unittest.cpp b/test/brpc_prometheus_metrics_unittest.cpp index c094a6ec..064c14f7 100644 --- a/test/brpc_prometheus_metrics_unittest.cpp +++ b/test/brpc_prometheus_metrics_unittest.cpp @@ -1,7 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2018 BiliBili, Inc. -// Author: Jiashun Zhu(zhujiashun@bilibili.com) -// Date: Tue Dec 3 11:27:18 CST 2018 #include #include "brpc/server.h" diff --git a/test/brpc_proto_unittest.cpp b/test/brpc_proto_unittest.cpp index d454f348..052a0671 100644 --- a/test/brpc_proto_unittest.cpp +++ b/test/brpc_proto_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Date: 2015/03/31 14:50:20 diff --git a/test/brpc_protobuf_json_unittest.cpp b/test/brpc_protobuf_json_unittest.cpp index b31b6a52..d7b4d1c9 100644 --- a/test/brpc_protobuf_json_unittest.cpp +++ b/test/brpc_protobuf_json_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/brpc_public_pbrpc_protocol_unittest.cpp b/test/brpc_public_pbrpc_protocol_unittest.cpp index 8bc771bd..82c9fc52 100644 --- a/test/brpc_public_pbrpc_protocol_unittest.cpp +++ b/test/brpc_public_pbrpc_protocol_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_redis_unittest.cpp b/test/brpc_redis_unittest.cpp index 35643cfd..36daa1fd 100644 --- a/test/brpc_redis_unittest.cpp +++ b/test/brpc_redis_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Date: Thu Jun 11 14:30:07 CST 2015 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include diff --git a/test/brpc_repeated_field_unittest.cpp b/test/brpc_repeated_field_unittest.cpp index e9cc6c8d..2f4ae8ed 100644 --- a/test/brpc_repeated_field_unittest.cpp +++ b/test/brpc_repeated_field_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Zhangyi Chen (chenzhangyi01@baidu.com) -// Date: 2015/10/10 17:55:13 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "repeated.pb.h" #include diff --git a/test/brpc_rtmp_unittest.cpp b/test/brpc_rtmp_unittest.cpp index 409aa2a2..10cd842e 100644 --- a/test/brpc_rtmp_unittest.cpp +++ b/test/brpc_rtmp_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Fri May 20 15:52:22 CST 2016 diff --git a/test/brpc_server_unittest.cpp b/test/brpc_server_unittest.cpp index e2cebac7..a6e611de 100644 --- a/test/brpc_server_unittest.cpp +++ b/test/brpc_server_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_snappy_compress_unittest.cpp b/test/brpc_snappy_compress_unittest.cpp index eaf00797..ee6a00e6 100644 --- a/test/brpc_snappy_compress_unittest.cpp +++ b/test/brpc_snappy_compress_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: 2015/01/20 19:01:06 diff --git a/test/brpc_socket_map_unittest.cpp b/test/brpc_socket_map_unittest.cpp index a44cc006..58814450 100644 --- a/test/brpc_socket_map_unittest.cpp +++ b/test/brpc_socket_map_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_socket_unittest.cpp b/test/brpc_socket_unittest.cpp index 5fbd8314..f1c45286 100644 --- a/test/brpc_socket_unittest.cpp +++ b/test/brpc_socket_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_sofa_pbrpc_protocol_unittest.cpp b/test/brpc_sofa_pbrpc_protocol_unittest.cpp index 655bfe81..c875f7bd 100644 --- a/test/brpc_sofa_pbrpc_protocol_unittest.cpp +++ b/test/brpc_sofa_pbrpc_protocol_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_ssl_unittest.cpp b/test/brpc_ssl_unittest.cpp index aaa5c4b6..f32dbcb7 100644 --- a/test/brpc_ssl_unittest.cpp +++ b/test/brpc_ssl_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // Baidu RPC - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 baidu-rpc authors // Date: Sun Jul 13 15:04:18 CST 2014 diff --git a/test/brpc_streaming_rpc_unittest.cpp b/test/brpc_streaming_rpc_unittest.cpp index 801fa9db..f7e62c81 100644 --- a/test/brpc_streaming_rpc_unittest.cpp +++ b/test/brpc_streaming_rpc_unittest.cpp @@ -1,5 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. // Date: 2015/10/22 16:28:44 diff --git a/test/brpc_uri_unittest.cpp b/test/brpc_uri_unittest.cpp index 6cd0e36e..51508e67 100644 --- a/test/brpc_uri_unittest.cpp +++ b/test/brpc_uri_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// File test_uri.cpp -// Date 2014/10/27 14:19:35 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include diff --git a/test/bthread_butex_unittest.cpp b/test/bthread_butex_unittest.cpp index fa49edf6..eb991fd0 100644 --- a/test/bthread_butex_unittest.cpp +++ b/test/bthread_butex_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/atomicops.h" diff --git a/test/bthread_cond_unittest.cpp b/test/bthread_cond_unittest.cpp index e996de47..948b75de 100644 --- a/test/bthread_cond_unittest.cpp +++ b/test/bthread_cond_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/bthread_countdown_event_unittest.cpp b/test/bthread_countdown_event_unittest.cpp index c8f5ae07..db0cae74 100644 --- a/test/bthread_countdown_event_unittest.cpp +++ b/test/bthread_countdown_event_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2016/06/03 13:25:44 diff --git a/test/bthread_dispatcher_unittest.cpp b/test/bthread_dispatcher_unittest.cpp index ca337b7a..a2008020 100644 --- a/test/bthread_dispatcher_unittest.cpp +++ b/test/bthread_dispatcher_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include // writev #include "butil/compat.h" diff --git a/test/bthread_execution_queue_unittest.cpp b/test/bthread_execution_queue_unittest.cpp index 513b9e5e..8c70cbe4 100644 --- a/test/bthread_execution_queue_unittest.cpp +++ b/test/bthread_execution_queue_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Zhangyi Chen (chenzhangyi01@baidu.com) -// Date: 2015/11/09 19:09:02 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include diff --git a/test/bthread_fd_unittest.cpp b/test/bthread_fd_unittest.cpp index 4ad2bb22..5e3acb61 100644 --- a/test/bthread_fd_unittest.cpp +++ b/test/bthread_fd_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "butil/compat.h" #include diff --git a/test/bthread_futex_unittest.cpp b/test/bthread_futex_unittest.cpp index dec5220b..86e6bb38 100644 --- a/test/bthread_futex_unittest.cpp +++ b/test/bthread_futex_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/bthread_id_unittest.cpp b/test/bthread_id_unittest.cpp index 98522920..6cd668a7 100644 --- a/test/bthread_id_unittest.cpp +++ b/test/bthread_id_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/bthread_key_unittest.cpp b/test/bthread_key_unittest.cpp index 1a181922..1ccf9e6b 100644 --- a/test/bthread_key_unittest.cpp +++ b/test/bthread_key_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include // std::sort #include "butil/atomicops.h" diff --git a/test/bthread_list_unittest.cpp b/test/bthread_list_unittest.cpp index e942f4f8..efcfbf4b 100644 --- a/test/bthread_list_unittest.cpp +++ b/test/bthread_list_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Tue Sep 30 16:52:32 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/time.h" diff --git a/test/bthread_mutex_unittest.cpp b/test/bthread_mutex_unittest.cpp index 4b93f251..38c43eed 100644 --- a/test/bthread_mutex_unittest.cpp +++ b/test/bthread_mutex_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/compat.h" diff --git a/test/bthread_ping_pong_unittest.cpp b/test/bthread_ping_pong_unittest.cpp index a877be04..76f559b4 100644 --- a/test/bthread_ping_pong_unittest.cpp +++ b/test/bthread_ping_pong_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/bthread_rwlock_unittest.cpp b/test/bthread_rwlock_unittest.cpp index 5083af91..60cbfbe2 100644 --- a/test/bthread_rwlock_unittest.cpp +++ b/test/bthread_rwlock_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/bthread_setconcurrency_unittest.cpp b/test/bthread_setconcurrency_unittest.cpp index b776e892..a16c2a70 100644 --- a/test/bthread_setconcurrency_unittest.cpp +++ b/test/bthread_setconcurrency_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/bthread_timer_thread_unittest.cpp b/test/bthread_timer_thread_unittest.cpp index c44566ba..9351fe41 100644 --- a/test/bthread_timer_thread_unittest.cpp +++ b/test/bthread_timer_thread_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Yang Liu (yangliu@baidu.com) +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/bthread_unittest.cpp b/test/bthread_unittest.cpp index 9a8346e0..66636dbe 100644 --- a/test/bthread_unittest.cpp +++ b/test/bthread_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/bthread_work_stealing_queue_unittest.cpp b/test/bthread_work_stealing_queue_unittest.cpp index d6a4710a..50618338 100644 --- a/test/bthread_work_stealing_queue_unittest.cpp +++ b/test/bthread_work_stealing_queue_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include // std::sort #include diff --git a/test/butil_unittest_main.cpp b/test/butil_unittest_main.cpp index 642e4537..96277e64 100644 --- a/test/butil_unittest_main.cpp +++ b/test/butil_unittest_main.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/bvar_agent_group_unittest.cpp b/test/bvar_agent_group_unittest.cpp index 0f1f42f9..8d9eaff9 100644 --- a/test/bvar_agent_group_unittest.cpp +++ b/test/bvar_agent_group_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author Zhangyi Chen (chenzhangyi01@baidu.com) -// Date 2014/09/26 12:43:49 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include // pthread_* diff --git a/test/bvar_file_dumper_unittest.cpp b/test/bvar_file_dumper_unittest.cpp index 95058cef..aed1d74a 100644 --- a/test/bvar_file_dumper_unittest.cpp +++ b/test/bvar_file_dumper_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/08/27 17:12:38 diff --git a/test/bvar_lock_timer_unittest.cpp b/test/bvar_lock_timer_unittest.cpp index db71e4ca..45dabb52 100644 --- a/test/bvar_lock_timer_unittest.cpp +++ b/test/bvar_lock_timer_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/03/06 18:34:03 diff --git a/test/bvar_percentile_unittest.cpp b/test/bvar_percentile_unittest.cpp index 3ae2a8aa..7aa67e62 100644 --- a/test/bvar_percentile_unittest.cpp +++ b/test/bvar_percentile_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2015/09/15 15:42:55 diff --git a/test/bvar_recorder_unittest.cpp b/test/bvar_recorder_unittest.cpp index 412ec36c..394850d8 100644 --- a/test/bvar_recorder_unittest.cpp +++ b/test/bvar_recorder_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author Zhangyi Chen (chenzhangyi01@baidu.com) // Date 2014/10/13 19:47:59 diff --git a/test/bvar_reducer_unittest.cpp b/test/bvar_reducer_unittest.cpp index 84e6aa46..45e42cd3 100644 --- a/test/bvar_reducer_unittest.cpp +++ b/test/bvar_reducer_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author Zhangyi Chen (chenzhangyi01@baidu.com) -// Date 2014/10/16 17:55:39 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include //std::numeric_limits diff --git a/test/bvar_sampler_unittest.cpp b/test/bvar_sampler_unittest.cpp index b0ccdcf4..0a521a49 100644 --- a/test/bvar_sampler_unittest.cpp +++ b/test/bvar_sampler_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include //std::numeric_limits #include "bvar/detail/sampler.h" diff --git a/test/bvar_status_unittest.cpp b/test/bvar_status_unittest.cpp index 74e7b624..28553f77 100644 --- a/test/bvar_status_unittest.cpp +++ b/test/bvar_status_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author Zhangyi Chen (chenzhangyi01@baidu.com) // Date 2014/10/13 19:47:59 diff --git a/test/bvar_variable_unittest.cpp b/test/bvar_variable_unittest.cpp index 6176ec90..941c9f1d 100644 --- a/test/bvar_variable_unittest.cpp +++ b/test/bvar_variable_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Ge,Jun (gejun@baidu.com) // Date: Fri Jul 24 17:19:40 CST 2015 diff --git a/test/cacheline_unittest.cpp b/test/cacheline_unittest.cpp index dc46e766..4d1372e6 100644 --- a/test/cacheline_unittest.cpp +++ b/test/cacheline_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/class_name_unittest.cpp b/test/class_name_unittest.cpp index 17591738..d3542669 100644 --- a/test/class_name_unittest.cpp +++ b/test/class_name_unittest.cpp @@ -1,7 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/class_name.h" diff --git a/test/endpoint_unittest.cpp b/test/endpoint_unittest.cpp index cbb49e58..503fb665 100644 --- a/test/endpoint_unittest.cpp +++ b/test/endpoint_unittest.cpp @@ -1,7 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/errno.h" diff --git a/test/errno_unittest.cpp b/test/errno_unittest.cpp index f97e3742..6bedc309 100644 --- a/test/errno_unittest.cpp +++ b/test/errno_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Wed Jul 30 08:41:06 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/errno.h" diff --git a/test/fd_guard_unittest.cpp b/test/fd_guard_unittest.cpp index 0f288537..67f06028 100644 --- a/test/fd_guard_unittest.cpp +++ b/test/fd_guard_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include // open #include // ^ diff --git a/test/find_cstr_unittest.cpp b/test/find_cstr_unittest.cpp index 43c29ce6..ae2a47d7 100644 --- a/test/find_cstr_unittest.cpp +++ b/test/find_cstr_unittest.cpp @@ -1,7 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/flat_map_unittest.cpp b/test/flat_map_unittest.cpp index 140617a4..6bcd7959 100644 --- a/test/flat_map_unittest.cpp +++ b/test/flat_map_unittest.cpp @@ -1,5 +1,19 @@ -// Copyright (c) 2013 Baidu, Inc. -// Author: gejun@baidu.com +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/iobuf_unittest.cpp b/test/iobuf_unittest.cpp index 61d9dfb0..972d0bf5 100644 --- a/test/iobuf_unittest.cpp +++ b/test/iobuf_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/object_pool_unittest.cpp b/test/object_pool_unittest.cpp index acca62df..ad1b71f1 100644 --- a/test/object_pool_unittest.cpp +++ b/test/object_pool_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/time.h" diff --git a/test/popen_unittest.cpp b/test/popen_unittest.cpp index 8c8ca8ef..d272bc77 100644 --- a/test/popen_unittest.cpp +++ b/test/popen_unittest.cpp @@ -1,4 +1,19 @@ -// Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Date: 2017/11/06 10:57:08 diff --git a/test/resource_pool_unittest.cpp b/test/resource_pool_unittest.cpp index 23ee0e37..9a56ff3b 100644 --- a/test/resource_pool_unittest.cpp +++ b/test/resource_pool_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sun Jul 13 15:04:18 CST 2014 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/time.h" diff --git a/test/scoped_lock_unittest.cpp b/test/scoped_lock_unittest.cpp index 7a04a3b0..9e592227 100644 --- a/test/scoped_lock_unittest.cpp +++ b/test/scoped_lock_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/scoped_lock.h" diff --git a/test/sstream_workaround.h b/test/sstream_workaround.h index 9840bf0a..05934e55 100644 --- a/test/sstream_workaround.h +++ b/test/sstream_workaround.h @@ -1,5 +1,19 @@ -// Copyright (c) 2017 Baidu, Inc. -// Author: Zhangyi Chen (chenzhangyi01@baidu.com) +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BUTIL_TEST_SSTREAM_WORKAROUND #define BUTIL_TEST_SSTREAM_WORKAROUND diff --git a/test/status_unittest.cpp b/test/status_unittest.cpp index eead8ff0..03f21bc0 100644 --- a/test/status_unittest.cpp +++ b/test/status_unittest.cpp @@ -1,7 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/test/string_printf_unittest.cpp b/test/string_printf_unittest.cpp index 184480ea..afb0612d 100644 --- a/test/string_printf_unittest.cpp +++ b/test/string_printf_unittest.cpp @@ -1,6 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/string_printf.h" diff --git a/test/synchronous_event_unittest.cpp b/test/synchronous_event_unittest.cpp index ff268c13..96b3c221 100644 --- a/test/synchronous_event_unittest.cpp +++ b/test/synchronous_event_unittest.cpp @@ -1,7 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Author: Ge,Jun (gejun@baidu.com) -// Date: Sat Aug 30 17:13:19 CST 2014 +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/synchronous_event.h" diff --git a/test/temp_file_unittest.cpp b/test/temp_file_unittest.cpp index 1e4fbbcf..128af082 100644 --- a/test/temp_file_unittest.cpp +++ b/test/temp_file_unittest.cpp @@ -1,7 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Author: Yan,Lin(yanlin@baidu.com) Ge,Jun(gejun@baidu.com) -// Date: Thu Oct 28 15:20:57 2010 +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include // errno diff --git a/test/unique_ptr_unittest.cpp b/test/unique_ptr_unittest.cpp index 44f0a704..f9a46356 100644 --- a/test/unique_ptr_unittest.cpp +++ b/test/unique_ptr_unittest.cpp @@ -1,7 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at // -// Author: Ge,Jun (gejun@baidu.com) -// Date: 2010-12-04 11:59 +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "butil/unique_ptr.h" diff --git a/tools/idl2proto b/tools/idl2proto index 771cf05e..dacaa389 100755 --- a/tools/idl2proto +++ b/tools/idl2proto @@ -1,8 +1,6 @@ #!/bin/bash -f # mcpack2pb - Make protobuf be front-end of mcpack/compack -# Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved -# Date: Mon Oct 19 17:17:36 CST 2015 # source shflags from current directory mydir="${BASH_SOURCE%/*}" diff --git a/tools/parallel_http/parallel_http.cpp b/tools/parallel_http/parallel_http.cpp index aa249263..46f418f7 100644 --- a/tools/parallel_http/parallel_http.cpp +++ b/tools/parallel_http/parallel_http.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2016 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/tools/rpc_press/info_thread.cpp b/tools/rpc_press/info_thread.cpp index 1940951d..99c9db1c 100644 --- a/tools/rpc_press/info_thread.cpp +++ b/tools/rpc_press/info_thread.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "info_thread.h" diff --git a/tools/rpc_press/info_thread.h b/tools/rpc_press/info_thread.h index 634d7e8f..3564f056 100644 --- a/tools/rpc_press/info_thread.h +++ b/tools/rpc_press/info_thread.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_RPC_REPLAY_INFO_THREAD_H #define BRPC_RPC_REPLAY_INFO_THREAD_H diff --git a/tools/rpc_press/json_loader.cpp b/tools/rpc_press/json_loader.cpp index 617528a0..9ca3877e 100644 --- a/tools/rpc_press/json_loader.cpp +++ b/tools/rpc_press/json_loader.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/tools/rpc_press/json_loader.h b/tools/rpc_press/json_loader.h index 4dba6da8..3294c49f 100644 --- a/tools/rpc_press/json_loader.h +++ b/tools/rpc_press/json_loader.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_JSON_LOADER_H #define BRPC_JSON_LOADER_H diff --git a/tools/rpc_press/pb_util.cpp b/tools/rpc_press/pb_util.cpp index 79d38dd9..781c5cf0 100644 --- a/tools/rpc_press/pb_util.cpp +++ b/tools/rpc_press/pb_util.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include "pb_util.h" diff --git a/tools/rpc_press/pb_util.h b/tools/rpc_press/pb_util.h index 4ad57393..d4203399 100644 --- a/tools/rpc_press/pb_util.h +++ b/tools/rpc_press/pb_util.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef UTIL_PB_UTIL_H #define UTIL_PB_UTIL_H diff --git a/tools/rpc_press/rpc_press.cpp b/tools/rpc_press/rpc_press.cpp index 639c3863..c176f962 100644 --- a/tools/rpc_press/rpc_press.cpp +++ b/tools/rpc_press/rpc_press.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/tools/rpc_press/rpc_press_impl.cpp b/tools/rpc_press/rpc_press_impl.cpp index 5b778486..f825f44c 100644 --- a/tools/rpc_press/rpc_press_impl.cpp +++ b/tools/rpc_press/rpc_press_impl.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include #include diff --git a/tools/rpc_press/rpc_press_impl.h b/tools/rpc_press/rpc_press_impl.h index adee1084..03126fd6 100644 --- a/tools/rpc_press/rpc_press_impl.h +++ b/tools/rpc_press/rpc_press_impl.h @@ -1,16 +1,19 @@ -// Copyright (c) 2015 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef PBRPCPRESS_PBRPC_PRESS_H #define PBRPCPRESS_PBRPC_PRESS_H diff --git a/tools/rpc_replay/info_thread.cpp b/tools/rpc_replay/info_thread.cpp index 58d6f09a..d20d70e8 100644 --- a/tools/rpc_replay/info_thread.cpp +++ b/tools/rpc_replay/info_thread.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #include "info_thread.h" diff --git a/tools/rpc_replay/info_thread.h b/tools/rpc_replay/info_thread.h index 461926d8..bec30f27 100644 --- a/tools/rpc_replay/info_thread.h +++ b/tools/rpc_replay/info_thread.h @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. #ifndef BRPC_RPC_REPLAY_INFO_THREAD_H #define BRPC_RPC_REPLAY_INFO_THREAD_H diff --git a/tools/rpc_replay/rpc_replay.cpp b/tools/rpc_replay/rpc_replay.cpp index 31b9d243..5c193fcc 100644 --- a/tools/rpc_replay/rpc_replay.cpp +++ b/tools/rpc_replay/rpc_replay.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/tools/rpc_view/rpc_view.cpp b/tools/rpc_view/rpc_view.cpp index 2a2efe84..732a5f59 100644 --- a/tools/rpc_view/rpc_view.cpp +++ b/tools/rpc_view/rpc_view.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) diff --git a/tools/trackme_server/trackme_server.cpp b/tools/trackme_server/trackme_server.cpp index aa6a36d4..c3733442 100644 --- a/tools/trackme_server/trackme_server.cpp +++ b/tools/trackme_server/trackme_server.cpp @@ -1,16 +1,19 @@ -// Copyright (c) 2014 Baidu, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Authors: Ge,Jun (gejun@baidu.com) From 7e5b6dad06ddeee1d2d3022de045a44f7fd605db Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 19 Jun 2019 15:06:34 +0800 Subject: [PATCH 251/270] Make RedisRequest derived from RedisRequestBase --- CMakeLists.txt | 3 +- src/brpc/redis.cpp | 162 ++------------------------------------ src/brpc/redis.h | 42 ++-------- src/brpc/redis_base.proto | 7 ++ 4 files changed, 22 insertions(+), 192 deletions(-) create mode 100644 src/brpc/redis_base.proto diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ba06491..363c4a70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -371,7 +371,8 @@ set(PROTO_FILES idl_options.proto brpc/policy/sofa_pbrpc_meta.proto brpc/policy/mongo.proto brpc/trackme.proto - brpc/streaming_rpc_meta.proto) + brpc/streaming_rpc_meta.proto + brpc/redis_base.proto) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/output/include/brpc) set(PROTOC_FLAGS ${PROTOC_FLAGS} -I${PROTOBUF_INCLUDE_DIR}) compile_proto(PROTO_HDRS PROTO_SRCS ${PROJECT_BINARY_DIR} diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp index c4ff4c5a..c4d176bc 100644 --- a/src/brpc/redis.cpp +++ b/src/brpc/redis.cpp @@ -14,123 +14,23 @@ // Authors: Ge,Jun (gejun@baidu.com) -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include #include -#include -#include -#include -#include -#include -#include -#include "butil/string_printf.h" -#include "butil/macros.h" -#include "brpc/controller.h" +#include #include "brpc/redis.h" #include "brpc/redis_command.h" - namespace brpc { DEFINE_bool(redis_verbose_crlf2space, false, "[DEBUG] Show \\r\\n as a space"); -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl(); -void protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto(); -void protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto(); -void protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto(); - -namespace { - -const ::google::protobuf::Descriptor* RedisRequest_descriptor_ = NULL; -const ::google::protobuf::Descriptor* RedisResponse_descriptor_ = NULL; - -} // namespace - -void protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "baidu/rpc/redis_base.proto"); - GOOGLE_CHECK(file != NULL); - RedisRequest_descriptor_ = file->message_type(0); - RedisResponse_descriptor_ = file->message_type(1); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - RedisRequest_descriptor_, &RedisRequest::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - RedisResponse_descriptor_, &RedisResponse::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto() { - delete RedisRequest::default_instance_; - delete RedisResponse::default_instance_; -} - -void protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - -#if GOOGLE_PROTOBUF_VERSION >= 3002000 - ::google::protobuf::internal::InitProtobufDefaults(); -#else - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); -#endif - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\032baidu/rpc/redis_base.proto\022\tbaidu.rpc\032" - " google/protobuf/descriptor.proto\"\016\n\014Red" - "isRequest\"\017\n\rRedisResponseB\003\200\001\001", 111); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "baidu/rpc/redis_base.proto", &protobuf_RegisterTypes); - RedisRequest::default_instance_ = new RedisRequest(); - RedisResponse::default_instance_ = new RedisResponse(); - RedisRequest::default_instance_->InitAsDefaultInstance(); - RedisResponse::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_once); -void protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto() { - ::google::protobuf::GoogleOnceInit( - &protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_once, - &protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_baidu_2frpc_2fredis_5fbase_2eproto { - StaticDescriptorInitializer_baidu_2frpc_2fredis_5fbase_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto(); - } -} static_descriptor_initializer_baidu_2frpc_2fredis_5fbase_2eproto_; - - -// =================================================================== - -#ifndef _MSC_VER -#endif // !_MSC_VER - RedisRequest::RedisRequest() - : ::google::protobuf::Message() { + + : RedisRequestBase() { SharedCtor(); } -void RedisRequest::InitAsDefaultInstance() { -} - RedisRequest::RedisRequest(const RedisRequest& from) - : ::google::protobuf::Message() { + : RedisRequestBase() { SharedCtor(); MergeFrom(from); } @@ -155,19 +55,6 @@ void RedisRequest::SetCachedSize(int size) const { _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } -const ::google::protobuf::Descriptor* RedisRequest::descriptor() { - protobuf_AssignDescriptorsOnce(); - return RedisRequest_descriptor_; -} - -const RedisRequest& RedisRequest::default_instance() { - if (default_instance_ == NULL) { - protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto(); - } - return *default_instance_; -} - -RedisRequest* RedisRequest::default_instance_ = NULL; RedisRequest* RedisRequest::New() const { return new RedisRequest; @@ -246,14 +133,6 @@ void RedisRequest::Swap(RedisRequest* other) { } } -::google::protobuf::Metadata RedisRequest::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = RedisRequest_descriptor_; - metadata.reflection = NULL; - return metadata; -} - bool RedisRequest::AddCommand(const butil::StringPiece& command) { if (_has_error) { return false; @@ -352,21 +231,13 @@ std::ostream& operator<<(std::ostream& os, const RedisRequest& r) { return os; } -// =================================================================== - -#ifndef _MSC_VER -#endif // !_MSC_VER - RedisResponse::RedisResponse() - : ::google::protobuf::Message() { + : RedisResponseBase() { SharedCtor(); } -void RedisResponse::InitAsDefaultInstance() { -} - RedisResponse::RedisResponse(const RedisResponse& from) - : ::google::protobuf::Message() { + : RedisResponseBase() { SharedCtor(); MergeFrom(from); } @@ -389,19 +260,6 @@ void RedisResponse::SharedDtor() { void RedisResponse::SetCachedSize(int size) const { _cached_size_ = size; } -const ::google::protobuf::Descriptor* RedisResponse::descriptor() { - protobuf_AssignDescriptorsOnce(); - return RedisResponse_descriptor_; -} - -const RedisResponse& RedisResponse::default_instance() { - if (default_instance_ == NULL) { - protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto(); - } - return *default_instance_; -} - -RedisResponse* RedisResponse::default_instance_ = NULL; RedisResponse* RedisResponse::New() const { return new RedisResponse; @@ -505,14 +363,6 @@ void RedisResponse::Swap(RedisResponse* other) { } } -::google::protobuf::Metadata RedisResponse::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = RedisResponse_descriptor_; - metadata.reflection = NULL; - return metadata; -} - // =================================================================== ParseError RedisResponse::ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count) { diff --git a/src/brpc/redis.h b/src/brpc/redis.h index d70af0a8..dee00b87 100644 --- a/src/brpc/redis.h +++ b/src/brpc/redis.h @@ -18,20 +18,16 @@ #define BRPC_REDIS_H #include -#include -#include -#include -#include -#include -#include "google/protobuf/descriptor.pb.h" +#include // dynamic_cast_if_available +#include // ReflectionOps::Merge #include "butil/iobuf.h" #include "butil/strings/string_piece.h" #include "butil/arena.h" -#include "redis_reply.h" -#include "parse_result.h" - +#include "brpc/redis_base.pb.h" +#include "brpc/redis_reply.h" +#include "brpc/parse_result.h" namespace brpc { @@ -46,7 +42,7 @@ namespace brpc { // if (!cntl.Failed()) { // LOG(INFO) << response.reply(0); // } -class RedisRequest : public ::google::protobuf::Message { +class RedisRequest : public RedisRequestBase { public: RedisRequest(); virtual ~RedisRequest(); @@ -124,10 +120,6 @@ public: ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } - static const ::google::protobuf::Descriptor* descriptor(); - static const RedisRequest& default_instance(); - ::google::protobuf::Metadata GetMetadata() const; - void Print(std::ostream&) const; private: @@ -140,20 +132,12 @@ private: bool _has_error; // previous AddCommand had error butil::IOBuf _buf; // the serialized request. mutable int _cached_size_; // ByteSize - -friend void protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl(); -friend void protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto(); -friend void protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto(); -friend void protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto(); - - void InitAsDefaultInstance(); - static RedisRequest* default_instance_; }; // Response from Redis. // Notice that a RedisResponse instance may contain multiple replies // due to pipelining. -class RedisResponse : public ::google::protobuf::Message { +class RedisResponse : public RedisResponseBase { public: RedisResponse(); virtual ~RedisResponse(); @@ -201,10 +185,6 @@ public: ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } - static const ::google::protobuf::Descriptor* descriptor(); - static const RedisResponse& default_instance(); - ::google::protobuf::Metadata GetMetadata() const; - private: void SharedCtor(); void SharedDtor(); @@ -215,14 +195,6 @@ private: butil::Arena _arena; int _nreply; mutable int _cached_size_; - -friend void protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto_impl(); -friend void protobuf_AddDesc_baidu_2frpc_2fredis_5fbase_2eproto(); -friend void protobuf_AssignDesc_baidu_2frpc_2fredis_5fbase_2eproto(); -friend void protobuf_ShutdownFile_baidu_2frpc_2fredis_5fbase_2eproto(); - - void InitAsDefaultInstance(); - static RedisResponse* default_instance_; }; std::ostream& operator<<(std::ostream& os, const RedisRequest&); diff --git a/src/brpc/redis_base.proto b/src/brpc/redis_base.proto new file mode 100644 index 00000000..a206d01c --- /dev/null +++ b/src/brpc/redis_base.proto @@ -0,0 +1,7 @@ +syntax="proto2"; +import "google/protobuf/descriptor.proto"; + +package brpc; + +message RedisRequestBase {} +message RedisResponseBase {} From 231b35af18bb56410b7f7097d6b57da3a8398a9f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 19 Jun 2019 19:16:21 +0800 Subject: [PATCH 252/270] Make RedisRequestBase be member of RedisRequest --- src/brpc/policy/baidu_rpc_protocol.cpp | 12 +++--- src/brpc/policy/hulu_pbrpc_protocol.cpp | 12 +++--- src/brpc/policy/sofa_pbrpc_protocol.cpp | 6 +-- src/brpc/progressive_attachment.h | 1 + src/brpc/redis.cpp | 49 ++++++++++++++++++------- src/brpc/redis.h | 15 +++++++- 6 files changed, 65 insertions(+), 30 deletions(-) diff --git a/src/brpc/policy/baidu_rpc_protocol.cpp b/src/brpc/policy/baidu_rpc_protocol.cpp index f6059c60..da70f34a 100644 --- a/src/brpc/policy/baidu_rpc_protocol.cpp +++ b/src/brpc/policy/baidu_rpc_protocol.cpp @@ -317,12 +317,12 @@ void ProcessRpcRequest(InputMessageBase* msg_base) { SampledRequest* sample = AskToBeSampled(); if (sample) { - sample->set_service_name(request_meta.service_name()); - sample->set_method_name(request_meta.method_name()); - sample->set_compress_type((CompressType)meta.compress_type()); - sample->set_protocol_type(PROTOCOL_BAIDU_STD); - sample->set_attachment_size(meta.attachment_size()); - sample->set_authentication_data(meta.authentication_data()); + sample->meta.set_service_name(request_meta.service_name()); + sample->meta.set_method_name(request_meta.method_name()); + sample->meta.set_compress_type((CompressType)meta.compress_type()); + sample->meta.set_protocol_type(PROTOCOL_BAIDU_STD); + sample->meta.set_attachment_size(meta.attachment_size()); + sample->meta.set_authentication_data(meta.authentication_data()); sample->request = msg->payload; sample->submit(start_parse_us); } diff --git a/src/brpc/policy/hulu_pbrpc_protocol.cpp b/src/brpc/policy/hulu_pbrpc_protocol.cpp index b0fbdb35..1daa69f2 100644 --- a/src/brpc/policy/hulu_pbrpc_protocol.cpp +++ b/src/brpc/policy/hulu_pbrpc_protocol.cpp @@ -345,15 +345,15 @@ void ProcessHuluRequest(InputMessageBase* msg_base) { const CompressType req_cmp_type = Hulu2CompressType((HuluCompressType)meta.compress_type()); SampledRequest* sample = AskToBeSampled(); if (sample) { - sample->set_service_name(meta.service_name()); - sample->set_method_index(meta.method_index()); - sample->set_compress_type(req_cmp_type); - sample->set_protocol_type(PROTOCOL_HULU_PBRPC); - sample->set_user_data(meta.user_data()); + sample->meta.set_service_name(meta.service_name()); + sample->meta.set_method_index(meta.method_index()); + sample->meta.set_compress_type(req_cmp_type); + sample->meta.set_protocol_type(PROTOCOL_HULU_PBRPC); + sample->meta.set_user_data(meta.user_data()); if (meta.has_user_message_size() && static_cast(meta.user_message_size()) < msg->payload.size()) { size_t attachment_size = msg->payload.size() - meta.user_message_size(); - sample->set_attachment_size(attachment_size); + sample->meta.set_attachment_size(attachment_size); } sample->request = msg->payload; sample->submit(start_parse_us); diff --git a/src/brpc/policy/sofa_pbrpc_protocol.cpp b/src/brpc/policy/sofa_pbrpc_protocol.cpp index 34ed83e9..d541b8c4 100644 --- a/src/brpc/policy/sofa_pbrpc_protocol.cpp +++ b/src/brpc/policy/sofa_pbrpc_protocol.cpp @@ -322,9 +322,9 @@ void ProcessSofaRequest(InputMessageBase* msg_base) { SampledRequest* sample = AskToBeSampled(); if (sample) { - sample->set_method_name(meta.method()); - sample->set_compress_type(req_cmp_type); - sample->set_protocol_type(PROTOCOL_SOFA_PBRPC); + sample->meta.set_method_name(meta.method()); + sample->meta.set_compress_type(req_cmp_type); + sample->meta.set_protocol_type(PROTOCOL_SOFA_PBRPC); sample->request = msg->payload; sample->submit(start_parse_us); } diff --git a/src/brpc/progressive_attachment.h b/src/brpc/progressive_attachment.h index 3af93681..26c88ea2 100644 --- a/src/brpc/progressive_attachment.h +++ b/src/brpc/progressive_attachment.h @@ -17,6 +17,7 @@ #ifndef BRPC_PROGRESSIVE_ATTACHMENT_H #define BRPC_PROGRESSIVE_ATTACHMENT_H +#include #include "butil/atomicops.h" #include "butil/iobuf.h" #include "butil/endpoint.h" // butil::EndPoint diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp index c4d176bc..5cf0ce20 100644 --- a/src/brpc/redis.cpp +++ b/src/brpc/redis.cpp @@ -24,13 +24,12 @@ namespace brpc { DEFINE_bool(redis_verbose_crlf2space, false, "[DEBUG] Show \\r\\n as a space"); RedisRequest::RedisRequest() - - : RedisRequestBase() { + : ::google::protobuf::Message() { SharedCtor(); } RedisRequest::RedisRequest(const RedisRequest& from) - : RedisRequestBase() { + : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } @@ -46,14 +45,10 @@ RedisRequest::~RedisRequest() { } void RedisRequest::SharedDtor() { - if (this != default_instance_) { - } } void RedisRequest::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); } RedisRequest* RedisRequest::New() const { @@ -84,9 +79,7 @@ void RedisRequest::SerializeWithCachedSizes( int RedisRequest::ByteSize() const { int total_size = _buf.size(); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } @@ -206,6 +199,22 @@ bool RedisRequest::SerializeTo(butil::IOBuf* buf) const { return true; } +const ::google::protobuf::Descriptor* RedisRequest::descriptor() { + return _base.GetDescriptor(); +} + +const RedisRequest& RedisRequest::default_instance() { + static RedisRequest req; + return req; +} + +::google::protobuf::Metadata RedisRequest::GetMetadata() const { + ::google::protobuf::Metadata metadata; + metadata.descriptor = _base.GetDescriptor(); + metadata.reflection = _base.GetReflection(); + return metadata; +} + void RedisRequest::Print(std::ostream& os) const { butil::IOBuf cp = _buf; butil::IOBuf seg; @@ -232,12 +241,12 @@ std::ostream& operator<<(std::ostream& os, const RedisRequest& r) { } RedisResponse::RedisResponse() - : RedisResponseBase() { + : ::google::protobuf::Message() { SharedCtor(); } RedisResponse::RedisResponse(const RedisResponse& from) - : RedisResponseBase() { + : ::google::protobuf::Message() { SharedCtor(); MergeFrom(from); } @@ -253,8 +262,6 @@ RedisResponse::~RedisResponse() { } void RedisResponse::SharedDtor() { - if (this != default_instance_) { - } } void RedisResponse::SetCachedSize(int size) const { @@ -363,6 +370,22 @@ void RedisResponse::Swap(RedisResponse* other) { } } +const ::google::protobuf::Descriptor* RedisResponse::descriptor() { + return _base.GetDescriptor(); +} + +const RedisResponse& RedisResponse::default_instance() { + static RedisResponse res; + return res; +} + +::google::protobuf::Metadata RedisResponse::GetMetadata() const { + ::google::protobuf::Metadata metadata; + metadata.descriptor = _base.GetDescriptor(); + metadata.reflection = _base.GetReflection(); + return metadata; +} + // =================================================================== ParseError RedisResponse::ConsumePartialIOBuf(butil::IOBuf& buf, int reply_count) { diff --git a/src/brpc/redis.h b/src/brpc/redis.h index dee00b87..68782902 100644 --- a/src/brpc/redis.h +++ b/src/brpc/redis.h @@ -19,6 +19,7 @@ #include +#include #include // dynamic_cast_if_available #include // ReflectionOps::Merge @@ -42,7 +43,7 @@ namespace brpc { // if (!cntl.Failed()) { // LOG(INFO) << response.reply(0); // } -class RedisRequest : public RedisRequestBase { +class RedisRequest : public ::google::protobuf::Message { public: RedisRequest(); virtual ~RedisRequest(); @@ -119,6 +120,10 @@ public: ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } + + static const ::google::protobuf::Descriptor* descriptor(); + static const RedisRequest& default_instance(); + ::google::protobuf::Metadata GetMetadata() const; void Print(std::ostream&) const; @@ -132,12 +137,13 @@ private: bool _has_error; // previous AddCommand had error butil::IOBuf _buf; // the serialized request. mutable int _cached_size_; // ByteSize + static RedisRequestBase _base; }; // Response from Redis. // Notice that a RedisResponse instance may contain multiple replies // due to pipelining. -class RedisResponse : public RedisResponseBase { +class RedisResponse : public ::google::protobuf::Message { public: RedisResponse(); virtual ~RedisResponse(); @@ -185,6 +191,10 @@ public: ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } + static const ::google::protobuf::Descriptor* descriptor(); + static const RedisResponse& default_instance(); + ::google::protobuf::Metadata GetMetadata() const; + private: void SharedCtor(); void SharedDtor(); @@ -195,6 +205,7 @@ private: butil::Arena _arena; int _nreply; mutable int _cached_size_; + static RedisResponseBase _base; }; std::ostream& operator<<(std::ostream& os, const RedisRequest&); From b564dd56836f6eaefb921b8c94581b5c85d09429 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Wed, 19 Jun 2019 19:16:52 +0800 Subject: [PATCH 253/270] Make RpcDumpMeta be member of SampledRequest --- src/brpc/rpc_dump.cpp | 4 ++-- src/brpc/rpc_dump.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/brpc/rpc_dump.cpp b/src/brpc/rpc_dump.cpp index 18f61f87..8c95ee22 100644 --- a/src/brpc/rpc_dump.cpp +++ b/src/brpc/rpc_dump.cpp @@ -240,7 +240,7 @@ bool RpcDumpContext::Serialize(butil::IOBuf& buf, SampledRequest* sample) { const size_t starting_size = buf.size(); butil::IOBufAsZeroCopyOutputStream buf_stream(&buf); - if (!sample->SerializeToZeroCopyStream(&buf_stream)) { + if (!sample->meta.SerializeToZeroCopyStream(&buf_stream)) { LOG(ERROR) << "Fail to serialize"; return false; } @@ -349,7 +349,7 @@ SampledRequest* SampleIterator::Pop(butil::IOBuf& buf, bool* format_error) { butil::IOBuf meta_buf; buf.cutn(&meta_buf, meta_size); std::unique_ptr req(new SampledRequest); - if (!ParsePbFromIOBuf(req.get(), meta_buf)) { + if (!ParsePbFromIOBuf(&req->meta, meta_buf)) { LOG(ERROR) << "Fail to parse RpcDumpMeta"; *format_error = true; return NULL; diff --git a/src/brpc/rpc_dump.h b/src/brpc/rpc_dump.h index e17213bd..318e49bd 100644 --- a/src/brpc/rpc_dump.h +++ b/src/brpc/rpc_dump.h @@ -46,9 +46,9 @@ DECLARE_bool(rpc_dump); // In practice, sampled requests are just small fraction of all requests. // The overhead of sampling should be negligible for overall performance. -struct SampledRequest : public bvar::Collected - , public RpcDumpMeta { +struct SampledRequest : public bvar::Collected { butil::IOBuf request; + RpcDumpMeta meta; // Implement methods of Sampled. void dump_and_destroy(size_t round) override; From 585d5393765d1d426a824512d83713b3580dc724 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 20 Jun 2019 15:42:30 +0800 Subject: [PATCH 254/270] Make the descriptor and reflection of esp_message, memcache, nshead_message, serialized_request, thrift_message be independent of protobuf. --- CMakeLists.txt | 2 +- src/brpc/esp_message.cpp | 108 ++--------------------- src/brpc/esp_message.h | 25 ++---- src/brpc/memcache.cpp | 152 ++++---------------------------- src/brpc/memcache.h | 43 +++------ src/brpc/nshead_message.cpp | 109 +++-------------------- src/brpc/nshead_message.h | 27 ++---- src/brpc/proto_base.proto | 18 ++++ src/brpc/redis.cpp | 6 ++ src/brpc/redis.h | 8 +- src/brpc/redis_base.proto | 7 -- src/brpc/serialized_request.cpp | 97 ++------------------ src/brpc/serialized_request.h | 26 ++---- src/brpc/thrift_message.cpp | 93 ++----------------- src/brpc/thrift_message.h | 23 +---- 15 files changed, 111 insertions(+), 633 deletions(-) create mode 100644 src/brpc/proto_base.proto delete mode 100644 src/brpc/redis_base.proto diff --git a/CMakeLists.txt b/CMakeLists.txt index 363c4a70..f469eb9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -372,7 +372,7 @@ set(PROTO_FILES idl_options.proto brpc/policy/mongo.proto brpc/trackme.proto brpc/streaming_rpc_meta.proto - brpc/redis_base.proto) + brpc/proto_base.proto) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/output/include/brpc) set(PROTOC_FLAGS ${PROTOC_FLAGS} -I${PROTOBUF_INCLUDE_DIR}) compile_proto(PROTO_HDRS PROTO_SRCS ${PROJECT_BINARY_DIR} diff --git a/src/brpc/esp_message.cpp b/src/brpc/esp_message.cpp index 26eff2c7..bb0ffcaf 100644 --- a/src/brpc/esp_message.cpp +++ b/src/brpc/esp_message.cpp @@ -12,99 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Generated by the protocol buffer compiler. DO NOT EDIT! - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include "esp_message.h" -#include - -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - +#include // WireFormatLite::GetTagWireType namespace brpc { -namespace { - -const ::google::protobuf::Descriptor* EspMessage_descriptor_ = NULL; - -} // namespace - -void protobuf_AssignDesc_esp_5fmessage_2eproto() { - protobuf_AddDesc_esp_5fmessage_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "esp_message.proto"); - GOOGLE_CHECK(file != NULL); - EspMessage_descriptor_ = file->message_type(0); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_esp_5fmessage_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EspMessage_descriptor_, &EspMessage::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_esp_5fmessage_2eproto() { - delete EspMessage::default_instance_; -} - -void protobuf_AddDesc_esp_5fmessage_2eproto() { - static bool already_here = false; - - if (already_here) { - return; - } - - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\021esp_message.proto\022\tbaidu.rpc\"\014\n\nEspMessage", 44); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "esp_message.proto", &protobuf_RegisterTypes); - EspMessage::default_instance_ = new EspMessage(); - EspMessage::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_esp_5fmessage_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_esp_5fmessage_2eproto { - StaticDescriptorInitializer_esp_5fmessage_2eproto() { - protobuf_AddDesc_esp_5fmessage_2eproto(); - } -} static_descriptor_initializer_esp_5fmessage_2eproto_; - - -// =================================================================== - -#ifndef _MSC_VER -#endif // !_MSC_VER +EspMessageBase EspMessage::_base; EspMessage::EspMessage() : ::google::protobuf::Message() { SharedCtor(); } -void EspMessage::InitAsDefaultInstance() { -} - EspMessage::EspMessage(const EspMessage& from) : ::google::protobuf::Message() { SharedCtor(); @@ -120,25 +40,17 @@ EspMessage::~EspMessage() { } void EspMessage::SharedDtor() { - if (this != default_instance_) { - } } const ::google::protobuf::Descriptor* EspMessage::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EspMessage_descriptor_; + return _base.GetDescriptor(); } const EspMessage& EspMessage::default_instance() { - if (default_instance_ == NULL) { - protobuf_AddDesc_esp_5fmessage_2eproto(); - } - - return *default_instance_; + static EspMessage req; + return req; } -EspMessage* EspMessage::default_instance_ = NULL; - EspMessage* EspMessage::New() const { return new EspMessage; } @@ -227,16 +139,10 @@ void EspMessage::Swap(EspMessage* other) { } ::google::protobuf::Metadata EspMessage::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = EspMessage_descriptor_; - metadata.reflection = NULL; + metadata.descriptor = _base.GetDescriptor(); + metadata.reflection = _base.GetReflection(); return metadata; } -// @@protoc_insertion_point(namespace_scope) - } // namespace brpc - - -// @@protoc_insertion_point(global_scope) diff --git a/src/brpc/esp_message.h b/src/brpc/esp_message.h index 8dc708d4..12c2ab92 100644 --- a/src/brpc/esp_message.h +++ b/src/brpc/esp_message.h @@ -17,23 +17,16 @@ #include -#include -#include -#include -#include -#include +#include +#include // dynamic_cast_if_available +#include // ReflectionOps::Merge #include "brpc/esp_head.h" #include "butil/iobuf.h" - +#include "brpc/proto_base.pb.h" namespace brpc { -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_esp_5fmessage_2eproto(); -void protobuf_AssignDesc_esp_5fmessage_2eproto(); -void protobuf_ShutdownFile_esp_5fmessage_2eproto(); - class EspMessage : public ::google::protobuf::Message { public: EspHead head; @@ -73,17 +66,15 @@ public: ::google::protobuf::uint8* SerializeWithCachedSizesToArray( ::google::protobuf::uint8* output) const; int GetCachedSize() const { return ByteSize(); } - ::google::protobuf::Metadata GetMetadata() const; + +protected: + ::google::protobuf::Metadata GetMetadata() const override; private: void SharedCtor(); void SharedDtor(); - friend void protobuf_AddDesc_esp_5fmessage_2eproto(); - friend void protobuf_AssignDesc_esp_5fmessage_2eproto(); - friend void protobuf_ShutdownFile_esp_5fmessage_2eproto(); - void InitAsDefaultInstance(); - static EspMessage* default_instance_; + static EspMessageBase _base; }; } // namespace brpc diff --git a/src/brpc/memcache.cpp b/src/brpc/memcache.cpp index b069a195..06e05472 100644 --- a/src/brpc/memcache.cpp +++ b/src/brpc/memcache.cpp @@ -14,119 +14,26 @@ // Authors: Ge,Jun (gejun@baidu.com) -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include -#include -#include -#include -#include +#include #include #include #include "butil/string_printf.h" #include "butil/macros.h" #include "butil/sys_byteorder.h" -#include "brpc/controller.h" +#include "butil/logging.h" #include "brpc/memcache.h" #include "brpc/policy/memcache_binary_header.h" - namespace brpc { -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl(); -void protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); -void protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); -void protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto(); - -namespace { - -const ::google::protobuf::Descriptor* MemcacheRequest_descriptor_ = NULL; -const ::google::protobuf::Descriptor* MemcacheResponse_descriptor_ = NULL; - -} // namespace - -void protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "baidu/rpc/memcache_base.proto"); - GOOGLE_CHECK(file != NULL); - MemcacheRequest_descriptor_ = file->message_type(0); - MemcacheResponse_descriptor_ = file->message_type(1); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MemcacheRequest_descriptor_, &MemcacheRequest::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MemcacheResponse_descriptor_, &MemcacheResponse::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto() { - delete MemcacheRequest::default_instance_; - delete MemcacheResponse::default_instance_; -} - -void protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - -#if GOOGLE_PROTOBUF_VERSION >= 3002000 - ::google::protobuf::internal::InitProtobufDefaults(); -#else - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); -#endif - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\035baidu/rpc/memcache_base.proto\022\tbaidu.r" - "pc\032 google/protobuf/descriptor.proto\"\021\n\017" - "MemcacheRequest\"\022\n\020MemcacheResponseB\003\200\001\001", 120); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "baidu/rpc/memcache_base.proto", &protobuf_RegisterTypes); - MemcacheRequest::default_instance_ = new MemcacheRequest(); - MemcacheResponse::default_instance_ = new MemcacheResponse(); - MemcacheRequest::default_instance_->InitAsDefaultInstance(); - MemcacheResponse::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_once); -void protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto() { - ::google::protobuf::GoogleOnceInit( - &protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_once, - &protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_baidu_2frpc_2fmemcache_5fbase_2eproto { - StaticDescriptorInitializer_baidu_2frpc_2fmemcache_5fbase_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); - } -} static_descriptor_initializer_baidu_2frpc_2fmemcache_5fbase_2eproto_; - - -// =================================================================== - -#ifndef _MSC_VER -#endif // !_MSC_VER +MemcacheRequestBase MemcacheRequest::_base; MemcacheRequest::MemcacheRequest() : ::google::protobuf::Message() { SharedCtor(); } -void MemcacheRequest::InitAsDefaultInstance() { -} - MemcacheRequest::MemcacheRequest(const MemcacheRequest& from) : ::google::protobuf::Message() { SharedCtor(); @@ -143,29 +50,21 @@ MemcacheRequest::~MemcacheRequest() { } void MemcacheRequest::SharedDtor() { - if (this != default_instance_) { - } } void MemcacheRequest::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); } + const ::google::protobuf::Descriptor* MemcacheRequest::descriptor() { - protobuf_AssignDescriptorsOnce(); - return MemcacheRequest_descriptor_; + return _base.GetDescriptor(); } const MemcacheRequest& MemcacheRequest::default_instance() { - if (default_instance_ == NULL) { - protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); - } - return *default_instance_; + static MemcacheRequest req; + return req; } -MemcacheRequest* MemcacheRequest::default_instance_ = NULL; - MemcacheRequest* MemcacheRequest::New() const { return new MemcacheRequest; } @@ -230,9 +129,7 @@ void MemcacheRequest::SerializeWithCachedSizes( int MemcacheRequest::ByteSize() const { int total_size = _buf.size(); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } @@ -278,26 +175,19 @@ void MemcacheRequest::Swap(MemcacheRequest* other) { } ::google::protobuf::Metadata MemcacheRequest::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = MemcacheRequest_descriptor_; - metadata.reflection = NULL; + metadata.descriptor = _base.GetDescriptor(); + metadata.reflection = _base.GetReflection(); return metadata; } -// =================================================================== - -#ifndef _MSC_VER -#endif // !_MSC_VER +MemcacheResponseBase MemcacheResponse::_base; MemcacheResponse::MemcacheResponse() : ::google::protobuf::Message() { SharedCtor(); } -void MemcacheResponse::InitAsDefaultInstance() { -} - MemcacheResponse::MemcacheResponse(const MemcacheResponse& from) : ::google::protobuf::Message() { SharedCtor(); @@ -313,29 +203,20 @@ MemcacheResponse::~MemcacheResponse() { } void MemcacheResponse::SharedDtor() { - if (this != default_instance_) { - } } void MemcacheResponse::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* MemcacheResponse::descriptor() { - protobuf_AssignDescriptorsOnce(); - return MemcacheResponse_descriptor_; + return _base.GetDescriptor(); } const MemcacheResponse& MemcacheResponse::default_instance() { - if (default_instance_ == NULL) { - protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); - } - return *default_instance_; + static MemcacheResponse res; + return res; } -MemcacheResponse* MemcacheResponse::default_instance_ = NULL; - MemcacheResponse* MemcacheResponse::New() const { return new MemcacheResponse; } @@ -377,9 +258,7 @@ void MemcacheResponse::SerializeWithCachedSizes( int MemcacheResponse::ByteSize() const { int total_size = _buf.size(); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } @@ -426,10 +305,9 @@ void MemcacheResponse::Swap(MemcacheResponse* other) { } ::google::protobuf::Metadata MemcacheResponse::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = MemcacheResponse_descriptor_; - metadata.reflection = NULL; + metadata.descriptor = _base.GetDescriptor(); + metadata.reflection = _base.GetReflection(); return metadata; } diff --git a/src/brpc/memcache.h b/src/brpc/memcache.h index 9ef168d0..3747b82b 100644 --- a/src/brpc/memcache.h +++ b/src/brpc/memcache.h @@ -18,15 +18,11 @@ #define BRPC_MEMCACHE_H #include -#include -#include -#include -#include -#include -#include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/message.h" #include "butil/iobuf.h" #include "butil/strings/string_piece.h" +#include "brpc/proto_base.pb.h" namespace brpc { @@ -87,6 +83,9 @@ public: int pipelined_count() const { return _pipelined_count; } + butil::IOBuf& raw_buffer() { return _buf; } + const butil::IOBuf& raw_buffer() const { return _buf; } + // Protobuf methods. MemcacheRequest* New() const; void CopyFrom(const ::google::protobuf::Message& from); @@ -106,10 +105,9 @@ public: static const ::google::protobuf::Descriptor* descriptor(); static const MemcacheRequest& default_instance(); - ::google::protobuf::Metadata GetMetadata() const; - butil::IOBuf& raw_buffer() { return _buf; } - const butil::IOBuf& raw_buffer() const { return _buf; } +protected: + ::google::protobuf::Metadata GetMetadata() const override; private: bool GetOrDelete(uint8_t command, const butil::StringPiece& key); @@ -127,14 +125,7 @@ private: int _pipelined_count; butil::IOBuf _buf; mutable int _cached_size_; - -friend void protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl(); -friend void protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); -friend void protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); -friend void protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto(); - - void InitAsDefaultInstance(); - static MemcacheRequest* default_instance_; + static MemcacheRequestBase _base; }; // Response from Memcache. @@ -202,6 +193,9 @@ public: bool PopDecrement(uint64_t* new_value, uint64_t* cas_value); bool PopTouch(); bool PopVersion(std::string* version); + butil::IOBuf& raw_buffer() { return _buf; } + const butil::IOBuf& raw_buffer() const { return _buf; } + static const char* status_str(Status); // implements Message ---------------------------------------------- @@ -223,13 +217,10 @@ public: static const ::google::protobuf::Descriptor* descriptor(); static const MemcacheResponse& default_instance(); + +protected: ::google::protobuf::Metadata GetMetadata() const; - butil::IOBuf& raw_buffer() { return _buf; } - const butil::IOBuf& raw_buffer() const { return _buf; } - - static const char* status_str(Status); - private: bool PopCounter(uint8_t command, uint64_t* new_value, uint64_t* cas_value); bool PopStore(uint8_t command, uint64_t* cas_value); @@ -242,13 +233,7 @@ private: butil::IOBuf _buf; mutable int _cached_size_; -friend void protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto_impl(); -friend void protobuf_AddDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); -friend void protobuf_AssignDesc_baidu_2frpc_2fmemcache_5fbase_2eproto(); -friend void protobuf_ShutdownFile_baidu_2frpc_2fmemcache_5fbase_2eproto(); - - void InitAsDefaultInstance(); - static MemcacheResponse* default_instance_; + static MemcacheResponseBase _base; }; } // namespace brpc diff --git a/src/brpc/nshead_message.cpp b/src/brpc/nshead_message.cpp index dc197f99..d569b2bc 100644 --- a/src/brpc/nshead_message.cpp +++ b/src/brpc/nshead_message.cpp @@ -14,104 +14,22 @@ // Authors: Ge,Jun (gejun@baidu.com) -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "brpc/nshead_message.h" - #include -#include "butil/logging.h" - -#include -#include -#include -#include -#include +#include // dynamic_cast_if_available +#include // ReflectionOps::Merge #include - +#include "brpc/nshead_message.h" +#include "butil/logging.h" namespace brpc { -namespace { -const ::google::protobuf::Descriptor* NsheadMessage_descriptor_ = NULL; -} // namespace - - -void protobuf_AssignDesc_baidu_2frpc_2fnshead_5fmessage_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "baidu/rpc/nshead_message.proto"); - GOOGLE_CHECK(file != NULL); - NsheadMessage_descriptor_ = file->message_type(0); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_baidu_2frpc_2fnshead_5fmessage_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - NsheadMessage_descriptor_, &NsheadMessage::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_baidu_2frpc_2fnshead_5fmessage_2eproto() { - delete NsheadMessage::default_instance_; -} - -void protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - -#if GOOGLE_PROTOBUF_VERSION >= 3002000 - ::google::protobuf::internal::InitProtobufDefaults(); -#else - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); -#endif - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\036baidu/rpc/nshead_message.proto\022\tbaidu." - "rpc\032 google/protobuf/descriptor.proto\"\017\n" - "\rNsheadMessageB\003\200\001\001", 99); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "baidu/rpc/nshead_message.proto", &protobuf_RegisterTypes); - NsheadMessage::default_instance_ = new NsheadMessage(); - NsheadMessage::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown( - &protobuf_ShutdownFile_baidu_2frpc_2fnshead_5fmessage_2eproto); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_once); -void protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto() { - ::google::protobuf::GoogleOnceInit( - &protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_once, - &protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_impl); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_baidu_2frpc_2fnshead_5fmessage_2eproto { - StaticDescriptorInitializer_baidu_2frpc_2fnshead_5fmessage_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto(); - } -} static_descriptor_initializer_baidu_2frpc_2fnshead_5fmessage_2eproto_; - - -// =================================================================== - -#ifndef _MSC_VER -#endif // !_MSC_VER +NsheadMessageBase NsheadMessage::_base; NsheadMessage::NsheadMessage() : ::google::protobuf::Message() { SharedCtor(); } -void NsheadMessage::InitAsDefaultInstance() { -} - NsheadMessage::NsheadMessage(const NsheadMessage& from) : ::google::protobuf::Message() { SharedCtor(); @@ -127,23 +45,17 @@ NsheadMessage::~NsheadMessage() { } void NsheadMessage::SharedDtor() { - if (this != default_instance_) { - } } const ::google::protobuf::Descriptor* NsheadMessage::descriptor() { - protobuf_AssignDescriptorsOnce(); - return NsheadMessage_descriptor_; + return _base.GetDescriptor(); } const NsheadMessage& NsheadMessage::default_instance() { - if (default_instance_ == NULL) - protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto(); - return *default_instance_; + static NsheadMessage message; + return message; } -NsheadMessage* NsheadMessage::default_instance_ = NULL; - NsheadMessage* NsheadMessage::New() const { return new NsheadMessage; } @@ -226,10 +138,9 @@ void NsheadMessage::Swap(NsheadMessage* other) { } ::google::protobuf::Metadata NsheadMessage::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = NsheadMessage_descriptor_; - metadata.reflection = NULL; + metadata.descriptor = _base.GetDescriptor(); + metadata.reflection = _base.GetReflection(); return metadata; } diff --git a/src/brpc/nshead_message.h b/src/brpc/nshead_message.h index 368c0828..e09efefe 100644 --- a/src/brpc/nshead_message.h +++ b/src/brpc/nshead_message.h @@ -19,24 +19,13 @@ #include -#include -#include -#include -#include -#include -#include "google/protobuf/descriptor.pb.h" - +#include #include "brpc/nshead.h" // nshead_t -#include "butil/iobuf.h" // IOBuf - +#include "butil/iobuf.h" // IOBuf +#include "brpc/proto_base.pb.h" namespace brpc { -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto(); -void protobuf_AssignDesc_baidu_2frpc_2fnshead_5fmessage_2eproto(); -void protobuf_ShutdownFile_baidu_2frpc_2fnshead_5fmessage_2eproto(); - // Representing a nshead request or response. class NsheadMessage : public ::google::protobuf::Message { public: @@ -76,19 +65,15 @@ public: ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return ByteSize(); } + +protected: ::google::protobuf::Metadata GetMetadata() const; private: void SharedCtor(); void SharedDtor(); -private: -friend void protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto_impl(); -friend void protobuf_AddDesc_baidu_2frpc_2fnshead_5fmessage_2eproto(); -friend void protobuf_AssignDesc_baidu_2frpc_2fnshead_5fmessage_2eproto(); -friend void protobuf_ShutdownFile_baidu_2frpc_2fnshead_5fmessage_2eproto(); - void InitAsDefaultInstance(); - static NsheadMessage* default_instance_; + static NsheadMessageBase _base; }; } // namespace brpc diff --git a/src/brpc/proto_base.proto b/src/brpc/proto_base.proto new file mode 100644 index 00000000..c890dec1 --- /dev/null +++ b/src/brpc/proto_base.proto @@ -0,0 +1,18 @@ +syntax="proto2"; +import "google/protobuf/descriptor.proto"; + +package brpc; + +message RedisRequestBase {} +message RedisResponseBase {} + +message EspMessageBase {} + +message MemcacheRequestBase {} +message MemcacheResponseBase {} + +message NsheadMessageBase {} + +message SerializedRequestBase {} + +message ThriftFramedMessageBase {} diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp index 5cf0ce20..e0148388 100644 --- a/src/brpc/redis.cpp +++ b/src/brpc/redis.cpp @@ -14,6 +14,8 @@ // Authors: Ge,Jun (gejun@baidu.com) +#include // dynamic_cast_if_available +#include // ReflectionOps::Merge #include #include #include "brpc/redis.h" @@ -23,6 +25,8 @@ namespace brpc { DEFINE_bool(redis_verbose_crlf2space, false, "[DEBUG] Show \\r\\n as a space"); +RedisRequestBase RedisRequest::_base; + RedisRequest::RedisRequest() : ::google::protobuf::Message() { SharedCtor(); @@ -240,6 +244,8 @@ std::ostream& operator<<(std::ostream& os, const RedisRequest& r) { return os; } +RedisResponseBase RedisResponse::_base; + RedisResponse::RedisResponse() : ::google::protobuf::Message() { SharedCtor(); diff --git a/src/brpc/redis.h b/src/brpc/redis.h index 68782902..99af603f 100644 --- a/src/brpc/redis.h +++ b/src/brpc/redis.h @@ -20,13 +20,11 @@ #include #include -#include // dynamic_cast_if_available -#include // ReflectionOps::Merge #include "butil/iobuf.h" #include "butil/strings/string_piece.h" #include "butil/arena.h" -#include "brpc/redis_base.pb.h" +#include "brpc/proto_base.pb.h" #include "brpc/redis_reply.h" #include "brpc/parse_result.h" @@ -123,10 +121,12 @@ public: static const ::google::protobuf::Descriptor* descriptor(); static const RedisRequest& default_instance(); - ::google::protobuf::Metadata GetMetadata() const; void Print(std::ostream&) const; +protected: + ::google::protobuf::Metadata GetMetadata() const override; + private: void SharedCtor(); void SharedDtor(); diff --git a/src/brpc/redis_base.proto b/src/brpc/redis_base.proto deleted file mode 100644 index a206d01c..00000000 --- a/src/brpc/redis_base.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax="proto2"; -import "google/protobuf/descriptor.proto"; - -package brpc; - -message RedisRequestBase {} -message RedisResponseBase {} diff --git a/src/brpc/serialized_request.cpp b/src/brpc/serialized_request.cpp index c6e73c25..9f79e6ef 100644 --- a/src/brpc/serialized_request.cpp +++ b/src/brpc/serialized_request.cpp @@ -14,95 +14,19 @@ // Authors: Ge,Jun (gejun@baidu.com) -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include // dynamic_cast_if_available #include "brpc/serialized_request.h" - -#include - -#include -#include -#include -#include -#include -#include - #include "butil/logging.h" - namespace brpc { -namespace { - -const ::google::protobuf::Descriptor* SerializedRequest_descriptor_ = NULL; - -} // namespace - -void protobuf_AssignDesc_baidu_2frpc_2fserialized_5frequest_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "baidu/rpc/serialized_request.proto"); - GOOGLE_CHECK(file != NULL); - SerializedRequest_descriptor_ = file->message_type(0); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_baidu_2frpc_2fserialized_5frequest_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SerializedRequest_descriptor_, &SerializedRequest::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_baidu_2frpc_2fserialized_5frequest_2eproto() { - delete SerializedRequest::default_instance_; -} - -void protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\"baidu/rpc/serialized_request.proto\022\tba" - "idu.rpc\"\023\n\021SerializedRequest", 68); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "baidu/rpc/serialized_request.proto", &protobuf_RegisterTypes); - SerializedRequest::default_instance_ = new SerializedRequest(); - SerializedRequest::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_baidu_2frpc_2fserialized_5frequest_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_baidu_2frpc_2fserialized_5frequest_2eproto { - StaticDescriptorInitializer_baidu_2frpc_2fserialized_5frequest_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto(); - } -} static_descriptor_initializer_baidu_2frpc_2fserialized_5frequest_2eproto_; - - -// =================================================================== - -#ifndef _MSC_VER -#endif // !_MSC_VER +SerializedRequestBase SerializedRequest::_base; SerializedRequest::SerializedRequest() : ::google::protobuf::Message() { SharedCtor(); } -void SerializedRequest::InitAsDefaultInstance() { -} - SerializedRequest::SerializedRequest(const SerializedRequest& from) : ::google::protobuf::Message() { SharedCtor(); @@ -117,26 +41,20 @@ SerializedRequest::~SerializedRequest() { } void SerializedRequest::SharedDtor() { - if (this != default_instance_) { - } } void SerializedRequest::SetCachedSize(int /*size*/) const { CHECK(false) << "You're not supposed to call " << __FUNCTION__; } const ::google::protobuf::Descriptor* SerializedRequest::descriptor() { - protobuf_AssignDescriptorsOnce(); - return SerializedRequest_descriptor_; + return _base.GetDescriptor(); } const SerializedRequest& SerializedRequest::default_instance() { - if (default_instance_ == NULL) - protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto(); - return *default_instance_; + static SerializedRequest req; + return req; } -SerializedRequest* SerializedRequest::default_instance_ = NULL; - SerializedRequest* SerializedRequest::New() const { return new SerializedRequest; } @@ -203,10 +121,9 @@ void SerializedRequest::Swap(SerializedRequest* other) { } ::google::protobuf::Metadata SerializedRequest::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = SerializedRequest_descriptor_; - metadata.reflection = NULL; + metadata.descriptor = _base.GetDescriptor(); + metadata.reflection = _base.GetReflection(); return metadata; } diff --git a/src/brpc/serialized_request.h b/src/brpc/serialized_request.h index 83952225..de7109d3 100644 --- a/src/brpc/serialized_request.h +++ b/src/brpc/serialized_request.h @@ -17,22 +17,12 @@ #ifndef BRPC_SERIALIZED_REQUEST_H #define BRPC_SERIALIZED_REQUEST_H -#include -#include -#include -#include -#include -#include +#include #include "butil/iobuf.h" - +#include "brpc/proto_base.pb.h" namespace brpc { -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto(); -void protobuf_AssignDesc_baidu_2frpc_2fserialized_5frequest_2eproto(); -void protobuf_ShutdownFile_baidu_2frpc_2fserialized_5frequest_2eproto(); - class SerializedRequest : public ::google::protobuf::Message { public: SerializedRequest(); @@ -59,9 +49,11 @@ public: bool IsInitialized() const; int ByteSize() const; int GetCachedSize() const { return (int)_serialized.size(); } - ::google::protobuf::Metadata GetMetadata() const; butil::IOBuf& serialized_data() { return _serialized; } const butil::IOBuf& serialized_data() const { return _serialized; } + +protected: + ::google::protobuf::Metadata GetMetadata() const; private: bool MergePartialFromCodedStream( @@ -78,13 +70,7 @@ private: private: butil::IOBuf _serialized; - -friend void protobuf_AddDesc_baidu_2frpc_2fserialized_5frequest_2eproto(); -friend void protobuf_AssignDesc_baidu_2frpc_2fserialized_5frequest_2eproto(); -friend void protobuf_ShutdownFile_baidu_2frpc_2fserialized_5frequest_2eproto(); - - void InitAsDefaultInstance(); - static SerializedRequest* default_instance_; + static SerializedRequestBase _base; }; } // namespace brpc diff --git a/src/brpc/thrift_message.cpp b/src/brpc/thrift_message.cpp index 0c0f87c5..3eb09627 100644 --- a/src/brpc/thrift_message.cpp +++ b/src/brpc/thrift_message.cpp @@ -30,86 +30,13 @@ namespace brpc { -namespace { -const ::google::protobuf::Descriptor* ThriftFramedMessage_descriptor_ = NULL; -} // namespace - - -void protobuf_AssignDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "thrift_framed_message.proto"); - GOOGLE_CHECK(file != NULL); - ThriftFramedMessage_descriptor_ = file->message_type(0); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ThriftFramedMessage_descriptor_, &ThriftFramedMessage::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_baidu_2frpc_2fthrift_framed_5fmessage_2eproto() { - delete ThriftFramedMessage::default_instance_; -} - -void protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - -#if GOOGLE_PROTOBUF_VERSION >= 3002000 - ::google::protobuf::internal::InitProtobufDefaults(); -#else - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); -#endif - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\033thrift_framed_message.proto\022\004brpc\"\025\n\023ThriftFramedMessage", 58); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "thrift_framed_message.proto", &protobuf_RegisterTypes); - ThriftFramedMessage::default_instance_ = new ThriftFramedMessage(); - ThriftFramedMessage::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_baidu_2frpc_2fthrift_framed_5fmessage_2eproto); - -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_once); -void protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto() { - ::google::protobuf::GoogleOnceInit( - &protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_once, - &protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_impl); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_baidu_2frpc_2fthrift_framed_5fmessage_2eproto { - StaticDescriptorInitializer_baidu_2frpc_2fthrift_framed_5fmessage_2eproto() { - protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto(); - } -} static_descriptor_initializer_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_; - - -// =================================================================== - -#ifndef _MSC_VER -#endif // !_MSC_VER +ThriftFramedMessageBase ThriftFramedMessage::_base; ThriftFramedMessage::ThriftFramedMessage() : ::google::protobuf::Message() { SharedCtor(); } -void ThriftFramedMessage::InitAsDefaultInstance() { -} - void ThriftFramedMessage::SharedCtor() { field_id = THRIFT_INVALID_FID; _own_raw_instance = false; @@ -124,23 +51,17 @@ ThriftFramedMessage::~ThriftFramedMessage() { } void ThriftFramedMessage::SharedDtor() { - if (this != default_instance_) { - } } const ::google::protobuf::Descriptor* ThriftFramedMessage::descriptor() { - protobuf_AssignDescriptorsOnce(); - return ThriftFramedMessage_descriptor_; + return _base.GetDescriptor(); } const ThriftFramedMessage& ThriftFramedMessage::default_instance() { - if (default_instance_ == NULL) - protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto(); - return *default_instance_; + static ThriftFramedMessage message; + return message; } -ThriftFramedMessage* ThriftFramedMessage::default_instance_ = NULL; - ThriftFramedMessage* ThriftFramedMessage::New() const { return new ThriftFramedMessage; } @@ -219,10 +140,9 @@ void ThriftFramedMessage::Swap(ThriftFramedMessage* other) { } ::google::protobuf::Metadata ThriftFramedMessage::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = ThriftFramedMessage_descriptor_; - metadata.reflection = NULL; + metadata.descriptor = _base.GetDescriptor(); + metadata.reflection = _base.GetReflection(); return metadata; } @@ -236,4 +156,3 @@ void ThriftStub::CallMethod(const char* method_name, } } // namespace brpc - diff --git a/src/brpc/thrift_message.h b/src/brpc/thrift_message.h index 82290868..bae57299 100644 --- a/src/brpc/thrift_message.h +++ b/src/brpc/thrift_message.h @@ -19,14 +19,7 @@ #include #include - -#include -#include -#include -#include -#include -#include "google/protobuf/descriptor.pb.h" - +#include #include "butil/iobuf.h" #include "butil/class_name.h" #include "brpc/channel_base.h" @@ -43,11 +36,6 @@ class TProtocol; namespace brpc { -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto(); -void protobuf_AssignDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto(); -void protobuf_ShutdownFile_baidu_2frpc_2fthrift_framed_5fmessage_2eproto(); - class ThriftStub; static const int16_t THRIFT_INVALID_FID = -1; @@ -110,18 +98,13 @@ public: ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return ByteSize(); } + +protected: ::google::protobuf::Metadata GetMetadata() const; private: void SharedCtor(); void SharedDtor(); -private: -friend void protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto_impl(); -friend void protobuf_AddDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto(); -friend void protobuf_AssignDesc_baidu_2frpc_2fthrift_framed_5fmessage_2eproto(); -friend void protobuf_ShutdownFile_baidu_2frpc_2fthrift_framed_5fmessage_2eproto(); - - void InitAsDefaultInstance(); static ThriftFramedMessage* default_instance_; }; From 66578349918631f661c167ca823cfc372e646d1e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 20 Jun 2019 15:44:11 +0800 Subject: [PATCH 255/270] Change Controller::rpc_dump_meta to Controller::sampled_request --- src/brpc/controller.cpp | 12 ++++++------ src/brpc/controller.h | 10 +++++----- src/brpc/policy/baidu_rpc_protocol.cpp | 8 ++++---- src/brpc/policy/hulu_pbrpc_protocol.cpp | 10 +++++----- src/brpc/policy/sofa_pbrpc_protocol.cpp | 6 +++--- src/brpc/rpc_dump.cpp | 1 - tools/rpc_replay/rpc_replay.cpp | 10 +++++----- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 7bbd9863..38107150 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -41,7 +41,7 @@ #include "brpc/retry_policy.h" #include "brpc/stream_impl.h" #include "brpc/policy/streaming_rpc_protocol.h" // FIXME -#include "brpc/rpc_dump.pb.h" +#include "brpc/rpc_dump.h" #include "brpc/details/usercode_backup_pool.h" // RunUserCode #include "brpc/mongo_service_adaptor.h" @@ -159,7 +159,7 @@ void Controller::ResetNonPods() { _server->_session_local_data_pool->Return(_session_local_data); } _mongo_session_data.reset(); - delete _rpc_dump_meta; + delete _sampled_request; if (!is_used_by_rpc() && _correlation_id != INVALID_BTHREAD_ID) { CHECK_NE(EPERM, bthread_id_cancel(_correlation_id)); @@ -213,7 +213,7 @@ void Controller::ResetPods() { _server = NULL; _oncancel_id = INVALID_BTHREAD_ID; _auth_context = NULL; - _rpc_dump_meta = NULL; + _sampled_request = NULL; _request_protocol = PROTOCOL_UNKNOWN; _max_retry = UNSET_MAGIC_NUM; _retry_policy = NULL; @@ -1331,9 +1331,9 @@ void WebEscape(const std::string& source, std::string* output) { } } -void Controller::reset_rpc_dump_meta(RpcDumpMeta* meta) { - delete _rpc_dump_meta; - _rpc_dump_meta = meta; +void Controller::reset_sampled_request(SampledRequest* req) { + delete _sampled_request; + _sampled_request = req; } void Controller::set_stream_creator(StreamCreator* sc) { diff --git a/src/brpc/controller.h b/src/brpc/controller.h index 9654ba1b..aecd7b90 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -63,7 +63,7 @@ class SharedLoadBalancer; class ExcludedServers; class RPCSender; class StreamSettings; -class RpcDumpMeta; +class SampledRequest; class MongoContext; class RetryPolicy; class InputMessageBase; @@ -258,10 +258,10 @@ public: int sub_count() const; const Controller* sub(int index) const; - // Get/own RpcDumpMeta for sending dumped requests. + // Get/own SampledRquest for sending dumped requests. // Deleted along with controller. - void reset_rpc_dump_meta(RpcDumpMeta* meta); - const RpcDumpMeta* rpc_dump_meta() { return _rpc_dump_meta; } + void reset_sampled_request(SampledRequest* req); + const SampledRequest* sampled_request() { return _sampled_request; } // Attach a StreamCreator to this RPC. Notice that the ownership of sc has // been transferred to cntl, and sc->DestroyStreamCreator() would be called @@ -672,7 +672,7 @@ private: bthread_id_t _oncancel_id; const AuthContext* _auth_context; // Authentication result butil::intrusive_ptr _mongo_session_data; - RpcDumpMeta* _rpc_dump_meta; + SampledRequest* _sampled_request; ProtocolType _request_protocol; // Some of them are copied from `Channel' which might be destroyed diff --git a/src/brpc/policy/baidu_rpc_protocol.cpp b/src/brpc/policy/baidu_rpc_protocol.cpp index da70f34a..ad7487c5 100644 --- a/src/brpc/policy/baidu_rpc_protocol.cpp +++ b/src/brpc/policy/baidu_rpc_protocol.cpp @@ -636,11 +636,11 @@ void PackRpcRequest(butil::IOBuf* req_buf, method->service()->name()); request_meta->set_method_name(method->name()); meta.set_compress_type(cntl->request_compress_type()); - } else if (cntl->rpc_dump_meta()) { + } else if (cntl->sampled_request()) { // Replaying. Keep service-name as the one seen by server. - request_meta->set_service_name(cntl->rpc_dump_meta()->service_name()); - request_meta->set_method_name(cntl->rpc_dump_meta()->method_name()); - meta.set_compress_type(cntl->rpc_dump_meta()->compress_type()); + request_meta->set_service_name(cntl->sampled_request()->meta.service_name()); + request_meta->set_method_name(cntl->sampled_request()->meta.method_name()); + meta.set_compress_type(cntl->sampled_request()->meta.compress_type()); } else { return cntl->SetFailed(ENOMETHOD, "%s.method is NULL", __FUNCTION__); } diff --git a/src/brpc/policy/hulu_pbrpc_protocol.cpp b/src/brpc/policy/hulu_pbrpc_protocol.cpp index 1daa69f2..edbda339 100644 --- a/src/brpc/policy/hulu_pbrpc_protocol.cpp +++ b/src/brpc/policy/hulu_pbrpc_protocol.cpp @@ -639,13 +639,13 @@ void PackHuluRequest(butil::IOBuf* req_buf, meta.set_service_name(method->service()->name()); meta.set_method_index(method->index()); meta.set_compress_type(CompressType2Hulu(cntl->request_compress_type())); - } else if (cntl->rpc_dump_meta()) { + } else if (cntl->sampled_request()) { // Replaying. Keep service-name as the one seen by server. - meta.set_service_name(cntl->rpc_dump_meta()->service_name()); - meta.set_method_index(cntl->rpc_dump_meta()->method_index()); + meta.set_service_name(cntl->sampled_request()->meta.service_name()); + meta.set_method_index(cntl->sampled_request()->meta.method_index()); meta.set_compress_type( - CompressType2Hulu(cntl->rpc_dump_meta()->compress_type())); - meta.set_user_data(cntl->rpc_dump_meta()->user_data()); + CompressType2Hulu(cntl->sampled_request()->meta.compress_type())); + meta.set_user_data(cntl->sampled_request()->meta.user_data()); } else { return cntl->SetFailed(ENOMETHOD, "method is NULL"); } diff --git a/src/brpc/policy/sofa_pbrpc_protocol.cpp b/src/brpc/policy/sofa_pbrpc_protocol.cpp index d541b8c4..fb1ddfe5 100644 --- a/src/brpc/policy/sofa_pbrpc_protocol.cpp +++ b/src/brpc/policy/sofa_pbrpc_protocol.cpp @@ -545,11 +545,11 @@ void PackSofaRequest(butil::IOBuf* req_buf, if (method) { meta.set_method(method->full_name()); meta.set_compress_type(CompressType2Sofa(cntl->request_compress_type())); - } else if (cntl->rpc_dump_meta()) { + } else if (cntl->sampled_request()) { // Replaying. - meta.set_method(cntl->rpc_dump_meta()->method_name()); + meta.set_method(cntl->sampled_request()->meta.method_name()); meta.set_compress_type( - CompressType2Sofa(cntl->rpc_dump_meta()->compress_type())); + CompressType2Sofa(cntl->sampled_request()->meta.compress_type())); } else { return cntl->SetFailed(ENOMETHOD, "method is NULL"); } diff --git a/src/brpc/rpc_dump.cpp b/src/brpc/rpc_dump.cpp index 8c95ee22..58741c2d 100644 --- a/src/brpc/rpc_dump.cpp +++ b/src/brpc/rpc_dump.cpp @@ -31,7 +31,6 @@ namespace bvar { std::string read_command_name(); } - namespace brpc { DECLARE_uint64(max_body_size); diff --git a/tools/rpc_replay/rpc_replay.cpp b/tools/rpc_replay/rpc_replay.cpp index 31b9d243..f9a6adaf 100644 --- a/tools/rpc_replay/rpc_replay.cpp +++ b/tools/rpc_replay/rpc_replay.cpp @@ -147,21 +147,21 @@ static void* replay_thread(void* arg) { continue; } brpc::Channel* chan = - chan_group->channel(sample->protocol_type()); + chan_group->channel(sample->meta.protocol_type()); if (chan == NULL) { LOG(ERROR) << "No channel on protocol=" - << sample->protocol_type(); + << sample->meta.protocol_type(); continue; } brpc::Controller* cntl = new brpc::Controller; req.Clear(); - cntl->reset_rpc_dump_meta(sample_guard.release()); - if (sample->attachment_size() > 0) { + cntl->reset_sampled_request(sample_guard.release()); + if (sample->meta.attachment_size() > 0) { sample->request.cutn( &req.serialized_data(), - sample->request.size() - sample->attachment_size()); + sample->request.size() - sample->meta.attachment_size()); cntl->request_attachment() = sample->request.movable(); } else { req.serialized_data() = sample->request.movable(); From 9dadee8c31eda2ea38daeac80768d9f94334b668 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 20 Jun 2019 16:51:50 +0800 Subject: [PATCH 256/270] Compatible with pb 3.8.0 --- src/brpc/esp_message.cpp | 6 ++---- src/brpc/memcache.cpp | 6 ++---- src/brpc/nshead_message.cpp | 5 +---- src/brpc/redis.cpp | 7 ++----- src/brpc/serialized_request.cpp | 5 +---- 5 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/brpc/esp_message.cpp b/src/brpc/esp_message.cpp index bb0ffcaf..518f4990 100644 --- a/src/brpc/esp_message.cpp +++ b/src/brpc/esp_message.cpp @@ -14,6 +14,7 @@ #include "esp_message.h" +#include // ReflectionOps::Merge #include // WireFormatLite::GetTagWireType namespace brpc { @@ -90,10 +91,7 @@ int EspMessage::ByteSize() const { void EspMessage::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); - const EspMessage* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - + const EspMessage* source = dynamic_cast(&from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { diff --git a/src/brpc/memcache.cpp b/src/brpc/memcache.cpp index 06e05472..cca8cf9f 100644 --- a/src/brpc/memcache.cpp +++ b/src/brpc/memcache.cpp @@ -135,8 +135,7 @@ int MemcacheRequest::ByteSize() const { void MemcacheRequest::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); - const MemcacheRequest* source = - ::google::protobuf::internal::dynamic_cast_if_available(&from); + const MemcacheRequest* source = dynamic_cast(&from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { @@ -264,8 +263,7 @@ int MemcacheResponse::ByteSize() const { void MemcacheResponse::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); - const MemcacheResponse* source = - ::google::protobuf::internal::dynamic_cast_if_available(&from); + const MemcacheResponse* source = dynamic_cast(&from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { diff --git a/src/brpc/nshead_message.cpp b/src/brpc/nshead_message.cpp index d569b2bc..d7ea3fed 100644 --- a/src/brpc/nshead_message.cpp +++ b/src/brpc/nshead_message.cpp @@ -15,7 +15,6 @@ // Authors: Ge,Jun (gejun@baidu.com) #include -#include // dynamic_cast_if_available #include // ReflectionOps::Merge #include #include "brpc/nshead_message.h" @@ -94,9 +93,7 @@ int NsheadMessage::ByteSize() const { void NsheadMessage::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); - const NsheadMessage* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + const NsheadMessage* source = dynamic_cast(&from); if (source == NULL) { LOG(ERROR) << "Can only merge from NsheadMessage"; return; diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp index e0148388..e07cad2a 100644 --- a/src/brpc/redis.cpp +++ b/src/brpc/redis.cpp @@ -14,7 +14,6 @@ // Authors: Ge,Jun (gejun@baidu.com) -#include // dynamic_cast_if_available #include // ReflectionOps::Merge #include #include @@ -89,8 +88,7 @@ int RedisRequest::ByteSize() const { void RedisRequest::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); - const RedisRequest* source = - ::google::protobuf::internal::dynamic_cast_if_available(&from); + const RedisRequest* source = dynamic_cast(&from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { @@ -308,8 +306,7 @@ int RedisResponse::ByteSize() const { void RedisResponse::MergeFrom(const ::google::protobuf::Message& from) { GOOGLE_CHECK_NE(&from, this); - const RedisResponse* source = - ::google::protobuf::internal::dynamic_cast_if_available(&from); + const RedisResponse* source = dynamic_cast(&from); if (source == NULL) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { diff --git a/src/brpc/serialized_request.cpp b/src/brpc/serialized_request.cpp index 9f79e6ef..d3f9e3b7 100644 --- a/src/brpc/serialized_request.cpp +++ b/src/brpc/serialized_request.cpp @@ -14,7 +14,6 @@ // Authors: Ge,Jun (gejun@baidu.com) -#include // dynamic_cast_if_available #include "brpc/serialized_request.h" #include "butil/logging.h" @@ -94,9 +93,7 @@ void SerializedRequest::MergeFrom(const SerializedRequest&) { void SerializedRequest::CopyFrom(const ::google::protobuf::Message& from) { if (&from == this) return; - const SerializedRequest* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + const SerializedRequest* source = dynamic_cast(&from); if (source == NULL) { CHECK(false) << "SerializedRequest can only CopyFrom SerializedRequest"; } else { From a3cc09cdadb9fb9be0672707e4099e5bb7ad9200 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 20 Jun 2019 17:29:56 +0800 Subject: [PATCH 257/270] Remove headers of test proto when 'make clean' --- test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 65fdd5d9..eb984765 100644 --- a/test/Makefile +++ b/test/Makefile @@ -161,7 +161,7 @@ all: $(TEST_BINS) .PHONY:clean clean:clean_bins @echo "Cleaning" - @rm -rf $(TEST_BUTIL_OBJS) $(TEST_BVAR_OBJS) $(TEST_BTHREAD_OBJS) $(TEST_BRPC_OBJS) $(TEST_PROTO_OBJS) + @rm -rf $(TEST_BUTIL_OBJS) $(TEST_BVAR_OBJS) $(TEST_BTHREAD_OBJS) $(TEST_BRPC_OBJS) $(TEST_PROTO_OBJS) $(TEST_PROTO_SOURCES:.proto=.pb.h) $(TEST_PROTO_SOURCES:.proto=.pb.cc) @$(MAKE) -C.. clean_debug .PHONY:clean_bins From 8b4ec84601cc35ea037243b1f375a23b2681bd12 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Thu, 20 Jun 2019 18:13:15 +0800 Subject: [PATCH 258/270] adapt callback.h after pb3.7 & remove unnecessary files --- src/brpc/callback.h | 5 +++++ src/brpc/memcache.cpp | 1 - src/brpc/memcache.h | 2 +- src/brpc/nshead_message.h | 2 -- src/brpc/progressive_attachment.h | 3 +-- src/brpc/proto_base.proto | 1 - src/brpc/redis.cpp | 2 +- src/brpc/redis.h | 7 +++---- src/brpc/thrift_message.h | 2 -- 9 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/brpc/callback.h b/src/brpc/callback.h index 334bb5c9..dd36bd11 100644 --- a/src/brpc/callback.h +++ b/src/brpc/callback.h @@ -10,6 +10,11 @@ #define BRPC_CALLBACK_H #include // Closure +#if GOOGLE_PROTOBUF_VERSION >= 3007000 +// After protobuf 3.7.0, callback.h is removed from common.h, we need to explicitly +// include this file. +#include +#endif namespace brpc { diff --git a/src/brpc/memcache.cpp b/src/brpc/memcache.cpp index cca8cf9f..e088c88f 100644 --- a/src/brpc/memcache.cpp +++ b/src/brpc/memcache.cpp @@ -15,7 +15,6 @@ // Authors: Ge,Jun (gejun@baidu.com) #include -#include #include #include #include "butil/string_printf.h" diff --git a/src/brpc/memcache.h b/src/brpc/memcache.h index 3747b82b..20a3a2fc 100644 --- a/src/brpc/memcache.h +++ b/src/brpc/memcache.h @@ -18,7 +18,7 @@ #define BRPC_MEMCACHE_H #include -#include "google/protobuf/message.h" +#include #include "butil/iobuf.h" #include "butil/strings/string_piece.h" diff --git a/src/brpc/nshead_message.h b/src/brpc/nshead_message.h index e09efefe..27fe96fb 100644 --- a/src/brpc/nshead_message.h +++ b/src/brpc/nshead_message.h @@ -17,8 +17,6 @@ #ifndef BRPC_NSHEAD_MESSAGE_H #define BRPC_NSHEAD_MESSAGE_H -#include - #include #include "brpc/nshead.h" // nshead_t #include "butil/iobuf.h" // IOBuf diff --git a/src/brpc/progressive_attachment.h b/src/brpc/progressive_attachment.h index 26c88ea2..c04ee3cd 100644 --- a/src/brpc/progressive_attachment.h +++ b/src/brpc/progressive_attachment.h @@ -17,7 +17,7 @@ #ifndef BRPC_PROGRESSIVE_ATTACHMENT_H #define BRPC_PROGRESSIVE_ATTACHMENT_H -#include +#include "brpc/callback.h" #include "butil/atomicops.h" #include "butil/iobuf.h" #include "butil/endpoint.h" // butil::EndPoint @@ -25,7 +25,6 @@ #include "brpc/socket_id.h" // SocketUniquePtr #include "brpc/shared_object.h" // SharedObject - namespace brpc { class ProgressiveAttachment : public SharedObject { diff --git a/src/brpc/proto_base.proto b/src/brpc/proto_base.proto index c890dec1..69733ff1 100644 --- a/src/brpc/proto_base.proto +++ b/src/brpc/proto_base.proto @@ -1,5 +1,4 @@ syntax="proto2"; -import "google/protobuf/descriptor.proto"; package brpc; diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp index e07cad2a..578f673a 100644 --- a/src/brpc/redis.cpp +++ b/src/brpc/redis.cpp @@ -16,7 +16,7 @@ #include // ReflectionOps::Merge #include -#include +#include "butil/status.h" #include "brpc/redis.h" #include "brpc/redis_command.h" diff --git a/src/brpc/redis.h b/src/brpc/redis.h index 99af603f..8346bad2 100644 --- a/src/brpc/redis.h +++ b/src/brpc/redis.h @@ -17,10 +17,7 @@ #ifndef BRPC_REDIS_H #define BRPC_REDIS_H -#include - #include - #include "butil/iobuf.h" #include "butil/strings/string_piece.h" #include "butil/arena.h" @@ -193,7 +190,9 @@ public: static const ::google::protobuf::Descriptor* descriptor(); static const RedisResponse& default_instance(); - ::google::protobuf::Metadata GetMetadata() const; + +protected: + ::google::protobuf::Metadata GetMetadata() const override; private: void SharedCtor(); diff --git a/src/brpc/thrift_message.h b/src/brpc/thrift_message.h index bae57299..a95f328b 100644 --- a/src/brpc/thrift_message.h +++ b/src/brpc/thrift_message.h @@ -17,8 +17,6 @@ #ifndef BRPC_THRIFT_MESSAGE_H #define BRPC_THRIFT_MESSAGE_H -#include -#include #include #include "butil/iobuf.h" #include "butil/class_name.h" From b89199c59b1fef613d81599e02e6d6f40df0d3d4 Mon Sep 17 00:00:00 2001 From: LorinLee Date: Thu, 20 Jun 2019 14:42:18 +0800 Subject: [PATCH 259/270] Add object_pool_unittest.cpp to unittest --- test/BUILD | 1 + test/CMakeLists.txt | 1 + test/Makefile | 1 + 3 files changed, 3 insertions(+) diff --git a/test/BUILD b/test/BUILD index 28d34b36..321f745e 100644 --- a/test/BUILD +++ b/test/BUILD @@ -136,6 +136,7 @@ TEST_BUTIL_SOURCES = [ "flat_map_unittest.cpp", "crc32c_unittest.cc", "iobuf_unittest.cpp", + "object_pool_unittest.cpp", "test_switches.cc", "scoped_locale.cc", "recordio_unittest.cpp", diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 621de98a..2b0d4937 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -149,6 +149,7 @@ SET(TEST_BUTIL_SOURCES ${PROJECT_SOURCE_DIR}/test/flat_map_unittest.cpp ${PROJECT_SOURCE_DIR}/test/crc32c_unittest.cc ${PROJECT_SOURCE_DIR}/test/iobuf_unittest.cpp + ${PROJECT_SOURCE_DIR}/test/object_pool_unittest.cpp ${PROJECT_SOURCE_DIR}/test/test_switches.cc ${PROJECT_SOURCE_DIR}/test/scoped_locale.cc ${PROJECT_SOURCE_DIR}/test/butil_unittest_main.cpp diff --git a/test/Makefile b/test/Makefile index 65fdd5d9..e5eb297a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -118,6 +118,7 @@ TEST_BUTIL_SOURCES = \ flat_map_unittest.cpp \ crc32c_unittest.cc \ iobuf_unittest.cpp \ + object_pool_unittest.cpp \ recordio_unittest.cpp \ test_switches.cc \ scoped_locale.cc \ From dd3fb73f25ce37acb12ad7b146734aee0fbc313e Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 21 Jun 2019 11:38:37 +0800 Subject: [PATCH 260/270] Fix compilation when thrift is enabled --- src/brpc/thrift_message.cpp | 1 - src/brpc/thrift_message.h | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/brpc/thrift_message.cpp b/src/brpc/thrift_message.cpp index 3eb09627..4b2f70e7 100644 --- a/src/brpc/thrift_message.cpp +++ b/src/brpc/thrift_message.cpp @@ -19,7 +19,6 @@ #include #include "butil/logging.h" -#include "brpc/details/controller_private_accessor.h" #include #include diff --git a/src/brpc/thrift_message.h b/src/brpc/thrift_message.h index a95f328b..ddf9d3c5 100644 --- a/src/brpc/thrift_message.h +++ b/src/brpc/thrift_message.h @@ -22,6 +22,7 @@ #include "butil/class_name.h" #include "brpc/channel_base.h" #include "brpc/controller.h" +#include "brpc/proto_base.pb.h" namespace apache { namespace thrift { @@ -103,7 +104,7 @@ protected: private: void SharedCtor(); void SharedDtor(); - static ThriftFramedMessage* default_instance_; + static ThriftFramedMessageBase _base; }; class ThriftStub { From 0a7432f01fdf33355f98f5d9304e33c2fd1c8362 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 21 Jun 2019 12:47:12 +0800 Subject: [PATCH 261/270] use descriptor of default_instance in base --- src/brpc/esp_message.cpp | 15 ++++----------- src/brpc/esp_message.h | 5 +---- src/brpc/memcache.cpp | 26 ++++++-------------------- src/brpc/memcache.h | 5 ----- src/brpc/nshead_message.cpp | 13 +++---------- src/brpc/nshead_message.h | 5 +---- src/brpc/redis.cpp | 26 ++++++-------------------- src/brpc/redis.h | 4 ---- src/brpc/serialized_request.cpp | 13 +++---------- src/brpc/serialized_request.h | 2 -- src/brpc/thrift_message.cpp | 13 +++---------- src/brpc/thrift_message.h | 2 -- 12 files changed, 27 insertions(+), 102 deletions(-) diff --git a/src/brpc/esp_message.cpp b/src/brpc/esp_message.cpp index 518f4990..8a3564e2 100644 --- a/src/brpc/esp_message.cpp +++ b/src/brpc/esp_message.cpp @@ -14,13 +14,11 @@ #include "esp_message.h" -#include // ReflectionOps::Merge +#include // ReflectionOps::Merge #include // WireFormatLite::GetTagWireType namespace brpc { -EspMessageBase EspMessage::_base; - EspMessage::EspMessage() : ::google::protobuf::Message() { SharedCtor(); @@ -44,12 +42,7 @@ void EspMessage::SharedDtor() { } const ::google::protobuf::Descriptor* EspMessage::descriptor() { - return _base.GetDescriptor(); -} - -const EspMessage& EspMessage::default_instance() { - static EspMessage req; - return req; + return EspMessageBase::descriptor(); } EspMessage* EspMessage::New() const { @@ -138,8 +131,8 @@ void EspMessage::Swap(EspMessage* other) { ::google::protobuf::Metadata EspMessage::GetMetadata() const { ::google::protobuf::Metadata metadata; - metadata.descriptor = _base.GetDescriptor(); - metadata.reflection = _base.GetReflection(); + metadata.descriptor = EspMessage::descriptor(); + metadata.reflection = NULL; return metadata; } diff --git a/src/brpc/esp_message.h b/src/brpc/esp_message.h index 12c2ab92..c8286c8c 100644 --- a/src/brpc/esp_message.h +++ b/src/brpc/esp_message.h @@ -73,11 +73,8 @@ protected: private: void SharedCtor(); void SharedDtor(); - - static EspMessageBase _base; }; } // namespace brpc - -#endif // PROTOBUF_esp_5fmessage_2eproto__INCLUDED +#endif // BRPC_ESP_MESSAGE_H diff --git a/src/brpc/memcache.cpp b/src/brpc/memcache.cpp index e088c88f..2bc8e4cf 100644 --- a/src/brpc/memcache.cpp +++ b/src/brpc/memcache.cpp @@ -26,8 +26,6 @@ namespace brpc { -MemcacheRequestBase MemcacheRequest::_base; - MemcacheRequest::MemcacheRequest() : ::google::protobuf::Message() { SharedCtor(); @@ -56,12 +54,7 @@ void MemcacheRequest::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* MemcacheRequest::descriptor() { - return _base.GetDescriptor(); -} - -const MemcacheRequest& MemcacheRequest::default_instance() { - static MemcacheRequest req; - return req; + return MemcacheRequestBase::descriptor(); } MemcacheRequest* MemcacheRequest::New() const { @@ -174,13 +167,11 @@ void MemcacheRequest::Swap(MemcacheRequest* other) { ::google::protobuf::Metadata MemcacheRequest::GetMetadata() const { ::google::protobuf::Metadata metadata; - metadata.descriptor = _base.GetDescriptor(); - metadata.reflection = _base.GetReflection(); + metadata.descriptor = MemcacheRequest::descriptor(); + metadata.reflection = NULL; return metadata; } -MemcacheResponseBase MemcacheResponse::_base; - MemcacheResponse::MemcacheResponse() : ::google::protobuf::Message() { SharedCtor(); @@ -207,12 +198,7 @@ void MemcacheResponse::SetCachedSize(int size) const { _cached_size_ = size; } const ::google::protobuf::Descriptor* MemcacheResponse::descriptor() { - return _base.GetDescriptor(); -} - -const MemcacheResponse& MemcacheResponse::default_instance() { - static MemcacheResponse res; - return res; + return MemcacheResponseBase::descriptor(); } MemcacheResponse* MemcacheResponse::New() const { @@ -303,8 +289,8 @@ void MemcacheResponse::Swap(MemcacheResponse* other) { ::google::protobuf::Metadata MemcacheResponse::GetMetadata() const { ::google::protobuf::Metadata metadata; - metadata.descriptor = _base.GetDescriptor(); - metadata.reflection = _base.GetReflection(); + metadata.descriptor = MemcacheResponse::descriptor(); + metadata.reflection = NULL; return metadata; } diff --git a/src/brpc/memcache.h b/src/brpc/memcache.h index 20a3a2fc..bfb4bb33 100644 --- a/src/brpc/memcache.h +++ b/src/brpc/memcache.h @@ -104,7 +104,6 @@ public: int GetCachedSize() const { return _cached_size_; } static const ::google::protobuf::Descriptor* descriptor(); - static const MemcacheRequest& default_instance(); protected: ::google::protobuf::Metadata GetMetadata() const override; @@ -125,7 +124,6 @@ private: int _pipelined_count; butil::IOBuf _buf; mutable int _cached_size_; - static MemcacheRequestBase _base; }; // Response from Memcache. @@ -216,7 +214,6 @@ public: int GetCachedSize() const { return _cached_size_; } static const ::google::protobuf::Descriptor* descriptor(); - static const MemcacheResponse& default_instance(); protected: ::google::protobuf::Metadata GetMetadata() const; @@ -232,8 +229,6 @@ private: std::string _err; butil::IOBuf _buf; mutable int _cached_size_; - - static MemcacheResponseBase _base; }; } // namespace brpc diff --git a/src/brpc/nshead_message.cpp b/src/brpc/nshead_message.cpp index d7ea3fed..1e47b841 100644 --- a/src/brpc/nshead_message.cpp +++ b/src/brpc/nshead_message.cpp @@ -22,8 +22,6 @@ namespace brpc { -NsheadMessageBase NsheadMessage::_base; - NsheadMessage::NsheadMessage() : ::google::protobuf::Message() { SharedCtor(); @@ -47,12 +45,7 @@ void NsheadMessage::SharedDtor() { } const ::google::protobuf::Descriptor* NsheadMessage::descriptor() { - return _base.GetDescriptor(); -} - -const NsheadMessage& NsheadMessage::default_instance() { - static NsheadMessage message; - return message; + return NsheadMessageBase::descriptor(); } NsheadMessage* NsheadMessage::New() const { @@ -136,8 +129,8 @@ void NsheadMessage::Swap(NsheadMessage* other) { ::google::protobuf::Metadata NsheadMessage::GetMetadata() const { ::google::protobuf::Metadata metadata; - metadata.descriptor = _base.GetDescriptor(); - metadata.reflection = _base.GetReflection(); + metadata.descriptor = NsheadMessage::descriptor(); + metadata.reflection = NULL; return metadata; } diff --git a/src/brpc/nshead_message.h b/src/brpc/nshead_message.h index 27fe96fb..ec9869a4 100644 --- a/src/brpc/nshead_message.h +++ b/src/brpc/nshead_message.h @@ -42,7 +42,6 @@ public: } static const ::google::protobuf::Descriptor* descriptor(); - static const NsheadMessage& default_instance(); void Swap(NsheadMessage* other); @@ -65,13 +64,11 @@ public: int GetCachedSize() const { return ByteSize(); } protected: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const override; private: void SharedCtor(); void SharedDtor(); - - static NsheadMessageBase _base; }; } // namespace brpc diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp index 578f673a..5de96520 100644 --- a/src/brpc/redis.cpp +++ b/src/brpc/redis.cpp @@ -24,8 +24,6 @@ namespace brpc { DEFINE_bool(redis_verbose_crlf2space, false, "[DEBUG] Show \\r\\n as a space"); -RedisRequestBase RedisRequest::_base; - RedisRequest::RedisRequest() : ::google::protobuf::Message() { SharedCtor(); @@ -202,18 +200,13 @@ bool RedisRequest::SerializeTo(butil::IOBuf* buf) const { } const ::google::protobuf::Descriptor* RedisRequest::descriptor() { - return _base.GetDescriptor(); -} - -const RedisRequest& RedisRequest::default_instance() { - static RedisRequest req; - return req; + return RedisRequestBase::descriptor(); } ::google::protobuf::Metadata RedisRequest::GetMetadata() const { ::google::protobuf::Metadata metadata; - metadata.descriptor = _base.GetDescriptor(); - metadata.reflection = _base.GetReflection(); + metadata.descriptor = RedisRequest::descriptor(); + metadata.reflection = NULL; return metadata; } @@ -242,8 +235,6 @@ std::ostream& operator<<(std::ostream& os, const RedisRequest& r) { return os; } -RedisResponseBase RedisResponse::_base; - RedisResponse::RedisResponse() : ::google::protobuf::Message() { SharedCtor(); @@ -374,18 +365,13 @@ void RedisResponse::Swap(RedisResponse* other) { } const ::google::protobuf::Descriptor* RedisResponse::descriptor() { - return _base.GetDescriptor(); -} - -const RedisResponse& RedisResponse::default_instance() { - static RedisResponse res; - return res; + return RedisResponseBase::descriptor(); } ::google::protobuf::Metadata RedisResponse::GetMetadata() const { ::google::protobuf::Metadata metadata; - metadata.descriptor = _base.GetDescriptor(); - metadata.reflection = _base.GetReflection(); + metadata.descriptor = RedisResponseBase::descriptor(); + metadata.reflection = NULL; return metadata; } diff --git a/src/brpc/redis.h b/src/brpc/redis.h index 8346bad2..052c3a6f 100644 --- a/src/brpc/redis.h +++ b/src/brpc/redis.h @@ -117,7 +117,6 @@ public: int GetCachedSize() const { return _cached_size_; } static const ::google::protobuf::Descriptor* descriptor(); - static const RedisRequest& default_instance(); void Print(std::ostream&) const; @@ -134,7 +133,6 @@ private: bool _has_error; // previous AddCommand had error butil::IOBuf _buf; // the serialized request. mutable int _cached_size_; // ByteSize - static RedisRequestBase _base; }; // Response from Redis. @@ -189,7 +187,6 @@ public: int GetCachedSize() const { return _cached_size_; } static const ::google::protobuf::Descriptor* descriptor(); - static const RedisResponse& default_instance(); protected: ::google::protobuf::Metadata GetMetadata() const override; @@ -204,7 +201,6 @@ private: butil::Arena _arena; int _nreply; mutable int _cached_size_; - static RedisResponseBase _base; }; std::ostream& operator<<(std::ostream& os, const RedisRequest&); diff --git a/src/brpc/serialized_request.cpp b/src/brpc/serialized_request.cpp index d3f9e3b7..071b383b 100644 --- a/src/brpc/serialized_request.cpp +++ b/src/brpc/serialized_request.cpp @@ -19,8 +19,6 @@ namespace brpc { -SerializedRequestBase SerializedRequest::_base; - SerializedRequest::SerializedRequest() : ::google::protobuf::Message() { SharedCtor(); @@ -46,12 +44,7 @@ void SerializedRequest::SetCachedSize(int /*size*/) const { CHECK(false) << "You're not supposed to call " << __FUNCTION__; } const ::google::protobuf::Descriptor* SerializedRequest::descriptor() { - return _base.GetDescriptor(); -} - -const SerializedRequest& SerializedRequest::default_instance() { - static SerializedRequest req; - return req; + return SerializedRequestBase::descriptor(); } SerializedRequest* SerializedRequest::New() const { @@ -119,8 +112,8 @@ void SerializedRequest::Swap(SerializedRequest* other) { ::google::protobuf::Metadata SerializedRequest::GetMetadata() const { ::google::protobuf::Metadata metadata; - metadata.descriptor = _base.GetDescriptor(); - metadata.reflection = _base.GetReflection(); + metadata.descriptor = SerializedRequest::descriptor(); + metadata.reflection = NULL; return metadata; } diff --git a/src/brpc/serialized_request.h b/src/brpc/serialized_request.h index de7109d3..248f30f7 100644 --- a/src/brpc/serialized_request.h +++ b/src/brpc/serialized_request.h @@ -36,7 +36,6 @@ public: } static const ::google::protobuf::Descriptor* descriptor(); - static const SerializedRequest& default_instance(); void Swap(SerializedRequest* other); @@ -70,7 +69,6 @@ private: private: butil::IOBuf _serialized; - static SerializedRequestBase _base; }; } // namespace brpc diff --git a/src/brpc/thrift_message.cpp b/src/brpc/thrift_message.cpp index 4b2f70e7..f588ab2d 100644 --- a/src/brpc/thrift_message.cpp +++ b/src/brpc/thrift_message.cpp @@ -29,8 +29,6 @@ namespace brpc { -ThriftFramedMessageBase ThriftFramedMessage::_base; - ThriftFramedMessage::ThriftFramedMessage() : ::google::protobuf::Message() { SharedCtor(); @@ -53,12 +51,7 @@ void ThriftFramedMessage::SharedDtor() { } const ::google::protobuf::Descriptor* ThriftFramedMessage::descriptor() { - return _base.GetDescriptor(); -} - -const ThriftFramedMessage& ThriftFramedMessage::default_instance() { - static ThriftFramedMessage message; - return message; + return ThriftFramedMessageBase::descriptor(); } ThriftFramedMessage* ThriftFramedMessage::New() const { @@ -140,8 +133,8 @@ void ThriftFramedMessage::Swap(ThriftFramedMessage* other) { ::google::protobuf::Metadata ThriftFramedMessage::GetMetadata() const { ::google::protobuf::Metadata metadata; - metadata.descriptor = _base.GetDescriptor(); - metadata.reflection = _base.GetReflection(); + metadata.descriptor = ThriftFramedMessage::descriptor(); + metadata.reflection = NULL; return metadata; } diff --git a/src/brpc/thrift_message.h b/src/brpc/thrift_message.h index ddf9d3c5..683af9fb 100644 --- a/src/brpc/thrift_message.h +++ b/src/brpc/thrift_message.h @@ -76,7 +76,6 @@ public: ThriftFramedMessage& operator=(const ThriftFramedMessage& from) = delete; static const ::google::protobuf::Descriptor* descriptor(); - static const ThriftFramedMessage& default_instance(); void Swap(ThriftFramedMessage* other); @@ -104,7 +103,6 @@ protected: private: void SharedCtor(); void SharedDtor(); - static ThriftFramedMessageBase _base; }; class ThriftStub { From fd34cbd615497978bd6a2e9ab55922caabee80fb Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 21 Jun 2019 14:04:16 +0800 Subject: [PATCH 262/270] revert changes related to SampleRequest --- src/brpc/controller.cpp | 10 +++++----- src/brpc/controller.h | 10 +++++----- src/brpc/policy/baidu_rpc_protocol.cpp | 8 ++++---- src/brpc/policy/hulu_pbrpc_protocol.cpp | 10 +++++----- src/brpc/policy/sofa_pbrpc_protocol.cpp | 6 +++--- src/brpc/rpc_dump.h | 14 +++++++++++--- src/brpc/rpc_dump.proto | 2 +- tools/rpc_replay/rpc_replay.cpp | 2 +- 8 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 38107150..231401a2 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -159,7 +159,7 @@ void Controller::ResetNonPods() { _server->_session_local_data_pool->Return(_session_local_data); } _mongo_session_data.reset(); - delete _sampled_request; + delete _rpc_dump_meta; if (!is_used_by_rpc() && _correlation_id != INVALID_BTHREAD_ID) { CHECK_NE(EPERM, bthread_id_cancel(_correlation_id)); @@ -213,7 +213,7 @@ void Controller::ResetPods() { _server = NULL; _oncancel_id = INVALID_BTHREAD_ID; _auth_context = NULL; - _sampled_request = NULL; + _rpc_dump_meta = NULL; _request_protocol = PROTOCOL_UNKNOWN; _max_retry = UNSET_MAGIC_NUM; _retry_policy = NULL; @@ -1331,9 +1331,9 @@ void WebEscape(const std::string& source, std::string* output) { } } -void Controller::reset_sampled_request(SampledRequest* req) { - delete _sampled_request; - _sampled_request = req; +void Controller::reset_rpc_dump_meta(RpcDumpMeta* meta) { + delete _rpc_dump_meta; + _rpc_dump_meta = meta; } void Controller::set_stream_creator(StreamCreator* sc) { diff --git a/src/brpc/controller.h b/src/brpc/controller.h index aecd7b90..9654ba1b 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -63,7 +63,7 @@ class SharedLoadBalancer; class ExcludedServers; class RPCSender; class StreamSettings; -class SampledRequest; +class RpcDumpMeta; class MongoContext; class RetryPolicy; class InputMessageBase; @@ -258,10 +258,10 @@ public: int sub_count() const; const Controller* sub(int index) const; - // Get/own SampledRquest for sending dumped requests. + // Get/own RpcDumpMeta for sending dumped requests. // Deleted along with controller. - void reset_sampled_request(SampledRequest* req); - const SampledRequest* sampled_request() { return _sampled_request; } + void reset_rpc_dump_meta(RpcDumpMeta* meta); + const RpcDumpMeta* rpc_dump_meta() { return _rpc_dump_meta; } // Attach a StreamCreator to this RPC. Notice that the ownership of sc has // been transferred to cntl, and sc->DestroyStreamCreator() would be called @@ -672,7 +672,7 @@ private: bthread_id_t _oncancel_id; const AuthContext* _auth_context; // Authentication result butil::intrusive_ptr _mongo_session_data; - SampledRequest* _sampled_request; + RpcDumpMeta* _rpc_dump_meta; ProtocolType _request_protocol; // Some of them are copied from `Channel' which might be destroyed diff --git a/src/brpc/policy/baidu_rpc_protocol.cpp b/src/brpc/policy/baidu_rpc_protocol.cpp index ad7487c5..7e99308b 100644 --- a/src/brpc/policy/baidu_rpc_protocol.cpp +++ b/src/brpc/policy/baidu_rpc_protocol.cpp @@ -636,11 +636,11 @@ void PackRpcRequest(butil::IOBuf* req_buf, method->service()->name()); request_meta->set_method_name(method->name()); meta.set_compress_type(cntl->request_compress_type()); - } else if (cntl->sampled_request()) { + } else if (cntl->rpc_dump_meta()) { // Replaying. Keep service-name as the one seen by server. - request_meta->set_service_name(cntl->sampled_request()->meta.service_name()); - request_meta->set_method_name(cntl->sampled_request()->meta.method_name()); - meta.set_compress_type(cntl->sampled_request()->meta.compress_type()); + request_meta->set_service_name(cntl->rpc_dump_meta()->meta.service_name()); + request_meta->set_method_name(cntl->rpc_dump_meta()->meta.method_name()); + meta.set_compress_type(cntl->rpc_dump_meta()->meta.compress_type()); } else { return cntl->SetFailed(ENOMETHOD, "%s.method is NULL", __FUNCTION__); } diff --git a/src/brpc/policy/hulu_pbrpc_protocol.cpp b/src/brpc/policy/hulu_pbrpc_protocol.cpp index edbda339..f8879805 100644 --- a/src/brpc/policy/hulu_pbrpc_protocol.cpp +++ b/src/brpc/policy/hulu_pbrpc_protocol.cpp @@ -639,13 +639,13 @@ void PackHuluRequest(butil::IOBuf* req_buf, meta.set_service_name(method->service()->name()); meta.set_method_index(method->index()); meta.set_compress_type(CompressType2Hulu(cntl->request_compress_type())); - } else if (cntl->sampled_request()) { + } else if (cntl->rpc_dump_meta()) { // Replaying. Keep service-name as the one seen by server. - meta.set_service_name(cntl->sampled_request()->meta.service_name()); - meta.set_method_index(cntl->sampled_request()->meta.method_index()); + meta.set_service_name(cntl->rpc_dump_meta()->meta.service_name()); + meta.set_method_index(cntl->rpc_dump_meta()->meta.method_index()); meta.set_compress_type( - CompressType2Hulu(cntl->sampled_request()->meta.compress_type())); - meta.set_user_data(cntl->sampled_request()->meta.user_data()); + CompressType2Hulu(cntl->rpc_dump_meta()->meta.compress_type())); + meta.set_user_data(cntl->rpc_dump_meta()->meta.user_data()); } else { return cntl->SetFailed(ENOMETHOD, "method is NULL"); } diff --git a/src/brpc/policy/sofa_pbrpc_protocol.cpp b/src/brpc/policy/sofa_pbrpc_protocol.cpp index fb1ddfe5..5aebc5a2 100644 --- a/src/brpc/policy/sofa_pbrpc_protocol.cpp +++ b/src/brpc/policy/sofa_pbrpc_protocol.cpp @@ -545,11 +545,11 @@ void PackSofaRequest(butil::IOBuf* req_buf, if (method) { meta.set_method(method->full_name()); meta.set_compress_type(CompressType2Sofa(cntl->request_compress_type())); - } else if (cntl->sampled_request()) { + } else if (cntl->rpc_dump_meta()) { // Replaying. - meta.set_method(cntl->sampled_request()->meta.method_name()); + meta.set_method(cntl->rpc_dump_meta()->meta.method_name()); meta.set_compress_type( - CompressType2Sofa(cntl->sampled_request()->meta.compress_type())); + CompressType2Sofa(cntl->rpc_dump_meta()->meta.compress_type())); } else { return cntl->SetFailed(ENOMETHOD, "method is NULL"); } diff --git a/src/brpc/rpc_dump.h b/src/brpc/rpc_dump.h index 318e49bd..832bddbb 100644 --- a/src/brpc/rpc_dump.h +++ b/src/brpc/rpc_dump.h @@ -21,7 +21,7 @@ #include "butil/iobuf.h" // IOBuf #include "butil/files/file_path.h" // FilePath #include "bvar/collector.h" -#include "brpc/rpc_dump.pb.h" // RpcDumpMeta +#include "brpc/rpc_dump.pb.h" // RpcDumpMetaProto namespace butil { class FileEnumerator; @@ -46,9 +46,17 @@ DECLARE_bool(rpc_dump); // In practice, sampled requests are just small fraction of all requests. // The overhead of sampling should be negligible for overall performance. -struct SampledRequest : public bvar::Collected { +// According to +// https://developers.google.com/protocol-buffers/docs/cpptutorial#parsing-and-serialization, +// we use combination instead of inheritance. +class RpcDumpMeta { +public: + RpcDumpMetaProto meta; +}; + +struct SampledRequest : public bvar::Collected + , public RpcDumpMeta { butil::IOBuf request; - RpcDumpMeta meta; // Implement methods of Sampled. void dump_and_destroy(size_t round) override; diff --git a/src/brpc/rpc_dump.proto b/src/brpc/rpc_dump.proto index e68e5a51..c4239235 100644 --- a/src/brpc/rpc_dump.proto +++ b/src/brpc/rpc_dump.proto @@ -3,7 +3,7 @@ import "brpc/options.proto"; package brpc; -message RpcDumpMeta { +message RpcDumpMetaProto { // baidu_std, hulu_pbrpc optional string service_name = 1; diff --git a/tools/rpc_replay/rpc_replay.cpp b/tools/rpc_replay/rpc_replay.cpp index f9a6adaf..44e4303c 100644 --- a/tools/rpc_replay/rpc_replay.cpp +++ b/tools/rpc_replay/rpc_replay.cpp @@ -157,7 +157,7 @@ static void* replay_thread(void* arg) { brpc::Controller* cntl = new brpc::Controller; req.Clear(); - cntl->reset_sampled_request(sample_guard.release()); + cntl->reset_rpc_dump_meta(sample_guard.release()); if (sample->meta.attachment_size() > 0) { sample->request.cutn( &req.serialized_data(), From 781e7940116869b24a428bb84072ab1ccc636ab1 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 21 Jun 2019 14:30:44 +0800 Subject: [PATCH 263/270] minor change --- src/brpc/redis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp index 5de96520..d4698979 100644 --- a/src/brpc/redis.cpp +++ b/src/brpc/redis.cpp @@ -370,7 +370,7 @@ const ::google::protobuf::Descriptor* RedisResponse::descriptor() { ::google::protobuf::Metadata RedisResponse::GetMetadata() const { ::google::protobuf::Metadata metadata; - metadata.descriptor = RedisResponseBase::descriptor(); + metadata.descriptor = RedisResponse::descriptor(); metadata.reflection = NULL; return metadata; } From 59cee299d6a52358297aa807b700def54f124f3a Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 21 Jun 2019 15:15:22 +0800 Subject: [PATCH 264/270] Make ~RpcDumpMeta vitrual --- src/brpc/rpc_dump.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/brpc/rpc_dump.h b/src/brpc/rpc_dump.h index 832bddbb..07c6e123 100644 --- a/src/brpc/rpc_dump.h +++ b/src/brpc/rpc_dump.h @@ -51,6 +51,7 @@ DECLARE_bool(rpc_dump); // we use combination instead of inheritance. class RpcDumpMeta { public: + virtual ~RpcDumpMeta() {} RpcDumpMetaProto meta; }; From ca6bd6bcac0376bacab63c31704eacee206f9cac Mon Sep 17 00:00:00 2001 From: gejun Date: Fri, 21 Jun 2019 16:31:24 +0800 Subject: [PATCH 265/270] Fix copyright part of a UT --- test/brpc_http_message_unittest.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/test/brpc_http_message_unittest.cpp b/test/brpc_http_message_unittest.cpp index 537a66d7..7eccf7cd 100644 --- a/test/brpc_http_message_unittest.cpp +++ b/test/brpc_http_message_unittest.cpp @@ -1,6 +1,20 @@ - // brpc - A framework to host and access services throughout Baidu. -// Copyright (c) 2014 Baidu, Inc. - +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// // Date 2014/10/24 16:44:30 #include From b840ac8f0175376eb841b8a9b266f0fe3f8c8f3f Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 21 Jun 2019 16:45:13 +0800 Subject: [PATCH 266/270] change reset_rpc_dump_meta to reset_sampled_request --- src/brpc/controller.cpp | 10 +++++----- src/brpc/controller.h | 10 +++++----- src/brpc/policy/baidu_rpc_protocol.cpp | 8 ++++---- src/brpc/policy/hulu_pbrpc_protocol.cpp | 10 +++++----- src/brpc/policy/sofa_pbrpc_protocol.cpp | 6 +++--- src/brpc/rpc_dump.h | 16 +++------------- src/brpc/rpc_dump.proto | 2 +- tools/rpc_replay/rpc_replay.cpp | 2 +- 8 files changed, 27 insertions(+), 37 deletions(-) diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp index 231401a2..d9267694 100644 --- a/src/brpc/controller.cpp +++ b/src/brpc/controller.cpp @@ -159,7 +159,7 @@ void Controller::ResetNonPods() { _server->_session_local_data_pool->Return(_session_local_data); } _mongo_session_data.reset(); - delete _rpc_dump_meta; + delete _sampled_request; if (!is_used_by_rpc() && _correlation_id != INVALID_BTHREAD_ID) { CHECK_NE(EPERM, bthread_id_cancel(_correlation_id)); @@ -213,7 +213,7 @@ void Controller::ResetPods() { _server = NULL; _oncancel_id = INVALID_BTHREAD_ID; _auth_context = NULL; - _rpc_dump_meta = NULL; + _sampled_request = NULL; _request_protocol = PROTOCOL_UNKNOWN; _max_retry = UNSET_MAGIC_NUM; _retry_policy = NULL; @@ -1331,9 +1331,9 @@ void WebEscape(const std::string& source, std::string* output) { } } -void Controller::reset_rpc_dump_meta(RpcDumpMeta* meta) { - delete _rpc_dump_meta; - _rpc_dump_meta = meta; +void Controller::reset_sampled_request(SampledRequest* req) { + delete _sampled_request; + _sampled_request = req; } void Controller::set_stream_creator(StreamCreator* sc) { diff --git a/src/brpc/controller.h b/src/brpc/controller.h index 9654ba1b..cf66809b 100755 --- a/src/brpc/controller.h +++ b/src/brpc/controller.h @@ -63,7 +63,7 @@ class SharedLoadBalancer; class ExcludedServers; class RPCSender; class StreamSettings; -class RpcDumpMeta; +class SampledRequest; class MongoContext; class RetryPolicy; class InputMessageBase; @@ -258,10 +258,10 @@ public: int sub_count() const; const Controller* sub(int index) const; - // Get/own RpcDumpMeta for sending dumped requests. + // Get/own SampledRequest for sending dumped requests. // Deleted along with controller. - void reset_rpc_dump_meta(RpcDumpMeta* meta); - const RpcDumpMeta* rpc_dump_meta() { return _rpc_dump_meta; } + void reset_sampled_request(SampledRequest* req); + const SampledRequest* sampled_request() { return _sampled_request; } // Attach a StreamCreator to this RPC. Notice that the ownership of sc has // been transferred to cntl, and sc->DestroyStreamCreator() would be called @@ -672,7 +672,7 @@ private: bthread_id_t _oncancel_id; const AuthContext* _auth_context; // Authentication result butil::intrusive_ptr _mongo_session_data; - RpcDumpMeta* _rpc_dump_meta; + SampledRequest* _sampled_request; ProtocolType _request_protocol; // Some of them are copied from `Channel' which might be destroyed diff --git a/src/brpc/policy/baidu_rpc_protocol.cpp b/src/brpc/policy/baidu_rpc_protocol.cpp index 7e99308b..ad7487c5 100644 --- a/src/brpc/policy/baidu_rpc_protocol.cpp +++ b/src/brpc/policy/baidu_rpc_protocol.cpp @@ -636,11 +636,11 @@ void PackRpcRequest(butil::IOBuf* req_buf, method->service()->name()); request_meta->set_method_name(method->name()); meta.set_compress_type(cntl->request_compress_type()); - } else if (cntl->rpc_dump_meta()) { + } else if (cntl->sampled_request()) { // Replaying. Keep service-name as the one seen by server. - request_meta->set_service_name(cntl->rpc_dump_meta()->meta.service_name()); - request_meta->set_method_name(cntl->rpc_dump_meta()->meta.method_name()); - meta.set_compress_type(cntl->rpc_dump_meta()->meta.compress_type()); + request_meta->set_service_name(cntl->sampled_request()->meta.service_name()); + request_meta->set_method_name(cntl->sampled_request()->meta.method_name()); + meta.set_compress_type(cntl->sampled_request()->meta.compress_type()); } else { return cntl->SetFailed(ENOMETHOD, "%s.method is NULL", __FUNCTION__); } diff --git a/src/brpc/policy/hulu_pbrpc_protocol.cpp b/src/brpc/policy/hulu_pbrpc_protocol.cpp index f8879805..edbda339 100644 --- a/src/brpc/policy/hulu_pbrpc_protocol.cpp +++ b/src/brpc/policy/hulu_pbrpc_protocol.cpp @@ -639,13 +639,13 @@ void PackHuluRequest(butil::IOBuf* req_buf, meta.set_service_name(method->service()->name()); meta.set_method_index(method->index()); meta.set_compress_type(CompressType2Hulu(cntl->request_compress_type())); - } else if (cntl->rpc_dump_meta()) { + } else if (cntl->sampled_request()) { // Replaying. Keep service-name as the one seen by server. - meta.set_service_name(cntl->rpc_dump_meta()->meta.service_name()); - meta.set_method_index(cntl->rpc_dump_meta()->meta.method_index()); + meta.set_service_name(cntl->sampled_request()->meta.service_name()); + meta.set_method_index(cntl->sampled_request()->meta.method_index()); meta.set_compress_type( - CompressType2Hulu(cntl->rpc_dump_meta()->meta.compress_type())); - meta.set_user_data(cntl->rpc_dump_meta()->meta.user_data()); + CompressType2Hulu(cntl->sampled_request()->meta.compress_type())); + meta.set_user_data(cntl->sampled_request()->meta.user_data()); } else { return cntl->SetFailed(ENOMETHOD, "method is NULL"); } diff --git a/src/brpc/policy/sofa_pbrpc_protocol.cpp b/src/brpc/policy/sofa_pbrpc_protocol.cpp index 5aebc5a2..fb1ddfe5 100644 --- a/src/brpc/policy/sofa_pbrpc_protocol.cpp +++ b/src/brpc/policy/sofa_pbrpc_protocol.cpp @@ -545,11 +545,11 @@ void PackSofaRequest(butil::IOBuf* req_buf, if (method) { meta.set_method(method->full_name()); meta.set_compress_type(CompressType2Sofa(cntl->request_compress_type())); - } else if (cntl->rpc_dump_meta()) { + } else if (cntl->sampled_request()) { // Replaying. - meta.set_method(cntl->rpc_dump_meta()->meta.method_name()); + meta.set_method(cntl->sampled_request()->meta.method_name()); meta.set_compress_type( - CompressType2Sofa(cntl->rpc_dump_meta()->meta.compress_type())); + CompressType2Sofa(cntl->sampled_request()->meta.compress_type())); } else { return cntl->SetFailed(ENOMETHOD, "method is NULL"); } diff --git a/src/brpc/rpc_dump.h b/src/brpc/rpc_dump.h index 07c6e123..1b51739c 100644 --- a/src/brpc/rpc_dump.h +++ b/src/brpc/rpc_dump.h @@ -21,13 +21,12 @@ #include "butil/iobuf.h" // IOBuf #include "butil/files/file_path.h" // FilePath #include "bvar/collector.h" -#include "brpc/rpc_dump.pb.h" // RpcDumpMetaProto +#include "brpc/rpc_dump.pb.h" // RpcDumpMeta namespace butil { class FileEnumerator; } - namespace brpc { DECLARE_bool(rpc_dump); @@ -46,18 +45,9 @@ DECLARE_bool(rpc_dump); // In practice, sampled requests are just small fraction of all requests. // The overhead of sampling should be negligible for overall performance. -// According to -// https://developers.google.com/protocol-buffers/docs/cpptutorial#parsing-and-serialization, -// we use combination instead of inheritance. -class RpcDumpMeta { -public: - virtual ~RpcDumpMeta() {} - RpcDumpMetaProto meta; -}; - -struct SampledRequest : public bvar::Collected - , public RpcDumpMeta { +struct SampledRequest : public bvar::Collected { butil::IOBuf request; + RpcDumpMeta meta; // Implement methods of Sampled. void dump_and_destroy(size_t round) override; diff --git a/src/brpc/rpc_dump.proto b/src/brpc/rpc_dump.proto index c4239235..e68e5a51 100644 --- a/src/brpc/rpc_dump.proto +++ b/src/brpc/rpc_dump.proto @@ -3,7 +3,7 @@ import "brpc/options.proto"; package brpc; -message RpcDumpMetaProto { +message RpcDumpMeta { // baidu_std, hulu_pbrpc optional string service_name = 1; diff --git a/tools/rpc_replay/rpc_replay.cpp b/tools/rpc_replay/rpc_replay.cpp index 44e4303c..f9a6adaf 100644 --- a/tools/rpc_replay/rpc_replay.cpp +++ b/tools/rpc_replay/rpc_replay.cpp @@ -157,7 +157,7 @@ static void* replay_thread(void* arg) { brpc::Controller* cntl = new brpc::Controller; req.Clear(); - cntl->reset_rpc_dump_meta(sample_guard.release()); + cntl->reset_sampled_request(sample_guard.release()); if (sample->meta.attachment_size() > 0) { sample->request.cutn( &req.serialized_data(), From 0ac002761ef2467539a75511f5501ae06d07525c Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 21 Jun 2019 17:00:45 +0800 Subject: [PATCH 267/270] update docs --- docs/cn/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index dbab05c3..b2c9359c 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -350,7 +350,7 @@ no known issues. no known issues. -## protobuf: 2.4-3.4 +## protobuf: 2.4-3.8 Be compatible with pb 3.x and pb 2.x with the same file: Don't use new types in proto3 and start the proto file with `syntax="proto2";` From 034c9a3bdad297ef0f9f191264ea28868360f533 Mon Sep 17 00:00:00 2001 From: zhujiashun Date: Fri, 21 Jun 2019 17:04:52 +0800 Subject: [PATCH 268/270] refine docs --- docs/cn/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cn/getting_started.md b/docs/cn/getting_started.md index b2c9359c..66cdadd2 100644 --- a/docs/cn/getting_started.md +++ b/docs/cn/getting_started.md @@ -350,7 +350,7 @@ no known issues. no known issues. -## protobuf: 2.4-3.8 +## protobuf: 2.4+ Be compatible with pb 3.x and pb 2.x with the same file: Don't use new types in proto3 and start the proto file with `syntax="proto2";` From 8c32109de6d697f4c14bf808e19f251fb3a47e9d Mon Sep 17 00:00:00 2001 From: gejun Date: Thu, 27 Jun 2019 19:03:57 +0800 Subject: [PATCH 269/270] still parse body when the http request contains upgrade header --- src/brpc/details/http_message.cpp | 3 +-- src/brpc/details/http_parser.cpp | 6 +----- src/brpc/details/http_parser.h | 8 +------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/brpc/details/http_message.cpp b/src/brpc/details/http_message.cpp index a0538086..ca179256 100644 --- a/src/brpc/details/http_message.cpp +++ b/src/brpc/details/http_message.cpp @@ -513,8 +513,7 @@ std::ostream& operator<<(std::ostream& os, const http_parser& parser) { if (parser.type == HTTP_REQUEST || parser.type == HTTP_BOTH) { os << " method=" << HttpMethod2Str((HttpMethod)parser.method); } - os << " upgrade=" << parser.upgrade - << " data=" << parser.data + os << " data=" << parser.data << '}'; return os; } diff --git a/src/brpc/details/http_parser.cpp b/src/brpc/details/http_parser.cpp index f0fbf1f1..1c575f9d 100644 --- a/src/brpc/details/http_parser.cpp +++ b/src/brpc/details/http_parser.cpp @@ -1741,10 +1741,6 @@ size_t http_parser_execute (http_parser *parser, parser->state = s_headers_done; - /* Set this here so that on_headers_complete() callbacks can see it */ - parser->upgrade = - (parser->flags & F_UPGRADE || parser->method == HTTP_CONNECT); - /* Here we call the headers_complete callback. This is somewhat * different than other callbacks because if the user returns 1, we * will interpret that as saying that this message has no body. This @@ -1783,7 +1779,7 @@ size_t http_parser_execute (http_parser *parser, parser->nread = 0; /* Exit, the rest of the connect is in a different protocol. */ - if (parser->upgrade) { + if (parser->method == HTTP_CONNECT) { parser->state = NEW_MESSAGE(); CALLBACK_NOTIFY(message_complete); return (p - data) + 1; diff --git a/src/brpc/details/http_parser.h b/src/brpc/details/http_parser.h index a36e5bb3..c586e22d 100644 --- a/src/brpc/details/http_parser.h +++ b/src/brpc/details/http_parser.h @@ -216,13 +216,7 @@ struct http_parser { unsigned int status_code : 16; /* responses only */ unsigned int method : 8; /* requests only */ unsigned int http_errno : 7; - - /* 1 = Upgrade header was present and the parser has exited because of that. - * 0 = No upgrade header present. - * Should be checked when http_parser_execute() returns in addition to - * error checking. - */ - unsigned int upgrade : 1; + unsigned int dummy : 1; /** PUBLIC **/ void *data; /* A pointer to get hook to the "connection" or "socket" object */ From d1d576e8c587bb0206cdd970bc6fe206aa930fe0 Mon Sep 17 00:00:00 2001 From: TanGuofu <267266206@qq.com> Date: Sun, 30 Jun 2019 17:10:16 +0800 Subject: [PATCH 270/270] remove ```#include wire_format_lite_inl.h``` to fix Protobuf 3.8 build error remove ```#include wire_format_lite_inl.h``` to fix Protobuf 3.8 build error test build ok with protobuf 3.6.1 and protobuf 3.8.0 --- src/brpc/thrift_message.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/brpc/thrift_message.cpp b/src/brpc/thrift_message.cpp index 17a905f6..c408f720 100644 --- a/src/brpc/thrift_message.cpp +++ b/src/brpc/thrift_message.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include #include