com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter Java Examples

The following examples show how to use com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZookeeperRegistry.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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);
	}
        	}
        }
    });
}
 
Example #2
Source File: ZookeeperRegistry.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
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);
	}
        	}
        }
    });
}
 
Example #3
Source File: ZookeeperRegistry.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
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);
            }
        }
    });
}
 
Example #4
Source File: ZookeeperRegistry.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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);
	}
        	}
        }
    });
}
 
Example #5
Source File: ZookeeperRegistry.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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);
	}
        	}
        }
    });
}
 
Example #6
Source File: ZookeeperRegistry.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
public ZookeeperRegistry(URL url, ZookeeperTransporter zookeeperTransporter) {
        super(url);
        if (url.isAnyHost()) {
            throw new IllegalStateException("registry address == null");
        }
//        group不进行配置默认值是dubbo
        String group = url.getParameter(Constants.GROUP_KEY, DEFAULT_ROOT);
        if (!group.startsWith(Constants.PATH_SEPARATOR)) {
            group = Constants.PATH_SEPARATOR + group;
        }
        this.root = group;
//        创建zkclient=》
        zkClient = zookeeperTransporter.connect(url);
//        添加监听器
        zkClient.addStateListener(new StateListener() {
            @Override
            public void stateChanged(int state) {
                if (state == RECONNECTED) {
                    try {
//                        恢复注册信息=》
                        recover();
                    } catch (Exception e) {
                        logger.error(e.getMessage(), e);
                    }
                }
            }
        });
    }
 
Example #7
Source File: ZookeeperRegistryFactory.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) {
    this.zookeeperTransporter = zookeeperTransporter;
}
 
Example #8
Source File: ZookeeperRegistryFactory.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) {
	this.zookeeperTransporter = zookeeperTransporter;
}
 
Example #9
Source File: ZookeeperRegistryFactory.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) {
	this.zookeeperTransporter = zookeeperTransporter;
}
 
Example #10
Source File: ZookeeperRegistryFactory.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) {
	this.zookeeperTransporter = zookeeperTransporter;
}
 
Example #11
Source File: ZookeeperRegistryFactory.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) {
	this.zookeeperTransporter = zookeeperTransporter;
}
 
Example #12
Source File: ZookeeperRegistryFactory.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setZookeeperTransporter(ZookeeperTransporter zookeeperTransporter) {
	this.zookeeperTransporter = zookeeperTransporter;
}