本文整理汇总了Java中com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter类的典型用法代码示例。如果您正苦于以下问题:Java ZookeeperTransporter类的具体用法?Java ZookeeperTransporter怎么用?Java ZookeeperTransporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ZookeeperTransporter类属于com.alibaba.dubbo.remoting.zookeeper包,在下文中一共展示了ZookeeperTransporter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ZookeeperRegistry
import com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter; //导入依赖的package包/类
public ZookeeperRegistry(URL url, ZookeeperTransporter zookeeperTransporter) {
super(url);
if (url.isAnyHost()) {
throw new IllegalStateException("registry address == null");
}
String group = url.getParameter(Constants.GROUP_KEY, DEFAULT_ROOT);
if (! group.startsWith(Constants.PATH_SEPARATOR)) {
group = Constants.PATH_SEPARATOR + group;
}
this.root = group;
zkClient = zookeeperTransporter.connect(url);
zkClient.addStateListener(new StateListener() {
public void stateChanged(int state) {
if (state == RECONNECTED) {
try {
recover();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
示例2: ZookeeperRegistry
import com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter; //导入依赖的package包/类
public ZookeeperRegistry(URL url, ZookeeperTransporter zookeeperTransporter) {
super(url);
if (url.isAnyHost()) {
throw new IllegalStateException("registry address == null");
}
String group = url.getParameter(Constants.GROUP_KEY, DEFAULT_ROOT);
if (!group.startsWith(Constants.PATH_SEPARATOR)) {
group = Constants.PATH_SEPARATOR + group;
}
this.root = group;
zkClient = zookeeperTransporter.connect(url);
zkClient.addStateListener(new StateListener() {
public void stateChanged(int state) {
if (state == RECONNECTED) {
try {
recover();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
示例3: ZookeeperRegistry
import com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter; //导入依赖的package包/类
public ZookeeperRegistry(URL url, ZookeeperTransporter zookeeperTransporter) {
super(url);
if (url.isAnyHost()) {
throw new IllegalStateException("registry address == null");
}
String group = url.getParameter(Constants.GROUP_KEY, DEFAULT_ROOT);
if (!group.startsWith(Constants.PATH_SEPARATOR)) {
group = Constants.PATH_SEPARATOR + group;
}
this.root = group;
zkClient = zookeeperTransporter.connect(url);
zkClient.addStateListener(state -> {
if (state == StateListener.RECONNECTED) {
try {
recover();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
});
}
示例4: ZookeeperRegistry
import com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter; //导入依赖的package包/类
public ZookeeperRegistry(URL url, ZookeeperTransporter zookeeperTransporter) {
super(url);
/*if (url.isAnyHost()) {
throw new IllegalStateException("registry address == null");
}*/
String group = url.getParameter(Constants.GROUP_KEY, DEFAULT_ROOT);
if (! group.startsWith(Constants.PATH_SEPARATOR)) {
group = Constants.PATH_SEPARATOR + group;
}
this.root = group;
zkClient = zookeeperTransporter.connect(url);
//主要处理Session失效之后重连的逻辑
zkClient.addStateListener(new StateListener() {
public void stateChanged(int state) {
if (state == RECONNECTED) {
try {
recover();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
示例5: ZookeeperRegistry
import com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter; //导入依赖的package包/类
public ZookeeperRegistry(URL url, ZookeeperTransporter zookeeperTransporter) {
super(url);
if (url.isAnyHost()) {
throw new IllegalStateException("registry address == null");
}
// 这里获取在dubbo:registry的group配置
String group = url.getParameter(Constants.GROUP_KEY, DEFAULT_ROOT);
// 如果group没有以/开头,则给他加上
if (! group.startsWith(Constants.PATH_SEPARATOR)) {
group = Constants.PATH_SEPARATOR + group;
}
this.root = group;
zkClient = zookeeperTransporter.connect(url);//连接上zk服务器上
zkClient.addStateListener(new StateListener() {// 增加绑定在连接上的状态变更监听器,如果RECONNECTED,则恢复连接
public void stateChanged(int state) {
if (state == RECONNECTED) {
try {
recover();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
});
}
示例6: setZookeeperTransporter
import com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter; //导入依赖的package包/类
public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) {
this.zookeeperTransporter = zookeeperTransporter;
}
示例7: setZookeeperTransporter
import com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter; //导入依赖的package包/类
public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) {
this.zookeeperTransporter = zookeeperTransporter;
}