com.alipay.sofa.rpc.registry.zk.ZookeeperOverrideObserver类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(176)

本文整理了Java中com.alipay.sofa.rpc.registry.zk.ZookeeperOverrideObserver类的一些代码示例,展示了ZookeeperOverrideObserver类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperOverrideObserver类的具体详情如下:
包路径:com.alipay.sofa.rpc.registry.zk.ZookeeperOverrideObserver
类名称: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);
  }
}

相关文章