remove location metadata (#540)

pull/544/head
lepdou 2 years ago committed by GitHub
parent 87c780f242
commit 2b5e8dcfa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,4 +23,5 @@
- [Feature: Optimized configuration update](https://github.com/Tencent/spring-cloud-tencent/pull/527)
- [Featuresupport pushGateway push metrics](https://github.com/Tencent/spring-cloud-tencent/pull/531)
- [Feature: remove location metadata](https://github.com/Tencent/spring-cloud-tencent/pull/534)
- [Feature: remove location metadata](https://github.com/Tencent/spring-cloud-tencent/pull/540)
- [add feature-env plugin & add spring cloud gateway staining plugin](https://github.com/Tencent/spring-cloud-tencent/pull/532)

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

@ -128,9 +128,6 @@ public class StaticMetadataManagerTest {
Assert.assertEquals("v1", metadata.get("k1"));
Assert.assertEquals("v22", metadata.get("k2"));
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();
Assert.assertEquals(2, transitiveMetadata.size());

@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
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.DefaultServiceInstances;
import com.tencent.polaris.api.pojo.Instance;
@ -84,6 +85,14 @@ public final class LoadBalancerUtils {
instance.setPort(serviceInstance.getPort());
instance.setWeight(DEFAULT_WEIGHT);
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;
}
}

Loading…
Cancel
Save