Browse Source

support zilliz cloud elastic serverless. (#895)

Signed-off-by: “yelusion” <xun.huang@zilliz.com>
yelusion 1 year ago
parent
commit
dcbb27ca61

+ 1 - 1
src/main/java/io/milvus/common/constant/MilvusClientConstant.java

@@ -7,7 +7,7 @@ public class MilvusClientConstant {
 
         public final static String HOST_HTTP_PREFIX = "http://";
 
-        public final static String CLOUD_SERVERLESS_URI_REGEX = "^https://in03-.{20,}zilliz.*.(com|cn)$";
+        public final static String CLOUD_SERVERLESS_URI_REGEX = "^(https://in03-.{20,}zilliz.*.(com|cn))|(https://in0\\d{1}-.{15,}serverless.*zilliz.*.(com|cn))$";
     }
     public static class StringValue {
         public final static String COLON = ":";

+ 3 - 3
src/main/java/io/milvus/param/ConnectParam.java

@@ -369,6 +369,9 @@ public class ConnectParam {
                 this.host = result.getHostname();
                 this.port = result.getPort();
                 this.databaseName = StringUtils.isNotEmpty(result.getDatabase()) ? result.getDatabase() : this.databaseName;
+                if (Pattern.matches(CLOUD_SERVERLESS_URI_REGEX, this.uri)) {
+                    this.port = 443;
+                }
             }
 
             if(host.startsWith(HOST_HTTPS_PREFIX)){
@@ -377,9 +380,6 @@ public class ConnectParam {
 
             if (StringUtils.isNotEmpty(token)) {
                 this.authorization = Base64.getEncoder().encodeToString(String.format("%s", token).getBytes(StandardCharsets.UTF_8));
-                if (Pattern.matches(CLOUD_SERVERLESS_URI_REGEX, this.uri)) {
-                    this.port = 443;
-                }
             }
 
             if (port < 0 || port > 0xFFFF) {