Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0] Always get mapping from remote when migrate #9988

Merged
merged 2 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ public Set<String> getCachedMapping(URL consumerURL) {
return getCachedMapping(ServiceNameMapping.buildMappingKey(consumerURL));
}

@Override
public Set<String> getRemoteMapping(URL consumerURL) {
return get(consumerURL);
}

@Override
public Set<String> removeCachedMapping(String serviceKey) {
return mappingCacheManager.remove(serviceKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ static Set<String> getAppNames(String content) {

Set<String> getCachedMapping(URL consumerURL);

Set<String> getRemoteMapping(URL consumerURL);

Map<String, Set<String>> getCachedMapping();

Set<String> removeCachedMapping(String serviceKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public MigrationStep getStep(URL consumerURL) {

if (applications != null) {
ServiceNameMapping serviceNameMapping = ServiceNameMapping.getDefaultExtension(consumerURL.getScopeModel());
Set<String> services = serviceNameMapping.getCachedMapping(consumerURL);
Set<String> services = serviceNameMapping.getRemoteMapping(consumerURL);
if (CollectionUtils.isNotEmpty(services)) {
for (String service : services) {
SubMigrationRule rule = applicationRules.get(service);
Expand Down Expand Up @@ -203,7 +203,7 @@ public float getThreshold(URL consumerURL) {

if (applications != null) {
ServiceNameMapping serviceNameMapping = ServiceNameMapping.getDefaultExtension(consumerURL.getScopeModel());
Set<String> services = serviceNameMapping.getCachedMapping(consumerURL);
Set<String> services = serviceNameMapping.getRemoteMapping(consumerURL);
if (CollectionUtils.isNotEmpty(services)) {
for (String service : services) {
SubMigrationRule rule = applicationRules.get(service);
Expand Down Expand Up @@ -243,7 +243,7 @@ public int getProportion(URL consumerURL) {

if (applications != null) {
ServiceNameMapping serviceNameMapping = ServiceNameMapping.getDefaultExtension(consumerURL.getScopeModel());
Set<String> services = serviceNameMapping.getCachedMapping(consumerURL);
Set<String> services = serviceNameMapping.getRemoteMapping(consumerURL);
if (CollectionUtils.isNotEmpty(services)) {
for (String service : services) {
SubMigrationRule rule = applicationRules.get(service);
Expand Down Expand Up @@ -279,7 +279,7 @@ public int getDelay(URL consumerURL) {

if (applications != null) {
ServiceNameMapping serviceNameMapping = ServiceNameMapping.getDefaultExtension(consumerURL.getScopeModel());
Set<String> services = serviceNameMapping.getCachedMapping(consumerURL);
Set<String> services = serviceNameMapping.getRemoteMapping(consumerURL);
if (CollectionUtils.isNotEmpty(services)) {
for (String service : services) {
SubMigrationRule rule = applicationRules.get(service);
Expand Down Expand Up @@ -319,7 +319,7 @@ public boolean getForce(URL consumerURL) {

if (applications != null) {
ServiceNameMapping serviceNameMapping = ServiceNameMapping.getDefaultExtension(consumerURL.getScopeModel());
Set<String> services = serviceNameMapping.getCachedMapping(consumerURL);
Set<String> services = serviceNameMapping.getRemoteMapping(consumerURL);
if (CollectionUtils.isNotEmpty(services)) {
for (String service : services) {
SubMigrationRule rule = applicationRules.get(service);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void test_parse() {

Mockito.when(url.getDisplayServiceKey()).thenReturn("GreetingService:1.0.1");
Mockito.when(url.getServiceInterface()).thenReturn("GreetingService");
when(mapping.getCachedMapping(any(URL.class))).thenReturn(Collections.singleton("TestApplication"));
when(mapping.getRemoteMapping(any(URL.class))).thenReturn(Collections.singleton("TestApplication"));

Set<String> services = new HashSet<>();
services.add("TestApplication");
Expand Down