Bläddra i källkod

Merge pull request #106 from sahuang/master

Java SDK 0.8.1
Xiaohai Xu 5 år sedan
förälder
incheckning
52e6933904

+ 1 - 0
README.md

@@ -15,6 +15,7 @@ The following table shows compatibilities between Milvus and Java SDK.
 
 
 | Milvus version | Java SDK version |
 | Milvus version | Java SDK version |
 | :------------: | :--------------: |
 | :------------: | :--------------: |
+|     0.9.1      |    0.8.1         |
 |     0.9.0      |    0.8.0         |
 |     0.9.0      |    0.8.0         |
 |     0.8.0      |    0.7.0         |
 |     0.8.0      |    0.7.0         |
 |     0.7.1      |    0.6.0         |
 |     0.7.1      |    0.6.0         |

+ 2 - 2
examples/pom.xml

@@ -25,7 +25,7 @@
 
 
     <groupId>io.milvus</groupId>
     <groupId>io.milvus</groupId>
     <artifactId>milvus-sdk-java-examples</artifactId>
     <artifactId>milvus-sdk-java-examples</artifactId>
-    <version>0.8.0</version>
+    <version>0.8.1</version>
     <build>
     <build>
         <plugins>
         <plugins>
             <plugin>
             <plugin>
@@ -63,7 +63,7 @@
         <dependency>
         <dependency>
             <groupId>io.milvus</groupId>
             <groupId>io.milvus</groupId>
             <artifactId>milvus-sdk-java</artifactId>
             <artifactId>milvus-sdk-java</artifactId>
-            <version>0.8.0</version>
+            <version>0.8.1</version>
         </dependency>
         </dependency>
         <dependency>
         <dependency>
             <groupId>com.google.code.gson</groupId>
             <groupId>com.google.code.gson</groupId>

+ 1 - 1
pom.xml

@@ -25,7 +25,7 @@
 
 
     <groupId>io.milvus</groupId>
     <groupId>io.milvus</groupId>
     <artifactId>milvus-sdk-java</artifactId>
     <artifactId>milvus-sdk-java</artifactId>
-    <version>0.8.0</version>
+    <version>0.8.1</version>
     <packaging>jar</packaging>
     <packaging>jar</packaging>
 
 
     <name>io.milvus:milvus-sdk-java</name>
     <name>io.milvus:milvus-sdk-java</name>

+ 2 - 2
src/main/java/io/milvus/client/MilvusClient.java

@@ -26,9 +26,9 @@ import java.util.List;
 /** The Milvus Client Interface */
 /** The Milvus Client Interface */
 public interface MilvusClient {
 public interface MilvusClient {
 
 
-  String clientVersion = "0.9.0";
+  String clientVersion = "0.8.1";
 
 
-  /** @return current Milvus client version: 0.9.0 */
+  /** @return current Milvus client version: 0.8.1 */
   default String getClientVersion() {
   default String getClientVersion() {
     return clientVersion;
     return clientVersion;
   }
   }

+ 7 - 0
src/main/java/io/milvus/client/MilvusGrpcClient.java

@@ -93,6 +93,13 @@ public class MilvusGrpcClient implements MilvusClient {
       blockingStub = MilvusServiceGrpc.newBlockingStub(channel);
       blockingStub = MilvusServiceGrpc.newBlockingStub(channel);
       futureStub = MilvusServiceGrpc.newFutureStub(channel);
       futureStub = MilvusServiceGrpc.newFutureStub(channel);
 
 
+      // check server version
+      String serverVersion = getServerVersion().getMessage();
+      if (!serverVersion.contains("0.9.")) {
+        logError("Connect failed! Server version {} does not match SDK version 0.8.1", serverVersion);
+        throw new ConnectFailedException("Failed to connect to Milvus server.");
+      }
+
     } catch (Exception e) {
     } catch (Exception e) {
       if (!(e instanceof ConnectFailedException)) {
       if (!(e instanceof ConnectFailedException)) {
         logError("Connect failed! {}", e.toString());
         logError("Connect failed! {}", e.toString());

+ 4 - 3
src/main/java/io/milvus/client/Response.java

@@ -69,11 +69,11 @@ public class Response {
     UNEXPECTED_ERROR(1),
     UNEXPECTED_ERROR(1),
     CONNECT_FAILED(2),
     CONNECT_FAILED(2),
     PERMISSION_DENIED(3),
     PERMISSION_DENIED(3),
-    TABLE_NOT_EXISTS(4),
+    COLLECTION_NOT_EXISTS(4),
     ILLEGAL_ARGUMENT(5),
     ILLEGAL_ARGUMENT(5),
     ILLEGAL_DIMENSION(7),
     ILLEGAL_DIMENSION(7),
     ILLEGAL_INDEX_TYPE(8),
     ILLEGAL_INDEX_TYPE(8),
-    ILLEGAL_TABLE_NAME(9),
+    ILLEGAL_COLLECTION_NAME(9),
     ILLEGAL_TOPK(10),
     ILLEGAL_TOPK(10),
     ILLEGAL_ROWRECORD(11),
     ILLEGAL_ROWRECORD(11),
     ILLEGAL_VECTOR_ID(12),
     ILLEGAL_VECTOR_ID(12),
@@ -93,7 +93,8 @@ public class Response {
     // Client side error
     // Client side error
     RPC_ERROR(-1),
     RPC_ERROR(-1),
     CLIENT_NOT_CONNECTED(-2),
     CLIENT_NOT_CONNECTED(-2),
-    UNKNOWN(-3);
+    UNKNOWN(-3),
+    VERSION_MISMATCH(-4);
 
 
     private final int code;
     private final int code;
 
 

+ 2 - 2
src/test/java/io/milvus/client/MilvusGrpcClientTest.java

@@ -174,7 +174,7 @@ class MilvusClientTest {
         new CollectionMapping.Builder(invalidCollectionName, dimension).build();
         new CollectionMapping.Builder(invalidCollectionName, dimension).build();
     Response createCollectionResponse = client.createCollection(invalidCollectionMapping);
     Response createCollectionResponse = client.createCollection(invalidCollectionMapping);
     assertFalse(createCollectionResponse.ok());
     assertFalse(createCollectionResponse.ok());
-    assertEquals(Response.Status.ILLEGAL_TABLE_NAME, createCollectionResponse.getStatus());
+    assertEquals(Response.Status.ILLEGAL_COLLECTION_NAME, createCollectionResponse.getStatus());
   }
   }
 
 
   @org.junit.jupiter.api.Test
   @org.junit.jupiter.api.Test
@@ -189,7 +189,7 @@ class MilvusClientTest {
     String nonExistingCollectionName = generator.generate(10);
     String nonExistingCollectionName = generator.generate(10);
     Response dropCollectionResponse = client.dropCollection(nonExistingCollectionName);
     Response dropCollectionResponse = client.dropCollection(nonExistingCollectionName);
     assertFalse(dropCollectionResponse.ok());
     assertFalse(dropCollectionResponse.ok());
-    assertEquals(Response.Status.TABLE_NOT_EXISTS, dropCollectionResponse.getStatus());
+    assertEquals(Response.Status.COLLECTION_NOT_EXISTS, dropCollectionResponse.getStatus());
   }
   }
 
 
   @org.junit.jupiter.api.Test
   @org.junit.jupiter.api.Test