remove location metadata (#542)

pull/545/head
lepdou 2 years ago committed by GitHub
parent f225f54a88
commit 8d3832f5b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,4 +24,5 @@
- [Feature: Optimized configuration update](https://github.com/Tencent/spring-cloud-tencent/pull/528) - [Feature: Optimized configuration update](https://github.com/Tencent/spring-cloud-tencent/pull/528)
- [Featuresupport pushGateway push metrics](https://github.com/Tencent/spring-cloud-tencent/pull/529) - [Featuresupport pushGateway push metrics](https://github.com/Tencent/spring-cloud-tencent/pull/529)
- [Feature: remove location metadata](https://github.com/Tencent/spring-cloud-tencent/pull/536) - [Feature: remove location metadata](https://github.com/Tencent/spring-cloud-tencent/pull/536)
- [Feature: remove location metadata](https://github.com/Tencent/spring-cloud-tencent/pull/542)
- [add feature-env plugin & add spring cloud gateway staining plugin](https://github.com/Tencent/spring-cloud-tencent/pull/533) - [add feature-env plugin & add spring cloud gateway staining plugin](https://github.com/Tencent/spring-cloud-tencent/pull/533)

@ -214,8 +214,7 @@ public class StaticMetadataManager {
mergedMetadataResult.putAll(configMetadata); mergedMetadataResult.putAll(configMetadata);
mergedMetadataResult.putAll(envMetadata); mergedMetadataResult.putAll(envMetadata);
mergedMetadataResult.putAll(customSPIMetadata); mergedMetadataResult.putAll(customSPIMetadata);
// set location info as metadata
mergedMetadataResult.putAll(getLocationMetadata());
this.mergedStaticMetadata = Collections.unmodifiableMap(mergedMetadataResult); this.mergedStaticMetadata = Collections.unmodifiableMap(mergedMetadataResult);
Map<String, String> mergedTransitiveMetadataResult = new HashMap<>(); Map<String, String> mergedTransitiveMetadataResult = new HashMap<>();

@ -128,9 +128,6 @@ public class StaticMetadataManagerTest {
Assert.assertEquals("v1", metadata.get("k1")); Assert.assertEquals("v1", metadata.get("k1"));
Assert.assertEquals("v22", metadata.get("k2")); Assert.assertEquals("v22", metadata.get("k2"));
Assert.assertEquals("v33", metadata.get("k3")); Assert.assertEquals("v33", metadata.get("k3"));
Assert.assertEquals("zone2", metadata.get("zone"));
Assert.assertEquals("region1", metadata.get("region"));
Assert.assertEquals("campus1", metadata.get("campus"));
Map<String, String> transitiveMetadata = metadataManager.getMergedStaticTransitiveMetadata(); Map<String, String> transitiveMetadata = metadataManager.getMergedStaticTransitiveMetadata();
Assert.assertEquals(2, transitiveMetadata.size()); Assert.assertEquals(2, transitiveMetadata.size());

@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.common.pojo.PolarisServiceInstance;
import com.tencent.polaris.api.pojo.DefaultInstance; import com.tencent.polaris.api.pojo.DefaultInstance;
import com.tencent.polaris.api.pojo.DefaultServiceInstances; import com.tencent.polaris.api.pojo.DefaultServiceInstances;
import com.tencent.polaris.api.pojo.Instance; import com.tencent.polaris.api.pojo.Instance;
@ -57,6 +58,14 @@ public final class LoadBalancerUtils {
instance.setPort(serviceInstance.getPort()); instance.setPort(serviceInstance.getPort());
instance.setWeight(100); instance.setWeight(100);
instance.setMetadata(serviceInstance.getMetadata()); instance.setMetadata(serviceInstance.getMetadata());
if (serviceInstance instanceof PolarisServiceInstance) {
PolarisServiceInstance polarisServiceInstance = (PolarisServiceInstance) serviceInstance;
instance.setRegion(polarisServiceInstance.getPolarisInstance().getRegion());
instance.setZone(polarisServiceInstance.getPolarisInstance().getZone());
instance.setCampus(polarisServiceInstance.getPolarisInstance().getCampus());
}
return instance; return instance;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
}); });

Loading…
Cancel
Save