diff options
author | thegeorg <thegeorg@yandex-team.com> | 2022-11-02 12:00:25 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2022-11-02 12:00:25 +0300 |
commit | 56086cfd6edecd0aec84a9b19ebf508e65b79e9d (patch) | |
tree | b07862bc7090d55666c870cb063c3ce0f46b6f5b /contrib/libs/grpc/src/cpp | |
parent | e3ffb0af25c5c456263ecb50cd8d4cec27e37dc4 (diff) | |
download | ydb-56086cfd6edecd0aec84a9b19ebf508e65b79e9d.tar.gz |
Cleanup unused grpc targets
* Merge grpc (core), grpc++ and gpr libraries into contrib/libs/grpc
* Drop unused grpc_unsecure, grpc++_unsecure and grpc++_error_details
* Remove abundance of hacks from import routine
Diffstat (limited to 'contrib/libs/grpc/src/cpp')
13 files changed, 0 insertions, 1303 deletions
diff --git a/contrib/libs/grpc/src/cpp/common/alts_context.cc b/contrib/libs/grpc/src/cpp/common/alts_context.cc deleted file mode 100644 index 31f0f083ef..0000000000 --- a/contrib/libs/grpc/src/cpp/common/alts_context.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* - * - * Copyright 2019 gRPC 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. - * - */ - -#include <grpc/grpc_security.h> -#include <grpcpp/security/alts_context.h> - -#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h" -#include "src/proto/grpc/gcp/altscontext.upb.h" - -namespace grpc { -namespace experimental { - -// A upb-generated grpc_gcp_AltsContext is passed in to construct an -// AltsContext. Normal users should use GetAltsContextFromAuthContext to get -// AltsContext, instead of constructing their own. -AltsContext::AltsContext(const grpc_gcp_AltsContext* ctx) { - upb_strview application_protocol = - grpc_gcp_AltsContext_application_protocol(ctx); - if (application_protocol.data != nullptr && application_protocol.size > 0) { - application_protocol_ = - TString(application_protocol.data, application_protocol.size); - } - upb_strview record_protocol = grpc_gcp_AltsContext_record_protocol(ctx); - if (record_protocol.data != nullptr && record_protocol.size > 0) { - record_protocol_ = TString(record_protocol.data, record_protocol.size); - } - upb_strview peer_service_account = - grpc_gcp_AltsContext_peer_service_account(ctx); - if (peer_service_account.data != nullptr && peer_service_account.size > 0) { - peer_service_account_ = - TString(peer_service_account.data, peer_service_account.size); - } - upb_strview local_service_account = - grpc_gcp_AltsContext_local_service_account(ctx); - if (local_service_account.data != nullptr && local_service_account.size > 0) { - local_service_account_ = - TString(local_service_account.data, local_service_account.size); - } - const grpc_gcp_RpcProtocolVersions* versions = - grpc_gcp_AltsContext_peer_rpc_versions(ctx); - if (versions != nullptr) { - const grpc_gcp_RpcProtocolVersions_Version* max_version = - grpc_gcp_RpcProtocolVersions_max_rpc_version(versions); - if (max_version != nullptr) { - int max_version_major = - grpc_gcp_RpcProtocolVersions_Version_major(max_version); - int max_version_minor = - grpc_gcp_RpcProtocolVersions_Version_minor(max_version); - peer_rpc_versions_.max_rpc_version.major_version = max_version_major; - peer_rpc_versions_.max_rpc_version.minor_version = max_version_minor; - } - const grpc_gcp_RpcProtocolVersions_Version* min_version = - grpc_gcp_RpcProtocolVersions_min_rpc_version(versions); - if (min_version != nullptr) { - int min_version_major = - grpc_gcp_RpcProtocolVersions_Version_major(min_version); - int min_version_minor = - grpc_gcp_RpcProtocolVersions_Version_minor(min_version); - peer_rpc_versions_.min_rpc_version.major_version = min_version_major; - peer_rpc_versions_.min_rpc_version.minor_version = min_version_minor; - } - } - if (grpc_gcp_AltsContext_security_level(ctx) >= GRPC_SECURITY_MIN || - grpc_gcp_AltsContext_security_level(ctx) <= GRPC_SECURITY_MAX) { - security_level_ = static_cast<grpc_security_level>( - grpc_gcp_AltsContext_security_level(ctx)); - } - if (grpc_gcp_AltsContext_has_peer_attributes(ctx)) { - size_t iter = UPB_MAP_BEGIN; - const grpc_gcp_AltsContext_PeerAttributesEntry* peer_attributes_entry = - grpc_gcp_AltsContext_peer_attributes_next(ctx, &iter); - while (peer_attributes_entry != nullptr) { - upb_strview key = - grpc_gcp_AltsContext_PeerAttributesEntry_key(peer_attributes_entry); - upb_strview val = - grpc_gcp_AltsContext_PeerAttributesEntry_value(peer_attributes_entry); - peer_attributes_map_[TString(key.data, key.size)] = - TString(val.data, val.size); - peer_attributes_entry = - grpc_gcp_AltsContext_peer_attributes_next(ctx, &iter); - } - } -} - -TString AltsContext::application_protocol() const { - return application_protocol_; -} - -TString AltsContext::record_protocol() const { return record_protocol_; } - -TString AltsContext::peer_service_account() const { - return peer_service_account_; -} - -TString AltsContext::local_service_account() const { - return local_service_account_; -} - -grpc_security_level AltsContext::security_level() const { - return security_level_; -} - -AltsContext::RpcProtocolVersions AltsContext::peer_rpc_versions() const { - return peer_rpc_versions_; -} - -const std::map<TString, TString>& AltsContext::peer_attributes() const { - return peer_attributes_map_; -} - -} // namespace experimental -} // namespace grpc diff --git a/contrib/libs/grpc/src/cpp/common/alts_util.cc b/contrib/libs/grpc/src/cpp/common/alts_util.cc deleted file mode 100644 index 4b955c621c..0000000000 --- a/contrib/libs/grpc/src/cpp/common/alts_util.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Copyright 2019 gRPC 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. - * - */ - -#include "upb/upb.hpp" - -#include <grpc/grpc_security.h> -#include <grpc/support/log.h> -#include <grpcpp/security/alts_context.h> -#include <grpcpp/security/alts_util.h> - -#include "src/core/lib/gprpp/memory.h" -#include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h" -#include "src/cpp/common/secure_auth_context.h" -#include "src/proto/grpc/gcp/altscontext.upb.h" - -namespace grpc { -namespace experimental { - -std::unique_ptr<AltsContext> GetAltsContextFromAuthContext( - const std::shared_ptr<const AuthContext>& auth_context) { - if (auth_context == nullptr) { - gpr_log(GPR_ERROR, "auth_context is nullptr."); - return nullptr; - } - std::vector<string_ref> ctx_vector = - auth_context->FindPropertyValues(TSI_ALTS_CONTEXT); - if (ctx_vector.size() != 1) { - gpr_log(GPR_ERROR, "contains zero or more than one ALTS context."); - return nullptr; - } - upb::Arena context_arena; - grpc_gcp_AltsContext* ctx = grpc_gcp_AltsContext_parse( - ctx_vector[0].data(), ctx_vector[0].size(), context_arena.ptr()); - if (ctx == nullptr) { - gpr_log(GPR_ERROR, "fails to parse ALTS context."); - return nullptr; - } - if (grpc_gcp_AltsContext_security_level(ctx) < GRPC_SECURITY_MIN || - grpc_gcp_AltsContext_security_level(ctx) > GRPC_SECURITY_MAX) { - gpr_log(GPR_ERROR, "security_level is invalid."); - return nullptr; - } - return y_absl::make_unique<AltsContext>(AltsContext(ctx)); -} - -grpc::Status AltsClientAuthzCheck( - const std::shared_ptr<const AuthContext>& auth_context, - const std::vector<TString>& expected_service_accounts) { - std::unique_ptr<AltsContext> alts_ctx = - GetAltsContextFromAuthContext(auth_context); - if (alts_ctx == nullptr) { - return grpc::Status(grpc::StatusCode::PERMISSION_DENIED, - "fails to parse ALTS context."); - } - if (std::find(expected_service_accounts.begin(), - expected_service_accounts.end(), - alts_ctx->peer_service_account()) != - expected_service_accounts.end()) { - return grpc::Status::OK; - } - return grpc::Status( - grpc::StatusCode::PERMISSION_DENIED, - "client " + alts_ctx->peer_service_account() + " is not authorized."); -} - -} // namespace experimental -} // namespace grpc diff --git a/contrib/libs/grpc/src/cpp/common/insecure_create_auth_context.cc b/contrib/libs/grpc/src/cpp/common/insecure_create_auth_context.cc deleted file mode 100644 index 4e5cbd0372..0000000000 --- a/contrib/libs/grpc/src/cpp/common/insecure_create_auth_context.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Copyright 2015 gRPC 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. - * - */ -#include <memory> - -#include <grpc/grpc.h> -#include <grpcpp/security/auth_context.h> - -namespace grpc { - -std::shared_ptr<const AuthContext> CreateAuthContext(grpc_call* call) { - (void)call; - return std::shared_ptr<const AuthContext>(); -} - -} // namespace grpc diff --git a/contrib/libs/grpc/src/cpp/server/load_reporter/constants.h b/contrib/libs/grpc/src/cpp/server/load_reporter/constants.h deleted file mode 100644 index dc9fadeab0..0000000000 --- a/contrib/libs/grpc/src/cpp/server/load_reporter/constants.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -#ifndef GRPC_SRC_CPP_SERVER_LOAD_REPORTER_UTIL_H -#define GRPC_SRC_CPP_SERVER_LOAD_REPORTER_UTIL_H - -#include <grpc/impl/codegen/port_platform.h> - -#include <stddef.h> - -namespace grpc { -namespace load_reporter { - -// TODO(juanlishen): Update the version number with the PR number every time -// there is any change to the server load reporter. -constexpr uint32_t kVersion = 15853; - -// TODO(juanlishen): This window size is from the internal spec for the load -// reporter. Need to ask the gRPC LB team whether we should make this and the -// fetching interval configurable. -constexpr uint32_t kFeedbackSampleWindowSeconds = 10; -constexpr uint32_t kFetchAndSampleIntervalSeconds = 1; - -constexpr size_t kLbIdLength = 8; -constexpr size_t kIpv4AddressLength = 8; -constexpr size_t kIpv6AddressLength = 32; - -constexpr char kInvalidLbId[] = "<INVALID_LBID_238dsb234890rb>"; - -// Call statuses. - -constexpr char kCallStatusOk[] = "OK"; -constexpr char kCallStatusServerError[] = "5XX"; -constexpr char kCallStatusClientError[] = "4XX"; - -// Tag keys. - -constexpr char kTagKeyToken[] = "token"; -constexpr char kTagKeyHost[] = "host"; -constexpr char kTagKeyUserId[] = "user_id"; -constexpr char kTagKeyStatus[] = "status"; -constexpr char kTagKeyMetricName[] = "metric_name"; - -// Measure names. - -constexpr char kMeasureStartCount[] = "grpc.io/lb/start_count"; -constexpr char kMeasureEndCount[] = "grpc.io/lb/end_count"; -constexpr char kMeasureEndBytesSent[] = "grpc.io/lb/bytes_sent"; -constexpr char kMeasureEndBytesReceived[] = "grpc.io/lb/bytes_received"; -constexpr char kMeasureEndLatencyMs[] = "grpc.io/lb/latency_ms"; -constexpr char kMeasureOtherCallMetric[] = "grpc.io/lb/other_call_metric"; - -// View names. - -constexpr char kViewStartCount[] = "grpc.io/lb_view/start_count"; -constexpr char kViewEndCount[] = "grpc.io/lb_view/end_count"; -constexpr char kViewEndBytesSent[] = "grpc.io/lb_view/bytes_sent"; -constexpr char kViewEndBytesReceived[] = "grpc.io/lb_view/bytes_received"; -constexpr char kViewEndLatencyMs[] = "grpc.io/lb_view/latency_ms"; -constexpr char kViewOtherCallMetricCount[] = - "grpc.io/lb_view/other_call_metric_count"; -constexpr char kViewOtherCallMetricValue[] = - "grpc.io/lb_view/other_call_metric_value"; - -} // namespace load_reporter -} // namespace grpc - -#endif // GRPC_SRC_CPP_SERVER_LOAD_REPORTER_UTIL_H diff --git a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats.h b/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats.h deleted file mode 100644 index f514b0752f..0000000000 --- a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -#ifndef GRPC_SRC_CPP_SERVER_LOAD_REPORTER_GET_CPU_STATS_H -#define GRPC_SRC_CPP_SERVER_LOAD_REPORTER_GET_CPU_STATS_H - -#include <grpc/impl/codegen/port_platform.h> - -#include <utility> - -namespace grpc { -namespace load_reporter { - -// Reads the CPU stats (in a pair of busy and total numbers) from the system. -// The units of the stats should be the same. -std::pair<uint64_t, uint64_t> GetCpuStatsImpl(); - -} // namespace load_reporter -} // namespace grpc - -#endif // GRPC_SRC_CPP_SERVER_LOAD_REPORTER_GET_CPU_STATS_H diff --git a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_linux.cc b/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_linux.cc deleted file mode 100644 index f778b13785..0000000000 --- a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_linux.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -#include <grpc/support/port_platform.h> - -#ifdef GPR_LINUX - -#include <inttypes.h> - -#include <cstdio> - -#include "src/cpp/server/load_reporter/get_cpu_stats.h" - -namespace grpc { -namespace load_reporter { - -std::pair<uint64_t, uint64_t> GetCpuStatsImpl() { - uint64_t busy = 0, total = 0; - FILE* fp; - fp = fopen("/proc/stat", "r"); - uint64_t user, nice, system, idle; - if (fscanf(fp, "cpu %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, &user, - &nice, &system, &idle) != 4) { - // Something bad happened with the information, so assume it's all invalid - user = nice = system = idle = 0; - } - fclose(fp); - busy = user + nice + system; - total = busy + idle; - return std::make_pair(busy, total); -} - -} // namespace load_reporter -} // namespace grpc - -#endif // GPR_LINUX diff --git a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_macos.cc b/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_macos.cc deleted file mode 100644 index dbdde304c2..0000000000 --- a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_macos.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -#include <grpc/support/port_platform.h> - -#ifdef GPR_APPLE - -#include <mach/mach.h> - -#include "src/cpp/server/load_reporter/get_cpu_stats.h" - -namespace grpc { -namespace load_reporter { - -std::pair<uint64_t, uint64_t> GetCpuStatsImpl() { - uint64_t busy = 0, total = 0; - host_cpu_load_info_data_t cpuinfo; - mach_msg_type_number_t count = HOST_CPU_LOAD_INFO_COUNT; - if (host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, - (host_info_t)&cpuinfo, &count) == KERN_SUCCESS) { - for (int i = 0; i < CPU_STATE_MAX; i++) total += cpuinfo.cpu_ticks[i]; - busy = total - cpuinfo.cpu_ticks[CPU_STATE_IDLE]; - } - return std::make_pair(busy, total); -} - -} // namespace load_reporter -} // namespace grpc - -#endif // GPR_APPLE diff --git a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc b/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc deleted file mode 100644 index 80fb8b6da1..0000000000 --- a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -#include <grpc/support/port_platform.h> - -#if !defined(GPR_LINUX) && !defined(GPR_WINDOWS) && !defined(GPR_APPLE) - -#include <grpc/support/log.h> - -#include "src/cpp/server/load_reporter/get_cpu_stats.h" - -namespace grpc { -namespace load_reporter { - -std::pair<uint64_t, uint64_t> GetCpuStatsImpl() { - uint64_t busy = 0, total = 0; - gpr_log(GPR_ERROR, - "Platforms other than Linux, Windows, and MacOS are not supported."); - return std::make_pair(busy, total); -} - -} // namespace load_reporter -} // namespace grpc - -#endif // !defined(GPR_LINUX) && !defined(GPR_WINDOWS) && !defined(GPR_APPLE) diff --git a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_windows.cc b/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_windows.cc deleted file mode 100644 index c03daddb35..0000000000 --- a/contrib/libs/grpc/src/cpp/server/load_reporter/get_cpu_stats_windows.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -#include <grpc/support/port_platform.h> - -#ifdef GPR_WINDOWS - -#include <windows.h> - -#include <cstdint> - -#include "src/cpp/server/load_reporter/get_cpu_stats.h" - -namespace grpc { -namespace load_reporter { - -namespace { - -uint64_t FiletimeToInt(const FILETIME& ft) { - ULARGE_INTEGER i; - i.LowPart = ft.dwLowDateTime; - i.HighPart = ft.dwHighDateTime; - return i.QuadPart; -} - -} // namespace - -std::pair<uint64_t, uint64_t> GetCpuStatsImpl() { - uint64_t busy = 0, total = 0; - FILETIME idle, kernel, user; - if (GetSystemTimes(&idle, &kernel, &user) != 0) { - total = FiletimeToInt(kernel) + FiletimeToInt(user); - busy = total - FiletimeToInt(idle); - } - return std::make_pair(busy, total); -} - -} // namespace load_reporter -} // namespace grpc - -#endif // GPR_WINDOWS diff --git a/contrib/libs/grpc/src/cpp/server/load_reporter/load_data_store.cc b/contrib/libs/grpc/src/cpp/server/load_reporter/load_data_store.cc deleted file mode 100644 index 78e6c32864..0000000000 --- a/contrib/libs/grpc/src/cpp/server/load_reporter/load_data_store.cc +++ /dev/null @@ -1,340 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -#include <grpc/impl/codegen/port_platform.h> - -#include "src/cpp/server/load_reporter/load_data_store.h" - -#include <stdio.h> - -#include <cstdlib> -#include <set> -#include <unordered_map> -#include <vector> - -#include "src/core/lib/iomgr/socket_utils.h" - -namespace grpc { -namespace load_reporter { - -// Some helper functions. -namespace { - -// Given a map from type K to a set of value type V, finds the set associated -// with the given key and erases the value from the set. If the set becomes -// empty, also erases the key-set pair. Returns true if the value is erased -// successfully. -template <typename K, typename V> -bool UnorderedMapOfSetEraseKeyValue(std::unordered_map<K, std::set<V>>& map, - const K& key, const V& value) { - auto it = map.find(key); - if (it != map.end()) { - size_t erased = it->second.erase(value); - if (it->second.empty()) { - map.erase(it); - } - return erased; - } - return false; -}; - -// Given a map from type K to a set of value type V, removes the given key and -// the associated set, and returns the set. Returns an empty set if the key is -// not found. -template <typename K, typename V> -std::set<V> UnorderedMapOfSetExtract(std::unordered_map<K, std::set<V>>& map, - const K& key) { - auto it = map.find(key); - if (it != map.end()) { - auto set = std::move(it->second); - map.erase(it); - return set; - } - return {}; -}; - -// From a non-empty container, returns a pointer to a random element. -template <typename C> -const typename C::value_type* RandomElement(const C& container) { - GPR_ASSERT(!container.empty()); - auto it = container.begin(); - std::advance(it, std::rand() % container.size()); - return &(*it); -} - -} // namespace - -LoadRecordKey::LoadRecordKey(const TString& client_ip_and_token, - TString user_id) - : user_id_(std::move(user_id)) { - GPR_ASSERT(client_ip_and_token.size() >= 2); - int ip_hex_size; - GPR_ASSERT(sscanf(client_ip_and_token.substr(0, 2).c_str(), "%d", - &ip_hex_size) == 1); - GPR_ASSERT(ip_hex_size == 0 || ip_hex_size == kIpv4AddressLength || - ip_hex_size == kIpv6AddressLength); - size_t cur_pos = 2; - client_ip_hex_ = client_ip_and_token.substr(cur_pos, ip_hex_size); - cur_pos += ip_hex_size; - if (client_ip_and_token.size() - cur_pos < kLbIdLength) { - lb_id_ = kInvalidLbId; - lb_tag_ = ""; - } else { - lb_id_ = client_ip_and_token.substr(cur_pos, kLbIdLength); - lb_tag_ = client_ip_and_token.substr(cur_pos + kLbIdLength); - } -} - -TString LoadRecordKey::GetClientIpBytes() const { - if (client_ip_hex_.empty()) { - return ""; - } else if (client_ip_hex_.size() == kIpv4AddressLength) { - uint32_t ip_bytes; - if (sscanf(client_ip_hex_.c_str(), "%x", &ip_bytes) != 1) { - gpr_log(GPR_ERROR, - "Can't parse client IP (%s) from a hex string to an integer.", - client_ip_hex_.c_str()); - return ""; - } - ip_bytes = grpc_htonl(ip_bytes); - return TString(reinterpret_cast<const char*>(&ip_bytes), - sizeof(ip_bytes)); - } else if (client_ip_hex_.size() == kIpv6AddressLength) { - uint32_t ip_bytes[4]; - for (size_t i = 0; i < 4; ++i) { - if (sscanf(client_ip_hex_.substr(i * 8, (i + 1) * 8).c_str(), "%x", - ip_bytes + i) != 1) { - gpr_log( - GPR_ERROR, - "Can't parse client IP part (%s) from a hex string to an integer.", - client_ip_hex_.substr(i * 8, (i + 1) * 8).c_str()); - return ""; - } - ip_bytes[i] = grpc_htonl(ip_bytes[i]); - } - return TString(reinterpret_cast<const char*>(ip_bytes), - sizeof(ip_bytes)); - } else { - GPR_UNREACHABLE_CODE(return ""); - } -} - -LoadRecordValue::LoadRecordValue(TString metric_name, uint64_t num_calls, - double total_metric_value) { - call_metrics_.emplace(std::move(metric_name), - CallMetricValue(num_calls, total_metric_value)); -} - -void PerBalancerStore::MergeRow(const LoadRecordKey& key, - const LoadRecordValue& value) { - // During suspension, the load data received will be dropped. - if (!suspended_) { - load_record_map_[key].MergeFrom(value); - gpr_log(GPR_DEBUG, - "[PerBalancerStore %p] Load data merged (Key: %s, Value: %s).", - this, key.ToString().c_str(), value.ToString().c_str()); - } else { - gpr_log(GPR_DEBUG, - "[PerBalancerStore %p] Load data dropped (Key: %s, Value: %s).", - this, key.ToString().c_str(), value.ToString().c_str()); - } - // We always keep track of num_calls_in_progress_, so that when this - // store is resumed, we still have a correct value of - // num_calls_in_progress_. - GPR_ASSERT(static_cast<int64_t>(num_calls_in_progress_) + - value.GetNumCallsInProgressDelta() >= - 0); - num_calls_in_progress_ += value.GetNumCallsInProgressDelta(); -} - -void PerBalancerStore::Suspend() { - suspended_ = true; - load_record_map_.clear(); - gpr_log(GPR_DEBUG, "[PerBalancerStore %p] Suspended.", this); -} - -void PerBalancerStore::Resume() { - suspended_ = false; - gpr_log(GPR_DEBUG, "[PerBalancerStore %p] Resumed.", this); -} - -uint64_t PerBalancerStore::GetNumCallsInProgressForReport() { - GPR_ASSERT(!suspended_); - last_reported_num_calls_in_progress_ = num_calls_in_progress_; - return num_calls_in_progress_; -} - -void PerHostStore::ReportStreamCreated(const TString& lb_id, - const TString& load_key) { - GPR_ASSERT(lb_id != kInvalidLbId); - SetUpForNewLbId(lb_id, load_key); - // Prior to this one, there was no load balancer receiving report, so we may - // have unassigned orphaned stores to assign to this new balancer. - // TODO(juanlishen): If the load key of this new stream is the same with - // some previously adopted orphan store, we may want to take the orphan to - // this stream. Need to discuss with LB team. - if (assigned_stores_.size() == 1) { - for (const auto& p : per_balancer_stores_) { - const TString& other_lb_id = p.first; - const std::unique_ptr<PerBalancerStore>& orphaned_store = p.second; - if (other_lb_id != lb_id) { - orphaned_store->Resume(); - AssignOrphanedStore(orphaned_store.get(), lb_id); - } - } - } - // The first connected balancer will adopt the kInvalidLbId. - if (per_balancer_stores_.size() == 1) { - SetUpForNewLbId(kInvalidLbId, ""); - ReportStreamClosed(kInvalidLbId); - } -} - -void PerHostStore::ReportStreamClosed(const TString& lb_id) { - auto it_store_for_gone_lb = per_balancer_stores_.find(lb_id); - GPR_ASSERT(it_store_for_gone_lb != per_balancer_stores_.end()); - // Remove this closed stream from our records. - GPR_ASSERT(UnorderedMapOfSetEraseKeyValue( - load_key_to_receiving_lb_ids_, it_store_for_gone_lb->second->load_key(), - lb_id)); - std::set<PerBalancerStore*> orphaned_stores = - UnorderedMapOfSetExtract(assigned_stores_, lb_id); - // The stores that were assigned to this balancer are orphaned now. They - // should be re-assigned to other balancers which are still receiving reports. - for (PerBalancerStore* orphaned_store : orphaned_stores) { - const TString* new_receiver = nullptr; - auto it = load_key_to_receiving_lb_ids_.find(orphaned_store->load_key()); - if (it != load_key_to_receiving_lb_ids_.end()) { - // First, try to pick from the active balancers with the same load key. - new_receiver = RandomElement(it->second); - } else if (!assigned_stores_.empty()) { - // If failed, pick from all the remaining active balancers. - new_receiver = &(RandomElement(assigned_stores_)->first); - } - if (new_receiver != nullptr) { - AssignOrphanedStore(orphaned_store, *new_receiver); - } else { - // Load data for an LB ID that can't be assigned to any stream should - // be dropped. - orphaned_store->Suspend(); - } - } -} - -PerBalancerStore* PerHostStore::FindPerBalancerStore( - const TString& lb_id) const { - return per_balancer_stores_.find(lb_id) != per_balancer_stores_.end() - ? per_balancer_stores_.find(lb_id)->second.get() - : nullptr; -} - -const std::set<PerBalancerStore*>* PerHostStore::GetAssignedStores( - const TString& lb_id) const { - auto it = assigned_stores_.find(lb_id); - if (it == assigned_stores_.end()) return nullptr; - return &(it->second); -} - -void PerHostStore::AssignOrphanedStore(PerBalancerStore* orphaned_store, - const TString& new_receiver) { - auto it = assigned_stores_.find(new_receiver); - GPR_ASSERT(it != assigned_stores_.end()); - it->second.insert(orphaned_store); - gpr_log(GPR_INFO, - "[PerHostStore %p] Re-assigned orphaned store (%p) with original LB" - " ID of %s to new receiver %s", - this, orphaned_store, orphaned_store->lb_id().c_str(), - new_receiver.c_str()); -} - -void PerHostStore::SetUpForNewLbId(const TString& lb_id, - const TString& load_key) { - // The top-level caller (i.e., LoadReportService) should guarantee the - // lb_id is unique for each reporting stream. - GPR_ASSERT(per_balancer_stores_.find(lb_id) == per_balancer_stores_.end()); - GPR_ASSERT(assigned_stores_.find(lb_id) == assigned_stores_.end()); - load_key_to_receiving_lb_ids_[load_key].insert(lb_id); - std::unique_ptr<PerBalancerStore> per_balancer_store( - new PerBalancerStore(lb_id, load_key)); - assigned_stores_[lb_id] = {per_balancer_store.get()}; - per_balancer_stores_[lb_id] = std::move(per_balancer_store); -} - -PerBalancerStore* LoadDataStore::FindPerBalancerStore( - const string& hostname, const string& lb_id) const { - auto it = per_host_stores_.find(hostname); - if (it != per_host_stores_.end()) { - const PerHostStore& per_host_store = it->second; - return per_host_store.FindPerBalancerStore(lb_id); - } else { - return nullptr; - } -} - -void LoadDataStore::MergeRow(const TString& hostname, - const LoadRecordKey& key, - const LoadRecordValue& value) { - PerBalancerStore* per_balancer_store = - FindPerBalancerStore(hostname, key.lb_id()); - if (per_balancer_store != nullptr) { - per_balancer_store->MergeRow(key, value); - return; - } - // Unknown LB ID. Track it until its number of in-progress calls drops to - // zero. - int64_t in_progress_delta = value.GetNumCallsInProgressDelta(); - if (in_progress_delta != 0) { - auto it_tracker = unknown_balancer_id_trackers_.find(key.lb_id()); - if (it_tracker == unknown_balancer_id_trackers_.end()) { - gpr_log( - GPR_DEBUG, - "[LoadDataStore %p] Start tracking unknown balancer (lb_id_: %s).", - this, key.lb_id().c_str()); - unknown_balancer_id_trackers_.insert( - {key.lb_id(), static_cast<uint64_t>(in_progress_delta)}); - } else if ((it_tracker->second += in_progress_delta) == 0) { - unknown_balancer_id_trackers_.erase(it_tracker); - gpr_log(GPR_DEBUG, - "[LoadDataStore %p] Stop tracking unknown balancer (lb_id_: %s).", - this, key.lb_id().c_str()); - } - } -} - -const std::set<PerBalancerStore*>* LoadDataStore::GetAssignedStores( - const TString& hostname, const TString& lb_id) { - auto it = per_host_stores_.find(hostname); - if (it == per_host_stores_.end()) return nullptr; - return it->second.GetAssignedStores(lb_id); -} - -void LoadDataStore::ReportStreamCreated(const TString& hostname, - const TString& lb_id, - const TString& load_key) { - per_host_stores_[hostname].ReportStreamCreated(lb_id, load_key); -} - -void LoadDataStore::ReportStreamClosed(const TString& hostname, - const TString& lb_id) { - auto it_per_host_store = per_host_stores_.find(hostname); - GPR_ASSERT(it_per_host_store != per_host_stores_.end()); - it_per_host_store->second.ReportStreamClosed(lb_id); -} - -} // namespace load_reporter -} // namespace grpc diff --git a/contrib/libs/grpc/src/cpp/server/load_reporter/load_data_store.h b/contrib/libs/grpc/src/cpp/server/load_reporter/load_data_store.h deleted file mode 100644 index 61ba618331..0000000000 --- a/contrib/libs/grpc/src/cpp/server/load_reporter/load_data_store.h +++ /dev/null @@ -1,348 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -#ifndef GRPC_SRC_CPP_SERVER_LOAD_REPORTER_LOAD_DATA_STORE_H -#define GRPC_SRC_CPP_SERVER_LOAD_REPORTER_LOAD_DATA_STORE_H - -#include <grpc/support/port_platform.h> - -#include <memory> -#include <set> -#include <unordered_map> - -#include <grpc/support/log.h> -#include <grpcpp/impl/codegen/config.h> - -#include "src/cpp/server/load_reporter/constants.h" - -#include <util/string/cast.h> - -namespace grpc { -namespace load_reporter { - -// The load data storage is organized in hierarchy. The LoadDataStore is the -// top-level data store. In LoadDataStore, for each host we keep a -// PerHostStore, in which for each balancer we keep a PerBalancerStore. Each -// PerBalancerStore maintains a map of load records, mapping from LoadRecordKey -// to LoadRecordValue. The LoadRecordValue contains a map of customized call -// metrics, mapping from a call metric name to the CallMetricValue. - -// The value of a customized call metric. -class CallMetricValue { - public: - explicit CallMetricValue(uint64_t num_calls = 0, - double total_metric_value = 0) - : num_calls_(num_calls), total_metric_value_(total_metric_value) {} - - void MergeFrom(CallMetricValue other) { - num_calls_ += other.num_calls_; - total_metric_value_ += other.total_metric_value_; - } - - // Getters. - uint64_t num_calls() const { return num_calls_; } - double total_metric_value() const { return total_metric_value_; } - - private: - // The number of calls that finished with this metric. - uint64_t num_calls_ = 0; - // The sum of metric values across all the calls that finished with this - // metric. - double total_metric_value_ = 0; -}; - -// The key of a load record. -class LoadRecordKey { - public: - LoadRecordKey(TString lb_id, TString lb_tag, TString user_id, - TString client_ip_hex) - : lb_id_(std::move(lb_id)), - lb_tag_(std::move(lb_tag)), - user_id_(std::move(user_id)), - client_ip_hex_(std::move(client_ip_hex)) {} - - // Parses the input client_ip_and_token to set client IP, LB ID, and LB tag. - LoadRecordKey(const TString& client_ip_and_token, TString user_id); - - TString ToString() const { - return "[lb_id_=" + lb_id_ + ", lb_tag_=" + lb_tag_ + - ", user_id_=" + user_id_ + ", client_ip_hex_=" + client_ip_hex_ + - "]"; - } - - bool operator==(const LoadRecordKey& other) const { - return lb_id_ == other.lb_id_ && lb_tag_ == other.lb_tag_ && - user_id_ == other.user_id_ && client_ip_hex_ == other.client_ip_hex_; - } - - // Gets the client IP bytes in network order (i.e., big-endian). - TString GetClientIpBytes() const; - - // Getters. - const TString& lb_id() const { return lb_id_; } - const TString& lb_tag() const { return lb_tag_; } - const TString& user_id() const { return user_id_; } - const TString& client_ip_hex() const { return client_ip_hex_; } - - struct Hasher { - void hash_combine(size_t* seed, const TString& k) const { - *seed ^= std::hash<TString>()(k) + 0x9e3779b9 + (*seed << 6) + - (*seed >> 2); - } - - size_t operator()(const LoadRecordKey& k) const { - size_t h = 0; - hash_combine(&h, k.lb_id_); - hash_combine(&h, k.lb_tag_); - hash_combine(&h, k.user_id_); - hash_combine(&h, k.client_ip_hex_); - return h; - } - }; - - private: - TString lb_id_; - TString lb_tag_; - TString user_id_; - TString client_ip_hex_; -}; - -// The value of a load record. -class LoadRecordValue { - public: - explicit LoadRecordValue(uint64_t start_count = 0, uint64_t ok_count = 0, - uint64_t error_count = 0, uint64_t bytes_sent = 0, - uint64_t bytes_recv = 0, uint64_t latency_ms = 0) - : start_count_(start_count), - ok_count_(ok_count), - error_count_(error_count), - bytes_sent_(bytes_sent), - bytes_recv_(bytes_recv), - latency_ms_(latency_ms) {} - - LoadRecordValue(TString metric_name, uint64_t num_calls, - double total_metric_value); - - void MergeFrom(const LoadRecordValue& other) { - start_count_ += other.start_count_; - ok_count_ += other.ok_count_; - error_count_ += other.error_count_; - bytes_sent_ += other.bytes_sent_; - bytes_recv_ += other.bytes_recv_; - latency_ms_ += other.latency_ms_; - for (const auto& p : other.call_metrics_) { - const TString& key = p.first; - const CallMetricValue& value = p.second; - call_metrics_[key].MergeFrom(value); - } - } - - int64_t GetNumCallsInProgressDelta() const { - return static_cast<int64_t>(start_count_ - ok_count_ - error_count_); - } - - TString ToString() const { - return "[start_count_=" + ::ToString(start_count_) + - ", ok_count_=" + ::ToString(ok_count_) + - ", error_count_=" + ::ToString(error_count_) + - ", bytes_sent_=" + ::ToString(bytes_sent_) + - ", bytes_recv_=" + ::ToString(bytes_recv_) + - ", latency_ms_=" + ::ToString(latency_ms_) + ", " + - ::ToString(call_metrics_.size()) + " other call metric(s)]"; - } - - bool InsertCallMetric(const TString& metric_name, - const CallMetricValue& metric_value) { - return call_metrics_.insert({metric_name, metric_value}).second; - } - - // Getters. - uint64_t start_count() const { return start_count_; } - uint64_t ok_count() const { return ok_count_; } - uint64_t error_count() const { return error_count_; } - uint64_t bytes_sent() const { return bytes_sent_; } - uint64_t bytes_recv() const { return bytes_recv_; } - uint64_t latency_ms() const { return latency_ms_; } - const std::unordered_map<TString, CallMetricValue>& call_metrics() const { - return call_metrics_; - } - - private: - uint64_t start_count_ = 0; - uint64_t ok_count_ = 0; - uint64_t error_count_ = 0; - uint64_t bytes_sent_ = 0; - uint64_t bytes_recv_ = 0; - uint64_t latency_ms_ = 0; - std::unordered_map<TString, CallMetricValue> call_metrics_; -}; - -// Stores the data associated with a particular LB ID. -class PerBalancerStore { - public: - using LoadRecordMap = - std::unordered_map<LoadRecordKey, LoadRecordValue, LoadRecordKey::Hasher>; - - PerBalancerStore(TString lb_id, TString load_key) - : lb_id_(std::move(lb_id)), load_key_(std::move(load_key)) {} - - // Merge a load record with the given key and value if the store is not - // suspended. - void MergeRow(const LoadRecordKey& key, const LoadRecordValue& value); - - // Suspend this store, so that no detailed load data will be recorded. - void Suspend(); - // Resume this store from suspension. - void Resume(); - // Is this store suspended or not? - bool IsSuspended() const { return suspended_; } - - bool IsNumCallsInProgressChangedSinceLastReport() const { - return num_calls_in_progress_ != last_reported_num_calls_in_progress_; - } - - uint64_t GetNumCallsInProgressForReport(); - - TString ToString() { - return "[PerBalancerStore lb_id_=" + lb_id_ + " load_key_=" + load_key_ + - "]"; - } - - void ClearLoadRecordMap() { load_record_map_.clear(); } - - // Getters. - const TString& lb_id() const { return lb_id_; } - const TString& load_key() const { return load_key_; } - const LoadRecordMap& load_record_map() const { return load_record_map_; } - - private: - TString lb_id_; - // TODO(juanlishen): Use bytestring protobuf type? - TString load_key_; - LoadRecordMap load_record_map_; - uint64_t num_calls_in_progress_ = 0; - uint64_t last_reported_num_calls_in_progress_ = 0; - bool suspended_ = false; -}; - -// Stores the data associated with a particular host. -class PerHostStore { - public: - // When a report stream is created, a PerBalancerStore is created for the - // LB ID (guaranteed unique) associated with that stream. If it is the only - // active store, adopt all the orphaned stores. If it is the first created - // store, adopt the store of kInvalidLbId. - void ReportStreamCreated(const TString& lb_id, - const TString& load_key); - - // When a report stream is closed, the PerBalancerStores assigned to the - // associate LB ID need to be re-assigned to other active balancers, - // ideally with the same load key. If there is no active balancer, we have - // to suspend those stores and drop the incoming load data until they are - // resumed. - void ReportStreamClosed(const TString& lb_id); - - // Returns null if not found. Caller doesn't own the returned store. - PerBalancerStore* FindPerBalancerStore(const TString& lb_id) const; - - // Returns null if lb_id is not found. The returned pointer points to the - // underlying data structure, which is not owned by the caller. - const std::set<PerBalancerStore*>* GetAssignedStores( - const TString& lb_id) const; - - private: - // Creates a PerBalancerStore for the given LB ID, assigns the store to - // itself, and records the LB ID to the load key. - void SetUpForNewLbId(const TString& lb_id, const TString& load_key); - - void AssignOrphanedStore(PerBalancerStore* orphaned_store, - const TString& new_receiver); - - std::unordered_map<TString, std::set<TString>> - load_key_to_receiving_lb_ids_; - - // Key: LB ID. The key set includes all the LB IDs that have been - // allocated for reporting streams so far. - // Value: the unique pointer to the PerBalancerStore of the LB ID. - std::unordered_map<TString, std::unique_ptr<PerBalancerStore>> - per_balancer_stores_; - - // Key: LB ID. The key set includes the LB IDs of the balancers that are - // currently receiving report. - // Value: the set of raw pointers to the PerBalancerStores assigned to the LB - // ID. Note that the sets in assigned_stores_ form a division of the value set - // of per_balancer_stores_. - std::unordered_map<TString, std::set<PerBalancerStore*>> assigned_stores_; -}; - -// Thread-unsafe two-level bookkeeper of all the load data. -// Note: We never remove any store objects from this class, as per the -// current spec. That's because premature removal of the store objects -// may lead to loss of critical information, e.g., mapping from lb_id to -// load_key, and the number of in-progress calls. Such loss will cause -// information inconsistency when the balancer is re-connected. Keeping -// all the stores should be fine for PerHostStore, since we assume there -// should only be a few hostnames. But it's a potential problem for -// PerBalancerStore. -class LoadDataStore { - public: - // Returns null if not found. Caller doesn't own the returned store. - PerBalancerStore* FindPerBalancerStore(const TString& hostname, - const TString& lb_id) const; - - // Returns null if hostname or lb_id is not found. The returned pointer points - // to the underlying data structure, which is not owned by the caller. - const std::set<PerBalancerStore*>* GetAssignedStores(const string& hostname, - const string& lb_id); - - // If a PerBalancerStore can be found by the hostname and LB ID in - // LoadRecordKey, the load data will be merged to that store. Otherwise, - // only track the number of the in-progress calls for this unknown LB ID. - void MergeRow(const TString& hostname, const LoadRecordKey& key, - const LoadRecordValue& value); - - // Is the given lb_id a tracked unknown LB ID (i.e., the LB ID was associated - // with some received load data but unknown to this load data store)? - bool IsTrackedUnknownBalancerId(const TString& lb_id) const { - return unknown_balancer_id_trackers_.find(lb_id) != - unknown_balancer_id_trackers_.end(); - } - - // Wrapper around PerHostStore::ReportStreamCreated. - void ReportStreamCreated(const TString& hostname, - const TString& lb_id, - const TString& load_key); - - // Wrapper around PerHostStore::ReportStreamClosed. - void ReportStreamClosed(const TString& hostname, - const TString& lb_id); - - private: - // Buffered data that was fetched from Census but hasn't been sent to - // balancer. We need to keep this data ourselves because Census will - // delete the data once it's returned. - std::unordered_map<TString, PerHostStore> per_host_stores_; - - // Tracks the number of in-progress calls for each unknown LB ID. - std::unordered_map<TString, uint64_t> unknown_balancer_id_trackers_; -}; - -} // namespace load_reporter -} // namespace grpc - -#endif // GRPC_SRC_CPP_SERVER_LOAD_REPORTER_LOAD_DATA_STORE_H diff --git a/contrib/libs/grpc/src/cpp/server/load_reporter/util.cc b/contrib/libs/grpc/src/cpp/server/load_reporter/util.cc deleted file mode 100644 index 4b4e778a62..0000000000 --- a/contrib/libs/grpc/src/cpp/server/load_reporter/util.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Copyright 2018 gRPC 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. - * - */ - -#include <grpc/impl/codegen/port_platform.h> - -#include <cmath> - -#include <grpc/support/log.h> -#include <grpcpp/ext/server_load_reporting.h> - -namespace grpc { -namespace load_reporter { -namespace experimental { - -void AddLoadReportingCost(grpc::ServerContext* ctx, - const TString& cost_name, double cost_value) { - if (std::isnormal(cost_value)) { - TString buf; - buf.resize(sizeof(cost_value) + cost_name.size()); - memcpy(&(*buf.begin()), &cost_value, sizeof(cost_value)); - memcpy(&(*buf.begin()) + sizeof(cost_value), cost_name.data(), - cost_name.size()); - ctx->AddTrailingMetadata(GRPC_LB_COST_MD_KEY, buf); - } else { - gpr_log(GPR_ERROR, "Call metric value is not normal."); - } -} - -} // namespace experimental -} // namespace load_reporter -} // namespace grpc diff --git a/contrib/libs/grpc/src/cpp/util/error_details.cc b/contrib/libs/grpc/src/cpp/util/error_details.cc deleted file mode 100644 index 0330f012c2..0000000000 --- a/contrib/libs/grpc/src/cpp/util/error_details.cc +++ /dev/null @@ -1,19 +0,0 @@ -/* - * - * Copyright 2017 gRPC 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. - * - */ - -#include <grpcpp/support/error_details.h> |