Merge branch '2021.0' of https://github.com/Tencent/spring-cloud-tencent into optimize/optimize-transfer

 Conflicts:
	CHANGELOG.md
pull/636/head
wulingxiao 3 years ago
commit 70a1d88559

@ -7,10 +7,14 @@
- [Optimize: optimize configuration conditional & optimize config data tips](https://github.com/Tencent/spring-cloud-tencent/pull/603) - [Optimize: optimize configuration conditional & optimize config data tips](https://github.com/Tencent/spring-cloud-tencent/pull/603)
- [Automatically transmit some headers specified by a environment varaible that directly defines header keys.](https://github.com/Tencent/spring-cloud-tencent/pull/606) - [Automatically transmit some headers specified by a environment varaible that directly defines header keys.](https://github.com/Tencent/spring-cloud-tencent/pull/606)
- [Optimize: Maybe remove Chinese characters](https://github.com/Tencent/spring-cloud-tencent/pull/607) - [Optimize: Maybe remove Chinese characters](https://github.com/Tencent/spring-cloud-tencent/pull/607)
- [Optimize: InstanceId of PolarisRegistration and PolarisServiceRegistry](https://github.com/Tencent/spring-cloud-tencent/pull/610)
- [ fix pr #606 cause ci fail](https://github.com/Tencent/spring-cloud-tencent/pull/613) - [ fix pr #606 cause ci fail](https://github.com/Tencent/spring-cloud-tencent/pull/613)
- [Bugfix: fix feign report call result error when using feign direct call](https://github.com/Tencent/spring-cloud-tencent/pull/621)
- [fix pr 606: modify a part of changes requested by review.](https://github.com/Tencent/spring-cloud-tencent/pull/620)
- [fix pr 613: modify a judgment logic](https://github.com/Tencent/spring-cloud-tencent/pull/618) - [fix pr 613: modify a judgment logic](https://github.com/Tencent/spring-cloud-tencent/pull/618)
- [fix pr 606: modify a part of changes requested by review.](https://github.com/Tencent/spring-cloud-tencent/pull/620)
- [Bugfix: fix feign report call result error when using feign direct call](https://github.com/Tencent/spring-cloud-tencent/pull/621)
- [remove useless code for router](https://github.com/Tencent/spring-cloud-tencent/pull/626)
- [Feature: support new label expression](https://github.com/Tencent/spring-cloud-tencent/pull/627) - [Feature: support new label expression](https://github.com/Tencent/spring-cloud-tencent/pull/627)
- [feat:report the labels when using RestTemplate.](https://github.com/Tencent/spring-cloud-tencent/pull/629) - [feat:report the labels when using RestTemplate.](https://github.com/Tencent/spring-cloud-tencent/pull/629)
- [Optimize:optimize transfer](https://github.com/Tencent/spring-cloud-tencent/pull/636) - [Bugfix: fix throw npe when router context is null](https://github.com/Tencent/spring-cloud-tencent/pull/635)
- [fix:cancel reporting useless metadata.](https://github.com/Tencent/spring-cloud-tencent/pull/639)
- [Optimize:optimize transfer](https://github.com/Tencent/spring-cloud-tencent/pull/636)

@ -95,21 +95,23 @@ public class PolarisRouterServiceInstanceListSupplier extends DelegatingServiceI
Flux<List<ServiceInstance>> allServers = getDelegate().get(); Flux<List<ServiceInstance>> allServers = getDelegate().get();
// 2. filter by router // 2. filter by router
PolarisRouterContext routerContext = null;
DefaultRequestContext requestContext = (DefaultRequestContext) request.getContext(); DefaultRequestContext requestContext = (DefaultRequestContext) request.getContext();
PolarisRouterContext key;
if (requestContext instanceof RequestDataContext) { if (requestContext instanceof RequestDataContext) {
key = buildRouterContext(((RequestDataContext) requestContext).getClientRequest().getHeaders()); routerContext = buildRouterContext(((RequestDataContext) requestContext).getClientRequest().getHeaders());
} }
else if (requestContext.getClientRequest() instanceof PolarisLoadBalancerRequest) { else if (requestContext.getClientRequest() instanceof PolarisLoadBalancerRequest) {
key = buildRouterContext(((PolarisLoadBalancerRequest<?>) requestContext.getClientRequest()).getRequest() routerContext = buildRouterContext(((PolarisLoadBalancerRequest<?>) requestContext.getClientRequest()).getRequest()
.getHeaders()); .getHeaders());
} }
else {
if (routerContext == null) {
// return all servers if router context is null. // return all servers if router context is null.
return allServers; return allServers;
} }
return doRouter(allServers, key); return doRouter(allServers, routerContext);
} }
//set method to public for unit test //set method to public for unit test

@ -13,7 +13,6 @@
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the * CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License. * specific language governing permissions and limitations under the License.
*
*/ */
package com.tencent.cloud.common.metadata; package com.tencent.cloud.common.metadata;
@ -35,7 +34,7 @@ import org.springframework.util.CollectionUtils;
/** /**
* manage metadata from env/config file/custom spi. * manage metadata from env/config file/custom spi.
* *
* @author lepdou 2022-05-20 * @author lepdou, Haotian Zhang
*/ */
public class StaticMetadataManager { public class StaticMetadataManager {
/** /**
@ -67,6 +66,7 @@ public class StaticMetadataManager {
private Map<String, String> envMetadata; private Map<String, String> envMetadata;
private Map<String, String> envTransitiveMetadata; private Map<String, String> envTransitiveMetadata;
private Map<String, String> envDisposableMetadata; private Map<String, String> envDisposableMetadata;
private Map<String, String> envNotReportMetadata;
private Map<String, String> configMetadata; private Map<String, String> configMetadata;
private Map<String, String> configTransitiveMetadata; private Map<String, String> configTransitiveMetadata;
private Map<String, String> configDisposableMetadata; private Map<String, String> configDisposableMetadata;
@ -100,6 +100,7 @@ public class StaticMetadataManager {
Map<String, String> allEnvs = System.getenv(); Map<String, String> allEnvs = System.getenv();
envMetadata = new HashMap<>(); envMetadata = new HashMap<>();
envNotReportMetadata = new HashMap<>();
// parse all metadata // parse all metadata
for (Map.Entry<String, String> entry : allEnvs.entrySet()) { for (Map.Entry<String, String> entry : allEnvs.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
@ -110,11 +111,12 @@ public class StaticMetadataManager {
String sourceKey = ""; String sourceKey = "";
if (key.equals(ENV_TRAFFIC_CONTENT_RAW_TRANSHEADERS)) { if (key.equals(ENV_TRAFFIC_CONTENT_RAW_TRANSHEADERS)) {
sourceKey = key; sourceKey = key;
envNotReportMetadata.put(sourceKey, value);
} }
else { else {
sourceKey = StringUtils.substring(key, ENV_METADATA_PREFIX_LENGTH); sourceKey = StringUtils.substring(key, ENV_METADATA_PREFIX_LENGTH);
envMetadata.put(sourceKey, value);
} }
envMetadata.put(sourceKey, value);
LOGGER.info("[SCT] resolve metadata from env. key = {}, value = {}", sourceKey, value); LOGGER.info("[SCT] resolve metadata from env. key = {}, value = {}", sourceKey, value);
} }
@ -284,7 +286,7 @@ public class StaticMetadataManager {
} }
public String getTransHeaderFromEnv() { public String getTransHeaderFromEnv() {
return envMetadata.get(ENV_TRAFFIC_CONTENT_RAW_TRANSHEADERS); return envNotReportMetadata.get(ENV_TRAFFIC_CONTENT_RAW_TRANSHEADERS);
} }
public Map<String, String> getEnvTransitiveMetadata() { public Map<String, String> getEnvTransitiveMetadata() {

Loading…
Cancel
Save