本文整理汇总了Java中com.alibaba.dubbo.common.URL.getHost方法的典型用法代码示例。如果您正苦于以下问题:Java URL.getHost方法的具体用法?Java URL.getHost怎么用?Java URL.getHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.common.URL
的用法示例。
在下文中一共展示了URL.getHost方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FileExchangeGroup
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public FileExchangeGroup(URL url){
super(url);
String path = url.getHost() + "/" + url.getPath();
file = new File(path);
if (! file.exists()) {
throw new IllegalStateException("The group file not exists. file: " + path);
}
checkModifiedFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {
public void run() {
// 检测文件变更
try {
check();
} catch (Throwable t) { // 防御性容错
logger.error("Unexpected error occur at reconnect, cause: " + t.getMessage(), t);
}
}
}, 2000, 2000, TimeUnit.MILLISECONDS);
}
示例2: configure
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public URL configure(URL url) {
if (configuratorUrl == null || configuratorUrl.getHost() == null
|| url == null || url.getHost() == null) {
return url;
}
if (configuratorUrl.getPort() != 0) {// override输入提供端地址,意图是控制提供者机器。可能在提供端生效 也可能在消费端生效
if (url.getPort() == configuratorUrl.getPort()) {
return configureIfMatch(url.getHost(), url);
}
} else {// 没有端口,override输入消费端地址 或者 0.0.0.0
// 1.如果是消费端地址,则意图是控制消费者机器,必定在消费端生效,提供端忽略;
// 2.如果是0.0.0.0可能是控制提供端,也可能是控制提供端
if (url.getParameter(Constants.SIDE_KEY, Constants.PROVIDER).equals(Constants.CONSUMER)) {
return configureIfMatch(NetUtils.getLocalHost(), url);// NetUtils.getLocalHost是消费端注册到zk的消费者地址
} else if (url.getParameter(Constants.SIDE_KEY, Constants.CONSUMER).equals(Constants.PROVIDER)) {
return configureIfMatch(Constants.ANYHOST_VALUE, url);//控制所有提供端,地址必定是0.0.0.0,否则就要配端口从而执行上面的if分支了
}
}
return url;
}
示例3: configure
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public URL configure(URL url) {
if (configuratorUrl == null || configuratorUrl.getHost() == null
|| url == null || url.getHost() == null) {
return url;
}
if (Constants.ANYHOST_VALUE.equals(configuratorUrl.getHost())
|| url.getHost().equals(configuratorUrl.getHost())) {
String configApplication = configuratorUrl.getParameter(Constants.APPLICATION_KEY, configuratorUrl.getUsername());
String currentApplication = url.getParameter(Constants.APPLICATION_KEY, url.getUsername());
if (configApplication == null || Constants.ANY_VALUE.equals(configApplication)
|| configApplication.equals(currentApplication)) {
if (configuratorUrl.getPort() == 0 || url.getPort() == configuratorUrl.getPort()) {
Set<String> condtionKeys = new HashSet<String>();
condtionKeys.add(Constants.CATEGORY_KEY);
condtionKeys.add(Constants.CHECK_KEY);
condtionKeys.add(Constants.DYNAMIC_KEY);
condtionKeys.add(Constants.ENABLED_KEY);
for (Map.Entry<String, String> entry : configuratorUrl.getParameters().entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.startsWith("~") || Constants.APPLICATION_KEY.equals(key)
|| Constants.SIDE_KEY.equals(key)) {
condtionKeys.add(key);
if (value != null && ! Constants.ANY_VALUE.equals(value)
&& ! value.equals(url.getParameter(key.startsWith("~") ? key.substring(1) : key))) {
return url;
}
}
}
return doConfigure(url, configuratorUrl.removeParameters(condtionKeys));
}
}
}
return url;
}
示例4: url2Override
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public static com.alibaba.dubbo.registry.common.domain.Override url2Override(Pair<Long, URL> pair) {
if (pair == null) {
return null;
}
Long id = pair.getKey();
URL url = pair.getValue();
if (null == url)
return null;
com.alibaba.dubbo.registry.common.domain.Override o = new com.alibaba.dubbo.registry.common.domain.Override();
o.setId(id);
Map<String, String> parameters = new HashMap<String, String>(url.getParameters());
o.setService(url.getServiceKey());
parameters.remove(Constants.INTERFACE_KEY);
parameters.remove(Constants.GROUP_KEY);
parameters.remove(Constants.VERSION_KEY);
parameters.remove(Constants.APPLICATION_KEY);
parameters.remove(Constants.CATEGORY_KEY);
parameters.remove(Constants.DYNAMIC_KEY);
parameters.remove(Constants.ENABLED_KEY);
o.setEnabled(url.getParameter(Constants.ENABLED_KEY, true));
String host = url.getHost();
boolean anyhost = url.getParameter(Constants.ANYHOST_VALUE, false);
if(!anyhost || !"0.0.0.0".equals(host)) {
o.setAddress(url.getAddress());
}
o.setApplication(url.getParameter(Constants.APPLICATION_KEY, url.getUsername()));
parameters.remove(Constants.VERSION_KEY);
o.setParams(StringUtils.toQueryString(parameters));
return o;
}
示例5: url2Override
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public static com.alibaba.dubbo.registry.common.domain.Override url2Override(Pair<Long, URL> pair) {
if (pair == null) {
return null;
}
Long id = pair.getKey();
URL url = pair.getValue();
if (null == url)
return null;
com.alibaba.dubbo.registry.common.domain.Override o = new com.alibaba.dubbo.registry.common.domain.Override();
o.setId(id);
Map<String, String> parameters = new HashMap<String, String>(url.getParameters());
o.setService(url.getServiceKey());
parameters.remove(Constants.INTERFACE_KEY);
parameters.remove(Constants.GROUP_KEY);
parameters.remove(Constants.VERSION_KEY);
parameters.remove(Constants.APPLICATION_KEY);
parameters.remove(Constants.CATEGORY_KEY);
parameters.remove(Constants.DYNAMIC_KEY);
parameters.remove(Constants.ENABLED_KEY);
o.setEnabled(url.getParameter(Constants.ENABLED_KEY, true));
String host = url.getHost();
boolean anyhost = url.getParameter(Constants.ANYHOST_VALUE, false);
if (!anyhost || !"0.0.0.0".equals(host)) {
o.setAddress(url.getAddress());
}
o.setApplication(url.getParameter(Constants.APPLICATION_KEY, url.getUsername()));
parameters.remove(Constants.VERSION_KEY);
o.setParams(StringUtils.toQueryString(parameters));
return o;
}