-
Notifications
You must be signed in to change notification settings - Fork 26.5k
[compatible] Registry compatibility #3882 #4015
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a0a8422
fix #2842. remove duplicate SPI definitions for 2.7.x
cvictory 98b2f4b
Merge branch 'master' of github.com:apache/incubator-dubbo
cvictory 19824c3
fix: rename the thread name from DubboRegistryFailedRetryTimer to Dub…
cvictory 05b158d
Merge branch 'master' of github.com:apache/incubator-dubbo
cvictory 6b6023f
Merge branch 'master' of github.com:apache/incubator-dubbo
cvictory fbc167d
Merge branch 'master' of github.com:apache/incubator-dubbo
cvictory c18a07c
Merge branch 'master' of github.com:apache/incubator-dubbo into regis…
cvictory c0da2ee
compatible with Regigistry. #3882
cvictory 6b58cd0
add licence
cvictory 84c3dde
Merge branch 'master' of github.com:apache/incubator-dubbo into regis…
cvictory 477d652
fix review issue. #3882
cvictory a15eb55
#3883
cvictory File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
dubbo-compatible/src/main/java/com/alibaba/dubbo/common/utils/UrlUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed 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 specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.alibaba.dubbo.common.utils; | ||
|
|
||
| import com.alibaba.dubbo.common.URL; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** | ||
| * 2019-04-17 | ||
| */ | ||
| @Deprecated | ||
| public class UrlUtils { | ||
|
|
||
| public static URL parseURL(String address, Map<String, String> defaults) { | ||
| return new URL(UrlUtils.parseURL(address, defaults)); | ||
| } | ||
|
|
||
| public static List<URL> parseURLs(String address, Map<String, String> defaults) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.parseURLs(address, defaults).stream().map(e -> new URL(e)).collect(Collectors.toList()); | ||
| } | ||
|
|
||
| public static Map<String, Map<String, String>> convertRegister(Map<String, Map<String, String>> register) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.convertRegister(register); | ||
| } | ||
|
|
||
| public static Map<String, String> convertSubscribe(Map<String, String> subscribe) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.convertSubscribe(subscribe); | ||
| } | ||
|
|
||
| public static Map<String, Map<String, String>> revertRegister(Map<String, Map<String, String>> register) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.revertRegister(register); | ||
| } | ||
|
|
||
| public static Map<String, String> revertSubscribe(Map<String, String> subscribe) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.revertSubscribe(subscribe); | ||
| } | ||
|
|
||
| public static Map<String, Map<String, String>> revertNotify(Map<String, Map<String, String>> notify) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.revertNotify(notify); | ||
| } | ||
|
|
||
| //compatible for dubbo-2.0.0 | ||
| public static List<String> revertForbid(List<String> forbid, Set<URL> subscribed) { | ||
| Set<org.apache.dubbo.common.URL> urls = subscribed.stream().map(e -> e.getOriginalURL()).collect(Collectors.toSet()); | ||
| return org.apache.dubbo.common.utils.UrlUtils.revertForbid(forbid, urls); | ||
| } | ||
|
|
||
| public static URL getEmptyUrl(String service, String category) { | ||
| return new URL(org.apache.dubbo.common.utils.UrlUtils.getEmptyUrl(service, category)); | ||
| } | ||
|
|
||
| public static boolean isMatchCategory(String category, String categories) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.isMatchCategory(category, categories); | ||
| } | ||
|
|
||
| public static boolean isMatch(URL consumerUrl, URL providerUrl) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.isMatch(consumerUrl.getOriginalURL(), providerUrl.getOriginalURL()); | ||
| } | ||
|
|
||
| public static boolean isMatchGlobPattern(String pattern, String value, URL param) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.isMatchGlobPattern(pattern, value, param.getOriginalURL()); | ||
| } | ||
|
|
||
| public static boolean isMatchGlobPattern(String pattern, String value) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.isMatchGlobPattern(pattern, value); | ||
| } | ||
|
|
||
| public static boolean isServiceKeyMatch(URL pattern, URL value) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.isServiceKeyMatch(pattern.getOriginalURL(), value.getOriginalURL()); | ||
| } | ||
|
|
||
|
|
||
| public static boolean isConfigurator(URL url) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.isConfigurator(url.getOriginalURL()); | ||
| } | ||
|
|
||
| public static boolean isRoute(URL url) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.isRoute(url.getOriginalURL()); | ||
| } | ||
|
|
||
| public static boolean isProvider(URL url) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.isProvider(url.getOriginalURL()); | ||
| } | ||
|
|
||
| public static int getHeartbeat(URL url) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.getHeartbeat(url.getOriginalURL()); | ||
| } | ||
|
|
||
| public static int getIdleTimeout(URL url) { | ||
| return org.apache.dubbo.common.utils.UrlUtils.getIdleTimeout(url.getOriginalURL()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
dubbo-compatible/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistry.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed 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 specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.alibaba.dubbo.registry.support; | ||
|
|
||
| import org.apache.dubbo.common.URL; | ||
| import org.apache.dubbo.registry.NotifyListener; | ||
| import org.apache.dubbo.registry.Registry; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** | ||
| * 2019-04-16 | ||
| */ | ||
| @Deprecated | ||
| public abstract class AbstractRegistry implements Registry { | ||
|
|
||
| private CompatibleAbstractRegistry abstractRegistry; | ||
|
|
||
| public AbstractRegistry(com.alibaba.dubbo.common.URL url) { | ||
| abstractRegistry = new CompatibleAbstractRegistry(url.getOriginalURL()); | ||
| } | ||
|
|
||
| @Override | ||
| public com.alibaba.dubbo.common.URL getUrl() { | ||
| return new com.alibaba.dubbo.common.URL(abstractRegistry.getUrl()); | ||
| } | ||
|
|
||
| protected void setUrl(com.alibaba.dubbo.common.URL url) { | ||
| abstractRegistry.setUrl(url.getOriginalURL()); | ||
| } | ||
|
|
||
| public Set<com.alibaba.dubbo.common.URL> getRegistered() { | ||
| return abstractRegistry.getRegistered().stream().map(url -> new com.alibaba.dubbo.common.URL(url)).collect(Collectors.toSet()); | ||
| } | ||
|
|
||
| public Map<com.alibaba.dubbo.common.URL, Set<com.alibaba.dubbo.registry.NotifyListener>> getSubscribed() { | ||
| return abstractRegistry.getSubscribed().entrySet() | ||
| .stream() | ||
| .collect(Collectors.toMap(entry -> new com.alibaba.dubbo.common.URL(entry.getKey()), | ||
| entry -> convertToNotifyListeners(entry.getValue()))); | ||
| } | ||
|
|
||
| public Map<com.alibaba.dubbo.common.URL, Map<String, List<com.alibaba.dubbo.common.URL>>> getNotified() { | ||
| return abstractRegistry.getNotified().entrySet().stream() | ||
| .collect(Collectors.toMap(entry -> new com.alibaba.dubbo.common.URL(entry.getKey()), | ||
| entry -> { | ||
| return entry.getValue().entrySet() | ||
| .stream() | ||
| .collect(Collectors.toMap(e -> e.getKey(), e -> { | ||
| return e.getValue().stream().map(url -> new com.alibaba.dubbo.common.URL(url)).collect(Collectors.toList()); | ||
| })); | ||
| })); | ||
| } | ||
|
|
||
|
|
||
| public List<com.alibaba.dubbo.common.URL> getCacheUrls(com.alibaba.dubbo.common.URL url) { | ||
| return abstractRegistry.lookup(url.getOriginalURL()).stream().map(tmpUrl -> new com.alibaba.dubbo.common.URL(tmpUrl)).collect(Collectors.toList()); | ||
| } | ||
|
|
||
| public List<com.alibaba.dubbo.common.URL> lookup(com.alibaba.dubbo.common.URL url) { | ||
| return abstractRegistry.lookup(url.getOriginalURL()).stream().map(tmpUrl -> new com.alibaba.dubbo.common.URL(tmpUrl)).collect(Collectors.toList()); | ||
| } | ||
|
|
||
| protected void notify(com.alibaba.dubbo.common.URL url, com.alibaba.dubbo.registry.NotifyListener listener, List<com.alibaba.dubbo.common.URL> urls) { | ||
| abstractRegistry.notify(url.getOriginalURL(), new com.alibaba.dubbo.registry.NotifyListener.ReverseCompatibleNotifyListener(listener), urls.stream().map(tmpUrl -> tmpUrl.getOriginalURL()).collect(Collectors.toList())); | ||
| } | ||
|
|
||
| public void register(com.alibaba.dubbo.common.URL url) { | ||
| abstractRegistry.register(url.getOriginalURL()); | ||
| } | ||
|
|
||
| public void unregister(com.alibaba.dubbo.common.URL url) { | ||
| abstractRegistry.unregister(url.getOriginalURL()); | ||
| } | ||
|
|
||
| public void subscribe(com.alibaba.dubbo.common.URL url, com.alibaba.dubbo.registry.NotifyListener listener) { | ||
| abstractRegistry.subscribe(url.getOriginalURL(), new com.alibaba.dubbo.registry.NotifyListener.ReverseCompatibleNotifyListener(listener)); | ||
| } | ||
|
|
||
| public void unsubscribe(com.alibaba.dubbo.common.URL url, com.alibaba.dubbo.registry.NotifyListener listener) { | ||
| abstractRegistry.unsubscribe(url.getOriginalURL(), new com.alibaba.dubbo.registry.NotifyListener.ReverseCompatibleNotifyListener(listener)); | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public void register(URL url) { | ||
| this.register(new com.alibaba.dubbo.common.URL(url)); | ||
| } | ||
|
|
||
| @Override | ||
| public void unregister(URL url) { | ||
| this.unregister(new com.alibaba.dubbo.common.URL(url)); | ||
| } | ||
|
|
||
| @Override | ||
| public void subscribe(URL url, NotifyListener listener) { | ||
| this.subscribe(new com.alibaba.dubbo.common.URL(url), new com.alibaba.dubbo.registry.NotifyListener.CompatibleNotifyListener(listener)); | ||
| } | ||
|
|
||
| @Override | ||
| public void unsubscribe(URL url, NotifyListener listener) { | ||
| this.unsubscribe(new com.alibaba.dubbo.common.URL(url), new com.alibaba.dubbo.registry.NotifyListener.CompatibleNotifyListener(listener)); | ||
| } | ||
|
|
||
| final Set<com.alibaba.dubbo.registry.NotifyListener> convertToNotifyListeners(Set<NotifyListener> notifyListeners) { | ||
| return notifyListeners.stream().map(listener -> new com.alibaba.dubbo.registry.NotifyListener.CompatibleNotifyListener(listener)).collect(Collectors.toSet()); | ||
| } | ||
|
|
||
|
|
||
| static class CompatibleAbstractRegistry extends org.apache.dubbo.registry.support.AbstractRegistry { | ||
| public CompatibleAbstractRegistry(URL url) { | ||
| super(url); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isAvailable() { | ||
| return false; | ||
| } | ||
|
|
||
| public void notify(URL url, NotifyListener listener, List<URL> urls) { | ||
| super.notify(url, listener, urls); | ||
| } | ||
|
|
||
| public void setUrl(URL url) { | ||
| super.setUrl(url); | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
...-compatible/src/main/java/com/alibaba/dubbo/registry/support/AbstractRegistryFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed 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 specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.alibaba.dubbo.registry.support; | ||
|
|
||
| import org.apache.dubbo.common.URL; | ||
| import org.apache.dubbo.registry.Registry; | ||
|
|
||
| /** | ||
| * 2019-04-16 | ||
| */ | ||
| @Deprecated | ||
| public abstract class AbstractRegistryFactory extends org.apache.dubbo.registry.support.AbstractRegistryFactory { | ||
|
|
||
|
|
||
| protected abstract com.alibaba.dubbo.registry.Registry createRegistry(com.alibaba.dubbo.common.URL url); | ||
|
|
||
| protected Registry createRegistry(URL url) { | ||
| return createRegistry(new com.alibaba.dubbo.common.URL(url)); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.