本文整理了Java中com.alipay.sofa.rpc.registry.zk.ZookeeperConfigObserver
类的一些代码示例,展示了ZookeeperConfigObserver
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperConfigObserver
类的具体详情如下:
包路径:com.alipay.sofa.rpc.registry.zk.ZookeeperConfigObserver
类名称:ZookeeperConfigObserver
[英]ZookeeperObserver for config node,subscribe interface level provider/consumer config.
[中]ZookePerObserver用于配置节点,订阅接口级提供者/使用者配置。
代码示例来源:origin: alipay/sofa-rpc
try {
if (configObserver == null) { // 初始化
configObserver = new ZookeeperConfigObserver();
configObserver.addConfigListener(config, listener);
final String configPath = buildConfigPath(rootPath, config);
pathChildrenCache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
INTERFACE_CONFIG_CACHE.put(configPath, pathChildrenCache);
configObserver.updateConfigAll(config, configPath, 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: //新增接口级配置
configObserver.addConfig(config, configPath, event.getData());
break;
case CHILD_REMOVED: //删除接口级配置
configObserver.removeConfig(config, configPath, event.getData());
break;
case CHILD_UPDATED:// 更新接口级配置
configObserver.updateConfig(config, configPath, event.getData());
break;
default:
break;
}
}
});
代码示例来源:origin: alipay/sofa-rpc
configObserver.removeConfigListener(config);
} catch (Exception e) {
if (!RpcRunningState.isShuttingDown()) {
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置修改子节点Data
*
* @param config 接口配置
* @param configPath 配置Path
* @param data 子节点Data
*/
public void updateConfig(AbstractInterfaceConfig config, String configPath, ChildData data) {
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, configPath, data, false);
}
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置新增子节点Data
*
* @param config 接口配置
* @param configPath 配置Path
* @param data 子节点Data
*/
public void addConfig(AbstractInterfaceConfig config, String configPath, ChildData data) {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive add 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, configPath, data, false);
}
}
代码示例来源: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: //新增接口级配置
configObserver.addConfig(config, configPath, event.getData());
break;
case CHILD_REMOVED: //删除接口级配置
configObserver.removeConfig(config, configPath, event.getData());
break;
case CHILD_UPDATED:// 更新接口级配置
configObserver.updateConfig(config, configPath, event.getData());
break;
default:
break;
}
}
});
代码示例来源:origin: alipay/sofa-rpc
try {
if (configObserver == null) { // 初始化
configObserver = new ZookeeperConfigObserver();
configObserver.addConfigListener(config, listener);
final String configPath = buildConfigPath(rootPath, config);
pathChildrenCache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
INTERFACE_CONFIG_CACHE.put(configPath, pathChildrenCache);
configObserver.updateConfigAll(config, configPath, pathChildrenCache.getCurrentData());
} catch (Exception e) {
throw new SofaRpcRuntimeException("Failed to subscribe provider config from zookeeperRegistry!", e);
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置新增子节点Data
*
* @param config 接口配置
* @param configPath 配置Path
* @param data 子节点Data
*/
public void addConfig(AbstractInterfaceConfig config, String configPath, ChildData data) {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive add 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, configPath, data, false);
}
}
代码示例来源:origin: alipay/sofa-rpc
configObserver.removeConfigListener(config);
} catch (Exception e) {
if (!RpcRunningState.isShuttingDown()) {
代码示例来源: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: //新增接口级配置
configObserver.addConfig(config, configPath, event.getData());
break;
case CHILD_REMOVED: //删除接口级配置
configObserver.removeConfig(config, configPath, event.getData());
break;
case CHILD_UPDATED:// 更新接口级配置
configObserver.updateConfig(config, configPath, event.getData());
break;
default:
break;
}
}
});
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
try {
if (configObserver == null) { // 初始化
configObserver = new ZookeeperConfigObserver();
configObserver.addConfigListener(config, listener);
final String configPath = buildConfigPath(rootPath, config);
pathChildrenCache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
INTERFACE_CONFIG_CACHE.put(configPath, pathChildrenCache);
configObserver.updateConfigAll(config, configPath, pathChildrenCache.getCurrentData());
} catch (Exception e) {
throw new SofaRpcRuntimeException("Failed to subscribe provider config from zookeeperRegistry!", e);
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置修改子节点Data
*
* @param config 接口配置
* @param configPath 配置Path
* @param data 子节点Data
*/
public void updateConfig(AbstractInterfaceConfig config, String configPath, ChildData data) {
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, configPath, data, false);
}
}
代码示例来源:origin: alipay/sofa-rpc
try {
if (null != configObserver) {
configObserver.removeConfigListener(config);
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置删除子节点Data
*
* @param config 接口配置
* @param configPath 配置Path
* @param data 子节点Data
*/
public void removeConfig(AbstractInterfaceConfig config, String configPath, ChildData data) {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive remove data is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive remove data: path=[" + data.getPath() + "]"
+ ", data=[" + StringSerializer.decode(data.getData()) + "]"
+ ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, configPath, data, true);
}
}
代码示例来源:origin: alipay/sofa-rpc
try {
if (null != configObserver) {
configObserver.removeConfigListener(config);
代码示例来源:origin: alipay/sofa-rpc
/**
* 接口配置删除子节点Data
*
* @param config 接口配置
* @param configPath 配置Path
* @param data 子节点Data
*/
public void removeConfig(AbstractInterfaceConfig config, String configPath, ChildData data) {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive remove data is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive remove data: path=[" + data.getPath() + "]"
+ ", data=[" + StringSerializer.decode(data.getData()) + "]"
+ ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, configPath, data, true);
}
}
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
configObserver.removeConfigListener(config);
} catch (Exception e) {
if (!RpcRunningState.isShuttingDown()) {
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
/**
* 接口配置删除子节点Data
*
* @param config 接口配置
* @param configPath 配置Path
* @param data 子节点Data
*/
public void removeConfig(AbstractInterfaceConfig config, String configPath, ChildData data) {
if (data == null) {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive remove data is null");
}
} else {
if (LOGGER.isInfoEnabled(config.getAppName())) {
LOGGER.infoWithApp(config.getAppName(), "Receive remove data: path=[" + data.getPath() + "]"
+ ", data=[" + StringSerializer.decode(data.getData()) + "]"
+ ", stat=[" + data.getStat() + "]");
}
notifyListeners(config, configPath, data, true);
}
}
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
try {
if (null != configObserver) {
configObserver.removeConfigListener(config);
代码示例来源:origin: com.alipay.sofa/sofa-rpc-all
/**
* 接口配置修改子节点Data
*
* @param config 接口配置
* @param configPath 配置Path
* @param data 子节点Data
*/
public void updateConfig(AbstractInterfaceConfig config, String configPath, ChildData data) {
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, configPath, data, false);
}
}
内容来源于网络,如有侵权,请联系作者删除!