|
14 | 14 | #include "metadata_router.h"
|
15 | 15 |
|
16 | 16 | #include <stddef.h>
|
| 17 | +#include <map> |
| 18 | +#include <string> |
17 | 19 |
|
18 | 20 | #include <utility>
|
19 | 21 |
|
@@ -49,6 +51,8 @@ ReturnCode MetadataServiceRouter::Init(Config* /*config*/, Context* context) {
|
49 | 51 | return kReturnOk;
|
50 | 52 | }
|
51 | 53 |
|
| 54 | +std::string MetadataServiceRouter::Name() { return "MetadataServiceRouter"; } |
| 55 | + |
52 | 56 | static bool MetadataMatch(const std::map<std::string, std::string>& metadata,
|
53 | 57 | const std::map<std::string, std::string>& instance_metadata) {
|
54 | 58 | if (metadata.size() > instance_metadata.size()) {
|
@@ -170,6 +174,17 @@ ReturnCode MetadataServiceRouter::DoRoute(RouteInfo& route_info, RouteResult* ro
|
170 | 174 | RouterSubsetCache* cache_value = router_cache_->GetWithRcuTime(cache_key);
|
171 | 175 | if (cache_value == nullptr) {
|
172 | 176 | cache_value = router_cache_->CreateOrGet(cache_key, [&] {
|
| 177 | + // 出现 metadata cache 需要执行 create 时进行打印相关辅助信息日志 |
| 178 | + std::string metadata_str_ = ""; |
| 179 | + for (std::map<std::string, std::string>::iterator it = cache_key.metadata_.begin(); |
| 180 | + it != cache_key.metadata_.end(); it++) { |
| 181 | + metadata_str_ += it->first + ":" + it->second + ","; |
| 182 | + } |
| 183 | + POLARIS_LOG(LOG_DEBUG, |
| 184 | + "ns(%s) svc(%s) metadata(%s) failover_type(%d) circuitbreaker_version(%" PRIu64 |
| 185 | + ") router_cache run create action", |
| 186 | + route_info.GetServiceKey().namespace_.c_str(), route_info.GetServiceKey().name_.c_str(), |
| 187 | + metadata_str_.c_str(), cache_key.failover_type_, cache_key.circuit_breaker_version_); |
173 | 188 | InstancesSet* prior_result = cache_key.prior_data_;
|
174 | 189 | std::set<Instance*> unhealthy_set;
|
175 | 190 | route_info.CalculateUnhealthySet(unhealthy_set);
|
|
0 commit comments