empiredan commented on code in PR #2306:
URL: 
https://github.com/apache/incubator-pegasus/pull/2306#discussion_r2895091003


##########
python-client/pypegasus/pgclient.py:
##########
@@ -253,20 +256,159 @@ class MetaSessionManager(SessionManager):
     def __init__(self, table_name, timeout):
         SessionManager.__init__(self, table_name, timeout)
         self.addr_list = []
+        self.host_ports = []
+        self.query_times = 0
+        
+    # validate if the given string is a valid IP address     
+    def is_valid_ip(self, address):
+        try:
+            ipaddress.ip_address(address)
+            return True
+        except ValueError:
+            return False
+            
+    def get_host_type(self, ip_list):
+        """
+        Determines the host type based on the provided list of IP addresses.
+        
+        This function analyzes the IP version distribution in the given list 
to classify
+        the host as IPv4-only, IPv6-only, mixed (both IPv4 and IPv6), or 
invalid.
+        """
+        has_ipv4 = False
+        has_ipv6 = False
+
+        for ip_str in ip_list:
+            try:
+                ip = ipaddress.ip_address(ip_str)
+                if ip.version == 4:
+                    has_ipv4 = True
+                elif ip.version == 6:
+                    has_ipv6 = True
+            except ValueError:
+                continue 
+
+        if has_ipv4 and has_ipv6:
+            return host_port_types.kHostTypeGroup

Review Comment:
   On the server side, `kHostTypeGroup` means that the `host_port` class stores 
a list of addresses. However, in the Python client it is defined as a mix of 
IPv4 and IPv6, which is inconsistent with the server-side definition. What is 
the rationale behind this design?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to