Skip to content

Commit

Permalink
make zookeeper registry configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
qdaxb committed Apr 28, 2016
1 parent 07b1048 commit 4b7ec9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Registry getRegistry(URL url) {
registries.put(registryUri, registry);
return registry;
} catch (Exception e) {
throw new MotanFrameworkException("Create registry false for url:" + url, MotanErrorMsgConstant.FRAMEWORK_INIT_ERROR);
throw new MotanFrameworkException("Create registry false for url:" + url, e, MotanErrorMsgConstant.FRAMEWORK_INIT_ERROR);
} finally {
lock.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.weibo.api.motan.registry.zookeeper;

import com.weibo.api.motan.common.URLParamType;
import com.weibo.api.motan.core.extension.SpiMeta;
import com.weibo.api.motan.registry.Registry;
import com.weibo.api.motan.registry.support.AbstractRegistryFactory;
Expand All @@ -34,13 +35,17 @@
public class ZookeeperRegistryFactory extends AbstractRegistryFactory {

@Override
protected Registry createRegistry(URL url) {
ZkClient client = null;
protected Registry createRegistry(URL registryUrl) {
try {
client = new ZkClient(url.getParameter("address"));
int timeout = registryUrl.getIntParameter(URLParamType.requestTimeout.getName(), URLParamType.requestTimeout.getIntValue());
int sessionTimeout =
registryUrl.getIntParameter(URLParamType.registrySessionTimeout.getName(),
URLParamType.registrySessionTimeout.getIntValue());
ZkClient zkClient = new ZkClient(registryUrl.getParameter("address"), sessionTimeout, timeout);
return new ZookeeperRegistry(registryUrl, zkClient);
} catch (ZkException e) {
LoggerUtil.error("[ZookeeperRegistry] fail to connect zookeeper, cause: " + e.getMessage());
throw e;
}
return new ZookeeperRegistry(url, client);
}
}

0 comments on commit 4b7ec9b

Please sign in to comment.