本文整理了Java中com.alipay.sofa.rpc.registry.zk.ZookeeperOverrideObserver
类的一些代码示例,展示了ZookeeperOverrideObserver
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperOverrideObserver
类的具体详情如下:
包路径:com.alipay.sofa.rpc.registry.zk.ZookeeperOverrideObserver
类名称:ZookeeperOverrideObserver
[英]ZookeeperObserver for override node,subscribe ip level provider/consumer config.
[中]ZookePerObserver用于覆盖节点,订阅ip级别的提供者/使用者配置。
代码示例来源:origin: alipay/sofa-rpc
try {
if (overrideObserver == null) { // 初始化
overrideObserver = new ZookeeperOverrideObserver();
overrideObserver.addConfigListener(config, listener);
final String overridePath = buildOverridePath(rootPath, config);
final AbstractInterfaceConfig registerConfig = getRegisterConfig(config);
pathChildrenCache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
INTERFACE_OVERRIDE_CACHE.put(overridePath, pathChildrenCache);
overrideObserver.updateConfigAll(config, overridePath, pathChildrenCache.getCurrentData());
} catch (Exception e) {
throw new SofaRpcRuntimeException("Failed to subscribe provider config from zookeeperRegistry!", e);
代码示例来源:origin: alipay/sofa-rpc
@Override
public void childEvent(CuratorFramework client1, PathChildrenCacheEvent event) throws Exception {
if (LOGGER.isDebugEnabled(config.getAppName())) {
LOGGER.debug("Receive zookeeper event: " + "type=[" + event.getType() + "]");
}
switch (event.getType()) {
case CHILD_ADDED: //新增IP级配置
overrideObserver.addConfig(config, overridePath, event.getData());
break;
case CHILD_REMOVED: //删除IP级配置
overrideObserver.removeConfig(config, overridePath, event.getData(), registerConfig);
break;
case CHILD_UPDATED:// 更新IP级配置
overrideObserver.updateConfig(config, overridePath, event.getData());
break;
default:
break;
}
}
});
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置修改子节点Data
*
* @param config 接口配置
* @param overridePath 覆盖Path
* @param data 子节点Data
* @throws Exception 转换配置异常
*/
public void updateConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive update data is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive update data: path=[" + data.getPath() + "]" +
", data=[" + StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, overridePath, data, false, null);
}
}
代码示例来源:origin: alipay/sofa-rpc
overrideObserver.removeConfigListener(config);
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置新增子节点Data
*
* @param config 接口配置
* @param overridePath 覆盖Path
* @param data 子节点Data
* @throws Exception 转换配置异常
*/
public void addConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive data is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive add data: path=[" + data.getPath() + "]" + ", data=[" +
StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, overridePath, data, false, null);
}
}
代码示例来源:origin: alipay/sofa-rpc
overrideObserver.removeConfigListener(config);
代码示例来源:origin: alipay/sofa-rpc
@Override
public void childEvent(CuratorFramework client1, PathChildrenCacheEvent event) throws Exception {
if (LOGGER.isDebugEnabled(config.getAppName())) {
LOGGER.debug("Receive zookeeper event: " + "type=[" + event.getType() + "]");
}
switch (event.getType()) {
case CHILD_ADDED: //新增IP级配置
overrideObserver.addConfig(config, overridePath, event.getData());
break;
case CHILD_REMOVED: //删除IP级配置
overrideObserver.removeConfig(config, overridePath, event.getData(), registerConfig);
break;
case CHILD_UPDATED:// 更新IP级配置
overrideObserver.updateConfig(config, overridePath, event.getData());
break;
default:
break;
}
}
});
代码示例来源:origin: alipay/sofa-rpc
try {
if (overrideObserver == null) { // 初始化
overrideObserver = new ZookeeperOverrideObserver();
overrideObserver.addConfigListener(config, listener);
final String overridePath = buildOverridePath(rootPath, config);
final AbstractInterfaceConfig registerConfig = getRegisterConfig(config);
pathChildrenCache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
INTERFACE_OVERRIDE_CACHE.put(overridePath, pathChildrenCache);
overrideObserver.updateConfigAll(config, overridePath, pathChildrenCache.getCurrentData());
} catch (Exception e) {
throw new SofaRpcRuntimeException("Failed to subscribe provider config from zookeeperRegistry!", e);
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置修改子节点Data
*
* @param config 接口配置
* @param overridePath 覆盖Path
* @param data 子节点Data
* @throws Exception 转换配置异常
*/
public void updateConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive update data is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive update data: path=[" + data.getPath() + "]" +
", data=[" + StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, overridePath, data, false, null);
}
}
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
overrideObserver.removeConfigListener(config);
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
@Override
public void childEvent(CuratorFramework client1, PathChildrenCacheEvent event) throws Exception {
if (LOGGER.isDebugEnabled(config.getAppName())) {
LOGGER.debug("Receive zookeeper event: " + "type=[" + event.getType() + "]");
}
switch (event.getType()) {
case CHILD_ADDED: //新增IP级配置
overrideObserver.addConfig(config, overridePath, event.getData());
break;
case CHILD_REMOVED: //删除IP级配置
overrideObserver.removeConfig(config, overridePath, event.getData(), registerConfig);
break;
case CHILD_UPDATED:// 更新IP级配置
overrideObserver.updateConfig(config, overridePath, event.getData());
break;
default:
break;
}
}
});
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
try {
if (overrideObserver == null) { // 初始化
overrideObserver = new ZookeeperOverrideObserver();
overrideObserver.addConfigListener(config, listener);
final String overridePath = buildOverridePath(rootPath, config);
final AbstractInterfaceConfig registerConfig = getRegisterConfig(config);
pathChildrenCache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
INTERFACE_OVERRIDE_CACHE.put(overridePath, pathChildrenCache);
overrideObserver.updateConfigAll(config, overridePath, pathChildrenCache.getCurrentData());
} catch (Exception e) {
throw new SofaRpcRuntimeException("Failed to subscribe provider config from zookeeperRegistry!", e);
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置新增子节点Data
*
* @param config 接口配置
* @param overridePath 覆盖Path
* @param data 子节点Data
* @throws Exception 转换配置异常
*/
public void addConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive data is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive add data: path=[" + data.getPath() + "]" + ", data=[" +
StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, overridePath, data, false, null);
}
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置删除子节点Data
*
* @param config 接口配置
* @param overridePath 覆盖Path
* @param data 子节点Data
* @param registerConfig 注册配置
* @throws Exception 转换配置异常
*/
public void removeConfig(AbstractInterfaceConfig config, String overridePath, ChildData data,
AbstractInterfaceConfig registerConfig)
throws Exception {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive data is null");
}
} else if (registerConfig == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Register config is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive data: path=[" + data.getPath() + "]" + ", data=[" +
StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, overridePath, data, true, registerConfig);
}
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置删除子节点Data
*
* @param config 接口配置
* @param overridePath 覆盖Path
* @param data 子节点Data
* @param registerConfig 注册配置
* @throws Exception 转换配置异常
*/
public void removeConfig(AbstractInterfaceConfig config, String overridePath, ChildData data,
AbstractInterfaceConfig registerConfig)
throws Exception {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive data is null");
}
} else if (registerConfig == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Register config is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive data: path=[" + data.getPath() + "]" + ", data=[" +
StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, overridePath, data, true, registerConfig);
}
}
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
/**
* 接口配置修改子节点Data
*
* @param config 接口配置
* @param overridePath 覆盖Path
* @param data 子节点Data
* @throws Exception 转换配置异常
*/
public void updateConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive update data is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive update data: path=[" + data.getPath() + "]" +
", data=[" + StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, overridePath, data, false, null);
}
}
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
/**
* 接口配置新增子节点Data
*
* @param config 接口配置
* @param overridePath 覆盖Path
* @param data 子节点Data
* @throws Exception 转换配置异常
*/
public void addConfig(AbstractInterfaceConfig config, String overridePath, ChildData data) throws Exception {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive data is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive add data: path=[" + data.getPath() + "]" + ", data=[" +
StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, overridePath, data, false, null);
}
}
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
/**
* 接口配置删除子节点Data
*
* @param config 接口配置
* @param overridePath 覆盖Path
* @param data 子节点Data
* @param registerConfig 注册配置
* @throws Exception 转换配置异常
*/
public void removeConfig(AbstractInterfaceConfig config, String overridePath, ChildData data,
AbstractInterfaceConfig registerConfig)
throws Exception {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive data is null");
}
} else if (registerConfig == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Register config is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive data: path=[" + data.getPath() + "]" + ", data=[" +
StringSerializer.decode(data.getData()) + "]" + ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, overridePath, data, true, registerConfig);
}
}
内容来源于网络,如有侵权,请联系作者删除!