Comments (2)
I had look this code below
@Bean
Registry getRegistry() {
URL url = URL.valueOf(registryAddress);
if (StringUtils.isNotEmpty(group)) {
url = url.addParameter(Constants.GROUP_KEY, group);
}
RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension();
Registry registry = registryFactory.getRegistry(url);
return registry;
}
You should know this URL.valueof may parse port .
So it makes our application fail to start
from dubbo-proxy.
I find a way to use backup key
You can see code
public static URL parseURL(String address, Map<String, String> defaults) {
if (address == null || address.length() == 0) {
return null;
}
String url;
if (address.indexOf("://") >= 0) {
url = address;
} else {
String[] addresses = Constants.COMMA_SPLIT_PATTERN.split(address);
url = addresses[0];
if (addresses.length > 1) {
StringBuilder backup = new StringBuilder();
for (int i = 1; i < addresses.length; i++) {
if (i > 1) {
backup.append(",");
}
backup.append(addresses[i]);
}
url += "?" + Constants.BACKUP_KEY + "=" + backup.toString();
}
}
String defaultProtocol = defaults == null ? null : defaults.get("protocol");
if (defaultProtocol == null || defaultProtocol.length() == 0) {
defaultProtocol = "dubbo";
}
String defaultUsername = defaults == null ? null : defaults.get("username");
String defaultPassword = defaults == null ? null : defaults.get("password");
int defaultPort = StringUtils.parseInteger(defaults == null ? null : defaults.get("port"));
String defaultPath = defaults == null ? null : defaults.get("path");
Map<String, String> defaultParameters = defaults == null ? null : new HashMap<String, String>(defaults);
if (defaultParameters != null) {
defaultParameters.remove("protocol");
defaultParameters.remove("username");
defaultParameters.remove("password");
defaultParameters.remove("host");
defaultParameters.remove("port");
defaultParameters.remove("path");
}
URL u = URL.valueOf(url);
boolean changed = false;
String protocol = u.getProtocol();
String username = u.getUsername();
String password = u.getPassword();
String host = u.getHost();
int port = u.getPort();
String path = u.getPath();
Map<String, String> parameters = new HashMap<String, String>(u.getParameters());
if ((protocol == null || protocol.length() == 0) && defaultProtocol != null && defaultProtocol.length() > 0) {
changed = true;
protocol = defaultProtocol;
}
if ((username == null || username.length() == 0) && defaultUsername != null && defaultUsername.length() > 0) {
changed = true;
username = defaultUsername;
}
if ((password == null || password.length() == 0) && defaultPassword != null && defaultPassword.length() > 0) {
changed = true;
password = defaultPassword;
}
/*if (u.isAnyHost() || u.isLocalHost()) {
changed = true;
host = NetUtils.getLocalHost();
}*/
if (port <= 0) {
if (defaultPort > 0) {
changed = true;
port = defaultPort;
} else {
changed = true;
port = 9090;
}
}
if (path == null || path.length() == 0) {
if (defaultPath != null && defaultPath.length() > 0) {
changed = true;
path = defaultPath;
}
}
if (defaultParameters != null && defaultParameters.size() > 0) {
for (Map.Entry<String, String> entry : defaultParameters.entrySet()) {
String key = entry.getKey();
String defaultValue = entry.getValue();
if (defaultValue != null && defaultValue.length() > 0) {
String value = parameters.get(key);
if (value == null || value.length() == 0) {
changed = true;
parameters.put(key, defaultValue);
}
}
}
}
if (changed) {
u = new URL(protocol, username, password, host, port, path, parameters);
}
return u;
}
Just because we use like xxx:2181,yyy:2181,zzz:2181 so I can write below
zookeeper://xxx:2181?backup=yyy:2181
from dubbo-proxy.
Related Issues (20)
- dubbo 有自带的cache版的ReferenceConfig不需要Map做缓存
- We need dubbo-proxy can handle with form post or queryString HOT 8
- We need handle with some error scenes HOT 1
- Dubbo proxy sometimes cannot response directly
- dubbo GenericInvoke throws exception local class incompatible HOT 1
- 如果方法有泛型参数的话,调用报错。是不是还不支持泛型参数啊?
- 在当前master(2.7.5-snapshot)分支中demo模块启动失败,请关注AbstractInterfaceConfig该类实现 HOT 1
- dubbo提供了rest功能,为什么不使用这个对外提供接口? HOT 1
- dubbo-proxy应当增加安全访问机制,避免内部服务全通 HOT 6
- 一个提问,我看源码中根据Parmatypes.length加上方法名去判断是哪个元数据,不会出现重载的方法调用不到的情况吗
- 不能指定tomcat的端口吗
- 文件接口如何处理?
- 多个注册中心怎么处理? HOT 1
- 能支持nacos吗 HOT 1
- dubbo注册之后,发现org.springframework.aop.SpringProxy被注册到里面了,有人知道怎么回事吗
- dubbo 2.6.3 is support ? HOT 1
- dubbo group not set for reference HOT 1
- update dubbo version HOT 1
- Not support dubbo attachments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dubbo-proxy.