浏览代码

Get server version interface for V2 (#1017)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 9 月之前
父节点
当前提交
5e23fcaa65

+ 1 - 1
.github/workflows/java_sdk_ci_test.yaml

@@ -19,7 +19,7 @@ jobs:
         run: |
           echo "deploy milvus"
           ls
-          sudo docker-compose up -d
+          sudo docker compose up -d
 
       - name: Build jar
         timeout-minutes: 30

+ 9 - 0
src/main/java/io/milvus/v2/client/MilvusClientV2.java

@@ -729,6 +729,15 @@ public class MilvusClientV2 {
         return retry(()->utilityService.describeAlias(this.blockingStub, request));
     }
 
+    /**
+     * Get server version
+     *
+     * @return String
+     */
+    public String getVersion() {
+        return retry(()->clientUtils.getVersion(this.blockingStub));
+    }
+
     /**
      * close client
      *

+ 6 - 3
src/main/java/io/milvus/v2/utils/ClientUtils.java

@@ -26,9 +26,7 @@ import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
 import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
 import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;
 import io.grpc.stub.MetadataUtils;
-import io.milvus.grpc.ListDatabasesRequest;
-import io.milvus.grpc.ListDatabasesResponse;
-import io.milvus.grpc.MilvusServiceGrpc;
+import io.milvus.grpc.*;
 import io.milvus.v2.client.ConnectConfig;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -129,4 +127,9 @@ public class ClientUtils {
             throw new IllegalArgumentException("Database " + dbName + " not exist");
         }
     }
+    public String getVersion(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub) {
+        GetVersionResponse response = blockingStub.getVersion(GetVersionRequest.newBuilder().build());
+        rpcUtils.handleResponse("Get server version", response.getStatus());
+        return response.getVersion();
+    }
 }

+ 3 - 3
src/test/java/io/milvus/client/MilvusMultiClientDockerTest.java

@@ -62,7 +62,7 @@ class MilvusMultiClientDockerTest {
 
         // start the test container
         Runtime runtime = Runtime.getRuntime();
-        String bashCommand = "docker-compose up -d";
+        String bashCommand = "docker compose up -d";
 
         try {
             logger.debug(bashCommand);
@@ -118,7 +118,7 @@ class MilvusMultiClientDockerTest {
 
         // stop all test dockers
         Runtime runtime = Runtime.getRuntime();
-        String bashCommand = "docker-compose down";
+        String bashCommand = "docker compose down";
 
         try {
             logger.debug("Milvus service stopping...");
@@ -135,7 +135,7 @@ class MilvusMultiClientDockerTest {
 
         // clean up log dir
         runtime = Runtime.getRuntime();
-        bashCommand = "docker-compose rm";
+        bashCommand = "docker compose rm";
 
         try {
             logger.debug(bashCommand);