private updateCachedHostWeightPairsPropertiesForRoundRobinClusterInfo()

in common/lib/round_robin_host_selector.ts [164:195]


  private updateCachedHostWeightPairsPropertiesForRoundRobinClusterInfo(roundRobinClusterInfo: RoundRobinClusterInfo, props?: Map<string, any>) {
    if (props) {
      const hostWeights = WrapperProperties.ROUND_ROBIN_HOST_WEIGHT_PAIRS.get(props);
      if (hostWeights) {
        const hostWeightPairs = hostWeights.split(",");
        hostWeightPairs.forEach((hostWeightPair) => {
          const pair = hostWeightPair.split(":");
          if (!pair || pair.length === 0 || pair.length !== 2) {
            throw new AwsWrapperError(Messages.get("HostSelector.roundRobinInvalidHostWeightPairs"));
          }

          const hostName = pair[0].trim();
          const hostWeight = pair[1].trim();

          if (!hostName || !hostWeight) {
            throw new AwsWrapperError(Messages.get("HostSelector.roundRobinInvalidHostWeightPairs"));
          }

          const weight = Number(hostWeight);
          if (isNaN(weight) || !Number.isInteger(weight) || weight < RoundRobinHostSelector.DEFAULT_WEIGHT) {
            throw new AwsWrapperError(Messages.get("HostSelector.roundRobinInvalidHostWeightPairs"));
          }
          roundRobinClusterInfo.clusterWeightsMap.set(hostName, weight);
        });

        roundRobinClusterInfo.lastClusterHostWeightPairPropertyValue = WrapperProperties.ROUND_ROBIN_HOST_WEIGHT_PAIRS.get(props);
      } else if (!hostWeights) {
        roundRobinClusterInfo.clusterWeightsMap.clear();
        roundRobinClusterInfo.lastClusterHostWeightPairPropertyValue = WrapperProperties.ROUND_ROBIN_HOST_WEIGHT_PAIRS.get(props);
      }
    }
  }