def _update_cache_properties_for_round_robin_cluster_info()

in aws_advanced_python_wrapper/host_selector.py [0:0]


    def _update_cache_properties_for_round_robin_cluster_info(self, round_robin_cluster_info: RoundRobinClusterInfo, props: Optional[Properties]):
        cluster_default_weight: int = RoundRobinHostSelector._DEFAULT_WEIGHT
        if props is not None:
            props_weight = WrapperProperties.ROUND_ROBIN_DEFAULT_WEIGHT.get_int(props)
            if props_weight < RoundRobinHostSelector._DEFAULT_WEIGHT:
                raise AwsWrapperError(Messages.get("RoundRobinHostSelector.RoundRobinInvalidDefaultWeight"))
            cluster_default_weight = props_weight
        round_robin_cluster_info.default_weight = cluster_default_weight

        if props is not None:
            host_weights: Optional[str] = WrapperProperties.ROUND_ROBIN_HOST_WEIGHT_PAIRS.get(props)
            if host_weights is not None and len(host_weights) != 0:
                host_weight_pairs: List[str] = host_weights.split(",")

                for pair in host_weight_pairs:
                    match = search(RoundRobinHostSelector._HOST_WEIGHT_PAIRS_PATTERN, pair)
                    if match:
                        host_name = match.group("host")
                        host_weight = match.group("weight")
                    else:
                        raise AwsWrapperError(Messages.get("RoundRobinHostSelector.RoundRobinInvalidHostWeightPairs"))

                    if len(host_name) == 0 or len(host_weight) == 0:
                        raise AwsWrapperError(Messages.get("RoundRobinHostSelector.RoundRobinInvalidHostWeightPairs"))
                    try:
                        weight: int = int(host_weight)

                        if weight < RoundRobinHostSelector._DEFAULT_WEIGHT:
                            raise AwsWrapperError(Messages.get("RoundRobinHostSelector.RoundRobinInvalidHostWeightPairs"))

                        round_robin_cluster_info.cluster_weights_dict[host_name] = weight
                    except ValueError:
                        raise AwsWrapperError(Messages.get("RoundRobinHostSelector.RoundRobinInvalidHostWeightPairs"))