gpt4 book ai didi

com.github.dapeng.registry.zookeeper.ZkServiceInfo.runtimeInstances()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 15:27:31 27 4
gpt4 key购买 nike

本文整理了Java中com.github.dapeng.registry.zookeeper.ZkServiceInfo.runtimeInstances()方法的一些代码示例,展示了ZkServiceInfo.runtimeInstances()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkServiceInfo.runtimeInstances()方法的具体详情如下:
包路径:com.github.dapeng.registry.zookeeper.ZkServiceInfo
类名称:ZkServiceInfo
方法名:runtimeInstances

ZkServiceInfo.runtimeInstances介绍

[英]instances list, always use cow collection
[中]实例列表,始终使用cow集合

代码示例

代码示例来源:origin: dapeng-soa/dapeng-soa

/**
 * 将zk config 中的权重设置,同步到运行实例中
 *
 * @param zkInfo
 */
public static void recalculateRuntimeInstanceWeight(ZkServiceInfo zkInfo) {
  if (zkInfo != null) {
    List<RuntimeInstance> runtimeInstances = zkInfo.runtimeInstances();
    if (runtimeInstances != null && runtimeInstances.size() > 0) {
      for (RuntimeInstance runtimeInstance : runtimeInstances) {
        if (zkInfo.weightGlobalConfig.ip != null) {   //没有全局配置的情况下ip = null,有全局配置ip = ""
          runtimeInstance.weight = zkInfo.weightGlobalConfig.weight;
        }
        if (zkInfo.weightServiceConfigs != null) {
          List<Weight> weights = zkInfo.weightServiceConfigs;
          for (Weight weight : weights) {
            if (weight.ip.equals(runtimeInstance.ip)) {
              if (weight.port == runtimeInstance.port) {
                runtimeInstance.weight = weight.weight;
                break;
              } else if (weight.port == -1) {
                runtimeInstance.weight = weight.weight;
              }
            }
          }
        }
      }
    }
  }
}

代码示例来源:origin: dapeng-soa/dapeng-soa

/**
 * 同步zk信息
 *
 * @param serviceInfo
 */
private void startWatch(ZkServiceInfo serviceInfo) {
  LOGGER.info(getClass().getSimpleName() + "::syncServiceZkInfo[serviceName:" + serviceInfo.serviceName() + "], runtimeInstants:" + serviceInfo.runtimeInstances().size());
  try {
    // sync runtimeList
    syncZkRuntimeInfo(serviceInfo);
    // sync router config
    syncZkRouteInfo(serviceInfo);
    // sync service config, no need to try 5 times any more
    syncZkConfigInfo(serviceInfo, zk, this, true);
    syncZkConfigInfo(serviceInfo, zk, this, false);
    // sync cookie injection rule
    syncZkCookieRuleInfo(serviceInfo);
    LOGGER.info(getClass().getSimpleName() + "::syncServiceZkInfo[serviceName:" + serviceInfo.serviceName() + "]:zkInfo succeed, runtimeInstants:" + serviceInfo.runtimeInstances().size());
  } catch (Exception e) {
    LOGGER.error(e.getMessage(), e);
    LOGGER.error(getClass().getSimpleName() + "::syncServiceZkInfo[serviceName:" + serviceInfo.serviceName() + "]:zkInfo failed, runtimeInstants:" + serviceInfo.runtimeInstances().size());
  }
}

代码示例来源:origin: dapeng-soa/dapeng-soa

serviceInfo.runtimeInstances().clear();
    LOGGER.info(getClass().getSimpleName() + "::syncZkRuntimeInfo["
        + serviceInfo.serviceName() + "]:no service instances found");
  List<RuntimeInstance> runtimeInstanceList = serviceInfo.runtimeInstances();
  runtimeInstanceList.clear();
  runtimeInstanceList.addAll(getRuntimeInstances(children, serviceInfo.serviceName()));
      + serviceInfo.serviceName() + " -> " + serviceInfo.runtimeInstances());
  return;
} catch (KeeperException | InterruptedException e) {

代码示例来源:origin: dapeng-soa/dapeng-soa

List<RuntimeInstance> compatibles = serviceInfo.runtimeInstances();
if (compatibles == null || compatibles.isEmpty()) {
  return null;

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com